/* fastlsq: a bright wind tunnel. Hairlines, white panels, one accent for live values. */

:root {
  color-scheme: light;
  --bg:        #f5f6f8;
  --bg-2:      #eceef2;
  --panel:     #ffffff;
  --panel-2:   #f8f9fb;
  --ink:       #0f1217;
  --ink-2:     #3a4150;
  --muted:     #687083;
  --muted-2:   #9aa1af;

  --rule:      rgba(15, 18, 23, .08);
  --rule-firm: rgba(15, 18, 23, .16);
  --glass:     rgba(255, 255, 255, .74);

  /* ONE accent: live, computed, interactive values. */
  --accent:      #2f4fe0;
  --accent-2:    #4a6bff;
  --accent-wash: rgba(47, 79, 224, .08);
  --ok:          #0e9a6a;
  --warm:        #d9772b;

  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans:  "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono:  "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --measure: 68ch;
  --gutter: 24px;
  --maxw: 1200px;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 18, 23, .04), 0 8px 28px -12px rgba(15, 18, 23, .14);
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background:
    radial-gradient(1100px 600px at 90% -10%, rgba(74, 107, 255, .07), transparent 60%),
    radial-gradient(900px 500px at -10% 45%, rgba(255, 150, 90, .05), transparent 60%);
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
@media (max-width: 520px) { :root { --gutter: 16px; } }

/* ---------- type ---------- */
h1, h2 { font-family: var(--serif); font-weight: 400; letter-spacing: -0.02em; color: var(--ink); }
h1 { font-size: clamp(2.6rem, 5.4vw, 4.5rem); line-height: 1; margin: 0 0 1.3rem; max-width: 16ch; }
h2 { font-size: clamp(2rem, 4vw, 3.1rem); line-height: 1.04; margin: 0 0 1rem; }
h3 { font-size: 1.04rem; line-height: 1.35; margin: 0 0 .5rem; font-weight: 600; letter-spacing: -0.012em; }
h1 em, h2 em {
  font-style: italic;
  background: linear-gradient(100deg, #2f4fe0 0%, #5b4cf0 40%, #b04ad6 72%, #e2683c 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  padding-right: .06em;
}
p { margin: 0 0 1.05rem; max-width: var(--measure); color: var(--ink-2); }
a { color: inherit; text-decoration-color: var(--rule-firm); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }
strong, b { color: var(--ink); font-weight: 600; }
sub, sup { font-size: .72em; }

.lede { font-size: clamp(1.02rem, 1.4vw, 1.14rem); color: var(--ink-2); max-width: 54ch; }

.mark {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .16em;
  text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: .9rem; margin-bottom: 1.8rem;
}
.mark::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--rule-firm), transparent); }

/* ---------- layout ---------- */
main > section { position: relative; }
main > section.wrap { padding: clamp(4.5rem, 9vw, 8rem) var(--gutter); }
main > section.wrap + section.wrap { border-top: 1px solid var(--rule); }
.cols { display: grid; gap: clamp(1.4rem, 3.4vw, 2.6rem); }
@media (min-width: 880px) {
  .cols-3 { grid-template-columns: repeat(3, 1fr); }
  .cols-2 { grid-template-columns: 1fr 1fr; }
}

/* ---------- banner + nav ---------- */
.banner {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .03em;
  padding: .5rem 0; color: var(--muted); background: #eaedf2; border-bottom: 1px solid var(--rule);
}
.banner .wrap { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.banner b { color: var(--ink); }
.banner a { color: var(--accent); text-decoration: none; }
.banner a:hover { text-decoration: underline; }

header.nav {
  position: sticky; top: 0; z-index: 30;
  background: rgba(245, 246, 248, .78);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--rule);
}
.nav-in { display: flex; align-items: center; justify-content: space-between; height: 58px; gap: 1rem; }
.logo { font-family: var(--mono); font-weight: 600; font-size: 1.02rem; letter-spacing: -0.02em; text-decoration: none; }
.logo span { color: var(--accent); }
.nav-links { display: none; gap: 1.4rem; font-family: var(--mono); font-size: .76rem; }
@media (min-width: 1020px) { .nav-links { display: flex; } }
.nav-links a { color: var(--muted); text-decoration: none; transition: color .15s; }
.nav-links a:hover { color: var(--ink); }
.nav-end { display: flex; align-items: center; gap: .9rem; }
.gh { font-family: var(--mono); font-size: .76rem; color: var(--muted); text-decoration: none; }
.gh:hover { color: var(--ink); }

