/* Tokens from the Diablo DAQ frontend (daq-server/diablo_server/frontend):
   true black, gray-only neutrals, square corners, no shadows, colour only where it means something. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fonts/inter-latin-wght-normal.woff2') format('woff2');
}

:root {
  --bg: #000000;
  --bg-2: #0b0b0b;
  --bg-3: #161616;
  --line: #1f1f1f;
  --line-strong: #333333;
  --ink: #ededed;
  --ink-2: #bdbdbd;
  --ink-3: #7a7a7a;
  --ink-4: #4d4d4d;
  --danger: #f87171;
  --warning: #e5b53a;
  --success: #4ade80;
  /* sensor trace colours, one per project family */
  --gn2: #27ae60;
  --fuel: #3498db;
  --lox: #e74c3c;
  --gse-low: #f39c12;
  --gse-mid: #9b59b6;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --gutter: clamp(16px, 6vw, 96px);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.7 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }
img { display: block; max-width: 100%; height: auto; }
figure { margin: 0; }
:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #2a2a2a; }

.caps {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.ctl {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line-strong);
  background: var(--bg-2);
  color: var(--ink);
  font: 600 11px var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  padding: 10px 14px;
  text-decoration: none;
  transition: background-color .12s, border-color .12s;
}
.ctl:hover { border-color: #5a5a5a; background: var(--bg-3); }

/* ── Landing: the name, typed, filling the first screen ───────────────── */
.landing {
  height: 100vh; height: 100svh; min-height: 560px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 38vw);
}
.landing-text { display: flex; flex-direction: column; justify-content: center; padding: 0 5vw; position: relative; min-width: 0; }
.boot { display: grid; gap: 4px; margin-bottom: 3vh; }
.typed {
  font-size: clamp(56px, 11vw, 200px);
  font-weight: 600; letter-spacing: -.045em; line-height: .9;
  min-height: 1.8em; /* reserve two lines so the page doesn't jump while typing */
}
.typed span#typed { white-space: pre-wrap; }
.cursor { display: inline-block; width: .08em; height: .78em; margin-left: .04em; background: var(--ink); vertical-align: -.02em; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.landing-sub { margin-top: 3vh; }
.scroll { position: absolute; left: 5vw; bottom: 28px; text-decoration: none; }
.scroll:hover { color: var(--ink); }
.landing-photo { overflow: hidden; min-width: 0; }
.landing-photo img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }

/* ── Intro + index ─────────────────────────────────────────────────────── */
main { max-width: 1280px; margin: 0 auto; padding: 0 var(--gutter); }
.intro { padding: 160px 0 120px; }
.lede { font-size: clamp(22px, 2.6vw, 32px); line-height: 1.4; letter-spacing: -.01em; max-width: 30ch; color: var(--ink); }
.links { display: flex; gap: 10px; margin-top: 40px; flex-wrap: wrap; }

/* ── Projects ──────────────────────────────────────────────────────────── */
.project { padding: 140px 0; border-top: 1px solid var(--line); }
.project header { margin-bottom: 56px; }
.project header .caps { display: flex; align-items: center; gap: 12px; }
.project header .caps::before { content: ""; width: 24px; height: 2px; background: var(--accent); }
.project h2 { font-size: clamp(26px, 3vw, 38px); font-weight: 600; letter-spacing: -.025em; line-height: 1.05; margin-top: 18px; }
.project .body { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: clamp(40px, 7vw, 112px); align-items: start; }
.project .text p { color: var(--ink-2); max-width: 52ch; }
.project ul { list-style: none; margin-top: 32px; display: grid; gap: 16px; max-width: 52ch; }
.project li { color: var(--ink-2); padding-left: 24px; position: relative; }
.project li::before { content: ""; position: absolute; left: 0; top: .85em; width: 10px; height: 1px; background: var(--accent); }
.visual > .caps { display: block; margin-bottom: 20px; }
.visual figcaption { margin-top: 16px; }
.wide { margin-top: 72px; }

/* readouts: DAQ-style numbers */
.readouts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); margin-top: 32px; }
.visual .readouts { margin-top: 0; }
.readouts > div { padding: 20px; min-width: 0; }
.readouts > div + div { border-left: 1px solid var(--line); }
.readouts .v { font: 500 32px var(--mono); font-variant-numeric: tabular-nums; line-height: 1.3; margin-top: 6px; }
.readouts .v small { font-size: 13px; color: var(--ink-3); margin-left: 4px; }

