/* ============================================================================
   SwiftTD — "The Anticipation Machine"
   Aesthetic: minimal technical blueprint on warm paper. Off-white ground, faint
   dotted grid, a single blue accent for the signal, near-black ink for text and
   the slick cursor. Newsreader (serif) for prose, IBM Plex Mono for instrument
   labels and readouts.
   ========================================================================== */

/* ---- Self-hosted fonts (formerly Google Fonts) ----------------------------
   IBM Plex Mono 400/500/600 (static) + Newsreader 400/500 (variable), latin +
   latin-ext. woff2 served from ./fonts — no third-party requests. */
@font-face {
  font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("./fonts/ibm-plex-mono-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("./fonts/ibm-plex-mono-400-latinext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("./fonts/ibm-plex-mono-500-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("./fonts/ibm-plex-mono-500-latinext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Mono"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("./fonts/ibm-plex-mono-600-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("./fonts/ibm-plex-mono-600-latinext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Newsreader"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("./fonts/newsreader-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("./fonts/newsreader-latinext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Newsreader"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("./fonts/newsreader-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("./fonts/newsreader-latinext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --paper: #f4f3ee;
  --panel: #fbfbf9;
  --ink: #16181d;
  --muted: #6c6f76;
  --faint: #9a9d96;
  --hair: rgba(20, 23, 28, 0.16);
  --hair-soft: rgba(20, 23, 28, 0.08);
  --dot: rgba(20, 23, 28, 0.13);
  --blue: #2b39e0;
  --blue-soft: rgba(43, 57, 224, 0.08);

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
  --frame: 1px solid var(--hair);
}

* { box-sizing: border-box; }
html { scrollbar-gutter: stable; } /* reserve the scrollbar space on every page so the top bar / layout width stays identical whether a page scrolls or not */
html, body { margin: 0; }

body {
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  background-color: var(--paper);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.4px);
  background-size: 22px 22px;
  background-position: -1px -1px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.grain { display: none; }

a { color: var(--blue); text-decoration: none; border-bottom: 1px solid rgba(43, 57, 224, 0.35); }
a:hover { border-bottom-color: var(--blue); }

/* ---- Masthead -------------------------------------------------------------- */
.masthead {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 62px; /* fixed bar height so it matches across pages regardless of content (button vs text) */
  padding: 0 clamp(18px, 4vw, 54px);
  border-bottom: var(--frame);
}
.wordmark { display: flex; align-items: baseline; gap: 9px; }
.wordmark .mark { color: var(--blue); font-size: 16px; letter-spacing: -2px; }
.wordmark-text {
  font-family: var(--mono); font-weight: 600; font-size: 16px;
  letter-spacing: 0.14em; text-transform: uppercase;
}
.masthead-meta {
  display: flex; align-items: center; gap: 9px;
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted);
}
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--faint);
}
.status-dot.ready {
  background: var(--blue);
  animation: live-pulse 1.6s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(43, 57, 224, 0.45); }
  50% { opacity: 0.5; box-shadow: 0 0 0 4px rgba(43, 57, 224, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .status-dot.ready { animation: none; }
}

.masthead-right { display: flex; align-items: center; gap: 16px; }
.nav-about {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink); background: transparent; border: 1px solid var(--hair);
  padding: 8px 13px; white-space: nowrap; transition: all 0.14s ease;
}
.nav-about:hover { color: var(--paper); background: var(--blue); border-color: var(--blue); }

/* ---- Console layout -------------------------------------------------------- */
.console {
  max-width: 960px; margin: 0 auto;
  padding: clamp(30px, 5vw, 66px) clamp(18px, 4vw, 54px) 40px;
}

.intro { max-width: 760px; margin-bottom: clamp(28px, 4vw, 46px); }
.overline {
  font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.26em; text-transform: uppercase;
  color: var(--blue); margin: 0 0 20px;
}
.title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  line-height: 0.98;
  letter-spacing: -0.015em;
  margin: 0 0 22px;
  color: var(--ink);
}
.lede {
  font-family: var(--serif);
  font-size: clamp(1.02rem, 1.5vw, 1.22rem);
  line-height: 1.55;
  max-width: 60ch; color: #34373d; margin: 0 0 14px;
}
.lede em { color: var(--blue); font-style: italic; }
.tagline {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em;
  color: var(--ink); margin: 0; text-transform: uppercase;
}
.tagline::before { content: "→ "; color: var(--blue); }

/* ---- Hover tooltip on a defined term --------------------------------------- */
.term {
  position: relative;
  color: var(--ink);
  font-style: normal;
  text-decoration: underline dotted;
  text-decoration-color: var(--muted);
  text-underline-offset: 4px;
  cursor: help;
  outline: none;
}
.term-pop {
  position: absolute;
  top: calc(100% + 12px);
  left: 0;
  z-index: 30;
  width: max-content;
  max-width: min(360px, 84vw);
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--hair);
  box-shadow: 0 16px 40px -20px rgba(20, 23, 28, 0.45);
  font-family: var(--serif);
  font-size: 0.92rem;
  font-style: normal;
  line-height: 1.5;
  letter-spacing: 0;
  text-transform: none;
  text-decoration: none;
  color: #34373d;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  pointer-events: none;
}
.term-pop::before {
  /* small blueprint tick on the corner */
  content: "";
  position: absolute;
  top: 8px; left: 8px;
  width: 9px; height: 9px;
  border-top: 1px solid var(--blue);
  border-left: 1px solid var(--blue);
  opacity: 0.6;
}
.term-pop strong { color: var(--ink); font-weight: 600; }
.term:hover .term-pop,
.term:focus .term-pop,
.term:focus-visible .term-pop {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ---- Rig: arena + rail ----------------------------------------------------- */
.rig {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.9fr);
  gap: clamp(16px, 2.4vw, 32px);
  align-items: start;
}

