/* Market analysis demo (js/market-demo.js): a light control panel and a light map, side by side on night pine,
   like the real tool we build for clients. Motion uses one easing family: a quick start and a soft settle. */

.mx {
  --mx-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --mx-spring: cubic-bezier(0.34, 1.4, 0.5, 1);
  --mx-ink: var(--pine-ink, #1E392F);
  --mx-muted: #5B6A61;
  --mx-hair: rgba(33, 61, 51, 0.12);
  position: relative;
  display: grid;
  gap: 16px;
  margin-top: 48px;
  color: var(--mx-ink);
  grid-template-columns: minmax(0, 1fr); /* the nowrap chip row must not widen the column on phones */
}
.mx > * { min-width: 0; }

/* ---------- Panel ---------- */
.mx__panel {
  pointer-events: none; /* watch-only demo */
  user-select: none;
  background: #FFFFFF;
  border-radius: 20px;
  padding: 22px 20px 20px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5), 0 40px 90px -40px rgba(0, 0, 0, 0.7);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-content: start;
}
.mx__title { margin: 0; font: 700 1.25rem/1.1 var(--wayfinding); }
.mx__sub { margin: 6px 0 0; font-size: 0.875rem; color: var(--mx-muted); display: flex; align-items: center; gap: 8px; }
.mx__label { margin: 0 0 8px; font: 700 0.8125rem/1.2 var(--wayfinding); color: var(--mx-ink); }
.mx__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mx__chip {
  font: 600 0.8125rem/1 var(--wayfinding);
  color: var(--mx-ink);
  background: #FFFFFF;
  border: 1px solid var(--mx-hair);
  border-radius: 999px;
  padding: 9px 12px;
  transition: background 0.35s var(--mx-ease), color 0.35s var(--mx-ease), border-color 0.35s var(--mx-ease);
}
.mx__chip[data-on] { background: var(--mx-ink); border-color: var(--mx-ink); color: #FFFFFF; }

.mx__stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.mx__stats div { display: flex; flex-direction: column-reverse; background: #F4F6F2; border-radius: 12px; padding: 12px; }
.mx__stats dd { margin: 0; font: 700 1.25rem/1.05 var(--wayfinding); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.mx__stats dt { margin-top: 4px; font-size: 0.75rem; line-height: 1.3; color: var(--mx-muted); }

.mx__note {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: #F4F6F2;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: #3B4A42;
  min-height: 4.6em;
}
.mx__ramp { display: block; height: 8px; border-radius: 4px; background: var(--ramp, #DCE6D3); transition: background 0.6s var(--mx-ease); }
.mx__ends { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; font-size: 0.75rem; color: var(--mx-muted); }

.mx__bars { list-style: none; margin: -6px 0 0; padding: 0; display: grid; gap: 9px; }
.mx__bars li { display: grid; grid-template-columns: 6.2rem 1fr 3rem; align-items: center; gap: 10px; font-size: 0.8125rem; }
.mx__bars .bar-track, .mx__cov .bar-track { display: block; height: 7px; border-radius: 4px; background: #E6ECE2; overflow: hidden; }
.mx__bars .bar-track i, .mx__cov .bar-track i {
  display: block;
  height: 100%;
  width: calc(var(--v, 0) * 1%);
  border-radius: 4px;
  background: var(--mx-ink);
  transition: width 0.9s var(--mx-ease);
}
.mx__bars .num { text-align: right; font: 700 0.8125rem/1 var(--wayfinding); font-variant-numeric: tabular-nums; }


/* ---------- Map ---------- */
.mx__map {
  position: relative;
  margin: 0;
  border-radius: 20px;
  overflow: hidden;
  background: #F8F9F7;
  aspect-ratio: 4 / 5;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5), 0 40px 90px -40px rgba(0, 0, 0, 0.75);
}
.mx__canvas, .mx__canvas.maplibregl-map { position: absolute; inset: 0; pointer-events: none; } /* maplibre-gl.css sets relative, which collapses the map */
.mx__canvas canvas { outline: none; }
.mx__tag { position: absolute; z-index: 3; top: 14px; right: 14px; }
.mx__attr {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 14px;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--mx-muted);
  background: linear-gradient(to top, rgba(248, 249, 247, 0.97), rgba(248, 249, 247, 0.7));
}
.mx__attr a { color: var(--mx-ink); }

/* "Your practice": a MapLibre marker, so it stays put when the map moves */
.mx__you { display: flex; align-items: center; gap: 10px; pointer-events: none; }
.mx__you > span:last-child {
  font: 700 0.8125rem/1 var(--wayfinding);
  color: var(--mx-ink);
  background: #FFFFFF;
  padding: 8px 11px;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(33, 61, 51, 0.18), 0 6px 18px rgba(33, 61, 51, 0.18);
}
.mx__station {
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 3px solid var(--mx-ink);
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.85), 0 6px 16px rgba(33, 61, 51, 0.35);
}
.mx__station::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--mx-ink); }

/* ---------- ZIP card ---------- */
.mx__card {
  position: absolute;
  z-index: 4;
  left: 0;
  top: 0;
  width: 300px;
  max-height: calc(100% - 24px);
  overflow: auto;
  transform: translate(var(--x, 12px), var(--y, 12px));
  background: #FFFFFF;
  border-radius: 16px;
  padding: 14px 16px 12px;
  box-shadow: 0 0 0 1px rgba(33, 61, 51, 0.1), 0 24px 60px -18px rgba(20, 42, 33, 0.45);
  transition: transform 0.9s var(--mx-ease);
}
.mx__card[hidden] { display: none; }
.mx__card.is-in { animation: mx-card-in 0.55s var(--mx-spring) both; }
@keyframes mx-card-in { from { opacity: 0; scale: 0.94; } to { opacity: 1; scale: 1; } }
.mx__card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.mx__card-head p { margin: 0; font: 600 0.9375rem/1.3 var(--wayfinding); }
.mx__card-head strong { color: var(--mx-ink); }
.mx__dist { margin-left: 4px; padding: 2px 7px; border-radius: 999px; background: #EEF2EB; font-size: 0.75rem; color: var(--mx-muted); white-space: nowrap; }
.mx__facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 12px 0 0; }
.mx__facts div { display: flex; flex-direction: column-reverse; }
.mx__facts dd { margin: 0; font: 700 1rem/1.1 var(--wayfinding); font-variant-numeric: tabular-nums; }
.mx__facts dt { margin-top: 3px; font-size: 0.6875rem; line-height: 1.3; color: var(--mx-muted); }
.mx__card-label { margin: 14px 0 8px; font: 700 0.8125rem/1 var(--wayfinding); }
.mx__cov { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.mx__covrow { display: flex; justify-content: space-between; font-size: 0.8125rem; margin-bottom: 4px; }
.mx__covrow .num { font: 700 0.8125rem/1 var(--wayfinding); font-variant-numeric: tabular-nums; }
.mx__cov details { margin-top: 4px; font-size: 0.75rem; }
.mx__cov summary { color: #4F7259; font-weight: 600; width: max-content; }
.mx__cov details ul { margin: 6px 0 0; padding: 0; list-style: none; display: grid; gap: 3px; color: var(--mx-ink); }
.mx__cov details ul li { padding: 3px 8px; border-radius: 6px; background: #F4F6F2; }
.mx__cov details p { margin: 5px 0 0; color: var(--mx-muted); font-size: 0.6875rem; }
.mx__cov details[open] ul { animation: mx-list-in 0.45s var(--mx-ease) both; }
@keyframes mx-list-in { from { opacity: 0; translate: 0 -4px; } to { opacity: 1; translate: 0 0; } }
.mx__card-foot { margin: 10px 0 0; font-size: 0.6875rem; color: var(--mx-muted); }

/* Phones and narrow maps: the card is a bottom sheet inside the map */
.mx__map.is-narrow .mx__card { left: 10px; right: 10px; top: auto; bottom: 10px; width: auto; max-height: 72%; transform: none; transition: none; }
.mx__map.is-narrow .mx__card.is-in { animation: mx-sheet-in 0.5s var(--mx-ease) both; }
@keyframes mx-sheet-in { from { opacity: 0; translate: 0 24px; } to { opacity: 1; translate: 0 0; } }

/* ---------- Tour ---------- */
.mx__cursor {
  position: absolute;
  z-index: 6;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  background: rgba(33, 61, 51, 0.9);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.95), 0 8px 22px rgba(20, 42, 33, 0.45);
  transform: translate(var(--cx, 50%), var(--cy, 50%));
  opacity: 0;
  pointer-events: none;
  transition: transform 0.7s var(--mx-ease), opacity 0.4s var(--mx-ease);
}
.mx__cursor.is-on { opacity: 1; }
.mx__cursor::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid rgba(33, 61, 51, 0.6); opacity: 0; }
.mx__cursor.is-tap::after { animation: mx-tap 0.5s var(--mx-ease); }
@keyframes mx-tap { from { opacity: 1; scale: 0.6; } to { opacity: 0; scale: 1.8; } }

@media (min-width: 1000px) {
  .mx { grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: stretch; }
  .mx__map { aspect-ratio: auto; min-height: 720px; }
}
@media (max-width: 999px) {
  /* the map comes first, so the tour plays where the visitor is looking */
  .mx__map { order: -1; }
  .mx__chips { flex-wrap: nowrap; overflow: hidden; }
  .mx__chip { flex: none; }
  .mx__attr { font-size: 0.6875rem; padding: 8px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .mx *, .mx *::after { animation: none !important; transition: none !important; }
}