/* packet diagram */
.packet { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; }
.packet .b {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong); border-bottom: 2px solid var(--c);
  font: 11px var(--mono); color: var(--ink-4); cursor: default;
  transition: background-color .12s, color .12s;
}
.packet .b.on { background: var(--bg-3); color: var(--ink); }
.packet-legend { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0 20px; margin-top: 28px; font: 13px var(--mono); }
.packet-legend > * { padding: 8px 0; border-top: 1px solid var(--line); color: var(--ink-3); transition: color .12s; }
.packet-legend .on { color: var(--ink); }

/* flow */
.flow { display: grid; gap: 10px; }
.flow .step { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 16px 20px; border: 1px solid var(--line); }
.flow .step .t { font-weight: 500; }
.flow .step .s { font: 12px var(--mono); color: var(--ink-3); white-space: nowrap; }
.flow .step.hl { border-color: var(--accent); }
.flow .step.hl .s { color: var(--accent); }

/* white-background plots flipped into the dark scheme */
.invert { filter: invert(1) hue-rotate(180deg); }

/* calendar mock */
.cal { border: 1px solid var(--line-strong); }
.cal .row { display: grid; grid-template-columns: 80px minmax(0, 1fr); border-top: 1px solid var(--line); }
.cal .row:first-child { border-top: 0; }
.cal .d { padding: 18px 14px; font: 12px var(--mono); color: var(--ink-3); border-right: 1px solid var(--line); }
.cal .ev {
  font: inherit; font-size: 14px; color: var(--ink); text-align: left; cursor: pointer;
  margin: 12px; padding: 8px 12px; border: 0; border-left: 2px solid var(--warning);
  background: var(--bg-2); transition: border-color .3s;
}
.cal .ev.done { border-left-color: var(--success); color: var(--ink-3); }

footer { max-width: 1280px; margin: 0 auto; padding: 48px var(--gutter); border-top: 1px solid var(--line); }

