/* How it works page. Builds on ../styles.css tokens and components. */

.how-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 40px; align-items: start; }
.toc { position: sticky; top: 76px; display: grid; gap: 2px; padding: 28px 0; font-size: 13.5px; }
.toc a { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--radius-sm); color: var(--text-2); text-decoration: none; }
.toc a:hover { background: var(--surface-2); color: var(--text); }
.toc a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.toc i { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--surface-3); font-style: normal; font-size: 11px; font-weight: 700; font-family: var(--font-num); flex: none; }
.toc a.active i { background: var(--accent); color: var(--accent-ink); }

.how-main { min-width: 0; padding-bottom: 40px; }
.how-main section { margin: 0; padding: 36px 0 8px; scroll-margin-top: 64px; }
.how-main p { color: var(--text-2); max-width: 70ch; }
.how-main b { color: var(--text); }
.small { font-size: 12.5px; }
.how-main h3 { margin: 0 0 6px; font-size: 16px; }
.how-main .sub { margin: 26px 0 8px; font-size: 18px; }

.how-hero { padding-top: 36px !important; }
.kicker { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 700; }
.how-hero h1 { margin: 14px 0 0; font-size: clamp(34px, 5vw, 52px); max-width: 18ch; }
.lead { font-size: 17px; margin: 14px 0 22px; }

.pipeline { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; counter-reset: p; }
.pipeline li { position: relative; display: grid; gap: 4px; align-content: start; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); font-size: 13px; color: var(--text-2); }
.pipeline li b { font-size: 15px; }
.pipeline li:not(:last-child)::after { content: ""; position: absolute; right: -9px; top: 50%; width: 8px; height: 8px; border-top: 2px solid var(--border-strong); border-right: 2px solid var(--border-strong); transform: translateY(-50%) rotate(45deg); z-index: 1; background: transparent; }
.step-n { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-family: var(--font-num); font-weight: 700; font-size: 12px; margin-bottom: 4px; }
.pipeline li:nth-child(1) .step-n { background: var(--info-soft); color: var(--info); }
.pipeline li:nth-child(2) .step-n { background: var(--warn-soft); color: var(--warn); }
.pipeline li:nth-child(3) .step-n { background: var(--pos-soft); color: var(--pos); }
.pipeline li:nth-child(5) .step-n { background: var(--neg-soft); color: var(--neg); }

.sec-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.sec-head h2 { margin: 0; font-size: 28px; }
.sec-n { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-family: var(--font-num); font-weight: 700; flex: none; }

.src-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0 12px; }
.src-card { padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.src-card p { margin: 6px 0 0; font-size: 13.5px; }
.src-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; margin-bottom: 10px; }
.src-from { font-size: 12.5px !important; color: var(--muted) !important; margin-top: 0 !important; }

