/* ─────────────────────────────────────────────────────────────
   Erika · Candidate Price Map
   An analytical "markets" micropage. Reuses the landing palette
   (cream + glass, accent blue) from styles.css, adds a data-dense,
   Kalshi-flavoured layer: monospace figures, range bars, a price
   strip and a role × region heatmap.
   ───────────────────────────────────────────────────────────── */

.pm {
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --pm-card-bg: rgba(255, 255, 255, 0.52);
  --pm-grid-line: rgba(22, 22, 22, 0.08);
}

.pm-main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--pad) 40px;
}

/* Active nav link */
.nav__links a.is-active { color: var(--ink); font-weight: 600; }

/* ───────────────────────────  HERO  ─────────────────────────── */
.pm-hero { padding: clamp(48px, 9vh, 104px) 0 28px; }
.pm-hero__inner { max-width: 820px; }
.pm-hero__title {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.02;
  font-size: clamp(40px, 7vw, 76px);
  margin: 18px 0 0;
}
.pm-hero__title em {
  font-family: inherit;
  font-style: normal;
  font-weight: 800;
  letter-spacing: inherit;
}
.pm-hero__sub {
  font-size: clamp(16px, 2.1vw, 20px);
  color: var(--ink-soft);
  max-width: 640px;
  margin: 18px 0 0;
}
/* ──────────────────────  HERO LINE CHART  ───────────────────── */
.pm-chart {
  margin: 30px 0 0;
  background: var(--pm-card-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(10px) saturate(1.1);
  padding: 20px 20px 12px;
}
.pm-chart__bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.pm-chart__readout { display: flex; flex-direction: column; min-width: 160px; }
.pm-readout__val {
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(30px, 5vw, 44px);
  letter-spacing: -0.03em;
  line-height: 1;
}
/* Odometer roll for the readout value */
.pm-roll { display: inline-flex; align-items: flex-end; }
.pm-roll__s { display: inline-block; white-space: pre; }
.pm-roll__d {
  display: inline-block; height: 1em; line-height: 1;
  overflow: hidden; vertical-align: bottom;
}
.pm-roll__strip {
  display: flex; flex-direction: column;
  transition: transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
  will-change: transform;
}
.pm-roll__n { display: block; height: 1em; line-height: 1; text-align: center; }
@media (prefers-reduced-motion: reduce) {
  .pm-roll__strip { transition: none; }
}
.pm-readout__lbl {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--ink-mute);
  letter-spacing: 0.01em;
}
/* Chart header: title + readout on the left, time controls on the right */
.pm-chart__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.pm-chart__h {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
}
.pm-seg--time { align-self: flex-start; }