/* ---------- hero / wind tunnel ---------- */
.hero {
  position: relative; padding: 0 !important;
  height: max(640px, calc(100svh - 92px));
  overflow: hidden; isolation: isolate;
  background: radial-gradient(120% 90% at 62% 58%, #ffffff 0%, #f1f3f7 55%, #e7eaf0 100%);
  border-bottom: 1px solid var(--rule);
}
#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: #eef1f6 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(245,246,248,.94) 0%, rgba(245,246,248,.7) 28%, rgba(245,246,248,0) 52%),
    linear-gradient(0deg, rgba(245,246,248,.85) 0%, rgba(245,246,248,0) 22%);
}
.hero-copy { position: relative; z-index: 2; padding-top: clamp(2.6rem, 8vh, 6rem); 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: .5rem; }
  #tunnel { position: relative; order: 1; height: 300px; inset: auto; }
  .hero-shade { display: none; }
  .hero-copy h1 { font-size: 2.6rem; }
  .eyebrow { font-size: .64rem; letter-spacing: .1em; }
}

.eyebrow {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 1.6rem;
  display: inline-flex; align-items: center; gap: .6rem;
  padding: .35rem .7rem; border: 1px solid var(--rule-firm); border-radius: 99px;
  background: rgba(255, 255, 255, .7); backdrop-filter: blur(8px);
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex: none; box-shadow: 0 0 8px rgba(14, 154, 106, .6); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.cta { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 2rem; align-items: stretch; }
.copybox {
  display: inline-flex; align-items: center; gap: .9rem;
  font-family: var(--mono); font-size: .86rem;
  border: 1px solid var(--rule-firm); background: rgba(255, 255, 255, .9);
  padding: .62rem .9rem; border-radius: 10px; box-shadow: var(--shadow);
}
.copybox .sig { color: var(--muted-2); }
.copybox button, .filerow button {
  font: inherit; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase;
  border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0;
}
.copybox button:hover, .filerow button:hover { color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--mono); font-size: .82rem; text-decoration: none; cursor: pointer;
  border: 1px solid transparent; padding: .62rem 1rem; color: #fff; border-radius: 10px;
  background: linear-gradient(180deg, #4a6bff, #2f4fe0); font-weight: 500;
  box-shadow: 0 6px 20px -8px rgba(47, 79, 224, .55);
  transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 26px -8px rgba(47, 79, 224, .65); }
.btn.ghost, .case .btn, .btn.small {
  background: rgba(255, 255, 255, .92); color: var(--ink); border-color: var(--rule-firm); box-shadow: var(--shadow);
}
.btn.ghost:hover, .case .btn:hover, .btn.small:hover { border-color: var(--accent); color: var(--accent); }
.btn.small { padding: .38rem .8rem; font-size: .76rem; }

/* HUD: frosted dock over the tunnel */
.hud {
  position: absolute; z-index: 3; right: var(--gutter); bottom: 22px;
  width: min(560px, calc(100% - 2 * var(--gutter)));
  background: var(--glass); border: 1px solid var(--rule-firm); border-radius: var(--radius);
  backdrop-filter: blur(16px) saturate(150%); -webkit-backdrop-filter: blur(16px) saturate(150%);
  padding: .85rem 1rem .8rem; font-family: var(--mono); font-size: .76rem; color: var(--muted);
  box-shadow: 0 18px 50px -22px rgba(15, 18, 23, .35);
}
.hud-row { display: flex; align-items: center; gap: .9rem; }
.hud-sub { margin-top: .7rem; padding-top: .65rem; border-top: 1px solid var(--rule); flex-wrap: wrap; row-gap: .5rem; }
.play {
  flex: none; width: 42px; height: 42px; border-radius: 50%; cursor: pointer;
  border: 1px solid transparent; background: linear-gradient(180deg, #4a6bff, #2f4fe0);
  display: grid; place-items: center; color: #fff; box-shadow: 0 6px 18px -6px rgba(47, 79, 224, .6);
  transition: transform .15s;
}
.play:hover { transform: scale(1.06); }
.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: .2rem; white-space: nowrap; gap: .6rem; }
.k { color: var(--muted-2); font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; }
.v { color: var(--ink); font-variant-numeric: tabular-nums; }
.v.live { color: var(--accent); }
.ticks { position: relative; height: 6px; margin-top: 2px; }
.ticks i { position: absolute; top: 0; width: 1px; height: 5px; background: var(--rule-firm); }
.stat { display: flex; flex-direction: column; align-items: flex-end; min-width: 92px; }
.stat .v { font-size: 1.25rem; line-height: 1.2; }
.delta { font-size: .68rem; color: var(--ok); min-height: 1em; }
.legend { display: flex; align-items: center; gap: .5rem; font-size: .66rem; }
.legend .bar { width: 110px; height: 6px; border-radius: 3px; display: inline-block; }
.hud-note { margin-left: auto; font-size: .66rem; color: var(--muted-2); }
.reshape-key { display: inline-flex; align-items: center; gap: .4rem; font-size: .66rem; color: #c81e6c; }
.reshape-key i { width: 10px; height: 10px; border-radius: 50%; background: #ff2e88; box-shadow: 0 0 8px rgba(255, 46, 136, .6); }
@media (max-width: 760px) {
  .hud { position: relative; order: 2; left: auto; right: auto; bottom: auto; width: auto; margin: 0 var(--gutter) 1.4rem; }
  .hud-note { display: none; }
}
.nojs { position: absolute; bottom: 2rem; z-index: 4; color: var(--muted); }

/* ---------- controls ---------- */
.ctl { display: flex; align-items: center; gap: .8rem; font-family: var(--mono); font-size: .76rem; color: var(--muted); margin-top: 1rem; flex-wrap: wrap; }
input[type=range] {
  -webkit-appearance: none; appearance: none; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) var(--fill, 0%), var(--rule-firm) var(--fill, 0%));
  flex: 1; min-width: 120px; margin: .5rem 0; cursor: pointer;
}
.scrub input[type=range] { width: 100%; margin: .35rem 0 0; }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: #fff; cursor: pointer; border: 3px solid var(--accent);
  box-shadow: 0 0 0 4px rgba(47, 79, 224, .14);
}
input[type=range]::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%; background: #fff; cursor: pointer; border: 3px solid var(--accent); }