.example-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.example-head img { width: 28px; height: 28px; image-rendering: pixelated; }
.example-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.ex { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.ex span { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.ex b { font-family: var(--font-num); font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.ex small { display: block; font-size: 11.5px; color: var(--text-2); }
.ex.jagex { background: var(--accent-soft); }

.timeline { list-style: none; margin: 8px 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: relative; }
.timeline::before { content: ""; position: absolute; left: 10%; right: 10%; top: 9px; height: 2px; background: var(--border-strong); }
.timeline li { position: relative; display: grid; justify-items: center; text-align: center; gap: 2px; padding: 26px 6px 0; font-size: 12.5px; color: var(--text-2); }
.timeline li::before { content: ""; position: absolute; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); }
.timeline li:last-child::before { background: var(--accent); }
.timeline b { font-size: 13px; }

.rules { display: grid; gap: 6px; margin: 10px 0 14px; font-size: 14px; color: var(--text-2); }
.rules div { display: block; }
.rules .dot { display: inline-block; margin-right: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; transform: translateY(1px); }

.ladder-svg { width: 100%; display: block; overflow: visible; }
.ladder-svg .tick { font-family: var(--font-num); font-size: 11px; fill: var(--text-2); }
.ladder-svg .lab { font-size: 11px; fill: var(--muted); }
.ladder-svg .big { font-family: var(--font-num); font-size: 12.5px; font-weight: 600; fill: var(--text); }
.ladder-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }

.taxcalc { display: flex; flex-wrap: wrap; gap: 16px; align-items: end; margin-top: 10px; }
.taxcalc .field span { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.taxcalc .field input { width: 180px; font-family: var(--font-num); }
.taxout { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.taxbar { width: 100%; height: 14px; border-radius: 7px; overflow: hidden; display: flex; background: var(--surface-3); }
.taxbar i { display: block; height: 100%; }

.funnel-row { display: grid; grid-template-columns: 220px minmax(0, 1fr) 70px; gap: 12px; align-items: center; padding: 5px 0; font-size: 13.5px; }
.funnel-row .fbar { height: 22px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.funnel-row .fbar i { display: block; height: 100%; border-radius: 6px; background: var(--accent); opacity: .85; }
.funnel-row b { font-family: var(--font-num); text-align: right; }
.funnel-row span small { display: block; color: var(--muted); font-size: 11.5px; }

.model-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.model-card { display: grid; align-content: start; gap: 8px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.model-card p { margin: 0; font-size: 13.5px; }
.model-card .pill { justify-self: start; }
.illo { width: 100%; height: auto; background: var(--surface-2); border-radius: var(--radius-sm); padding: 6px; }
.illo .chips rect { fill: var(--info-soft); stroke: var(--info); stroke-width: 1; }
.illo .chip-lines path, .illo .arrow-line { fill: none; stroke: var(--border-strong); stroke-width: 1.5; }
.illo .node { fill: var(--accent); }
.illo .node-t { fill: var(--accent-ink); font-weight: 700; font-size: 16px; }
.illo .noisy { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.illo .smooth { fill: none; stroke: var(--pos); stroke-width: 2.5; }
.illo .trend { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 5 4; }
.illo .node-dot { fill: var(--accent); }
.illo .avg { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 3 3; }
.illo .pull { fill: none; stroke: var(--warn); stroke-width: 2; }
.illo .lbl { font-size: 10px; fill: var(--muted); }
.chips-row { display: flex; flex-wrap: wrap; gap: 4px; }
.chips-row span { padding: 2px 8px; border-radius: 999px; background: var(--surface-2); font-size: 11px; color: var(--text-2); }

.folds { display: grid; gap: 8px; margin: 12px 0; }
.fold-axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-left: 64px; }
.fold { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 8px; align-items: center; font-size: 12px; color: var(--text-2); }
.fold .bar { display: flex; height: 18px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.fold .bar i { display: block; height: 100%; }
.fold .train { background: var(--accent-soft); }
.fold .gap { background: var(--surface-3); }
.fold .test { background: var(--series-sell); }
.metric-grid, .three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.metric { padding: 14px; border-radius: var(--radius); background: var(--surface-2); }
.metric p, .three p { margin: 4px 0 0; font-size: 13px; }

.demo-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0; }
.demo-pick select { height: 36px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; max-width: 100%; }
.demo-grid { display: grid; gap: 12px; }
.demo-two { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 12px; }
.wbar { display: grid; grid-template-columns: 150px minmax(0, 1fr) minmax(0, 1fr) 54px; gap: 6px; align-items: center; font-size: 12.5px; padding: 3px 0; }
.wbar .neg-side { display: flex; justify-content: flex-end; }
.wbar .neg-side i, .wbar .pos-side i { display: block; height: 12px; border-radius: 3px; }
.wbar .neg-side i { background: var(--series-sell); }
.wbar .pos-side i { background: var(--series-buy); }
.wbar b { font-family: var(--font-num); font-weight: 500; font-size: 11.5px; text-align: right; color: var(--text-2); }
.wbar-head span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wbar-head { display: grid; grid-template-columns: 150px minmax(0, 1fr) minmax(0, 1fr) 54px; gap: 6px; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.wbar-head span:nth-child(2) { text-align: right; }
.final { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

.meter { display: grid; grid-template-columns: repeat(4, 1fr); border-radius: 999px; overflow: hidden; font-size: 12px; font-weight: 700; text-align: center; }
.meter span { padding: 6px 0; }
.meter span:nth-child(1) { background: var(--surface-3); color: var(--text-2); }
.meter span:nth-child(2) { background: var(--warn-soft); color: var(--warn); }
.meter span:nth-child(3) { background: var(--info-soft); color: var(--info); }
.meter span:nth-child(4) { background: var(--pos-soft); color: var(--pos); }
.signal-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.signal { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.signal p { margin: 8px 0 0; font-size: 13px; }
.formula { display: grid; gap: 6px; margin-bottom: 12px; }
.formula div { display: grid; grid-template-columns: 80px 1fr; gap: 10px; font-size: 14px; }
.formula b { font-family: var(--font-num); font-weight: 500; font-size: 13px; }
.fresh-table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.fresh-table td, .fresh-table th { cursor: default; }
.limits { margin: 8px 0 18px; padding-left: 20px; color: var(--text-2); display: grid; gap: 6px; max-width: 70ch; }

@media (max-width: 1000px) {
  .how-layout { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
  .pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipeline li::after { display: none; }
  .model-grid, .signal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .demo-two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .topnav a { padding: 6px 8px; }
  .src-grid, .model-grid, .signal-grid, .metric-grid, .three, .final { grid-template-columns: minmax(0, 1fr); }
  .pipeline { grid-template-columns: minmax(0, 1fr); }
  .example-grid, .ladder-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .timeline { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .timeline::before { left: 7px; right: auto; top: 10px; bottom: 10px; width: 2px; height: auto; }
  .timeline li { justify-items: start; text-align: left; padding: 0 0 0 28px; }
  .timeline li::before { left: 0; top: 2px; }
  .funnel-row { grid-template-columns: minmax(0, 1fr) 60px; }
  .funnel-row .fbar { grid-column: 1 / -1; grid-row: 2; }
  .wbar, .wbar-head { grid-template-columns: 110px minmax(0, 1fr) minmax(0, 1fr) 46px; }
}

.sim h3 { margin-bottom: 8px; }
.sim-steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--text-2); font-size: 13.5px; }
.fm-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
.fm-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-top: 12px; }
.hbar { display: grid; grid-template-columns: 150px minmax(0, 1fr) 90px; gap: 10px; align-items: center; font-size: 13px; padding: 4px 0; }
.hbar .track { position: relative; height: 18px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.hbar .track i { position: absolute; top: 0; bottom: 0; border-radius: 6px; }
.hbar .track i.pos { background: var(--pos); opacity: .85; }
.hbar .track i.neg { background: var(--neg); opacity: .85; }
.hbar .track .zero { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--border-strong); }
.hbar b { font-family: var(--font-num); font-weight: 600; text-align: right; }
.hbar.best span:first-child { font-weight: 700; color: var(--accent); }
.gap-viz { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.gap-viz .ex b { font-size: 22px; }
.cal-svg { width: 100%; display: block; }
.cal-svg .axis { fill: var(--muted); font-size: 11px; font-family: var(--font-num); }
.cal-svg .lab { fill: var(--muted); font-size: 11px; }
@media (max-width: 1000px) { .fm-grid { grid-template-columns: minmax(0, 1fr); } .fm-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .hbar { grid-template-columns: 100px minmax(0, 1fr) 70px; } .gap-viz { grid-template-columns: minmax(0, 1fr); } }

.hbar .track .ci { position: absolute; top: 50%; height: 2px; margin-top: -1px; background: var(--text); opacity: .55; border-radius: 1px; }
.verdict ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 8px; color: var(--text-2); font-size: 14px; }
.verdict { border-left: 4px solid var(--accent); margin-bottom: 4px; }

/* New model report */
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.two .card h3, #simDays h3, #simRobust h3, #zooChart h3, #marketDays h3 { margin-bottom: 10px; }
#simDays, #simRobust, #marketDays { margin-top: 12px; }
.cal-svg .gridline { stroke: var(--border-strong); stroke-width: 1; }
@media (max-width: 1000px) { .two { grid-template-columns: minmax(0, 1fr); } }
