/* how-it-works page. Extends styles.css, reuses its tokens. */

.how { --panel: rgba(232, 228, 218, 0.035); --grid: rgba(232, 228, 218, 0.09); }

.nav-links a.here { color: var(--ink); }
.how .nav { background: rgba(4, 4, 4, 0.92); backdrop-filter: blur(14px); }

/* ---------- hero ---------- */

.how-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.9fr);
  gap: 56px;
  align-items: end;
  padding: 150px 40px 60px;
  max-width: 1320px;
  margin: 0 auto;
  border-bottom: 1px solid var(--hairline);
}

.how-hero h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(34px, 5.2vw, 68px);
  line-height: 1.04;
  letter-spacing: -0.015em;
  margin: 18px 0 22px;
}
.how-hero h1 span { display: block; }
.how-hero h1 em { font-style: italic; color: var(--moss); }

.how-hero .lede { max-width: 58ch; color: var(--dim); font-size: 13px; line-height: 1.75; }
.how-hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 26px; }

.site-card {
  border: 1px solid var(--hairline);
  background: var(--panel);
  padding: 20px;
}
.site-card-head { font-size: 9px; letter-spacing: 0.24em; color: var(--faint); }
.site-card canvas { display: block; width: 100%; height: auto; margin: 14px 0 16px; }
.site-card h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 26px;
  line-height: 1.1;
}
.site-card .dim { font-size: 10px; letter-spacing: 0.1em; margin-top: 4px; }

.site-stats { margin: 18px 0 14px; display: grid; gap: 10px; }
.site-stats > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.site-stats dt { font-size: 9px; letter-spacing: 0.2em; color: var(--faint); }
.site-stats dd { font-family: var(--serif); font-size: 22px; line-height: 1; }
.site-card-note { font-size: 10px; line-height: 1.7; color: var(--faint); border-top: 1px solid var(--hairline); padding-top: 12px; }

/* ---------- parallax ---------- */

/* Depth comes from transform only, never from top/margin, so a scroll frame
   stays on the compositor and never triggers layout. --py is written by the
   one rAF-throttled scroll pass in how.js. */
[data-parallax] {
  transform: translate3d(0, var(--py, 0px), 0);
  will-change: transform;
}

/* the stage reveal also uses transform, so it composes with the parallax
   offset rather than overwriting it */
.stage[data-parallax] { transform: translate3d(0, var(--py, 0px), 0); }

@media (prefers-reduced-motion: reduce) {
  [data-parallax] { transform: none; will-change: auto; }
}

/* ---------- signal rail ---------- */

.rail {
  position: sticky;
  top: var(--rail-top, 77px);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 40px;
  background: rgba(4, 4, 4, 0.9);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--hairline);
  overflow-x: auto;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail { position: sticky; }
.rail-label { font-size: 9px; letter-spacing: 0.24em; color: var(--faint); flex: none; }

.rail-steps { display: flex; gap: 5px; flex: none; align-items: center; }
.rail-step {
  width: 14px;
  height: 2px;
  background: var(--hairline);
  transition: background 0.4s;
}
.rail-step.done { background: var(--moss); }

.rail-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: var(--moss);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.25s linear;
}
.rail-clips { display: flex; gap: 8px; flex: 1 1 auto; }
.rail-play { flex: none; }

.chip {
  flex: none;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: none;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.chip:hover { color: var(--ink); border-color: var(--dim); }
.chip[aria-pressed="true"] { color: var(--bg); background: var(--ink); border-color: var(--ink); }
.chip .dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }
.chip .dot.safe { background: var(--moss); }
.chip .dot.alert { background: var(--ember); }

.pill.tiny { font-size: 9px; padding: 6px 12px; letter-spacing: 0.16em; cursor: pointer; background: none; font-family: var(--mono); }

/* ---------- stages ---------- */

.stages { max-width: 1320px; margin: 0 auto; padding: 0 40px; }

.stage { padding: 96px 0; border-bottom: 1px solid var(--hairline); }
.stage-head { max-width: 72ch; }
.stage-head h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(28px, 3.6vw, 46px);
  line-height: 1.1;
  margin: 14px 0 18px;
}
.stage-head .lede { color: var(--dim); font-size: 13px; line-height: 1.8; max-width: 64ch; }
.stage-head .lede em { color: var(--moss); font-style: normal; }

.formula {
  margin-top: 20px;
  display: inline-block;
  border: 1px solid var(--hairline);
  padding: 12px 18px;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--ink);
  background: var(--panel);
}
.formula sup { font-size: 9px; }

