/* Existing homepage and Stack Up layout components. */
/* ---------- Base & layout ---------- */
*{}
html{-webkit-text-size-adjust:100%}
/* Reserve the scrollbar's gutter on BOTH edges of the window. A classic
   desktop scrollbar otherwise takes its strip out of the right side only,
   which leaves the centered .wrap column with visibly more empty space on
   the right of the page than on the left. With both-edges the two gutters
   match, so the left and right spacing around the content come out equal. */
html{scrollbar-gutter:stable both-edges}
/* The page itself only ever scrolls up and down. Anything wider than the
   screen (a table, a chart) scrolls sideways inside its own container —
   see .table-scroll below — instead of making the whole page drift
   left and right on touch devices. */
html, body{overflow-x:hidden; overflow-x:clip}
body{
  margin:0; background:var(--bg); color:var(--ink);
  font-family:"IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size:16px; line-height:1.55;
}
img{max-width:100%; height:auto}
.wrap{  }
@media (max-width:560px){ .wrap{} }

/* ---------- Page intro / headings ---------- */
.intro{max-width:760px}
h1{
  font-family:"IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-weight:700;
  margin:0 0 12px; letter-spacing:-.01em;
}
.lede{ color:var(--ink-2); margin:0 0 18px; max-width:68ch}
.lede strong{color:var(--ink)}

/* ---------- Stat strip ---------- */
.stat-strip{
  display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin:22px 0 6px;
}
@media (max-width:640px){ .stat-strip{grid-template-columns:1fr 1fr} .stat-strip .stat:last-child{grid-column:1/-1} }
.stat{
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  padding:14px 16px; box-shadow:var(--shadow);
}
.stat .k{font-size:12px; font-weight:600; letter-spacing:.07em; text-transform:uppercase; color:var(--ink-3); margin:0 0 4px}
.stat .v{font-family:"IBM Plex Sans", system-ui, sans-serif; font-size:clamp(22px,3.4vw,28px); font-weight:600; line-height:1.1; margin:0}
.stat .n{font-size:13px; color:var(--ink-2); margin:5px 0 0}
.stat .v.mean{color:var(--mean)}

/* ---------- Controls & segmented buttons ---------- */
.controls{
  display:flex; flex-wrap:wrap; gap:14px 22px; align-items:flex-end;
  margin:26px 0 0; padding:16px; background:var(--surface);
  border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow);
}
.ctl-group{display:flex; flex-direction:column; gap:7px}
.ctl-label{ font-weight:600; letter-spacing:.07em; text-transform:uppercase; color:var(--ink-3)}
.seg{display:inline-flex; background:var(--surface-2); border:1px solid var(--line); border-radius:10px; padding:3px; gap:2px; flex-wrap:wrap}
.seg button{
  appearance:none; border:0; background:transparent; color:var(--ink-2);
  font:inherit;  font-weight:600; padding:8px 14px; border-radius:7px; cursor:pointer;
}
.seg button:hover{color:var(--ink)}
.seg button[aria-pressed="true"]{background:var(--surface); color:var(--accent-ink); box-shadow:0 1px 3px rgba(0,0,0,.14)}
.seg button:focus-visible, input:focus-visible, select:focus-visible{outline:2px solid var(--accent); outline-offset:2px}

