/*
 * "How it works": a public map of the research engine, served locally and on the hosted site. Every colour, font and radius comes from the app's tokens (styles/tokens.css), so
 * the page follows the dashboard's light and dark themes. Colour roles follow web/tokens.json:
 * neutral ink for structure and flow, scenario blues only where the drawing shows scenarios,
 * series-6 (violet) only for roles that run on a different model from the coordinator, and the
 * warning hue only for the hurdle line. Green and red stay reserved for return verdicts.
 * Like the rest of the app, sections are separated by space, not cards, borders or pills, and
 * labels are sentence case in the body face: no eyebrows, capitals or monospace as decoration.
 * Every rule is scoped under .hiw so nothing here leaks into the shared shell.
 */
.hiw {
  --hiw-alt: var(--series-6);
  --hiw-alt-soft: color-mix(in srgb, var(--series-6) 13%, var(--surface-raised));
  --hiw-band: color-mix(in srgb, var(--text) 4.5%, var(--surface-page));
  max-width: 1360px; margin: 0 auto; padding-block: var(--space-8) var(--space-16);
  color: var(--text); font-size: var(--text-prose); line-height: var(--leading-body);
}
.hiw .wrap { max-width: 1080px; margin: 0 auto; }
.hiw h1, .hiw h2, .hiw h3 { font-stretch: var(--stretch-display); letter-spacing: -0.015em; text-wrap: balance; margin: 0; }
.hiw h1 { font-size: clamp(34px, 5vw, 56px); line-height: 1.04; font-weight: 750; }
.hiw h2 { font-size: clamp(24px, 3vw, 32px); line-height: 1.12; font-weight: 700; }
.hiw h3 { font-size: 18px; line-height: 1.25; font-weight: 650; }
.hiw p { margin: 0; }
.hiw p a, .hiw figcaption a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 2px; }
.hiw p a:hover, .hiw figcaption a:hover { text-decoration-color: var(--text); }

.hiw .top { display: flex; justify-content: flex-start; align-items: baseline; gap: var(--space-4); flex-wrap: wrap; color: var(--text-muted); font-size: var(--text-ui); }
.hiw .top ul { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0; padding: 0; }
.hiw .top a { color: var(--text-secondary); text-decoration: none; }
.hiw .top a:hover { color: var(--text); text-decoration: underline; }

.hiw .hero { padding-block: var(--space-12) var(--space-10); display: grid; gap: var(--space-6); }
.hiw .lede { font-size: clamp(17px, 1.8vw, 20px); line-height: 1.55; color: var(--text-secondary); max-width: 46em; }
.hiw .stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-6); }
.hiw .stat { display: grid; gap: 2px; align-content: start; }
.hiw .stat b { font-size: 40px; font-weight: 650; font-stretch: var(--stretch-figure); line-height: 1.05; font-variant-numeric: tabular-nums; }
.hiw .stat span { font-size: var(--text-ui); color: var(--text-muted); line-height: 1.4; }


.hiw section.block { padding-block: var(--space-12) 0; margin-top: var(--space-8); }
.hiw .head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: var(--space-4) var(--space-12); align-items: start; margin-bottom: var(--space-6); }
.hiw .head p { color: var(--text-secondary); font-size: 16px; }

.hiw figure { margin: 0; }
.hiw .sheet { padding: 0; }
.hiw .scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.hiw .scroll svg { display: block; width: 100%; height: auto; }
.hiw .scroll.big svg { min-width: 1060px; }
.hiw .scroll.mid svg { min-width: 860px; }
.hiw .swipe { display: none; font-size: var(--text-s); color: var(--text-muted); margin-top: var(--space-2); }
.hiw figcaption { margin-top: var(--space-3); font-size: 14px; color: var(--text-muted); line-height: 1.55; max-width: 62em; }
.hiw .legend { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: var(--space-3); font-size: var(--text-ui); color: var(--text-secondary); }
.hiw .legend i { display: inline-block; vertical-align: middle; margin-right: 8px; }
.hiw .sw-flow { width: 26px; height: 0; border-top: 2px solid var(--text); }
.hiw .sw-fb { width: 26px; height: 0; border-top: 2px dashed var(--text-muted); }
.hiw .sw-alt { width: 14px; height: 14px; border-radius: 3px; background: var(--hiw-alt-soft); border: 1.5px solid var(--hiw-alt); }
.hiw .sw-tick { font-style: normal; font-weight: 700; color: var(--text); }