/* Body: role rail (left) + plot (right) */
.pm-chart__body { display: flex; gap: 22px; align-items: flex-start; }
.pm-rolerail {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 234px;
  flex: 0 0 auto;
  overflow-y: auto;            /* max-height set in JS = chart height */
  scrollbar-width: thin;
  scrollbar-color: var(--ink-faint) transparent;
}
.pm-rolerail::-webkit-scrollbar { width: 6px; }
.pm-rolerail::-webkit-scrollbar-thumb { background: var(--ink-faint); border-radius: 999px; }
.pm-role {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.pm-role:hover { background: rgba(0, 0, 0, 0.04); color: var(--ink); }
.pm-role.is-active { background: var(--ink); color: #fff; }
.pm-role.is-active .pm-role__val { color: rgba(255, 255, 255, 0.65); }
.pm-role__ic { width: 19px; height: 19px; flex: 0 0 auto; display: block; }
.pm-role__lbl {
  flex: 1; min-width: 0;
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pm-role__val { font-family: var(--mono); font-size: 12px; color: var(--ink-mute); }

.pm-chart__plot { flex: 1; min-width: 0; }
.pm-chart__plot svg { width: 100%; height: auto; display: block; overflow: visible; }
.pm-chart__empty {
  display: flex; align-items: center; justify-content: center;
  min-height: 240px; color: var(--ink-mute); font-size: 15px;
}

/* SVG chart primitives */
.pm-c-grid { stroke: var(--pm-grid-line); stroke-width: 1; }
.pm-c-ylab, .pm-c-xlab { font-family: var(--mono); font-size: 12px; fill: var(--ink-mute); }
.pm-c-line { fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
.pm-cdot {
  stroke: rgba(255, 255, 255, 0.85); stroke-width: 1.4;
  opacity: 0.55; cursor: pointer; transition: opacity 0.12s;
}
.pm-cdot:hover { opacity: 1; }
.pm-c-tagdot { fill: var(--accent); }
.pm-c-tagbg { fill: var(--ink); }
.pm-c-tagtx { fill: #fff; font-family: var(--mono); font-weight: 700; font-size: 13px; }
.pm-c-crossline { stroke: var(--ink-faint); stroke-width: 1; stroke-dasharray: 3 3; }
.pm-c-crossdot { fill: var(--accent); stroke: #fff; stroke-width: 2; }
.pm-c-hit { cursor: crosshair; }

@media (max-width: 760px) {
  /* Stack the rail above the plot; rows become horizontal pills. */
  .pm-chart__body { flex-direction: column; }
  .pm-rolerail {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }
  .pm-role {
    width: auto;
    padding: 6px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.4);
  }
  .pm-role__val { display: none; }
}

/* ─────────────────────────  CONTROLS  ───────────────────────── */
.pm-controls {
  position: sticky;
  top: 8px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 18px 0 8px;
  padding: 10px 14px;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: var(--glass-shadow);
}
.pm-controls__group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pm-controls__label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-mute); font-weight: 600;
}
.pm-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.pm-chip {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.4);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.pm-chip:hover { color: var(--ink); border-color: var(--ink-faint); }
.pm-chip.is-active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.pm-chip__n { opacity: 0.55; font-family: var(--mono); font-size: 11px; margin-left: 5px; }

/* Segmented sort control */
.pm-seg {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 3px;
}
.pm-seg button {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}
.pm-seg button.is-active { background: var(--ink); color: #fff; }

/* ─────────────────────────  SECTIONS  ───────────────────────── */
.pm-section { padding: 38px 0 6px; }
.pm-section__head { max-width: 760px; margin-bottom: 22px; }
.pm-section__head h2 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.025em;
  font-size: clamp(24px, 3.6vw, 34px);
  margin: 0;
}
.pm-section__head p { color: var(--ink-soft); margin: 8px 0 0; font-size: 15.5px; }

/* ───────────────────────  MARKET CARDS  ─────────────────────── */
.pm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}
.pm-card {
  position: relative;
  background: var(--pm-card-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 20px;
  backdrop-filter: blur(8px);
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.pm-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--glass-shadow);
  border-color: var(--ink-faint);
}
.pm-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--glass-shadow);
}
.pm-card__top {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
}
.pm-card__role {
  font-family: var(--font-display);
  font-weight: 700; font-size: 16.5px; letter-spacing: -0.01em; margin: 0;
  line-height: 1.2;
}
.pm-card__ic { flex: none; width: 24px; height: 24px; margin-top: 1px; }
.pm-card__price {
  display: flex; align-items: baseline; gap: 6px; margin: 16px 0 2px;
}
.pm-card__price-num {
  font-family: var(--mono); font-weight: 700; font-size: 34px; letter-spacing: -0.03em;
  line-height: 1;
}
.pm-card__price-unit { font-size: 13px; color: var(--ink-mute); }
.pm-card__median-tag {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-mute);
}