.seg { display: inline-flex; border: 1px solid var(--rule-firm); border-radius: 9px; overflow: hidden; background: rgba(255, 255, 255, .85); }
.seg button {
  font-family: var(--mono); font-size: .74rem; background: none; border: 0;
  padding: .42rem .75rem; cursor: pointer; color: var(--muted);
  border-right: 1px solid var(--rule); transition: color .15s, background .15s;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--accent-wash); color: var(--accent); }

/* ---------- panels / figures ---------- */
figure { margin: 0; }
canvas { display: block; width: 100%; height: auto; }
.panel {
  background: var(--panel);
  border: 1px solid var(--rule); border-radius: var(--radius);
  padding: clamp(.9rem, 2vw, 1.4rem);
  margin-top: 1.6rem; box-shadow: var(--shadow);
}
figcaption, .caption { font-family: var(--mono); font-size: .7rem; color: var(--muted-2); margin-top: .7rem; letter-spacing: .03em; }

.readout {
  display: flex; flex-wrap: wrap; gap: 1.2rem 2.6rem;
  font-family: var(--mono); font-size: .8rem; margin: 1.1rem 0 0;
  padding-top: 1rem; border-top: 1px solid var(--rule);
}
.readout div { display: flex; flex-direction: column; gap: .15rem; }
.readout .v { font-size: 1.04rem; }

/* cards */
.cards { margin-top: 2.6rem; }
.card {
  position: relative; padding: 1.4rem 1.4rem 1.1rem;
  background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, #4a6bff, #b04ad6 60%, #e2683c);
  opacity: .8;
}
.card-k { font-family: var(--mono); font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-bottom: .9rem; }
.card p { font-size: .92rem; margin: 0; }

.facts { margin-top: 2.4rem; }
.facts caption { caption-side: top; text-align: left; font-family: var(--mono); font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); padding-bottom: .6rem; }
.facts td.num { text-align: right; color: var(--ink); }

.steps .step-n { font-family: var(--serif); font-size: 3rem; line-height: 1; color: transparent; -webkit-text-stroke: 1px var(--rule-firm); margin-bottom: .6rem; }

