/* fastlsq: a lab sheet. White paper, black ink rules, square corners, flat colour.
   Same family as event2vec.com: Archivo (wide for display) and IBM Plex Mono.
   Blue marks live, computed values; yellow highlights; red and green for losses and gains. */

:root {
  color-scheme: light;
  --paper:  #ffffff;
  --ink:    #15181d;
  --ink-2:  #3c434f;
  --muted:  #687180;
  --muted-2:#8e96a3;
  --rule:   #dde1e6;
  --tint:   #f4f6f8;

  --blue:   #2a7bcf;
  --red:    #d6453a;
  --yellow: #f0be2c;
  --yellow-ink: #8c6a00;
  --green:  #3a9b5c;
  --orange: #e2862a;

  /* names the scripts read */
  --accent: var(--blue);
  --accent-wash: color-mix(in srgb, var(--blue) 10%, transparent);
  --ok: var(--green);
  --rule-firm: var(--ink);

  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --text:    "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;

  --measure: 68ch;
  --gutter: clamp(16px, 4vw, 48px);
  --maxw: 1120px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 70px; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-size: 17px;
  line-height: 1.6;
  font-variation-settings: "wdth" 100;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: var(--yellow); color: #15181d; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- type ---------- */
h1, h2, h3 { font-family: var(--display); color: var(--ink); text-wrap: balance; margin: 0; }
h1 {
  font-size: clamp(44px, 6.6vw, 86px); line-height: .92; font-weight: 700;
  font-variation-settings: "wdth" 118; letter-spacing: -0.035em;
  margin: 0 0 24px; max-width: 13ch;
}
h2 {
  font-size: clamp(28px, 3.4vw, 40px); line-height: 1.06; font-weight: 650;
  font-variation-settings: "wdth" 112; letter-spacing: -0.02em; margin: 0 0 18px;
}
h3 { font-size: 18px; line-height: 1.25; font-weight: 650; font-variation-settings: "wdth" 105; margin: 0 0 8px; }
h1 em, h2 em { font-style: normal; color: var(--blue); }
p { margin: 0 0 16px; max-width: var(--measure); color: var(--ink-2); text-wrap: pretty; }
p em { color: var(--ink); }
a { color: var(--blue); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
strong, b { color: var(--ink); font-weight: 650; }
sub, sup { font-size: .72em; }

.lede { font-size: clamp(18px, 1.9vw, 21px); line-height: 1.45; color: var(--ink); max-width: 40ch; }

/* section number, set like a figure label: § 01 What you are looking at */
.mark {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  border-top: 2px solid var(--ink); padding-top: 12px; margin-bottom: 28px;
  font-family: var(--display); font-weight: 700; font-size: 15px;
  font-variation-settings: "wdth" 115; color: var(--ink);
}
.mark span { font-weight: 500; color: var(--ink-2); font-variation-settings: "wdth" 100; }

.label, .k {
  font-family: var(--mono); font-size: 11px; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
}

/* ---------- layout ---------- */
main > section { position: relative; }
main > section.wrap { padding-block: clamp(56px, 8vw, 96px) 8px; }
.cols { display: grid; gap: clamp(20px, 3.4vw, 40px); }
.cols > * { min-width: 0; }
@media (min-width: 880px) {
  .cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cols-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* ---------- banner + nav ---------- */
.banner {
  font-size: 13.5px; padding: 7px 0; color: var(--ink-2); background: var(--tint);
}
.banner .wrap { display: flex; justify-content: space-between; gap: 4px 16px; flex-wrap: wrap; }
.banner b { color: var(--ink); }

header.nav { position: sticky; top: 0; z-index: 30; background: var(--paper); }
.nav-in { display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: 16px; border-bottom: 1px solid var(--ink); }
.logo {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--display); font-weight: 700; font-size: 19px;
  font-variation-settings: "wdth" 125; letter-spacing: -0.01em;
  color: var(--ink); text-decoration: none;
}
.logo svg { width: 26px; height: 14px; flex: none; }
.nav-links { display: none; gap: 6px 20px; font-size: 14px; }
@media (min-width: 1020px) { .nav-links { display: flex; } }
.nav-links a, .gh { color: var(--ink-2); text-decoration: none; }
.nav-links a:hover, .gh:hover { color: var(--ink); text-decoration: underline; }
.nav-end { display: flex; align-items: center; gap: 16px; font-size: 14px; }

/* ---------- hero / wind tunnel ---------- */
.hero {
  position: relative; padding: 0 !important;
  height: max(640px, calc(100svh - 100px));
  overflow: hidden; isolation: isolate;
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
}
#tunnel { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; touch-action: pan-y; cursor: grab; }
#tunnel:active { cursor: grabbing; }
/* no WebGL 2 / no float targets: a still of the tunnel instead */
.hero.no-tunnel { background: #fff url("media/tunnel-poster.jpg") 70% 60% / cover no-repeat; }
.hero.no-tunnel #tunnel { visibility: hidden; }
@media (max-width: 760px) { .hero.no-tunnel #tunnel { visibility: visible; background: url("media/tunnel-poster.jpg") center / cover no-repeat; } }
.hero-shade {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255,255,255,.96) 0%, rgba(255,255,255,.78) 30%, rgba(255,255,255,0) 54%),
    linear-gradient(0deg, rgba(255,255,255,.9) 0%, rgba(255,255,255,0) 22%);
}
.hero-copy { position: relative; z-index: 2; padding-top: clamp(40px, 8vh, 88px); pointer-events: none; }
.hero-copy > * { pointer-events: auto; }
@media (max-width: 760px) {
  .hero { height: auto; display: flex; flex-direction: column; }
  .hero-copy { order: 0; padding-bottom: 8px; }
  #tunnel { position: relative; order: 1; height: 300px; inset: auto; }
  .hero-shade { display: none; }
}

.eyebrow {
  display: inline-flex; align-items: center; gap: 10px; margin-bottom: 22px;
  font-family: var(--mono); font-size: 12px; color: var(--ink-2);
}
.dot { width: 9px; height: 9px; background: var(--green); flex: none; animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; align-items: stretch; }
.copybox {
  display: inline-flex; align-items: stretch; max-width: 100%;
  font-family: var(--mono); font-size: 15px;
  border: 1px solid var(--ink); background: var(--paper);
}
.copybox .sig { padding: 9px 0 9px 14px; color: var(--muted); }
.copybox code { padding: 9px 14px 9px 8px; white-space: nowrap; overflow-x: auto; font-size: 15px; }
.copybox button {
  appearance: none; border: 0; border-left: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  font: 500 13px var(--mono); padding: 0 14px; cursor: pointer;
}
.copybox button:hover { background: var(--blue); }
.filerow button {
  appearance: none; border: 0; border-left: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  font: 500 12px var(--mono); padding: 0 12px; cursor: pointer; align-self: stretch;
}
.filerow button:hover { background: var(--blue); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: 500 14px var(--text); text-decoration: none; cursor: pointer;
  border: 1px solid var(--ink); padding: 9px 16px; color: var(--paper); background: var(--ink);
}
.btn:hover { background: var(--blue); border-color: var(--blue); }
.btn.ghost, .case .btn, .btn.small { background: var(--paper); color: var(--ink); }
.btn.ghost:hover, .case .btn:hover, .btn.small:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.small { padding: 6px 12px; font-size: 13px; }

/* HUD: a white instrument panel over the tunnel */
.hud {
  position: absolute; z-index: 3; right: var(--gutter); bottom: 22px;
  width: min(560px, calc(100% - 2 * var(--gutter)));
  background: rgba(255, 255, 255, .94); border: 1px solid var(--ink);
  padding: 12px 14px 11px; font-family: var(--mono); font-size: 12.5px; color: var(--muted);
}
.hud-row { display: flex; align-items: center; gap: 14px; }
.hud-sub { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--rule); flex-wrap: wrap; row-gap: 8px; }
.play {
  flex: none; width: 42px; height: 42px; cursor: pointer;
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  display: grid; place-items: center;
}
.play:hover { background: var(--blue); border-color: var(--blue); }
.play svg { width: 15px; height: 15px; fill: currentColor; }
.play .i-pause { display: none; }
.play[aria-pressed="true"] .i-play { display: none; }
.play[aria-pressed="true"] .i-pause { display: inline; }
.scrub { flex: 1; min-width: 0; }
.scrub-top { display: flex; justify-content: space-between; margin-bottom: 2px; white-space: nowrap; gap: 10px; }
.v { color: var(--ink); font-family: var(--mono); font-variant-numeric: tabular-nums; }
.v.live { color: var(--blue); }
.ticks { position: relative; height: 6px; margin-top: 2px; }
.ticks i { position: absolute; top: 0; width: 1px; height: 5px; background: var(--ink); }
.stat { display: flex; flex-direction: column; align-items: flex-end; min-width: 92px; }
.stat .v {
  font-family: var(--display); font-size: 28px; line-height: 1; font-weight: 700;
  font-variation-settings: "wdth" 115; letter-spacing: -0.02em; margin-top: 2px;
}
.delta { font-size: 11.5px; color: var(--green); font-weight: 500; min-height: 1em; margin-top: 3px; }
.legend { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.legend .bar { width: 110px; height: 8px; display: inline-block; }
.hud-note { margin-left: auto; font-size: 11px; color: var(--muted); }
.reshape-key { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: #c81e6c; }
.reshape-key i { width: 8px; height: 8px; background: #ff2e88; }
@media (max-width: 760px) {
  .hud { position: relative; order: 2; left: auto; right: auto; bottom: auto; width: auto; margin: 0 var(--gutter) 22px; }
  .hud-note { display: none; }
}
.nojs { position: absolute; bottom: 2rem; z-index: 4; color: var(--muted); }

/* ---------- controls ---------- */
.ctl { display: flex; align-items: center; gap: 12px; font-family: var(--mono); font-size: 12.5px; color: var(--muted); margin-top: 16px; flex-wrap: wrap; }
input[type=range] {
  -webkit-appearance: none; appearance: none; height: 2px; border-radius: 0;
  background: linear-gradient(90deg, var(--blue) var(--fill, 0%), var(--rule) var(--fill, 0%));
  flex: 1; min-width: 120px; margin: 8px 0; cursor: pointer;
}
.scrub input[type=range] { width: 100%; margin: 6px 0 0; }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 0;
  background: var(--paper); cursor: pointer; border: 2px solid var(--ink);
}
input[type=range]::-moz-range-thumb { width: 10px; height: 10px; border-radius: 0; background: var(--paper); cursor: pointer; border: 2px solid var(--ink); }

.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--ink); background: var(--paper); }
.seg button {
  appearance: none; font: 500 12.5px var(--text); background: transparent; border: 0;
  padding: 6px 11px; cursor: pointer; color: var(--ink);
}
.seg button + button { border-left: 1px solid var(--ink); }
.seg button:hover { background: var(--tint); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* ---------- figures ---------- */
figure { margin: 0; }
canvas { display: block; width: 100%; height: auto; }
.panel { margin-top: 28px; border-top: 2px solid var(--ink); padding-top: 14px; }
.panel canvas { background: var(--tint); }
figcaption, .caption { font-size: 13.5px; line-height: 1.5; color: var(--muted); margin-top: 10px; }

.readout {
  display: flex; flex-wrap: wrap; gap: 14px 40px;
  font-family: var(--mono); font-size: 13px; margin: 14px 0 0;
  padding-top: 12px; border-top: 1px solid var(--ink);
}
.readout div { display: flex; flex-direction: column; gap: 2px; }
.readout .v { font-size: 16px; }

/* cards: three notes under a rule */
.cards { margin-top: 36px; }
.card { border-top: 1px solid var(--ink); padding-top: 12px; }
.card-k {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
}
.card-k::before { content: ""; width: 9px; height: 9px; background: var(--blue); flex: none; }
.cards .card:nth-child(2) .card-k::before { background: var(--yellow); }
.cards .card:nth-child(3) .card-k::before { background: var(--red); }
.card p { font-size: 15px; line-height: 1.55; margin: 0; }

.facts { margin-top: 40px; }
.facts caption {
  caption-side: top; text-align: left; padding-bottom: 8px;
  font-family: var(--display); font-weight: 700; font-size: 15px; font-variation-settings: "wdth" 115; color: var(--ink);
  border-bottom: 2px solid var(--ink);
}
.facts td.num { text-align: right; color: var(--ink); }

.steps > div { border-top: 1px solid var(--ink); padding-top: 12px; }
.steps .step-n {
  font-family: var(--display); font-size: 52px; line-height: .9; font-weight: 700;
  font-variation-settings: "wdth" 125; letter-spacing: -0.04em; color: var(--blue); margin-bottom: 14px;
}
.steps > div:nth-child(2) .step-n { color: var(--yellow); }
.steps > div:nth-child(3) .step-n { color: var(--red); }

/* ---------- code ---------- */
.codeblock { min-width: 0; border: 1px solid var(--ink); align-self: start; }
.codeblock > .readout, .codeblock > .caption, .codeblock > .caveat { margin-inline: 14px; }
.codeblock > .caption { margin-bottom: 12px; }
.codeblock > .readout { border-top: 0; padding-top: 4px; }
pre {
  font-family: var(--mono); font-size: 13px; line-height: 1.65;
  background: var(--tint); padding: 16px 18px; overflow-x: auto; margin: 0; tab-size: 4; color: var(--ink-2);
}
code { font-family: var(--mono); font-size: .9em; }
p code, td code, li code { font-size: .86em; background: var(--tint); padding: 1px 4px; }
.tok-kw { color: var(--blue); }
.tok-str { color: var(--yellow-ink); }
.tok-com { color: var(--muted); }
.filerow {
  display: flex; justify-content: space-between; align-items: stretch;
  font-family: var(--mono); font-size: 12px; color: var(--ink-2);
  border-bottom: 1px solid var(--ink); background: var(--paper);
}
.filerow span { margin-right: auto; padding: 8px 12px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14.5px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 14px 8px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-weight: 600; font-size: 13px; color: var(--muted); }
td { color: var(--ink-2); }
td.num { font-family: var(--mono); font-size: 13.5px; }

/* ---------- case studies ---------- */
.case { display: grid; gap: 28px; margin-top: 36px; border-top: 2px solid var(--ink); padding-top: 18px; }
.case + .case { margin-top: 48px; }
@media (min-width: 940px) { .case { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: start; } }
.case img { width: 100%; height: auto; display: block; background: var(--tint); }
.case h3 { font-size: clamp(22px, 2.4vw, 26px); font-variation-settings: "wdth" 112; letter-spacing: -0.015em; margin-bottom: 12px; }
.case table { margin: 6px 0 18px; }

.caveat {
  background: var(--tint); border-left: 3px solid var(--yellow);
  padding: 12px 16px; margin: 20px 0; color: var(--ink-2); font-size: 15px; line-height: 1.55; max-width: 80ch;
}

/* ---------- footer ---------- */
footer { margin-top: 72px; font-size: 14px; }
footer > .wrap { border-top: 1px solid var(--ink); padding-top: 28px; padding-bottom: 40px; }
footer .cols { gap: 24px; }
footer a { color: var(--ink-2); text-decoration: none; display: block; padding: 2px 0; }
footer a:hover { color: var(--ink); text-decoration: underline; }
footer h4 { font-family: var(--mono); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 400; margin: 0 0 8px; }
.colophon { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 32px; padding-top: 14px; border-top: 1px solid var(--rule); font-size: 13.5px; color: var(--muted); }

/* ---------- search ---------- */
.searchbtn {
  display: inline-flex; align-items: center; gap: 8px; font: 14px var(--text);
  color: var(--ink-2); background: var(--paper); border: 1px solid var(--ink); padding: 4px 8px; cursor: pointer;
}
.searchbtn:hover { background: var(--ink); color: var(--paper); }
.searchbtn kbd { font: 12px var(--mono); color: inherit; opacity: .7; }

dialog#search {
  border: 1px solid var(--ink); background: var(--paper); color: var(--ink);
  padding: 0; width: min(640px, 92vw); margin-top: 12vh; border-radius: 0;
}
dialog#search::backdrop { background: rgba(21, 24, 29, .3); }
#search input {
  width: 100%; font: 17px var(--text); padding: 16px 18px;
  border: 0; border-bottom: 1px solid var(--ink); background: none; color: var(--ink); outline: none;
}
#search-results { list-style: none; margin: 0; padding: 6px; max-height: 52vh; overflow-y: auto; }
#search-results li a { display: block; padding: 10px 12px; text-decoration: none; color: var(--ink); }
#search-results li a:hover, #search-results li a:focus { background: var(--tint); outline: none; }
#search-results .r-t { font-weight: 650; font-size: 15px; display: block; }
#search-results .r-s { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; display: block; }
#search-results .r-x { font-size: 14px; color: var(--ink-2); display: block; }
#search-results mark { background: color-mix(in srgb, var(--yellow) 45%, transparent); color: var(--ink); }
.search-empty { padding: 18px; color: var(--muted); font-size: 15px; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}
