/* RQ4 explorer — styled to the charleslikesdata design system:
   Poppins, monochrome grayscale + one pale analytical blue, pill geometry,
   10px cards, generous whitespace. Chart series colors are the validated
   analytical-blue pair (six-check palette validator, light & dark). */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }

.viz-root {
  color-scheme: light;
  /* --- site tokens (light) --- */
  --surface-page: #fff;
  --surface-muted: #f9f9f9;
  --surface-card: #fff;
  --surface-accent: rgba(235, 241, 248, 0.4);
  --surface-accent-solid: #ebf1f8;
  --surface-inverse: #353535;
  --surface-inverse-hover: #000;
  --text-heading: #353535;
  --text-primary: #353535;
  --text-secondary: #555;
  --text-muted: #666;
  --text-on-dark: #fff;
  --border-strong: #353535;
  --border-hairline: #e0e0e0;
  --border-inactive: #ccc;
  --shadow-card: 0 4px 6px rgba(0, 0, 0, 0.1);
  /* --- chart roles (validated pair + supports) --- */
  --accent: #1a55a0;        /* Post2 / emphasis */
  --accent-soft: #4e90e0;   /* Post1 */
  --link: #1c5eae;
  --deemph: #c2c0ba;
  --grid: #ececec;
  --zero: #b3b1aa;
  --base-band: #ebf1f8;
  --count-fill: #dbe5f2;

  font-family: 'Poppins', -apple-system, blinkmacsystemfont, 'Segoe UI', sans-serif;
  background: var(--surface-page);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  padding: 48px 24px 80px;
}
:root[data-theme="dark"] .viz-root {
  color-scheme: dark;
  --surface-page: #1a1a19;
  --surface-muted: #232322;
  --surface-card: #202020;
  --surface-accent: rgba(43, 63, 90, 0.35);
  --surface-accent-solid: #24344a;
  --surface-inverse: #f0f0f0;
  --surface-inverse-hover: #fff;
  --text-heading: #fff;
  --text-primary: #ececea;
  --text-secondary: #c3c2b7;
  --text-muted: #8f8d83;
  --text-on-dark: #1a1a19;
  --border-strong: #e0e0e0;
  --border-hairline: #3a3935;
  --border-inactive: #4a4944;
  --shadow-card: 0 4px 6px rgba(0, 0, 0, 0.4);
  --accent: #2b66b4;
  --accent-soft: #4f92e2;
  --link: #7ab0f0;
  --deemph: #55534d;
  --grid: #2e2d2a;
  --zero: #6b695f;
  --base-band: #24344a;
  --count-fill: #2b4361;
}

.masthead, .metro-switch, .verdict, .panel { max-width: 1080px; margin: 0 auto; }

.eyebrow {
  font-size: 0.85rem; letter-spacing: 0.08em; text-transform: uppercase;
  font-weight: 500; color: var(--text-muted); margin: 0 0 8px;
}
h1 {
  font-size: clamp(1.9rem, 4.5vw, 3rem); font-weight: 600;
  color: var(--text-heading); line-height: 1.2; margin: 0 0 14px;
}
.lede { color: var(--text-secondary); font-weight: 300; max-width: 62ch; margin: 0 0 18px; }
.links { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 8px; }
.links a {
  display: inline-flex; align-items: center;
  font-size: 0.95rem; font-weight: 600; line-height: 1;
  color: var(--text-heading); text-decoration: none;
  border: 2px solid var(--border-strong); border-radius: 2rem;
  padding: 0.6rem 1.15rem; transition: background 300ms ease, transform 300ms ease;
}
.links a:hover { background: var(--surface-accent); transform: translateY(-2px); }
#theme-toggle {
  margin-left: auto; font: inherit; font-size: 0.85rem; font-weight: 500; cursor: pointer;
  background: var(--surface-muted); color: var(--text-secondary);
  border: 1px solid var(--border-inactive); border-radius: 2rem; padding: 0.45rem 1rem;
}

.metro-switch { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 30px; }
.chip {
  font: inherit; font-size: 0.95rem; font-weight: 500; cursor: pointer; line-height: 1;
  background: var(--surface-card); color: var(--text-secondary);
  border: 1px solid var(--border-inactive); border-radius: 2rem; padding: 0.6rem 1.15rem;
  transition: background 300ms ease, color 300ms ease, border-color 300ms ease;
}
.chip:hover { background: var(--surface-accent); border-color: var(--border-strong); color: var(--text-heading); }
.chip.is-on {
  background: var(--surface-inverse); color: var(--text-on-dark);
  border-color: var(--surface-inverse); font-weight: 600;
}
.chip:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