.arena-wrap {
  position: relative; margin: 0; aspect-ratio: 1 / 1; width: 100%;
  border: var(--frame);
  background: var(--panel);
  background-image: radial-gradient(rgba(20, 23, 28, 0.06) 1px, transparent 1.4px);
  background-size: 22px 22px;
}
/* engineering corner ticks */
.arena-wrap::before, .arena-wrap::after {
  content: ""; position: absolute; width: 14px; height: 14px;
  border: 1px solid var(--blue); opacity: 0.6; pointer-events: none;
}
.arena-wrap::before { top: 7px; left: 7px; border-right: 0; border-bottom: 0; }
.arena-wrap::after { bottom: 7px; right: 7px; border-left: 0; border-top: 0; }
.arena { position: absolute; inset: 0; width: 100%; height: 100%; cursor: none; touch-action: none; }

.fig-tag {
  position: absolute; top: 9px; left: 26px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--muted); pointer-events: none;
}
.edge-tag {
  position: absolute; top: 50%; right: 6px;
  transform: translateY(-50%) rotate(180deg); writing-mode: vertical-rl;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--faint); pointer-events: none;
}
.arena-hint {
  position: absolute; left: 14px; bottom: 10px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted); pointer-events: none;
}
.arena-hint .kbd { color: var(--blue); margin-right: 6px; }

/* ---- Rail modules ---------------------------------------------------------- */
.rail { display: flex; flex-direction: column; gap: clamp(12px, 1.6vw, 16px); }
.module {
  border: var(--frame); background: var(--panel);
  padding: 15px 16px 16px; position: relative;
}
.module-title {
  font-family: var(--mono); font-weight: 500; font-size: 10.5px;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted);
  margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.module-note { font-size: 11px; color: var(--muted); margin: 12px 0 0; line-height: 1.45; }

/* Gauge */
.gauge-module { display: flex; flex-direction: column; align-items: center; }
.gauge { position: relative; width: 158px; height: 158px; }
.gauge-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge-track { fill: none; stroke: var(--hair); stroke-width: 3; }
.gauge-arc {
  fill: none; stroke: var(--blue); stroke-width: 4; stroke-linecap: round;
  stroke-dasharray: 0 100; transition: stroke-dasharray 0.08s linear;
}
.gauge-readout {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
}
.gauge-value {
  font-family: var(--mono); font-weight: 500; font-size: 42px; line-height: 1;
  color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.gauge-unit { font-size: 9.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--faint); }

/* Scope */
.scope-module .legend {
  display: inline-flex; gap: 12px; align-items: center;
  font-size: 9.5px; letter-spacing: 0.1em; color: var(--muted);
}
.swatch { display: inline-block; width: 10px; height: 2px; margin-right: 4px; vertical-align: middle; }
.swatch-heat { background: var(--blue); }
.swatch-cool { background: var(--muted); }
.swatch-spark { background: var(--ink); }
.scope { width: 100%; height: 124px; display: block; }