/* ---------- Cards ---------- */
.card{
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  box-shadow:var(--shadow); padding:22px 22px 18px; margin-top:16px;
}
@media (max-width:560px){ .card{padding:16px 14px 12px} }
.card-head{display:flex; flex-wrap:wrap; gap:8px 16px; align-items:baseline; justify-content:space-between; margin-bottom:4px}
.card h2{font-family:"IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;  margin:0; }
.card-note{ color:var(--ink-2); margin:0 0 14px}

/* Legend row with color swatches (charts, keys, map pins, …) */
.legend{display:flex; gap:16px;  color:var(--ink-2); flex-wrap:wrap}
.legend span{display:inline-flex; align-items:center; gap:6px}
.swatch{width:14px; height:10px; border-radius:3px; display:inline-block}

/* Callout box for the takeaway inside a card */
.insight{
  margin-top:16px; background:var(--accent-soft); border-radius:10px; padding:13px 16px;
   color:var(--ink);
}
.insight strong{color:var(--accent-ink)}
@media (prefers-color-scheme: dark){ .insight strong{color:var(--accent)} }

/* ---------- Forms & result panel ---------- */
.compare{display:grid; grid-template-columns:1fr 1fr; gap:22px}
@media (max-width:720px){ .compare{grid-template-columns:1fr} }
.compare h2{font-family:"IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;  margin:0 0 6px; }
.compare p{color:var(--ink-2);  margin:0 0 14px}
.field{display:flex; flex-direction:column; gap:6px; margin-bottom:12px}
.field label{ font-weight:600; color:var(--ink-2)}
.field input, .field select{
  font:inherit; font-size:16px; padding:10px 12px; border-radius:9px;
  border:1px solid var(--line); background:var(--bg); color:var(--ink); width:100%;
}
.verdict{
  border:1px solid var(--line); border-radius:10px; padding:15px 16px; background:var(--surface-2);
  font-size:15px; min-height:96px; display:flex; flex-direction:column; justify-content:center; gap:4px;
}
.verdict .big{font-family:"IBM Plex Sans", system-ui, sans-serif; font-size:20px; font-weight:600}
.verdict p{margin:0;  color:var(--ink)}

/* ---------- Tables ---------- */
.table-card{padding:6px 22px 14px}
@media (max-width:560px){ .table-card{padding:6px 14px 10px} }
/* Wrap a table in .table-scroll when its columns can't shrink to phone
   width: the table then swipes sideways inside its card while the page
   keeps scrolling straight up and down. */
.table-scroll{overflow-x:auto; overscroll-behavior-x:contain; -webkit-overflow-scrolling:touch}
table{width:100%; border-collapse:collapse; font-size:15px}
caption, .table-title{text-align:left; font-family:"IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif; font-size:19px; font-weight:600; padding:14px 0 8px}
/* A .table-title sits above a .table-scroll wrapper so the heading stays
   put while the table grid swipes sideways underneath it. */
.table-title{margin:0}
th, td{padding:9px 8px; text-align:left; border-bottom:1px solid var(--line); vertical-align:top}
thead th{ letter-spacing:.06em; text-transform:uppercase; color:var(--ink-3); border-bottom:2px solid var(--line)}
td.num, th.num{text-align:right; font-family:"IBM Plex Sans", system-ui, sans-serif;  white-space:nowrap}
tbody tr:last-child td{border-bottom:0}
tr.you-row td{background:var(--mean-soft); font-weight:600}
@media (max-width:560px){
  td.num, th.num{}
  th, td{padding:8px 5px}
}

/* ---------- Explainer cards & footer ---------- */
.two-col{display:grid; grid-template-columns:1fr 1fr; gap:22px; margin-top:16px}
@media (max-width:720px){ .two-col{grid-template-columns:1fr} }
.plain-card{background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); padding:20px 22px}
.plain-card h3{font-family:"IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;  margin:0 0 8px; }
.plain-card p, .plain-card li{ color:var(--ink-2)}
.plain-card p{margin:0 0 8px}
.plain-card ul{margin:0; padding-left:18px}
.plain-card li{margin-bottom:5px}
footer{margin-top:26px; font-size:13px; color:var(--ink-3)}
footer a{color:var(--accent-ink)}
@media (prefers-color-scheme: dark){ footer a{color:var(--accent)} }
footer p{margin:0 0 6px}
/* Collapsible "Source data" disclosure in the footer: collapsed by default,
   the arrow rotates down when open. */
.src-toggle{display:inline-flex; align-items:center; gap:7px; background:none; border:0; padding:2px 0; margin:0 0 4px; font-family:"IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif; font-size:16px; font-weight:600; color:var(--ink); cursor:pointer}
.src-toggle .src-arrow{width:14px; height:14px; flex:none; transition:transform .25s ease}
.src-toggle[aria-expanded="true"] .src-arrow{transform:rotate(90deg)}
.src-toggle:hover{color:var(--accent-ink)}
@media (prefers-color-scheme: dark){ .src-toggle:hover{color:var(--accent)} }
@media (prefers-reduced-motion: reduce){ .src-toggle .src-arrow{transition:none} }
.src-body[hidden]{display:none}