.verdict {
  margin-top: 26px; background: var(--surface-card);
  border: 1px solid var(--border-hairline); border-radius: 10px;
  box-shadow: var(--shadow-card); padding: 24px 28px;
}
.verdict h2 { margin: 0 0 6px; font-size: 1.5rem; font-weight: 600; color: var(--text-heading); }
.verdict .badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 12px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.85rem; font-weight: 500; color: var(--text-secondary);
  background: var(--surface-muted); border: 1px solid var(--border-hairline);
  border-radius: 2rem; padding: 0.35rem 0.85rem;
}
.verdict p.reading { margin: 0 0 16px; color: var(--text-primary); font-weight: 300; max-width: 75ch; }
.statrow { display: flex; flex-wrap: wrap; gap: 12px 30px; color: var(--text-muted); font-size: 0.85rem; }
.statrow b {
  color: var(--text-heading); font-size: 1.25rem; font-weight: 600;
  font-variant-numeric: tabular-nums; display: block; line-height: 1.3;
}

.panel { margin-top: 48px; }
.panel-head { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-start; justify-content: space-between; }
.panel h2 { margin: 0 0 8px; font-size: 1.5rem; font-weight: 600; color: var(--text-heading); }
.panel .sub { color: var(--text-secondary); font-weight: 300; font-size: 0.95rem; max-width: 72ch; margin: 0 0 16px; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; }
.chip.sm { font-size: 0.85rem; padding: 0.45rem 0.95rem; }

.legend { display: flex; gap: 18px; font-size: 0.85rem; color: var(--text-secondary); margin: 4px 0 10px; flex-wrap: wrap; }
.legend .key { display: inline-flex; align-items: center; gap: 7px; }
.swatch { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

.coef-svg, .es-svg, .map-svg { width: 100%; height: auto; display: block; }
svg text { font-family: inherit; }

.es-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.es-cell h3 { margin: 0 0 2px; font-size: 1rem; font-weight: 600; color: var(--text-heading); }
.es-cell .drift { font-size: 0.85rem; color: var(--text-muted); margin: 0 0 8px; }

.map-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 24px; align-items: start; }
.map-side { font-size: 0.85rem; color: var(--text-secondary); }
.map-side h3 { margin: 0 0 6px; font-size: 0.95rem; font-weight: 600; color: var(--text-heading); }
.ramp { display: block; width: 100%; height: 12px; border-radius: 6px; margin: 6px 0 4px; border: 1px solid var(--border-hairline); }
.ramp-labels { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.hatch-key { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; }
.hatch-key .sw { width: 18px; height: 14px; border: 1px solid var(--border-inactive); border-radius: 3px; }
@media (max-width: 760px) { .map-wrap { grid-template-columns: 1fr; } }

.tableview { margin-top: 12px; color: var(--text-secondary); font-size: 0.95rem; }
.tableview summary { cursor: pointer; font-weight: 500; }
.tableview table { border-collapse: collapse; margin-top: 10px; font-size: 0.85rem; width: 100%; }
.tableview th, .tableview td { border: 1px solid var(--border-hairline); padding: 5px 9px; text-align: right; font-variant-numeric: tabular-nums; }
.tableview th { background: var(--surface-muted); font-weight: 600; color: var(--text-heading); }
.tableview th:first-child, .tableview td:first-child { text-align: left; }
.tableview .twrap { overflow-x: auto; max-height: 420px; overflow-y: auto; }

.estimand {
  background: var(--surface-muted); border: 1px solid var(--border-hairline);
  border-radius: 10px; padding: 24px 28px;
}
.estimand ul { margin: 10px 0 16px; padding-left: 20px; color: var(--text-secondary); font-weight: 300; }
.estimand li { margin: 7px 0; }
.estimand li strong { color: var(--text-heading); font-weight: 600; }
.colophon { color: var(--text-muted); font-size: 0.85rem; margin: 0; }
.colophon a { color: var(--link); }
code {
  background: var(--surface-card); border: 1px solid var(--border-hairline);
  border-radius: 5px; padding: 0 5px; font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.tip {
  position: fixed; pointer-events: none; z-index: 10;
  background: var(--surface-inverse); color: var(--text-on-dark);
  font-size: 0.8rem; line-height: 1.45; padding: 8px 11px; border-radius: 8px;
  max-width: 270px; opacity: 0; transition: opacity 80ms linear;
  box-shadow: var(--shadow-card);
}
.tip.show { opacity: 0.98; }
.tip b { font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .viz-root { padding: 28px 14px 56px; }
  .panel-head { flex-direction: column; }
  .verdict { padding: 18px 20px; }
}