.stage-body { margin-top: 42px; display: grid; gap: 28px; }
.stage-body.ingest { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stage-body.baseline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stage-body.attribute { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stage-body.flagging { grid-template-columns: minmax(0, 2fr) minmax(230px, 1fr); align-items: stretch; }
.panel.wide { grid-column: 1 / -1; }

.panel {
  border: 1px solid var(--hairline);
  background: var(--panel);
  padding: 16px;
  min-width: 0;
}
.panel figcaption {
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--dim);
  margin-bottom: 14px;
  display: flex;
  justify-content: flex-start;
  align-items: baseline;
  gap: 12px;
  line-height: 1.6;
}
/* only captions that carry a control need the two-up layout */
.panel figcaption:has(.fig-right) { justify-content: space-between; }
.panel figcaption .fig-right { flex: none; margin-left: auto; }
.panel canvas { display: block; width: 100%; height: auto; }
.panel-note { font-size: 10.5px; line-height: 1.75; color: var(--dim); margin-top: 14px; }
.panel-note em { color: var(--moss); font-style: normal; }
.axis-row { display: flex; justify-content: space-between; font-size: 9px; letter-spacing: 0.14em; color: var(--faint); margin-top: 8px; }

.stage-foot { margin-top: 26px; font-size: 9.5px; letter-spacing: 0.14em; color: var(--dim); }

.morph-range { width: 100%; margin-top: 14px; accent-color: var(--moss); }

/* ---------- verdict ---------- */

.verdict-panel {
  border: 1px solid var(--hairline);
  background: var(--panel);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
}
.verdict-word { font-family: var(--serif); font-size: 46px; line-height: 1; }
.verdict-word.alert { color: var(--ember); }
.verdict-word.safe { color: var(--moss); }
.verdict-sub { font-size: 10px; letter-spacing: 0.14em; color: var(--faint); margin-top: 8px; line-height: 1.7; }
.readout { display: grid; gap: 12px; }
.readout > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; border-top: 1px solid var(--hairline); padding-top: 10px; }
.readout dt { font-size: 9px; letter-spacing: 0.18em; color: var(--faint); }
.readout dd { font-size: 14px; letter-spacing: 0.04em; }

/* ---------- callouts ---------- */

.callout, .caveats {
  margin-top: 32px;
  border-left: 2px solid var(--moss);
  background: var(--panel);
  padding: 20px 24px;
  max-width: 78ch;
}
.callout-head { font-size: 9px; letter-spacing: 0.24em; color: var(--moss); margin-bottom: 12px; }
.callout p { font-size: 12px; line-height: 1.85; color: var(--dim); }
.callout strong { color: var(--ink); font-weight: 500; }
.caveats ul { list-style: none; display: grid; gap: 12px; }
.caveats li { font-size: 12px; line-height: 1.8; color: var(--dim); padding-left: 18px; position: relative; }
.caveats li::before { content: ""; position: absolute; left: 0; top: 9px; width: 7px; height: 1px; background: var(--ember); }

/* ---------- bars ---------- */

.bars { display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 116px minmax(0, 1fr) 52px; align-items: center; gap: 12px; }
.bar-name { font-size: 9.5px; letter-spacing: 0.12em; color: var(--dim); }
.bar-track { position: relative; height: 16px; background: rgba(232, 228, 218, 0.06); overflow: hidden; }
.bar-fill { position: absolute; inset: 0 auto 0 0; background: var(--moss); width: 0; transition: width 0.7s cubic-bezier(0.2, 0.7, 0.2, 1); }
.bar-row.top .bar-fill { background: var(--ember); }
.bar-row.unknown .bar-fill { background: var(--dim); }
.bar-value { font-size: 10.5px; text-align: right; color: var(--dim); }
.bar-row.top .bar-value, .bar-row.top .bar-name { color: var(--ink); }
.bar-gate { position: absolute; top: 0; bottom: 0; width: 1px; border-left: 1px dashed rgba(232, 228, 218, 0.5); }

/* ---------- ground truth strip ---------- */

.attr-truth {
  margin-top: 28px;
  border: 1px solid var(--hairline);
  padding: 18px 22px;
  font-size: 11.5px;
  line-height: 1.85;
  color: var(--dim);
}
.attr-truth strong { color: var(--ink); font-weight: 500; }
.attr-truth .split { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 10px; }
.attr-truth .split span { font-size: 10px; letter-spacing: 0.1em; color: var(--faint); }
.attr-truth .split b { color: var(--ink); font-weight: 500; }

/* ---------- results table ---------- */

.table-wrap { margin-top: 36px; overflow-x: auto; }
.results { width: 100%; border-collapse: collapse; font-size: 11.5px; min-width: 620px; }
.results th, .results td { text-align: right; padding: 13px 14px; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
.results th:first-child, .results td:first-child { text-align: left; }
.results thead th { font-size: 9px; letter-spacing: 0.18em; color: var(--faint); font-weight: 400; }
.results tbody tr.bg-row td { color: var(--moss); }
.results td .cell-bar { display: block; height: 2px; background: var(--ember); margin-top: 6px; }
.results td .sr { display: block; font-size: 8.5px; letter-spacing: 0.16em; color: var(--faint); margin-top: 5px; }
.results tbody tr.bg-row td .cell-bar { background: var(--moss); }

/* ---------- motion ---------- */

.stage { opacity: 0.001; transition: opacity 0.7s; }
.stage.in { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .stage { opacity: 1; transition: none; }
  .bar-fill { transition: none; }
  .rail-progress { transition: none; }
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  /* stacked on a phone the two hero blocks sit one above the other, so
     drifting them apart just opens a gap */
  .how-hero [data-parallax] { transform: none; }
  .rail-steps { display: none; }
  .how-hero { grid-template-columns: minmax(0, 1fr); padding: 120px 20px 44px; gap: 34px; }
  .stages { padding: 0 20px; }
  .rail { padding: 12px 20px; gap: 12px; }
  .stage { padding: 64px 0; }
  .stage-body.ingest,
  .stage-body.baseline,
  .stage-body.attribute,
  .stage-body.flagging { grid-template-columns: minmax(0, 1fr); }
  .bar-row { grid-template-columns: 90px minmax(0, 1fr) 46px; }
  .verdict-word { font-size: 36px; }
}