/* Range bar: min ── median ── max */
.pm-range { margin: 18px 0 6px; }
.pm-range__bar {
  position: relative; height: 6px; border-radius: 999px;
  background: linear-gradient(90deg,
    hsl(152 65% 45% / 0.85), hsl(48 90% 52% / 0.85), hsl(8 78% 55% / 0.85));
}
.pm-range__fill {
  position: absolute; top: 0; bottom: 0; border-radius: 999px;
  background: rgba(22, 22, 22, 0.10);
}
/* Typical range (p25–p75) framed over the full min–max gradient */
.pm-range__band {
  position: absolute; top: -3px; bottom: -3px; border-radius: 999px;
  border: 1.5px solid rgba(22, 22, 22, 0.5);
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 1px 3px rgba(22, 22, 22, 0.12);
}
.pm-range__pt {
  position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: #fff; border: 2.5px solid var(--ink);
}
/* Enlarged, transparent hover target so the thin bar is easy to sweep */
.pm-range__hit {
  position: absolute; left: 0; right: 0; top: -12px; bottom: -12px;
  cursor: crosshair;
}
/* While sweeping a card's bar, the headline shows the probed value, not the median */
.pm-card--probing .pm-card__median-tag { visibility: hidden; }
.pm-card--probing .pm-range__pt { transition: none; }
.pm-range__pt { transition: left 0.25s cubic-bezier(0.22, 0.61, 0.36, 1); }
.pm-range__labels {
  display: flex; justify-content: space-between; margin-top: 8px;
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-mute);
}
.pm-card__meta {
  display: flex; gap: 18px; margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--pm-grid-line);
}
.pm-card__meta div { display: flex; flex-direction: column; gap: 3px; }
.pm-card__meta b { font-family: var(--mono); font-weight: 700; font-size: 15px; }
.pm-card__meta span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-mute); }
.pm-card__flags { display: flex; gap: 5px; margin-top: 14px; flex-wrap: wrap; }
.pm-flag {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 6px;
  background: rgba(22, 22, 22, 0.05); color: var(--ink-soft);
}
.pm-flag--small { background: var(--accent-soft); color: var(--accent-strong); }

/* ─────────────────────────  HEATMAP  ────────────────────────── */
.pm-heatwrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pm-heat {
  display: grid;
  gap: 6px;
  min-width: 560px;
}
.pm-heat__cell {
  border-radius: 10px;
  padding: 12px 10px;
  min-height: 56px;
  display: flex; flex-direction: column; justify-content: center;
  border: 1px solid var(--pm-grid-line);
}
.pm-heat__corner, .pm-heat__colhead, .pm-heat__rowhead { background: transparent; border: none; }
.pm-heat__colhead {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  text-align: center; align-items: center; min-height: 0; padding: 4px;
}
.pm-heat__rowhead {
  font-size: 13.5px; font-weight: 600; justify-content: center; padding-right: 12px;
  min-height: 0;
}
.pm-heat__val { font-family: var(--mono); font-weight: 700; font-size: 15px; line-height: 1; }
.pm-heat__sub { font-family: var(--mono); font-size: 10.5px; opacity: 0.7; margin-top: 4px; }
.pm-heat__cell--data { cursor: pointer; transition: transform 0.12s, box-shadow 0.12s; }
.pm-heat__cell--data:hover {
  transform: scale(1.04); box-shadow: 0 6px 18px rgba(22, 22, 22, 0.18); z-index: 2;
}
.pm-heat__cell--empty { background: rgba(255,255,255,0.25); color: var(--ink-faint); }
.pm-heat__cell--empty .pm-heat__val { font-weight: 400; }

.pm-legend {
  display: flex; align-items: center; gap: 10px; margin-top: 16px;
  font-size: 12px; color: var(--ink-mute);
}
.pm-legend__bar {
  width: 160px; height: 8px; border-radius: 999px;
  background: linear-gradient(90deg,
    hsl(152 65% 45%), hsl(48 90% 52%), hsl(8 78% 55%));
}

/* ─────────────────────────  GEO MAP  ────────────────────────── */
.pm-section__head--row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; max-width: none;
}
.pm-seg--geo { align-self: flex-start; flex: 0 0 auto; }