/* Metrics */
.metric { display: flex; flex-direction: column; gap: 3px; }
.metric-label { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.metric-value {
  font-family: var(--mono); font-weight: 500; font-size: 21px;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.metric-lead { margin-bottom: 14px; }
.metric-lead .metric-value { font-size: 34px; color: var(--blue); }
.metric-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px 16px;
  border-top: 1px solid var(--hair-soft); padding-top: 13px;
}

/* Settings */
.settings-module { padding: 0; }
.settings-module > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted);
}
.settings-module > summary::-webkit-details-marker { display: none; }
.summary-icon { color: var(--blue); }
.settings-body { padding: 4px 16px 18px; display: flex; flex-direction: column; gap: 16px; }
.control { display: flex; flex-direction: column; gap: 8px; }
.control-label {
  font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
  display: flex; justify-content: space-between;
}
.control-label code { color: var(--blue); font-size: 12px; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 2px; background: var(--hair); outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 13px; height: 13px; border-radius: 50%;
  background: var(--blue); border: 2px solid var(--panel);
}
input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--panel); background: var(--blue);
}

.control-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  flex: 1 1 auto; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted);
  background: transparent; border: 1px solid var(--hair); padding: 9px 10px; cursor: pointer;
  transition: all 0.14s ease;
}
.btn:hover { color: var(--ink); border-color: var(--blue); }
.btn[aria-pressed="true"] { color: var(--panel); background: var(--blue); border-color: var(--blue); }
.btn-warn:hover { color: var(--blue); border-color: var(--blue); }

/* ---- Explainer ------------------------------------------------------------- */
.explainer { margin-top: clamp(36px, 6vw, 70px); border-top: var(--frame); padding-top: 30px; }
.explainer-title {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--blue); margin: 0 0 22px;
}
.explainer-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(18px, 3vw, 40px); }
.explainer-cols p {
  font-family: var(--serif); margin: 0; color: #3a3d44; font-size: 15px; line-height: 1.6;
}
.explainer-cols strong { color: var(--ink); font-weight: 600; }
.explainer-cols em { color: var(--blue); font-style: italic; }

/* ---- Footer ---------------------------------------------------------------- */
.colophon {
  max-width: 960px; margin: 0 auto; padding: 26px clamp(18px, 4vw, 54px) 48px;
  border-top: var(--frame); display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  font-size: 11px; letter-spacing: 0.06em; color: var(--muted);
}
.colophon-dim { color: var(--blue); }

.noscript { display: block; padding: 20px; color: var(--blue); text-align: center; }

/* ---- Responsive ------------------------------------------------------------ */
@media (max-width: 920px) {
  .rig { grid-template-columns: 1fr; }
  .arena-wrap { max-width: 560px; }
  .explainer-cols { grid-template-columns: 1fr; gap: 18px; }
}
@media (max-width: 540px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
}

/* ---- About page ------------------------------------------------------------ */
.nav-home {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); border-bottom: none;
}
.nav-home:hover { color: var(--blue); border-bottom: none; }

.about { max-width: 860px; }
.about-card {
  display: grid; grid-template-columns: 210px 1fr; gap: clamp(24px, 4vw, 52px);
  align-items: start;
}
.about-portrait {
  aspect-ratio: 5 / 4; width: 100%;
  border: 1px solid var(--hair); background: var(--panel);
  background-image: radial-gradient(rgba(20, 23, 28, 0.06) 1px, transparent 1.4px);
  background-size: 14px 14px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--faint); overflow: hidden;
}
.about-portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.about-name { font-size: clamp(2rem, 5vw, 3.2rem); margin: 0 0 18px; }
.about-bio {
  font-family: var(--serif); font-size: clamp(1rem, 1.4vw, 1.16rem);
  line-height: 1.62; color: #34373d; margin: 0 0 14px; max-width: 56ch;
}
.about-links {
  list-style: none; padding: 0; margin: 26px 0 0;
  display: flex; flex-direction: column; gap: 11px;
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.04em;
}
.about-links a { color: var(--blue); border-bottom: none; }
.about-links a:hover { border-bottom: 1px solid var(--blue); }
.about-links .ext { color: var(--muted); }
@media (max-width: 640px) {
  .about-card { grid-template-columns: 1fr; }
  .about-portrait { max-width: 200px; }
}