/* Inline drawings: the page's CSS styles the SVG classes, so both themes come from tokens. */
.hiw svg text { font-family: var(--font-sans); font-stretch: 88%; }
.hiw .band { fill: var(--hiw-band); }
.hiw .band-l { fill: var(--text-muted); font-size: 12px; font-weight: 600; }
.hiw .card { fill: var(--surface-raised); stroke: var(--border-strong); stroke-width: 1; }
.hiw .card-k { fill: var(--surface-raised); stroke: var(--text); stroke-width: 1.8; }
.hiw .card-alt { fill: var(--hiw-alt-soft); stroke: var(--hiw-alt); stroke-width: 1.4; }
.hiw .card-sunk { fill: var(--surface-sunk); stroke: var(--border-strong); stroke-width: 1; }
.hiw .card-acc { fill: var(--selection-soft); stroke: var(--text-secondary); stroke-width: 1.2; }
.hiw .frame { fill: none; stroke: var(--border-strong); stroke-width: 1; }
.hiw .frame-d { fill: none; stroke: var(--border-strong); stroke-width: 1.2; stroke-dasharray: 5 4; }
.hiw .rule { stroke: var(--border); stroke-width: 1; }
.hiw .t-k { fill: var(--text-muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.hiw .t-h { fill: var(--text); font-size: 14px; font-weight: 650; }
.hiw .t-hs { fill: var(--text); font-size: 12.5px; font-weight: 600; }
.hiw .t-s { fill: var(--text-muted); font-size: 11px; }
.hiw .t-g { fill: var(--text-secondary); font-size: 10.8px; }
.hiw .t-tick { fill: var(--text); font-size: 10.8px; font-weight: 700; }
.hiw .t-out { fill: var(--text); font-size: 10.8px; font-weight: 700; }
.hiw .t-acc { fill: var(--text); font-size: 11px; font-weight: 600; }
.hiw .t-fb { fill: var(--text-muted); font-size: 11px; font-weight: 500; }
.hiw .t-fbk { fill: var(--text-secondary); font-size: 11.5px; font-weight: 650; }
.hiw .flow { stroke: var(--text); stroke-width: 1.5; fill: none; }
.hiw .fb { stroke: var(--text-muted); stroke-width: 1.4; fill: none; stroke-dasharray: 5 4; }
.hiw .m-flow { fill: var(--text); }
.hiw .m-fb { fill: var(--text-muted); }
.hiw .bar-in { fill: var(--text-secondary); }
.hiw .bar-out { fill: var(--border-strong); opacity: 0.6; }
.hiw .bar-key { fill: var(--scenario-base); }
.hiw .s-down { stroke: var(--scenario-downside); } .hiw .s-base { stroke: var(--scenario-base); } .hiw .s-up { stroke: var(--scenario-upside); }
.hiw .f-down { fill: var(--scenario-downside); } .hiw .f-base { fill: var(--scenario-base); } .hiw .f-up { fill: var(--scenario-upside); }
.hiw .axis { stroke: var(--border-strong); stroke-width: 1; }
.hiw .hurdle { stroke: var(--warning); stroke-width: 1.4; stroke-dasharray: 3 3; }
.hiw .t-warn { fill: var(--warning); font-size: 11px; font-weight: 600; }

.hiw .table-wrap { overflow-x: auto; }
.hiw table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.hiw th, .hiw td { text-align: left; padding: 10px 16px 10px 0; vertical-align: top; }
.hiw thead th { font-size: var(--text-s); font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.hiw tbody tr + tr td { border-top: 1px solid var(--border-soft); }
.hiw tbody tr.grp td { font-weight: 650; font-size: 14.5px; color: var(--text); padding-block: var(--space-5) 6px; }
.hiw tbody tr.grp + tr td { border-top: 0; }
.hiw td.n { font-size: 13px; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.hiw td.c { font-weight: 600; white-space: nowrap; }
.hiw td.s { color: var(--text-secondary); }
/* The date a rule took effect: quiet text beside the check, not a badge. */
.hiw .since { margin-left: 6px; font-size: var(--text-s); font-weight: 400; color: var(--text-muted); white-space: nowrap; }

.hiw .limits { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6) var(--space-12); }
/* A table or figure followed by notes/tables: space separates them, as between sections. */
.hiw .table-wrap + .limits { margin-top: var(--space-10); }
.hiw figure + .limits { margin-top: var(--space-8); }
.hiw figure + .table-wrap { margin-top: var(--space-6); }
.hiw .limits div { display: grid; gap: 6px; align-content: start; }
.hiw .limits h3 { font-size: 16px; }
.hiw .limits p { font-size: 14.5px; color: var(--text-secondary); }

.hiw .foot { padding-top: var(--space-12); color: var(--text-muted); font-size: var(--text-ui); display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }

@media (max-width: 1000px) {
  .hiw .head { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .hiw .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* One column on phones: a hairline between notes, with room so it never touches the heading. */
  .hiw .limits div + div { border-top: 1px solid var(--border-soft); padding-top: var(--space-5); }
  .hiw .swipe { display: block; }
}

/* Cost and results: numeric columns and the short notes between its tables. */
.hiw th.r, .hiw td.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hiw h3.sub { font-size: 16px; margin-top: var(--space-10); margin-bottom: var(--space-2); }
.hiw p.note { font-size: 14px; color: var(--text-secondary); margin-bottom: var(--space-4); max-width: 72ch; }
.hiw .table-wrap + p.note { margin-top: var(--space-3); }
.hiw ul.note, .hiw ol.note { font-size: 14px; color: var(--text-secondary); margin: 0 0 var(--space-4); max-width: 72ch; padding-left: 1.2em; }
.hiw ul.note li + li, .hiw ol.note li + li { margin-top: var(--space-2); }