.pm-geowrap {
  display: flex;
  gap: 22px;
  align-items: stretch;
  background: var(--pm-card-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(10px) saturate(1.1);
  padding: 18px;
}
.pm-geo {
  flex: 1; min-width: 0;
  display: flex; align-items: center; justify-content: center;
}
.pm-geo svg { width: 100%; height: auto; max-height: 520px; display: block; overflow: visible; }
.pm-geo__land {
  fill: rgba(120, 130, 150, 0.07);
  stroke: var(--ink-faint);
  stroke-width: 1.2;
  stroke-linejoin: round;
}
.pm-geo__dot { stroke: rgba(255, 255, 255, 0.9); stroke-width: 1.4; transition: opacity 0.12s; }
.pm-geo__pt { cursor: pointer; }
.pm-geo__pt:hover .pm-geo__dot { stroke-width: 2.4; }
.pm-geo__lab {
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  fill: var(--ink); paint-order: stroke;
  stroke: var(--pm-card-bg); stroke-width: 3.5px; stroke-linejoin: round;
}

/* Side: most-active locations list */
.pm-geo__side {
  flex: 0 0 232px;
  display: flex; flex-direction: column; gap: 2px;
  align-self: center;
}
.pm-geo__sidehead {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-mute); font-weight: 700; margin: 0 0 8px 4px;
}
.pm-geo__row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--ink-soft); font-family: inherit;
  text-align: left; cursor: pointer; transition: background 0.15s;
}
.pm-geo__row:hover { background: rgba(0, 0, 0, 0.04); }
.pm-geo__rowdot {
  width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}
.pm-geo__rowcity {
  flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pm-geo__rowval { font-family: var(--mono); font-size: 12.5px; color: var(--ink-mute); }

@media (max-width: 760px) {
  .pm-geowrap { flex-direction: column; }
  .pm-geo__side { flex-basis: auto; width: 100%; }
}

/* ───────────────────────  METHODOLOGY  ──────────────────────── */
.pm-method { max-width: 760px; }
.pm-method h2 {
  font-family: var(--font-display); font-weight: 800;
  letter-spacing: -0.025em; font-size: clamp(22px, 3vw, 30px); margin: 0 0 18px;
}
.pm-method ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.pm-method li {
  position: relative; padding-left: 26px; color: var(--ink-soft); font-size: 15.5px;
}
.pm-method li::before {
  content: ""; position: absolute; left: 4px; top: 9px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
}
.pm-method strong { color: var(--ink); }

/* ────────────────────────  CTA BAND  ────────────────────────── */
.pm-ctaband {
  margin: 56px 0 8px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(255, 157, 122, 0.30), transparent 55%),
    radial-gradient(120% 140% at 100% 100%, rgba(168, 191, 224, 0.34), transparent 55%),
    var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  padding: clamp(34px, 6vw, 60px);
  text-align: center;
}
.pm-ctaband__inner { max-width: 600px; margin: 0 auto; }
.pm-ctaband h2 {
  font-family: "Cabinet Grotesk", sans-serif; font-weight: 800;
  letter-spacing: -0.025em; font-size: clamp(26px, 4vw, 40px); margin: 0;
}
.pm-ctaband p { color: var(--ink-soft); font-size: 16.5px; margin: 14px 0 26px; }

/* ─────────────────────────  TOOLTIP  ────────────────────────── */
.pm-tip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  background: var(--ink);
  color: #fff;
  border-radius: 12px;
  padding: 10px 13px;
  font-size: 13px;
  line-height: 1.4;
  max-width: 240px;
  box-shadow: 0 14px 34px -10px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, calc(-100% - 12px));
  transition: opacity 0.1s;
}
.pm-tip__role { font-weight: 700; }
.pm-tip__price { font-family: var(--mono); font-weight: 700; font-size: 16px; margin: 2px 0; }
.pm-tip__meta { opacity: 0.75; font-size: 12px; }
.pm-tip::after {
  content: ""; position: absolute; left: 50%; bottom: -6px;
  transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--ink); border-bottom: 0;
}

/* Reveal-on-scroll (mirrors the landing's .reveal) */
.pm-card, .pm-stat { opacity: 1; }

@media (prefers-reduced-motion: no-preference) {
  .pm-reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.5s ease, transform 0.5s ease; }
  .pm-reveal.in { opacity: 1; transform: none; }
}