@media (max-width: 860px) {
  .landing { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 42svh; }
  .landing-photo { order: -1; }
  .landing-text { padding: 24px 16px 64px; }
  .scroll { left: 16px; bottom: 20px; }
  .intro { padding: 96px 0 72px; }
  .project { padding: 88px 0; }
  .project header { margin-bottom: 36px; }
  .project .body { grid-template-columns: minmax(0, 1fr); }
  .wide { margin-top: 48px; overflow-x: auto; }
  .wide img { min-width: 720px; }
  .readouts .v { font-size: 24px; }
  .flow .step { padding: 14px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* schematic sheets: Altium's paper colour kept, click for full size */
.sheets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.sheets a { display: block; text-decoration: none; }
.sheets img { border: 1px solid var(--line-strong); transition: border-color .12s; }
.sheets a:hover img { border-color: var(--ink-3); }
.sheets .caps { display: block; margin-top: 14px; }
@media (max-width: 860px) { .sheets { grid-template-columns: minmax(0, 1fr); } .wide.sheets { overflow: visible; } .wide.sheets img { min-width: 0; } }
.sheets.one { grid-template-columns: minmax(0, 1fr); }

/* ── Block diagrams: the software equivalent of the schematic sheets ──── */
.dot { width: 7px; height: 7px; border-radius: 9999px; display: inline-block; flex: none; }
.diagram > .caps { display: block; margin-bottom: 24px; }
.diagram svg { width: 100%; height: auto; display: block; overflow: visible; }
.diagram .bx { fill: var(--bg); stroke: var(--line-strong); stroke-width: 1; }
.diagram .bx.hl { stroke: var(--accent); }
.diagram .t { fill: var(--ink); font: 500 14px Inter, -apple-system, sans-serif; }
.diagram .s { fill: var(--ink-3); font: 11px var(--mono); }
.diagram .s.hl, .diagram .lb.hl { fill: var(--accent); }
.diagram .lb { fill: var(--ink-3); font: 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.diagram .w { fill: none; stroke: var(--ink-4); stroke-width: 1.2; }
.diagram .w.dash { stroke-dasharray: 3 4; }
.diagram .rg { fill: none; stroke: var(--accent); stroke-dasharray: 4 5; opacity: .55; }
.diagram .ah { fill: var(--ink-4); }

/* link-state list */
.ladder div { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); font: 13px var(--mono); color: var(--ink-2); }
.ladder div:last-child { border-bottom: 1px solid var(--line); }
.ladder div span:last-child { margin-left: auto; color: var(--ink-4); font-size: 12px; text-align: right; }

@media (max-width: 860px) {
  .wide.diagram { overflow-x: auto; }
  .wide.diagram svg { min-width: 760px; }
}

/* CMX865A C-BUS register breakdown */
.cbus > .caps { display: block; margin-bottom: 24px; }
.cbus-wire { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); margin-bottom: 20px; }
.cbus-wire > div { padding: 16px 18px; display: grid; gap: 4px; min-width: 0; }
.cbus-wire > div + div { border-left: 1px solid var(--line); }
.cbus-wire b { font-size: 26px; font-weight: 500; color: var(--ink); }
.cbus-wire em { font: normal 12px var(--mono); color: var(--ink-3); }
.packet.bits { grid-template-columns: repeat(16, minmax(0, 1fr)); }
.packet.bits .b { flex-direction: column; gap: 2px; font-size: 18px; color: var(--ink-2); aspect-ratio: auto; height: 64px; }
.packet.bits .b small { font-size: 10px; color: var(--ink-4); }
.packet.bits .b.on { color: var(--ink); }
.cbus .note { margin-top: 20px; max-width: 80ch; }
.note { display: block; font: 12px/1.6 var(--mono); color: var(--ink-4); }
@media (max-width: 860px) {
  .packet.bits { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .cbus-wire b { font-size: 20px; }
}

/* two figures side by side (Gater: register breakdown + schematic) */
.pair { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(40px, 5vw, 72px); align-items: start; }
.pair .packet.bits .b { height: 54px; font-size: 16px; }
.pair .cbus-wire b { font-size: 22px; }
@media (max-width: 1100px) { .pair { grid-template-columns: minmax(0, 1fr); } }
.pair .sheets a { display: flex; flex-direction: column-reverse; }
.pair .sheets .caps { margin: 0 0 24px; }

/* equations pulled from the MSCI write-up */
.math > .caps { display: block; margin-bottom: 24px; }
.math var { font-style: italic; }
.math .eq {
  font-family: "STIX Two Math", "STIX Two Text", "Latin Modern Math", "Cambria Math", "Times New Roman", serif;
  font-size: clamp(20px, 2vw, 26px); color: var(--ink); line-height: 1.5;
  padding: 18px 0 4px; border-top: 1px solid var(--line); overflow-x: auto; white-space: nowrap;
}
.math .eq sub { font-size: .62em; }
.math .eq-note { font-size: 14px; color: var(--ink-3); margin-bottom: 18px; }
.math .eq-note var { font-family: "STIX Two Text", "Times New Roman", serif; }
.result { width: 100%; border-collapse: collapse; margin-top: 8px; font: 13px var(--mono); font-variant-numeric: tabular-nums; }
.result th { text-align: right; font-weight: 500; color: var(--ink-4); padding: 8px 0 8px 12px; letter-spacing: .08em; }
.result td { text-align: right; padding: 10px 0 10px 12px; border-top: 1px solid var(--line); color: var(--ink-3); }
.result td:first-child, .result th:first-child { text-align: left; padding-left: 0; }
.result td var { font-family: "STIX Two Text", "Times New Roman", serif; font-size: 15px; }
.result tr.best td { color: var(--ink); }
.result tr.best td:first-child { box-shadow: inset 2px 0 0 var(--accent); padding-left: 10px; }
/* the invert filter flips the border too, so pre-invert it to land on --line-strong */
.sheets img.invert { border-color: #cccccc; }

/* Eos: captured levels from the tap's own log */
.capture svg { width: 100%; height: auto; display: block; }
.capture .g { stroke: var(--line); stroke-width: 1; }
.capture .ax { fill: var(--ink-4); font: 11px var(--mono); }
.capture .tr { fill: none; stroke-width: 1.6; stroke-linejoin: round; }
.capture .note { margin-top: 14px; }
.diagram .w.hl { stroke: var(--accent); }
.diagram .bx.bad { stroke: var(--danger); }
.diagram .s.bad { fill: var(--danger); }

/* each project sits in one hairline box; the open spacing stays inside it */
.project { border: 1px solid var(--line); padding: clamp(40px, 5vw, 72px); margin-bottom: 48px; }
.project + .project { border-top: 1px solid var(--line); }
.intro { padding-bottom: 72px; }
@media (max-width: 860px) {
  .project { padding: 40px 16px; margin-bottom: 24px; }
}
.diagram .bx.ok { stroke: var(--success); }
.diagram .s.ok { fill: var(--success); }
.diagram .bx.warn { stroke: var(--warning); }
.diagram .s.warn { fill: var(--warning); }
.diagram .note { margin-top: 20px; }
.visual.diagram > .caps { margin-bottom: 20px; }
/* the state machine sits in a half-width column, so its text is set larger to stay readable */
.diagram svg.sm .t { font-size: 17px; }
.diagram svg.sm .s { font-size: 13.5px; }