/* ---------- code ---------- */
.codeblock { min-width: 0; }
pre {
  font-family: var(--mono); font-size: .8rem; line-height: 1.7;
  background: #fbfcfd; border: 1px solid var(--rule);
  border-radius: 0 0 12px 12px;
  padding: 1.1rem 1.2rem; overflow-x: auto; margin: 0; tab-size: 4; color: #1e2430;
}
code { font-family: var(--mono); font-size: .9em; }
p code, td code, li code { background: var(--bg-2); border: 1px solid var(--rule); border-radius: 5px; padding: .05em .35em; }
.tok-kw { color: #6d3fd9; }
.tok-str { color: #0b8457; }
.tok-com { color: var(--muted-2); font-style: italic; }
.filerow {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--mono); font-size: .72rem; color: var(--muted);
  border: 1px solid var(--rule); border-bottom: 0; padding: .5rem .85rem;
  background: var(--panel-2); border-radius: 12px 12px 0 0;
}
.filerow::before { content: "● ● ●"; letter-spacing: .25em; color: var(--muted-2); font-size: .55rem; margin-right: .8rem; }
.filerow span { margin-right: auto; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .6rem .6rem .6rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-family: var(--mono); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-2); font-weight: 400; }
td { color: var(--ink-2); }
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- case studies ---------- */
.case { display: grid; gap: 1.8rem; margin-top: 2.6rem; padding: clamp(1rem, 2.4vw, 1.8rem); border: 1px solid var(--rule); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.case + .case { margin-top: 1.6rem; }
@media (min-width: 940px) { .case { grid-template-columns: 1.05fr 1fr; align-items: start; } }
.case img { width: 100%; height: auto; display: block; border-radius: 10px; border: 1px solid var(--rule); background: #fff; }
.case h3 { font-family: var(--serif); font-weight: 400; font-size: 1.7rem; letter-spacing: -0.01em; margin-bottom: .8rem; }

.caveat {
  border-left: 2px solid var(--accent); padding: .15rem 0 .15rem 1rem;
  margin: 1.4rem 0; color: var(--ink-2); font-size: .92rem; max-width: 80ch;
}

/* ---------- footer ---------- */
footer { border-top: 1px solid var(--rule); padding: 3.4rem 0 4rem; font-size: .88rem; background: #eceef2; }
footer .cols { gap: 2rem; }
footer a { color: var(--muted); text-decoration: none; display: block; padding: .2rem 0; }
footer a:hover { color: var(--accent); }
footer h4 { font-family: var(--mono); font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted-2); font-weight: 400; margin: 0 0 .7rem; }
.colophon { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 2.6rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); font-family: var(--mono); font-size: .72rem; color: var(--muted-2); }

/* ---------- search ---------- */
.searchbtn {
  display: inline-flex; align-items: center; gap: .6rem; font-family: var(--mono);
  font-size: .74rem; color: var(--muted); background: rgba(255, 255, 255, .85);
  border: 1px solid var(--rule-firm); padding: .34rem .6rem; cursor: pointer; border-radius: 8px;
}
.searchbtn:hover { color: var(--ink); border-color: var(--accent); }
.searchbtn kbd { font: inherit; font-size: .68rem; color: var(--muted-2); border: 1px solid var(--rule-firm); padding: 0 .3rem; border-radius: 4px; }

dialog#search {
  border: 1px solid var(--rule-firm); background: var(--panel); color: var(--ink);
  padding: 0; width: min(640px, 92vw); margin-top: 12vh; border-radius: var(--radius);
  box-shadow: 0 40px 120px -20px rgba(15, 18, 23, .35);
}
dialog#search::backdrop { background: rgba(15, 18, 23, .25); backdrop-filter: blur(4px); }
#search input {
  width: 100%; font-family: var(--mono); font-size: 1rem; padding: 1.05rem 1.15rem;
  border: 0; border-bottom: 1px solid var(--rule); background: none; color: var(--ink); outline: none;
}
#search-results { list-style: none; margin: 0; padding: .45rem; max-height: 52vh; overflow-y: auto; }
#search-results li a { display: block; padding: .65rem .75rem; text-decoration: none; border-radius: 9px; }
#search-results li a:hover, #search-results li a:focus { background: var(--accent-wash); outline: none; }
#search-results .r-t { font-weight: 600; font-size: .92rem; display: block; }
#search-results .r-s { font-family: var(--mono); font-size: .68rem; color: var(--muted-2); letter-spacing: .1em; text-transform: uppercase; display: block; }
#search-results .r-x { font-size: .84rem; color: var(--muted); display: block; }
#search-results mark { background: var(--accent-wash); color: var(--accent); }
.search-empty { padding: 1.2rem; color: var(--muted); font-size: .9rem; }

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

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

