/* =========================================================
   Anirudh Kowshik: personal site
   Plain CSS, no build step. Mobile-first.
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
  --bg: #0c0d10;
  --bg-elev: #131519;
  --bg-elev-2: #191c22;
  --line: #24272f;
  --line-strong: #343842;
  --text: #ecebe6;
  --muted: #a5a7ae;       /* ~8:1 on --bg */
  --faint: #8b8e96;       /* ~5.9:1 on --bg, still AA for small text */
  --accent: #7cc4b8;      /* restrained teal */
  --accent-strong: #9ad6cc;
  --accent-soft: rgba(124, 196, 184, 0.12);
  --accent-line: rgba(124, 196, 184, 0.35);

  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --todo: #f2b84b;        /* owner placeholders only */
  --fail: #ef8a7d;        /* a failed station on the test line */
  --fail-soft: rgba(239, 138, 125, 0.12);
  --fail-line: rgba(239, 138, 125, 0.45);
  --warn: #e2b36b;        /* a rack in repair, a station waiting for its retest */
  --panel: #08090b;       /* the test line's equipment panel */

  /* type scale (1.25 minor third-ish, fluid at the top end) */
  --fs-xs: .75rem;
  --fs-sm: .875rem;
  --fs-base: 1rem;
  --fs-md: 1.125rem;
  --fs-lg: clamp(1.3rem, 1.1rem + .9vw, 1.6rem);
  --fs-xl: clamp(1.6rem, 1.2rem + 1.8vw, 2.3rem);
  --fs-hero: clamp(2.6rem, 1.6rem + 5vw, 5rem);

  --radius: 14px;
  --radius-lg: 20px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --maxw: 1120px;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --nav-h: 60px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: var(--text); text-decoration-color: var(--faint); text-underline-offset: 3px; transition: color .2s var(--ease), text-decoration-color .2s var(--ease); }
a:hover { color: var(--accent); text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
h1, h2, h3 { line-height: 1.15; margin: 0; font-weight: 600; letter-spacing: -0.015em; }
h1, .hero-line, .sec-line, .contact-line, .feature h3, .card h3, .project h2 { font-family: var(--display); }
p { margin: 0 0 1em; }
ul, ol { margin: 0; padding: 0; list-style: none; }
::selection { background: var(--accent); color: var(--bg); }
.mono { font-family: var(--mono); }
.accent { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--bg); padding: .5rem 1rem; z-index: 100; border-radius: 8px; }
.skip:focus { left: 1rem; top: 1rem; }

/* ---------- Nav ---------- */
.nav { position: sticky; top: 0; z-index: 50; }
/* Named on the inner row, not .nav: a view-transition-name makes an element a
   backdrop root, which would switch off the blur on .nav::before. */
.nav-inner { view-transition-name: site-nav; }
/* The glass sits on its own layer so its opacity can follow the scroll */
.nav::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: rgba(12, 13, 16, 0.86);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line);
  opacity: .55; transition: opacity .35s var(--ease);
}
.nav.scrolled::before { opacity: 1; }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: var(--nav-h); gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-family: var(--mono); font-weight: 500; font-size: var(--fs-sm); text-decoration: none; letter-spacing: .06em; flex-shrink: 0; }
.nav nav { min-width: 0; position: relative; }
.nav ul { display: flex; gap: 1.4rem; overflow-x: auto; scrollbar-width: none; padding: .5rem 0; }
.nav ul::-webkit-scrollbar { display: none; }
.nav li a { position: relative; font-size: var(--fs-sm); color: var(--muted); text-decoration: none; white-space: nowrap; padding: .25rem 0; }
.nav li a::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 1px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease); }
.nav li a:hover, .nav li a.active { color: var(--text); }
.nav li a.active::after, .nav li a:hover::after { transform: scaleX(1); }
@media (max-width: 720px) {
  .nav ul { gap: 1.1rem; padding-right: 1.5rem; }
  /* hint that the link row scrolls on small screens */
  .nav nav { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
}

/* "link up" LED */
.led { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), 0 0 10px rgba(124,196,184,.6); flex-shrink: 0; animation: pulse 3.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* ---------- Hero ---------- */
.hero { position: relative; isolation: isolate; padding: clamp(1.5rem, 5vh, 3.5rem) 0 clamp(3rem, 7vh, 4.5rem); }
.hero-grid { display: grid; gap: 2.75rem; align-items: center; }
.hero .wrap { max-width: 1240px; }
/* The photo is sized by the viewport height as well as its width, so the
   whole portrait (4:5, never cropped) fits on a laptop's first screen. */
.hero { --photo-w: min(calc(100vw - 2 * var(--gutter)), 480px); }
@media (min-width: 960px) {
  .hero { --photo-w: min(40vw, 500px, calc((100svh - var(--nav-h) - 13rem) * .8)); }
  .hero-grid { grid-template-columns: minmax(0, 1fr) var(--photo-w); gap: clamp(3rem, 6vw, 5.5rem); }
}

/* Role, employer, location */
.status { display: flex; flex-direction: column; gap: .15rem; font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 1.25rem; line-height: 1.5; }
.status > span:first-child { color: var(--text); }
.status .sep { color: var(--faint); margin: 0 .2rem; }

/* The portrait: the whole 800x1000 photo, never cropped at rest */
.hero-visual { width: var(--photo-w); justify-self: start; }
.hero-frame { position: relative; }
@media (min-width: 960px) { .hero-visual { justify-self: end; } }
.hero-photo {
  position: relative; margin: 0; aspect-ratio: 4 / 5; overflow: hidden; border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #2a3442 0%, #3a3438 55%, #1d1b1e 100%);
  box-shadow: 0 0 0 1px rgba(236,235,230,.08), 0 40px 90px -50px rgba(124,196,184,.55), 0 20px 50px -30px rgba(0,0,0,.9);
  animation: rise 1s var(--ease) .05s backwards;
}
.hero-photo img { width: 100%; height: 100%; object-fit: contain; transform-origin: 50% 40%; }

/* The scope: a canvas eye diagram over a static SVG fallback, so it is never empty.
   It sits under the buttons as a small instrument, with its caption beside it. */
.hero-scope { display: flex; align-items: center; gap: 1.25rem; margin-top: 1.5rem; }
.scope {
  position: relative; flex: none; margin: 0; width: clamp(190px, 14vw, 200px);
  padding: .45rem .45rem .35rem; border-radius: calc(var(--radius) + 2px);
  background: rgba(12, 13, 16, .86); border: 1px solid var(--line-strong);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 24px 50px -20px rgba(0,0,0,.85), 0 0 0 1px rgba(0,0,0,.4);
  animation: rise 1s var(--ease) .2s backwards;
}
.scope-screen {
  position: relative; aspect-ratio: 16 / 10; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line-strong);
  background:
    url("images/eye-fallback.svg") center / 100% 100% no-repeat,
    linear-gradient(rgba(236,235,230,.085) 1px, transparent 1px) 0 0 / 12.5% 12.5%,
    linear-gradient(90deg, rgba(236,235,230,.085) 1px, transparent 1px) 0 0 / 12.5% 12.5%,
    radial-gradient(120% 90% at 50% 40%, #0f1716 0%, #070909 70%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.02), inset 0 0 60px rgba(0,0,0,.6), 0 30px 80px -45px rgba(124,196,184,.45);
}
.scope-screen::after { /* center crosshair, like scope graticule */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(rgba(236,235,230,.17), rgba(236,235,230,.17)) 50% 0 / 1px 100% no-repeat,
    linear-gradient(rgba(236,235,230,.17), rgba(236,235,230,.17)) 0 50% / 100% 1px no-repeat;
}
.scope-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* Once the canvas is drawing, hide the static fallback traces (grid stays) */
.scope.live .scope-screen {
  background:
    linear-gradient(rgba(236,235,230,.085) 1px, transparent 1px) 0 0 / 12.5% 12.5%,
    linear-gradient(90deg, rgba(236,235,230,.085) 1px, transparent 1px) 0 0 / 12.5% 12.5%,
    radial-gradient(120% 90% at 50% 40%, #0f1716 0%, #070909 70%);
}
.scope-readout { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 .75rem; padding: .4rem .2rem 0; font-family: var(--mono); font-size: .66rem; line-height: 1.5; color: var(--muted); letter-spacing: .03em; }
.scope-meas b { color: var(--accent); font-weight: 500; font-variant-numeric: tabular-nums; }
.scope-note { margin: 0; font-size: .8rem; line-height: 1.5; color: var(--faint); max-width: 30ch; }
.scope-note .hint { color: var(--muted); }

/* Owner placeholders: impossible to mistake for real content */
.todo {
  display: inline; font-family: var(--mono); font-size: .78em; font-weight: 500; letter-spacing: 0; text-transform: none;
  color: var(--todo); background: rgba(242,184,75,.08);
  outline: 1px dashed var(--todo); outline-offset: 1px; border-radius: 4px; padding: 0 .3em;
  white-space: normal; -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.btn .todo { font-size: .68rem; }
.btn-primary .todo { color: #3a2a00; background: #f6d48e; }
.hero h1 { font-size: var(--fs-hero); font-weight: 700; letter-spacing: -0.04em; line-height: 1; }
.hero-line { font-size: var(--fs-xl); font-weight: 500; letter-spacing: -0.02em; line-height: 1.2; margin: 1.25rem 0 1.5rem; max-width: 32ch; text-wrap: balance; }
.hero-line em { font-style: normal; color: var(--accent); }
.pitch { color: var(--muted); max-width: 40rem; font-size: var(--fs-md); }
.pitch strong { color: var(--text); font-weight: 500; }
.hero-text > * { animation: rise .9s var(--ease) both; }
.hero-text > *:nth-child(2) { animation-delay: .05s; }
.hero-text > *:nth-child(3) { animation-delay: .1s; }
.hero-text > *:nth-child(4) { animation-delay: .15s; }
.hero-text > *:nth-child(5) { animation-delay: .2s; }
/* transform only: text is painted (and counts for LCP) from the first frame */
@keyframes rise { from { transform: translateY(10px); } to { transform: none; } }

.cta { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 46px; padding: 0 1.35rem;
  border: 1px solid var(--line-strong); border-radius: 999px;
  font-size: .95rem; font-weight: 500; text-decoration: none; color: var(--text);
  background: rgba(19, 21, 25, .7);
  transition: transform .25s var(--ease), border-color .25s var(--ease), background .25s var(--ease), color .25s var(--ease);
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #0c0d10; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #0c0d10; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); padding: 0 .75rem; }
.btn-ghost:hover { border-color: transparent; color: var(--accent); }

/* ---------- Hero teaser: a small preview of the test line ----------
   A link to #test-line. Seven stations light up in order and the fourth
   (Network blade) fails; what happens next is in the section below. The
   resting state, which is also the reduced-motion state, is the failed frame.
   Only opacity and transform animate, and nothing changes size. */
.teaser {
  display: flex; align-items: center; gap: .6rem 1.1rem; width: fit-content; max-width: 100%;
  margin-top: 1.5rem; padding: .65rem 1rem; border: 1px solid var(--accent-line); border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(124, 196, 184, .09), rgba(19, 21, 25, .6) 60%); color: var(--text); text-decoration: none;
  box-shadow: 0 16px 40px -28px rgba(124, 196, 184, .7);
  transition: border-color .25s var(--ease), background-color .25s var(--ease), box-shadow .25s var(--ease);
}
.teaser:hover { color: var(--text); border-color: var(--accent); box-shadow: 0 16px 44px -22px rgba(124, 196, 184, .9); }
.teaser:hover .arrow { transform: translateY(3px); }
.teaser-strip { position: relative; flex: none; display: flex; align-items: center; justify-content: space-between; width: 9.5rem; height: 20px; }
.teaser-strip::before { content: ""; position: absolute; left: 5px; right: 5px; top: 50%; height: 1px; margin-top: -.5px; background: var(--line-strong); }
.teaser-strip i { position: relative; width: 10px; height: 10px; border-radius: 50%; background: var(--bg); box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.teaser-strip i::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--accent); opacity: 0; animation-play-state: var(--play, running); }
.teaser-strip i:nth-child(-n+4)::after { opacity: 1; }
.teaser-strip i:nth-child(4)::after { background: var(--fail); box-shadow: 0 0 0 4px rgba(239, 138, 125, .18); }
/* the rack at the station under test: its box spans first dot centre to last */
.teaser-at { position: absolute; left: 5px; right: 5px; top: 0; bottom: 0; opacity: 0; transform: translateX(50%); pointer-events: none; animation-play-state: var(--play, running); }
.teaser-at::before {
  content: ""; position: absolute; left: -7px; top: 0; width: 14px; height: 20px; border-radius: 3.5px; border: 1.5px solid var(--accent);
  background: repeating-linear-gradient(180deg, transparent 0 2px, rgba(124, 196, 184, .75) 2px 4px) 50% 3px / 7px 12px no-repeat, var(--bg-elev-2);
  box-shadow: 0 0 10px rgba(124, 196, 184, .45);
}
.teaser-text { display: grid; gap: .1rem; min-width: 0; line-height: 1.35; }
.teaser-cue { font-size: 1rem; font-weight: 600; }
.teaser-cue .arrow { display: inline-block; margin-left: .15rem; color: var(--accent); animation-play-state: var(--play, running); }
.teaser-note { font-family: var(--mono); font-size: .7rem; letter-spacing: .02em; color: var(--fail); }
@media (prefers-reduced-motion: no-preference) {
  .teaser-strip i:nth-child(1)::after { animation-name: teaser-1; }
  .teaser-strip i:nth-child(2)::after { animation-name: teaser-2; }
  .teaser-strip i:nth-child(3)::after { animation-name: teaser-3; }
  .teaser-strip i:nth-child(4)::after { animation-name: teaser-4; }
  .teaser-at { animation-name: teaser-at; }
  .teaser-cue .arrow { animation-name: teaser-nudge; animation-duration: 2.4s; animation-timing-function: var(--ease); animation-iteration-count: infinite; }
  .teaser-strip i::after, .teaser-at { animation-duration: 12s; animation-timing-function: var(--ease); animation-iteration-count: infinite; }
}
/* 12 s loop: three passes, the failure, a long hold, a short reset */
@keyframes teaser-1 { 0%, 6% { opacity: 0; } 9%, 93% { opacity: 1; } 97%, 100% { opacity: 0; } }
@keyframes teaser-2 { 0%, 20% { opacity: 0; } 23%, 93% { opacity: 1; } 97%, 100% { opacity: 0; } }
@keyframes teaser-3 { 0%, 34% { opacity: 0; } 37%, 93% { opacity: 1; } 97%, 100% { opacity: 0; } }
@keyframes teaser-4 { 0%, 48% { opacity: 0; } 51%, 93% { opacity: 1; } 97%, 100% { opacity: 0; } }
@keyframes teaser-at {
  0% { opacity: 0; transform: translateX(0); }
  3%, 10% { opacity: 1; transform: translateX(0); }
  15%, 24% { opacity: 1; transform: translateX(16.667%); }
  29%, 38% { opacity: 1; transform: translateX(33.333%); }
  43%, 49% { opacity: 1; transform: translateX(50%); }
  52%, 100% { opacity: 0; transform: translateX(50%); }
}
@keyframes teaser-nudge { 0%, 55%, 100% { transform: none; } 75% { transform: translateY(4px); } }
/* paused while the hero is off screen, its text has faded out, or the tab is hidden (script.js) */
.hero.paused .teaser, .hero.text-out .teaser, .tab-hidden .teaser { --play: paused; }


/* Quick facts strip */
.facts { display: grid; grid-template-columns: 1fr; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
@media (min-width: 560px) { .facts { grid-template-columns: 1fr 1fr; } }
@media (min-width: 980px) { .facts { grid-template-columns: repeat(4, 1fr); } }
.facts div { padding: 1.1rem 0; border-top: 1px solid var(--line); }
.facts div:first-child { border-top: 0; }
@media (min-width: 560px) {
  .facts div { padding: 1.25rem 1.25rem 1.25rem 0; }
  .facts div:nth-child(-n+2) { border-top: 0; }
  .facts div:nth-child(even) { padding-left: 1.25rem; border-left: 1px solid var(--line); }
}
@media (min-width: 980px) {
  .facts div { border-top: 0; padding: 1.4rem 1.25rem; border-left: 1px solid var(--line); }
  .facts div:first-child { border-left: 0; padding-left: 0; }
}
.facts dt { font-family: var(--mono); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin-bottom: .3rem; }
.facts dd { margin: 0; font-size: .95rem; color: var(--text); line-height: 1.45; }

/* ---------- Sections: label column + content column ---------- */
.section { padding-top: clamp(4.5rem, 12vh, 7.5rem); }
.section-grid { display: grid; gap: 1.25rem; }
.section-grid > * { min-width: 0; } /* wide children (the test line's rail) scroll inside the column */
@media (min-width: 900px) {
  .section-grid { grid-template-columns: 190px minmax(0, 1fr); gap: 3.5rem; }
  .sec-head { position: sticky; top: calc(var(--nav-h) + 2rem); align-self: start; }
}
.sec-head { display: flex; align-items: baseline; gap: .75rem; }
@media (min-width: 900px) { .sec-head { flex-direction: column; gap: .4rem; } }
.sec-head h2 { font-size: var(--fs-sm); font-family: var(--mono); font-weight: 500; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.sec-line { font-size: var(--fs-lg); font-weight: 500; letter-spacing: -0.015em; line-height: 1.3; color: var(--text); margin-bottom: 2rem; max-width: 34ch; text-wrap: balance; }
.sec-line em { font-style: normal; color: var(--accent); }
.sub { font-family: var(--mono); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .1em; color: var(--faint); font-weight: 500; margin: 3.5rem 0 1.25rem; }

/* ---------- About ---------- */
.about-grid { display: grid; gap: 2.5rem; }
@media (min-width: 1040px) { .about-grid { grid-template-columns: minmax(0, 1fr) 330px; gap: 3rem; } }
.prose p { color: var(--muted); max-width: 40rem; }
.prose p strong { color: var(--text); font-weight: 500; }

/* The stack: rack-unit style list of layers he has worked across */
.stack { border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(180deg, var(--bg-elev) 0%, rgba(19,21,25,.4) 100%); padding: .5rem; align-self: start; }
.stack-title { display: flex; justify-content: space-between; font-family: var(--mono); font-size: var(--fs-xs); color: var(--faint); letter-spacing: .06em; text-transform: uppercase; padding: .55rem .7rem .7rem; margin: 0; }
.stack ol { display: grid; gap: 4px; }
.stack li {
  display: grid; grid-template-columns: 2.2rem 1fr auto; align-items: center; gap: .6rem;
  padding: .6rem .7rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); font-size: var(--fs-sm);
  transition: border-color .3s var(--ease), background .3s var(--ease), transform .3s var(--ease);
}
.stack li:hover { border-color: var(--accent-line); background: var(--bg-elev-2); transform: translateX(3px); }
.stack .u { font-family: var(--mono); font-size: .7rem; color: var(--faint); }
.stack .layer { display: block; color: var(--text); font-weight: 500; line-height: 1.3; }
.stack .what { display: block; color: var(--faint); font-size: .78rem; line-height: 1.35; }
.stack .where { position: relative; font-family: var(--mono); font-size: .68rem; color: var(--muted); display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; }
.stack .where::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
.stack .where::after { content: ""; position: absolute; left: 0; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px rgba(124,196,184,.8); opacity: 0; transition: opacity .3s var(--ease); }
.stack li.now .where::after, .stack li:hover .where::after { opacity: 1; }
.stack-caption { font-size: .78rem; color: var(--faint); padding: .7rem .7rem .35rem; margin: 0; }

/* ---------- Experience timeline ---------- */
.timeline { position: relative; display: grid; gap: 0; }
.role { position: relative; display: grid; gap: .5rem 2rem; padding: 1.75rem 0; border-top: 1px solid var(--line); }
.role:last-child { border-bottom: 1px solid var(--line); }
@media (min-width: 720px) { .role { grid-template-columns: 170px minmax(0, 1fr); } }
.role-meta { display: flex; flex-direction: column; gap: .2rem; }
.role-when { font-family: var(--mono); font-size: var(--fs-xs); color: var(--faint); letter-spacing: .04em; }
.role-org { font-weight: 600; font-size: var(--fs-md); }
.role-where { font-size: .8rem; color: var(--faint); }
.role h3 { font-size: var(--fs-base); font-weight: 500; color: var(--muted); }
.role-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem 1.5rem; flex-wrap: wrap; margin-bottom: .6rem; }
.impact { display: inline-flex; align-items: baseline; gap: .5rem; font-family: var(--mono); font-size: var(--fs-xs); color: var(--accent); border: 1px solid var(--accent-line); background: var(--accent-soft); border-radius: 999px; padding: .2rem .7rem; white-space: nowrap; }
.impact b { font-weight: 500; font-size: .85rem; }
.headline { color: var(--text); font-size: 1.04rem; line-height: 1.5; margin-bottom: .75rem; max-width: 46rem; }
.role ul { display: grid; gap: .35rem; }
.role li { position: relative; padding-left: 1.1rem; color: var(--muted); font-size: .95rem; max-width: 46rem; }
.role li::before { content: ""; position: absolute; left: 0; top: .72em; width: 6px; height: 1px; background: var(--accent); }
.role li b { color: var(--text); font-weight: 500; }
.role.current .role-when { color: var(--accent); }
.role.current .role-when::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: .45rem; vertical-align: .1em; box-shadow: 0 0 8px rgba(124,196,184,.7); }
.tags { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1rem 0 0; }
.tags li, .skills li {
  font-family: var(--mono); font-size: .72rem; color: var(--muted); padding: .2rem .65rem;
  border: 1px solid var(--line); border-radius: 999px; background: transparent;
}
.role ul.tags { display: flex; gap: .4rem; }
.role .tags li { padding: .2rem .65rem; font-size: .72rem; max-width: none; color: var(--muted); }
.role .tags li::before { display: none; }

/* ---------- Skills ---------- */
.skill-group { display: grid; gap: .8rem 2rem; padding: 1.5rem 0; border-top: 1px solid var(--line); }
.skill-group:last-child { border-bottom: 1px solid var(--line); }
@media (min-width: 720px) { .skill-group { grid-template-columns: 170px minmax(0, 1fr); } }
.skill-group dt { font-weight: 600; font-size: 1rem; line-height: 1.4; padding-top: .15rem; }
.skill-group dd { margin: 0; }
.skills ul { display: flex; flex-wrap: wrap; gap: .45rem; }
.skills li { font-size: .76rem; padding: .3rem .75rem; line-height: 1.4; transition: border-color .25s var(--ease), color .25s var(--ease), background .25s var(--ease); }
.skills li:hover { border-color: var(--accent-line); color: var(--text); }
@media (max-width: 480px) { .skills li { font-size: .7rem; padding: .3rem .65rem; } }
.skill-group.primary li { color: var(--text); border-color: var(--accent-line); background: var(--accent-soft); }
.skill-group.primary dt::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: .55rem; vertical-align: .15em; box-shadow: 0 0 8px rgba(124,196,184,.7); }

/* Education */
.edu-wrap { display: grid; gap: 1.5rem; align-items: center; }
@media (min-width: 760px) { .edu-wrap { grid-template-columns: minmax(0, 1fr) 300px; gap: 2.5rem; } }
.edu li { display: grid; gap: .1rem; padding: .9rem 0; border-top: 1px solid var(--line); }
.edu li:first-child { border-top: 0; padding-top: 0; }
.edu strong { font-weight: 500; }
.edu span { color: var(--muted); font-size: .92rem; }
.edu-photo {
  position: relative; margin: 0; aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden;
  background: radial-gradient(120% 90% at 30% 15%, #1e2a2a 0%, var(--bg-elev) 60%, var(--bg) 100%);
  border: 1px solid var(--line);
}
.edu-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; filter: saturate(.9) contrast(1.03); transition: transform .8s var(--ease); }
.edu-photo:hover img { transform: scale(1.03); }
.edu-photo figcaption { position: absolute; z-index: 2; left: 0; right: 0; bottom: 0; padding: 1.5rem .9rem .7rem; font-size: .78rem; color: #d9d8d3; background: linear-gradient(180deg, transparent, rgba(12,13,16,.85)); }

/* ---------- Projects ---------- */
.feature {
  position: relative; display: grid; gap: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--bg-elev-2) 0%, var(--bg-elev) 40%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 30px 60px -40px rgba(0,0,0,.8);
  transition: border-color .35s var(--ease);
}
.feature:hover { border-color: var(--accent-line); }
@media (min-width: 860px) { .feature { grid-template-columns: 1.1fr 1fr; } }
.feature-media { position: relative; margin: 0; background: #0f1114; border-bottom: 1px solid var(--line); overflow: hidden; min-height: 220px; }
@media (min-width: 860px) { .feature-media { border-bottom: 0; border-right: 1px solid var(--line); } }
.feature-media img { width: 100%; height: 100%; object-fit: cover; object-position: top center; transition: transform .8s var(--ease); }
.feature:hover .feature-media img { transform: scale(1.025); }
.feature-body { padding: clamp(1.5rem, 3vw, 2.25rem); display: flex; flex-direction: column; }
.kicker { font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: .6rem; }
.feature h3 { font-size: var(--fs-lg); margin-bottom: .75rem; }
.feature p { color: var(--muted); font-size: .97rem; }
.links { margin-top: auto; padding-top: 1.25rem; display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; }
.links a, .more { font-size: .9rem; text-decoration: none; color: var(--accent); }
.links a:hover { text-decoration: underline; }
.arrow { display: inline-block; transition: transform .3s var(--ease); }
a:hover .arrow, .card:hover .arrow { transform: translateX(3px); }

.card {
  position: relative; display: flex; flex-direction: column; padding: 1.4rem; overflow: hidden;
  background: linear-gradient(180deg, var(--bg-elev-2) 0%, var(--bg-elev) 55%);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
  text-decoration: none; color: inherit;
  transition: border-color .3s var(--ease);
}
a.card:hover { border-color: var(--accent-line); color: inherit; }
.card h3 { font-size: 1.05rem; margin-bottom: .5rem; }
.card p { color: var(--muted); font-size: .92rem; margin-bottom: .5rem; }
.card .more { margin-top: auto; padding-top: .75rem; }
.credit { margin-top: 1rem; font-size: .85rem; color: var(--faint); }
.nda { margin-top: 2.5rem; padding: 1.1rem 1.25rem; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); font-size: .92rem; }
.nda p { margin: 0; }

/* ---------- Reading ---------- */
.reading li { border-top: 1px solid var(--line); }
.reading li:last-child { border-bottom: 1px solid var(--line); }
.reading a.read { display: grid; gap: .3rem 2rem; padding: 1.35rem .25rem; text-decoration: none; color: inherit; transition: background .3s var(--ease), padding .3s var(--ease); border-radius: 8px; }
@media (min-width: 720px) { .reading a.read { grid-template-columns: 130px minmax(0, 1fr); } }
.reading a.read:hover { background: var(--bg-elev); padding-left: .9rem; padding-right: .9rem; }
.reading .date { font-family: var(--mono); font-size: var(--fs-xs); color: var(--faint); padding-top: .2rem; }
.reading .src { display: block; font-family: var(--mono); font-size: var(--fs-xs); color: var(--accent); letter-spacing: .03em; margin-bottom: .15rem; }
.reading .t { display: block; font-weight: 500; font-size: 1.04rem; line-height: 1.4; transition: color .2s var(--ease); }
.reading a.read:hover .t { color: var(--accent-strong); }
.reading .why { display: block; color: var(--muted); font-size: .92rem; margin-top: .35rem; }

/* ---------- Off the clock: photo mosaic ---------- */
.mosaic { display: grid; gap: .75rem; grid-template-columns: 1fr 1fr; grid-auto-rows: 190px; }
@media (min-width: 720px) { .mosaic { grid-template-columns: 1.25fr 1fr 1fr; grid-auto-rows: 250px; gap: 1rem; } }
.tile { position: relative; margin: 0; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--line);
  background: radial-gradient(120% 90% at 20% 0%, #1f2a2b 0%, transparent 60%), linear-gradient(160deg, #171a21 0%, #0f1115 100%); }
.tile::before { content: attr(data-label); position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--mono); font-size: var(--fs-xs); color: var(--faint); letter-spacing: .1em; text-transform: uppercase; }
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; filter: saturate(.85) brightness(.92); transition: transform 1s var(--ease), filter .6s var(--ease); }
.tile:hover img { transform: scale(1.045); filter: saturate(1.05) brightness(1); }
.tile figcaption {
  position: absolute; z-index: 2; left: 0; right: 0; bottom: 0; padding: 2.5rem 1rem .9rem;
  background: linear-gradient(180deg, transparent 0%, rgba(10,11,13,.88) 70%);
  font-size: .85rem; line-height: 1.4; color: #dddcd6;
}
.tile figcaption b { display: block; font-family: var(--mono); font-weight: 500; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin-bottom: .2rem; }
.tile-hiking { grid-row: span 2; }
.tile-food { grid-column: span 2; }
.tile-food img { object-position: 50% 55%; }
.tile-hiking img { object-position: 15% 50%; }
@media (max-width: 719px) {
  .tile figcaption { padding: 2rem .75rem .7rem; font-size: .78rem; }
}

/* ---------- Contact / footer ---------- */
.contact-line { font-size: var(--fs-xl); font-weight: 500; letter-spacing: -0.02em; line-height: 1.2; max-width: 20ch; margin-bottom: 1rem; text-wrap: balance; }
.contact-line em { font-style: normal; color: var(--accent); }
.contact p.note { color: var(--muted); max-width: 36rem; }
.footer { margin-top: clamp(4rem, 12vh, 7rem); padding-bottom: 2.5rem; color: var(--faint); font-size: .8rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1.5rem; border-top: 1px solid var(--line); padding-top: 1.5rem; }
.footer p { margin: 0; }
.footer a { color: var(--muted); }

/* ---------- Scroll reveal fallback (JS + IntersectionObserver, only in
   browsers without scroll-driven animations) ---------- */
.io-reveal .reveal { opacity: 0; transform: translateY(16px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.io-reveal .reveal.in { opacity: 1; transform: none; }

/* ---------- Project detail pages ---------- */
.project { padding-top: clamp(2.5rem, 8vh, 4.5rem); padding-bottom: 2rem; max-width: 920px; }
.back { display: inline-flex; gap: .4rem; font-size: .9rem; color: var(--muted); text-decoration: none; margin-bottom: 2.25rem; }
.back:hover { color: var(--accent); }
.project .kicker { margin-bottom: 1rem; }
.project h1 { font-size: clamp(2.2rem, 1.4rem + 4vw, 3.6rem); font-weight: 700; letter-spacing: -0.035em; line-height: 1.05; }
.project .lede { color: var(--muted); font-size: var(--fs-md); max-width: 42rem; margin: 1.25rem 0 1.5rem; }
.project .tags { margin: 0 0 .5rem; }
.project h2 { display: flex; align-items: baseline; gap: .75rem; font-size: var(--fs-lg); margin: 3.75rem 0 1.1rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.project h2 span { font-family: var(--mono); font-size: var(--fs-xs); color: var(--accent); font-weight: 400; letter-spacing: .08em; }
.project p, .project li { color: var(--muted); }
.project > p { max-width: 44rem; }
.project strong { color: var(--text); font-weight: 500; }
.project ul.points { display: grid; gap: .7rem; max-width: 46rem; }
.project ul.points li { position: relative; padding-left: 1.2rem; }
.project ul.points li::before { content: ""; position: absolute; left: 0; top: .78em; width: 7px; height: 1px; background: var(--accent); }
.project code { font-family: var(--mono); font-size: .85em; background: var(--bg-elev-2); border: 1px solid var(--line); padding: .1em .35em; border-radius: 5px; color: var(--text); }

/* Architecture flow: signal-path style steps */
.flow { display: grid; gap: .6rem; counter-reset: step; margin: 1.25rem 0; }
@media (min-width: 760px) { .flow { grid-auto-flow: column; grid-auto-columns: 1fr; gap: 1.5rem; } }
.flow li { counter-increment: step; position: relative; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; font-size: .9rem; color: var(--muted); }
@media (min-width: 760px) {
  .flow li:not(:last-child)::after { content: ""; position: absolute; top: 1.55rem; right: calc(-1.5rem - 1px); width: 1.5rem; height: 1px; background: var(--accent-line); }
}
.flow li::before { content: counter(step, decimal-leading-zero); display: block; font-family: var(--mono); font-size: .72rem; color: var(--accent); margin-bottom: .35rem; }
.flow li strong { display: block; color: var(--text); margin-bottom: .25rem; }

.shots { display: grid; gap: 1rem; margin-top: 1.25rem; }
@media (min-width: 720px) { .shots { grid-template-columns: 1fr 1fr; } .shots .wide { grid-column: 1 / -1; } }
.shots figure { margin: 0; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.shots img { width: 100%; height: auto; }
.shots figcaption { font-size: .78rem; color: var(--faint); padding: .6rem .9rem; font-family: var(--mono); }

.project-nav { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.project-nav a { color: var(--accent); text-decoration: none; font-size: .9rem; }
.project-nav a:hover { text-decoration: underline; }
.project > * { animation: rise .7s var(--ease) both; }
.project .note { margin-top: 3rem; font-size: .85rem; color: var(--faint); }


/* =========================================================
   Depth, texture and motion
   The default state (no .motion class) is the final, fully
   visible state. script.js adds .motion only when the visitor
   has not asked for reduced motion. Only transform and opacity
   are animated.
   ========================================================= */

/* Film grain over the whole page: one static, composited layer */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 90; pointer-events: none; opacity: .045;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* Scroll progress line: CSS scroll timeline, or script.js where unsupported */
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 70; pointer-events: none;
  background: linear-gradient(90deg, rgba(124,196,184,.4), var(--accent) 60%, var(--accent-strong));
  box-shadow: 0 0 10px rgba(124,196,184,.55);
  transform-origin: 0 50%; transform: scaleX(0);
}

/* ---------- Hero: a lit stage against the flat sections below ---------- */
.hero {
  overflow-x: clip; /* keep the glow from widening the page */
  background:
    radial-gradient(70% 70% at 78% 8%, rgba(124,196,184,.085), transparent 70%),
    radial-gradient(50% 60% at 0% 0%, rgba(124,196,184,.04), transparent 70%),
    linear-gradient(180deg, #0f1114 0%, #0d0e12 70%, var(--bg) 100%);
}
.hero::before { /* dot-grid texture, fading toward the bottom */
  content: ""; position: absolute; inset: 0; z-index: -2; pointer-events: none;
  background-image: radial-gradient(rgba(236,235,230,.07) 1px, transparent 1.2px);
  background-size: 28px 28px;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0,0,0,.6) 55%, transparent 100%);
          mask-image: linear-gradient(180deg, #000 0%, rgba(0,0,0,.6) 55%, transparent 100%);
}
.hero::after { /* glowing hairline where the hero ends */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--accent-line) 30%, rgba(124,196,184,.6) 62%, transparent);
}
.btn-primary { box-shadow: 0 10px 30px -12px rgba(124,196,184,.6); }

/* Quick-facts strip: a "packet" travels along the top link */
.facts { position: relative; overflow: hidden; }
.motion .facts::before {
  content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 7%, transparent 14%);
  transform: translateX(-14%);
  animation: packet 6s linear 2s infinite;
}
@keyframes packet { from { transform: translateX(-14%); } to { transform: translateX(100%); } }
.hero.paused ~ .wrap .facts::before { animation-play-state: paused; }

/* ---------- Rack panel: units power on bottom-up, lit LEDs pulse ---------- */
.stack { position: relative; box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 30px 70px -45px rgba(124,196,184,.35); }
.stack li { position: relative; overflow: hidden; }
.stack li::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: linear-gradient(90deg, transparent, rgba(124,196,184,.14), transparent);
  transform: translateX(-100%);
}
.stack li:nth-child(6) { --n: 0; } .stack li:nth-child(5) { --n: 1; } .stack li:nth-child(4) { --n: 2; }
.stack li:nth-child(3) { --n: 3; } .stack li:nth-child(2) { --n: 4; } .stack li:nth-child(1) { --n: 5; }
.motion .stack li.now .where::after { opacity: 0; }
.motion .stack.on li::after { animation: scan .9s var(--ease) calc(var(--n) * 160ms) both; }
.motion .stack.on li .where::after { animation: blink .5s steps(1, end) calc(var(--n) * 160ms + 200ms) both; }
.motion .stack.on li.now .where::after { opacity: 1; animation: boot .5s steps(1, end) calc(var(--n) * 160ms + 200ms) both, led 2.6s ease-in-out calc(var(--n) * 160ms + 900ms) infinite; }
.motion .stack.on li:hover .where::after { opacity: 1; }
@keyframes scan { 0% { opacity: 1; transform: translateX(-100%); } 100% { opacity: 0; transform: translateX(100%); } }
@keyframes blink { 0% { opacity: 1; } 30% { opacity: 0; } 55% { opacity: .8; } 100% { opacity: 0; } }
@keyframes boot { 0% { opacity: 1; } 30% { opacity: 0; } 55% { opacity: 1; } 100% { opacity: 1; } }
@keyframes led { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.stack.paused li .where::after { animation-play-state: paused; }

/* ---------- Experience: a rail that draws as you scroll, roles slide in ---------- */
.timeline { --rail-pad: 1.25rem; padding-left: var(--rail-pad); }
@media (min-width: 720px) { .timeline { --rail-pad: 1.75rem; } }
.timeline::before, .timeline::after {
  content: ""; position: absolute; left: 3px; top: 0; bottom: 0; width: 1px; pointer-events: none;
}
.timeline::before { background: var(--line); }
.timeline::after {
  background: linear-gradient(180deg, var(--accent) 0%, rgba(124,196,184,.5) 85%, rgba(124,196,184,0) 100%);
  box-shadow: 0 0 8px rgba(124,196,184,.5);
  transform-origin: 50% 0; transform: scaleY(var(--p, 1));
}
.role::before, .role::after {
  content: ""; position: absolute; top: 2.2rem; left: calc(-1 * var(--rail-pad) - .5px); width: 8px; height: 8px; border-radius: 50%; pointer-events: none;
}
.role::before { background: var(--bg); border: 1px solid var(--line-strong); }
.role::after { background: var(--accent); box-shadow: 0 0 10px rgba(124,196,184,.8); transition: opacity .5s var(--ease) .15s; }
.io-reveal .role { opacity: 0; transform: translateX(-18px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.io-reveal .role.in { opacity: 1; transform: none; }
.io-reveal .role:not(.in)::after { opacity: 0; }

/* ---------- Skills: hover glow ---------- */
.skill-group { position: relative; }
.skill-group::before { /* accent glow behind the hovered group */
  content: ""; position: absolute; inset: 0 -1rem; z-index: -1; border-radius: var(--radius); pointer-events: none; opacity: 0;
  background: radial-gradient(60% 120% at 0% 50%, rgba(124,196,184,.07), transparent 70%);
  transition: opacity .4s var(--ease);
}
.skill-group:hover::before { opacity: 1; }
.skills { isolation: isolate; }

/* =========================================================
   Scroll-driven motion (Chrome/Edge 115+, Safari 26+)
   Every effect is tied to scroll position, so it never runs on its own,
   and the resting state at the top of the page is the unanimated state.
   Only transform-type properties (translate, scale), opacity and filter
   move. Browsers without support get a small rAF fallback from script.js;
   reduced motion gets none of it.
   ========================================================= */
@media (prefers-reduced-motion: no-preference) {
  @supports ((animation-timeline: scroll()) and (animation-range: 0% 100%)) {
    /* thin teal progress line */
    .progress { animation: progress-grow linear both; animation-timeline: scroll(root block); }
    /* the nav's glass firms up over the first part of the hero */
    .nav::before { transition: none; animation: nav-glass linear both; animation-timeline: scroll(root block); animation-range: 0 40vh; }
  }
  @supports ((animation-timeline: view()) and (animation-range: exit)) {
    /* phones and short screens (no pinned stage): the portrait settles in, then fades as the hero leaves */
    .hero:not(.pin) .hero-visual { view-timeline: --portrait block; }
    .hero:not(.pin) .hero-frame { animation: portrait-in linear both, portrait-out linear both; animation-timeline: --portrait, --portrait; animation-range: entry 10% cover 45%, exit 10% exit 100%; }

    /* sections and roles ease in as they enter, then sit still */
    .reveal > .section-grid, .role, .feature, .mosaic {
      animation: settle linear both; animation-timeline: view(); animation-range: entry 0% entry 55%;
    }
  }
}
@keyframes progress-grow { to { transform: scaleX(1); } }
@keyframes nav-glass { from { opacity: 0; } to { opacity: 1; } }
@keyframes portrait-in { from { scale: .86; opacity: .4; } }
@keyframes portrait-out { to { scale: 1.12; opacity: 0; } }
@keyframes settle { from { opacity: 0; translate: 0 2.25rem; } }

/* Cross-page transitions between the home page and project pages */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root) { animation: vt-out .2s cubic-bezier(.4, 0, 1, 1) both; }
  ::view-transition-new(root) { animation: vt-in .38s var(--ease) both; }
}
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; translate: 0 10px; } }

/* ---------- Reduced motion: everything in its final state ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .nav::before { opacity: 1; }
}
@media print {
  *, *::before, *::after { animation: none !important; }
  .progress, .nav::before { display: none; }
}

/* Impact pill holding a placeholder may wrap on small screens */
.impact:has(.todo) { white-space: normal; }

/* ---------- Projects: method first, tool slot, compact earlier work ---------- */
#projects .feature + .card, #projects .card + .feature, #projects .feature + .feature { margin-top: 1rem; }
.method-media {
  display: grid; place-items: center; padding: 1.75rem; min-height: 0;
  background:
    linear-gradient(rgba(236,235,230,.04) 1px, transparent 1px) 0 0 / 100% 22px,
    radial-gradient(120% 90% at 30% 20%, #142120 0%, #0f1114 70%);
}
.layers { width: 100%; max-width: 300px; display: grid; gap: 6px; }
.layers li {
  display: flex; align-items: center; gap: .8rem; padding: .7rem .9rem;
  border: 1px solid var(--accent-line); border-radius: 8px; background: rgba(12,13,16,.7);
  font-family: var(--mono); font-size: .8rem; color: var(--text); letter-spacing: .04em;
}
.layers li span { color: var(--accent); font-size: .7rem; }
.layers li::after { content: ""; margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px rgba(124,196,184,.8); }
.tool-card { border-style: dashed; }
.tool-card h3 { font-size: 1.05rem; }
.links-todo { margin: 0; }
.mini { display: grid; gap: 0; }
.mini li { border-top: 1px solid var(--line); }
.mini li:last-child { border-bottom: 1px solid var(--line); }
.mini a { display: grid; gap: .1rem .9rem; padding: .85rem .25rem; text-decoration: none; color: inherit; border-radius: 8px; transition: background .3s var(--ease); }
@media (min-width: 720px) { .mini a { grid-template-columns: 4rem 14rem minmax(0, 1fr); align-items: baseline; } }
.mini a:hover { background: var(--bg-elev); }
.mini-k { font-family: var(--mono); font-size: var(--fs-xs); color: var(--accent); letter-spacing: .06em; }
.mini-t { font-weight: 500; }
.mini-d { color: var(--muted); font-size: .9rem; }

/* ---------- Method page ---------- */
.share { display: grid; gap: 1rem; max-width: 46rem; }
@media (min-width: 720px) { .share { grid-template-columns: 1fr 1fr; } }
.share > div { padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: var(--radius); }
.share h3 { font-family: var(--mono); font-size: var(--fs-xs); font-weight: 500; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin-bottom: .6rem; }
.share ul.points { gap: .45rem; }

/* Below the two-column hero: name, role, hero line and the ways to reach him
   come first, then the portrait, then the pitch. */
@media (max-width: 959px) {
  .hero-grid { gap: 0; }
  .hero-text { display: contents; }
  .hero-text .cta { order: 3; margin: 0 0 1rem; }
  .teaser { order: 3; width: auto; margin: 0 0 2.25rem; }
  .hero-visual { order: 4; margin-bottom: 2.25rem; }
  .hero-text .pitch { order: 5; margin: 0; }
  .hero-scope { order: 6; margin-top: 2rem; }
}
@media (max-width: 479px) {
  .hero-scope { flex-direction: column; align-items: flex-start; } .scope { width: 100%; max-width: 320px; }
  .teaser { flex-direction: column; align-items: stretch; }
  .teaser-strip { width: auto; }
}
@media (max-width: 599px) {
  .hero-text .cta { gap: .5rem; }
  .hero-text .pitch { font-size: var(--fs-base); }
  .hero-line { margin: 1rem 0 1.25rem; }
  .btn { min-height: 44px; padding: 0 1.1rem; }
}

.also { margin: 1.25rem 0 0; font-size: .9rem; color: var(--muted); }
.also-k { font-family: var(--mono); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin-right: .6rem; }

.reading li.mine { border-top-color: var(--accent-line); }
.reading li.mine + li { border-top-color: var(--accent-line); }
.reading li.mine .src { color: var(--accent-strong); }
@media (max-width: 480px) {
  .nav-inner { gap: .6rem; }
  .nav ul { gap: .7rem; padding-right: 0; }
  .nav li a { font-size: .78rem; }
  .nav .nav-line { display: none; } /* no room at phone width; the hero teaser links there */
  .nav nav { -webkit-mask-image: none; mask-image: none; }
}
@media (max-width: 349px) {
  .nav nav { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
}

/* ---------- 404 ---------- */
.notfound { min-height: calc(100vh - var(--nav-h) - 8rem); display: grid; align-content: center; padding-top: 3rem; padding-bottom: 3rem; }
.notfound .code { font-family: var(--mono); font-size: var(--fs-xs); color: var(--accent); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 1rem; }
.notfound h1 { font-size: clamp(2.2rem, 1.4rem + 4vw, 3.6rem); letter-spacing: -0.035em; max-width: 16ch; }
.notfound p { color: var(--muted); max-width: 34rem; margin-top: 1rem; }
.notfound pre { font-family: var(--mono); font-size: .78rem; color: var(--muted); background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; overflow-x: auto; max-width: 34rem; margin: 1.5rem 0 0; }

/* ---------- Pinned hero stage (script.js adds .pin on wide, tall-enough screens) ----------
   The hero becomes a tall track with a sticky, one-screen stage inside it.
   Scrolling through the track glides the portrait to the centre and grows it
   to fill the screen (whole photo, never cropped), holds, then fades it out
   as the next section arrives. script.js writes only transform and opacity.
   Without JS, or with reduced motion, there is no .pin and no track. */
.hero.pin { height: 250vh; padding: 0; }
.hero.pin > .wrap {
  position: sticky; top: var(--nav-h);
  height: calc(100vh - var(--nav-h)); height: calc(100svh - var(--nav-h));
  align-content: center;
}
.hero.pin .hero-visual { position: relative; z-index: 3; }
.hero.pin .hero-frame { will-change: transform, opacity; transform-origin: 50% 50%; }
.hero.pin .hero-text { will-change: transform, opacity; }
.hero.pin::after { display: none; }
@media (min-width: 960px) and (max-height: 860px) {
  .hero .status { margin-bottom: .9rem; }
  .hero-line { margin: 1rem 0 1.1rem; }
  .cta { margin-top: 1.4rem; }
  .teaser { margin-top: 1.1rem; }
  .hero-scope { margin-top: 1.1rem; }
  .scope { width: 150px; }
  .scope-readout .scope-meas { display: none; }
}

/* ---------- Home page: the test line (line.js) ----------
   The centrepiece of the home page. Without JS every station reads as its own
   short section. With JS (.is-live) it becomes a piece of test equipment:
   a floor of seven bays with a rack that moves between them and a repair
   loop overhead, a status strip, a log, and one station's detail at a time.
   Only transform and opacity animate, and every part that changes has its
   space reserved, so nothing below moves while it runs. */
/* the hero teaser lands here with the section's top edge right under the nav */
#test-line { scroll-margin-top: -16px; position: relative; isolation: isolate; }
#test-line + .wrap .facts { margin-top: clamp(3.5rem, 9vh, 5.5rem); }
#test-line::before { /* a lit floor behind the section, full width, fading out at both ends */
  content: ""; position: absolute; z-index: -1; top: 0; bottom: -3rem; left: calc(50% - 50vw); right: calc(50% - 50vw); pointer-events: none;
  background:
    radial-gradient(60rem 30rem at 50% 26rem, rgba(124,196,184,.075), transparent 70%),
    radial-gradient(rgba(236,235,230,.06) 1px, transparent 1.2px) 0 0 / 28px 28px;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 9rem, #000 52rem, transparent 78rem);
          mask-image: linear-gradient(180deg, transparent 0, #000 9rem, #000 52rem, transparent 78rem);
}
#test-line .sec-line { font-size: clamp(1.75rem, 1.15rem + 2.7vw, 2.85rem); font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; max-width: 19ch; margin-bottom: 1.5rem; }
@media (min-width: 900px) {
  /* this section drops the label column so the equipment can use the full width */
  #test-line .section-grid { display: block; }
  #test-line .sec-head { position: static; margin-bottom: 1.25rem; }
  .line-intro { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 3.5rem; align-items: end; }
  .line-intro .sec-line { margin-bottom: 0; }
  .line-intro .prose p:last-child { margin-bottom: 0; }
}

.line { margin: 1.75rem 0 0; }
.line p, .line li { color: var(--muted); }
.line strong { color: var(--text); font-weight: 500; }
.stage { padding: 1.5rem 0 .5rem; border-top: 1px solid var(--line); }
.stage h3 { font-family: var(--display); font-size: 1.35rem; font-weight: 600; letter-spacing: -0.015em; color: var(--text); margin-bottom: .6rem; }
.stage h3 small { display: block; font-family: var(--font); font-size: .95rem; font-weight: 400; letter-spacing: 0; color: var(--accent); margin-top: .2rem; }
.stage > p { max-width: 44rem; }
.stage h4 { font-size: .8rem; font-weight: 600; color: var(--text); margin: 1.1rem 0 .45rem; }
.stage-cols { display: grid; gap: 0 2.5rem; }
@media (min-width: 720px) { .stage-cols { grid-template-columns: 1.1fr 1fr; } }
.stage-cols p { font-size: .95rem; }
.checks { display: grid; gap: .5rem; }
.checks li { position: relative; padding-left: 1.6rem; font-size: .95rem; border-radius: 6px; transition: color .3s, background-color .3s; }
.checks li::before {
  content: ""; position: absolute; left: 0; top: .32em; width: .95rem; height: .95rem; border-radius: 4px;
  border: 1px solid var(--line-strong); background: var(--bg-elev);
  transition: background-color .25s var(--ease), border-color .25s var(--ease);
}
.checks li::after { /* the tick */
  content: ""; position: absolute; left: .33rem; top: .48em; width: .28rem; height: .5rem;
  border: solid var(--bg); border-width: 0 2px 2px 0; transform: rotate(45deg) scale(0); transition: transform .3s var(--ease);
}
.checks li.ok::before { background: var(--accent); border-color: var(--accent); }
.checks li.ok::after { transform: rotate(45deg) scale(1); }
.checks li.bad { color: var(--text); }
.checks li.bad::before { background: var(--fail); border-color: var(--fail); }
.checks li.bad::after { /* a cross, so a failed check is not red alone */
  left: .08rem; top: .32em; width: .8rem; height: .95rem; border: 0; transform: none;
  background: linear-gradient(var(--bg), var(--bg)) 50% 50% / .62rem 2px no-repeat, linear-gradient(var(--bg), var(--bg)) 50% 50% / 2px .62rem no-repeat;
  rotate: 45deg;
}
.checks li.now { color: var(--text); background: var(--accent-soft); box-shadow: -.4rem 0 0 var(--accent-soft), .4rem 0 0 var(--accent-soft); }
.checks li.now::before { border-color: var(--accent); }
/* no JS: every check is shown as done */
.line:not(.is-live) .checks li::before { background: var(--accent-soft); border-color: var(--accent-line); }

/* the network-blade figure: compute blades wired to network blades through the cartridge */
.netfig { display: block; width: 100%; max-width: 30rem; height: auto; margin: 1.25rem 0 .25rem; overflow: visible; }
.netfig text { fill: var(--faint); font: 11px var(--font); text-anchor: middle; }
.netfig .blades rect { fill: var(--bg-elev-2); stroke: var(--line-strong); }
.netfig .blades.net rect { stroke: var(--accent-line); }
.netfig .cables path { fill: none; stroke: rgba(124,196,184,.28); stroke-width: 1; }
.line.is-live .stage:not([hidden]) .netfig .cables path { stroke-dasharray: 2 12; stroke: rgba(124,196,184,.7); stroke-linecap: round; }
.line.is-live.has-fault .stage:not([hidden]) .netfig .cables path.bad { stroke: var(--fail); stroke-width: 2; stroke-dasharray: 3 5; animation: none; }

/* ----- the equipment ----- */
.line.is-live {
  --rack-w: 46px; --rack-h: 66px; --bay-w: 66px; --bay-h: 88px;
  --lane: 76px;      /* headroom above the bays for the repair loop */
  --loop-y: 35px;    /* where the loop's top run sits inside that headroom */
  --halo: 239, 138, 125;
  position: relative; margin-top: 2.75rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  background:
    linear-gradient(rgba(236,235,230,.028) 1px, transparent 1px) 0 0 / 100% 22px,
    linear-gradient(180deg, #12161a 0%, var(--panel) 22rem);
  box-shadow: 0 0 0 1px rgba(0,0,0,.5), 0 1px 0 rgba(236,235,230,.06) inset, 0 60px 120px -70px rgba(124,196,184,.6), 0 40px 80px -40px rgba(0,0,0,.95);
}
@media (min-width: 1160px) { .line.is-live { margin-inline: calc(-1 * clamp(0rem, (100vw - var(--maxw)) / 2 - 1.5rem, 4rem)); } }
.line.is-live::after { /* halo: red on a failure, amber in repair, teal once shipped */
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  border: 1px solid rgb(var(--halo)); box-shadow: inset 0 0 90px rgba(var(--halo), .1), 0 0 70px -18px rgba(var(--halo), .55);
  opacity: 0; transition: opacity .45s var(--ease);
}
.line.has-fault::after { opacity: 1; }
.line.is-fixed { --halo: 226, 179, 107; }
.line.is-fixed::after { opacity: .7; }
.line[data-state="shipped"] { --halo: 124, 196, 184; }
.line[data-state="shipped"]::after { opacity: .8; }

/* the floor: bays on a rail */
.line-floor { padding: .6rem 1.5rem .25rem; }
.line-rail { position: relative; display: grid; grid-template-columns: repeat(var(--n, 7), minmax(0, 1fr)); padding-top: var(--lane); }
.line-track { position: absolute; left: calc(50% / var(--n, 7)); right: calc(50% / var(--n, 7)); top: calc(var(--lane) + var(--bay-h) + 21px); height: 2px; background: var(--line-strong); border-radius: 2px; }
.line-fill { position: absolute; inset: 0; background: var(--accent); box-shadow: 0 0 12px rgba(124,196,184,.7); transform-origin: 0 50%; transform: scaleX(0); transition: transform .9s var(--ease); }
.line-stop {
  position: relative; z-index: 1; display: grid; justify-items: center; align-content: start; min-width: 0; padding: 0 .15rem .7rem;
  background: none; border: 0; color: var(--muted); font: inherit; text-align: center; cursor: pointer; border-radius: 12px;
  transition: color .25s var(--ease);
}
.line-stop:hover { color: var(--text); }
.line-stop:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.line-bay {
  position: relative; overflow: hidden; width: var(--bay-w); height: var(--bay-h); border-radius: 11px;
  border: 1.5px dashed var(--line-strong); background: rgba(236,235,230,.02);
  transition: border-color .3s var(--ease), background-color .3s var(--ease), box-shadow .3s var(--ease);
}
.line-bay::after { /* the scan that runs while a station is testing */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 45%; opacity: 0;
  background: linear-gradient(180deg, transparent, rgba(124,196,184,.38)); border-bottom: 1px solid var(--accent-strong);
  transform: translateY(-100%);
}
.line-stop:hover .line-bay { border-color: var(--faint); }
.line-node { position: relative; width: 18px; height: 18px; margin: 12px 0 7px; border-radius: 50%; background: var(--panel); border: 2px solid var(--line-strong); transition: background-color .3s, border-color .3s, box-shadow .3s; }
.line-node::after { content: ""; position: absolute; inset: 0; opacity: 0; }
.line-n { font-family: var(--mono); font-size: .68rem; line-height: 1.4; color: var(--faint); }
.line-name { font-size: .88rem; font-weight: 500; line-height: 1.3; }
.line-tag { font-family: var(--mono); font-size: .7rem; line-height: 1.5; min-height: 1.5em; color: var(--faint); }

.line-stop.is-current { color: var(--text); }
.line-stop.is-current .line-bay { border-style: solid; border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 4px rgba(124,196,184,.07), 0 0 34px -4px rgba(124,196,184,.45); }
.line-stop.is-current .line-node { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.line-stop.is-run .line-tag { color: var(--text); }
.line-stop.is-pass .line-bay { border-style: solid; border-color: var(--accent-line); }
.line-stop.is-pass .line-node { background: var(--accent); border-color: var(--accent); }
.line-stop.is-pass .line-node::after { /* tick */
  opacity: 1; inset: 2px 4.5px 4px; border: solid var(--bg); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.line-stop.is-pass .line-tag { color: var(--accent); }
.line-stop.is-fail { color: var(--fail); }
.line-stop.is-fail .line-bay { border-style: solid; border-color: var(--fail); background: var(--fail-soft); box-shadow: 0 0 0 4px rgba(239,138,125,.1), 0 0 40px -2px rgba(239,138,125,.6); }
.line-stop.is-fail .line-node { background: var(--fail); border-color: var(--fail); box-shadow: 0 0 0 5px rgba(239,138,125,.2); }
.line-stop.is-fail .line-node::after { /* cross */
  opacity: 1; rotate: 45deg;
  background: linear-gradient(var(--bg), var(--bg)) 50% 50% / 10px 2px no-repeat, linear-gradient(var(--bg), var(--bg)) 50% 50% / 2px 10px no-repeat;
}
.line-stop.is-fail .line-tag { color: var(--fail); font-weight: 600; }
.line-stop.is-redo .line-bay { border-color: var(--warn); }
.line-stop.is-redo .line-node { border-color: var(--warn); border-style: dashed; }
.line-stop.is-redo .line-tag { color: var(--warn); }

/* the repair loop: leaves the line at the station that failed, re-enters earlier */
.line-loop {
  position: absolute; top: var(--loop-y); height: calc(var(--lane) - var(--loop-y) - 6px);
  border: 2px dashed currentColor; border-bottom: 0; border-radius: 16px 16px 0 0;
  color: var(--line-strong); opacity: 0; pointer-events: none; transition: opacity .4s var(--ease), color .4s var(--ease);
}
.line-loop::after { /* arrowhead: back down into the re-entry bay */
  content: ""; position: absolute; left: -7px; bottom: -3px; border: 6px solid transparent; border-top: 8px solid currentColor; border-bottom: 0;
}
.line-loop-label { position: absolute; left: calc(100% + 16px); top: -.8em; white-space: nowrap; font-family: var(--mono); font-size: .72rem; line-height: 1.6; color: var(--faint); transition: color .4s var(--ease); }
.line-loop-label b { font-weight: 500; }
.line.with-fault .line-loop { opacity: 1; }
.line.has-fault .line-loop, .line.is-lifted .line-loop { color: var(--fail); }
.line.has-fault .line-loop-label, .line.is-lifted .line-loop-label { color: var(--fail); }
.line.is-fixed .line-loop, .line.is-fixed .line-loop-label { color: var(--warn); }

/* the rack */
.line-rack {
  position: absolute; z-index: 2; left: 0; top: calc(var(--lane) + (var(--bay-h) - var(--rack-h)) / 2);
  width: var(--rack-w); height: var(--rack-h); margin-left: calc(var(--rack-w) / -2); pointer-events: none;
  transform: translate(var(--x, 0px), var(--y, 0px)); transition: transform .9s var(--ease);
}
.line.is-lifted .line-rack { --y: calc(var(--loop-y) - var(--lane) - var(--bay-h) / 2); }
.line-rack-body {
  display: grid; grid-template-rows: repeat(6, 1fr); gap: 3px; width: 100%; height: 100%; padding: 6px 5px; border-radius: 7px;
  background: linear-gradient(180deg, #20252c, #12151a); border: 1.5px solid var(--accent);
  box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 0 24px rgba(124,196,184,.45), 0 12px 18px -8px #000;
  transition: border-color .3s var(--ease), box-shadow .3s var(--ease);
}
.line-rack-body i { position: relative; display: block; border-radius: 2px; background: rgba(124,196,184,.3); transition: background-color .3s var(--ease); }
.line-rack-body i::after { content: ""; position: absolute; right: 3px; top: 50%; width: 3px; height: 3px; margin-top: -1.5px; border-radius: 50%; background: var(--accent-strong); }
.line.has-fault .line-rack-body { border-color: var(--fail); box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 0 30px rgba(239,138,125,.7), 0 12px 18px -8px #000; }
.line.has-fault .line-rack-body i { background: rgba(236,235,230,.14); }
.line.has-fault .line-rack-body i::after { background: var(--faint); }
.line.has-fault .line-rack-body i:nth-child(2) { background: var(--fail); }
.line.is-fixed .line-rack-body { border-color: var(--warn); box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 0 26px rgba(226,179,107,.5), 0 12px 18px -8px #000; }
.line[data-state="shipped"] .line-rack-body i { background: rgba(124,196,184,.75); }

/* the status strip: what state the rack is in, in words, and the controls */
.line-bar {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: .9rem 1.5rem; align-items: center;
  padding: 1rem 1.5rem; border-block: 1px solid var(--line); background: rgba(236,235,230,.022);
  transition: background-color .45s var(--ease), border-color .45s var(--ease);
}
.line.has-fault .line-bar { background: var(--fail-soft); border-color: var(--fail-line); }
.line-state { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 .8rem; align-items: center; }
.line-state-ico { position: relative; grid-row: span 2; width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--panel); transition: background-color .3s, border-color .3s, box-shadow .3s; }
.line-state-ico::after { content: ""; position: absolute; inset: 0; margin: auto; width: .6rem; height: .6rem; border-radius: 50%; background: var(--faint); }
.line-state-word { font-family: var(--display); font-size: 1.45rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; color: var(--text); }
.line-state-at { font-size: .85rem; line-height: 1.3; min-height: 1.3em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line[data-state="run"] .line-state-ico { border-color: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.line[data-state="run"] .line-state-ico::after { background: var(--accent); }
.line[data-state="pass"] .line-state-ico, .line[data-state="shipped"] .line-state-ico { background: var(--accent); border-color: var(--accent); }
.line[data-state="pass"] .line-state-ico::after, .line[data-state="shipped"] .line-state-ico::after { /* tick */
  width: .55rem; height: 1rem; border-radius: 0; background: none; border: solid var(--bg); border-width: 0 3px 3px 0; transform: translateY(-2px) rotate(45deg);
}
.line[data-state="pass"] .line-state-word, .line[data-state="shipped"] .line-state-word { color: var(--accent-strong); }
.line[data-state="fail"] .line-state-ico, .line[data-state="repair"] .line-state-ico { background: var(--fail); border-color: var(--fail); box-shadow: 0 0 0 5px rgba(239,138,125,.2), 0 0 26px rgba(239,138,125,.55); }
.line[data-state="fail"] .line-state-ico::after, .line[data-state="repair"] .line-state-ico::after { /* cross */
  width: 1.2rem; height: 1.2rem; border-radius: 0; rotate: 45deg;
  background: linear-gradient(var(--bg), var(--bg)) 50% 50% / 100% 3px no-repeat, linear-gradient(var(--bg), var(--bg)) 50% 50% / 3px 100% no-repeat;
}
.line[data-state="fail"] .line-state-word, .line[data-state="repair"] .line-state-word { color: var(--fail); }
.line[data-state="fixed"] .line-state-ico { border-color: var(--warn); box-shadow: 0 0 0 5px rgba(226,179,107,.14); }
.line[data-state="fixed"] .line-state-ico::after { /* a turn-back arrow would be noise at this size: a ring reads as "in work" */
  width: 1rem; height: 1rem; background: none; border: 3px solid var(--warn); border-left-color: transparent;
}
.line[data-state="fixed"] .line-state-word { color: var(--warn); }
.line-say { display: grid; align-content: center; min-height: 4.65em; font-size: .95rem; line-height: 1.55; }
.line-say p { margin: 0; color: var(--text); max-width: 62ch; }
.line-say p:empty { display: none; }
.line-say .line-note { color: var(--muted); }
.line-ctl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .6rem .75rem; align-items: center; }
.line-ctl .btn { min-height: 42px; white-space: nowrap; }
.line-run { min-width: 8.75rem; }
.line-pause { min-width: 6.25rem; }
.line-pause:disabled { opacity: .4; cursor: default; transform: none; border-color: var(--line-strong); }
.line-fault { grid-column: 1 / -1; display: inline-flex; align-items: center; gap: .55rem; width: fit-content; min-height: 42px; padding: 0 .1rem; font-size: .9rem; color: var(--muted); cursor: pointer; }
.line-fault:hover { color: var(--text); }
.line-fault input { width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--fail); }
@media (min-width: 560px) {
  .line-bar { grid-template-columns: 12rem minmax(0, 1fr); }
  .line-say { grid-column: 1 / -1; grid-row: 2; min-height: 3.1em; }
  .line-ctl { display: flex; justify-content: flex-end; flex-wrap: nowrap; gap: .75rem; }
  .line-fault { margin-left: .35rem; }
}
@media (min-width: 1100px) {
  .line-bar { grid-template-columns: 12rem minmax(0, 1fr) auto; padding: .75rem 1.75rem; }
  .line-say { grid-column: auto; grid-row: auto; }
}

/* log and station detail */
.line-body { display: grid; gap: 1.5rem; padding: 1.25rem 1.1rem 1.5rem; }
.line-console { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: #050607; overflow: hidden; transition: border-color .45s var(--ease); }
.line.has-fault .line-console { border-color: var(--fail-line); }
.line-console-head { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem .95rem; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: .7rem; color: var(--faint); }
.line-log {
  /* older lines fade out under the header once the log has scrolled */
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 1.1rem); mask-image: linear-gradient(180deg, transparent 0, #000 1.1rem);
  height: 15.5rem; overflow: hidden; font-family: var(--mono); font-size: .78rem; line-height: 1.75; color: var(--muted); }
.line-log-roll { padding: 1.1rem .95rem .8rem; transition: transform .3s var(--ease); }
.line-row { margin: 0 -.45rem; padding: 0 .45rem; border-radius: 4px; overflow-wrap: anywhere; }
.line-row.is-head { color: var(--faint); }
.line-row.is-head:not(:first-child) { margin-top: .45rem; }
.line-row.is-bad { color: var(--fail); }
.line-row.is-bad::before { content: "! "; }
.line-row.is-pass { color: var(--accent); background: var(--accent-soft); }
.line-row.is-fail { color: var(--fail); font-weight: 600; background: var(--fail-soft); box-shadow: inset 2px 0 0 var(--fail); }
.line.is-paused .line-log { opacity: .7; }
.line-stages { display: grid; min-width: 0; container-type: inline-size; }
.line.is-live .stage { grid-area: 1 / 1; border-top: 0; padding: 0; }
.line.is-live .stage:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; border-radius: 6px; }
.line.is-live .stage h3 { font-size: 1.5rem; }
.line.is-live .netfig { max-width: 21rem; margin: .5rem 0 0; }
@container (max-width: 33rem) { .line.is-live .stage-cols { grid-template-columns: minmax(0, 1fr); } }
@container (min-width: 33rem) {
  /* the cabling figure sits beside the station's description */
  .line.is-live .stage:has(> .netfig) { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: 0 1.5rem; align-content: start; }
  .line.is-live .stage:has(> .netfig) > * { grid-column: 1 / -1; }
  .line.is-live .stage:has(> .netfig) > p { grid-column: 1; }
  .line.is-live .stage:has(> .netfig) > .netfig { grid-column: 2; margin: 0; align-self: center; }
  .line.is-live .stage:has(> .netfig) .netfig text { font-size: 15px; }
}
@media (min-width: 900px) {
  .line-body { grid-template-columns: minmax(0, .82fr) minmax(0, 1fr); gap: 2.25rem; align-items: start; padding: 1.25rem 1.75rem 1.9rem; }
  /* every station occupies the same cell, so the panel keeps one height as stations change */
  .line.is-live .stage[hidden] { display: block; visibility: hidden; }
  .line-log { height: clamp(16.5rem, 100svh - 33rem, 24rem); }
}

/* phones: the whole line fits across the screen; station names move to the status strip */
@media (max-width: 639px) {
  .line.is-live { --rack-w: 28px; --rack-h: 42px; --bay-w: 36px; --bay-h: 54px; --lane: 56px; --loop-y: 26px; }
  .line-floor { padding: .75rem .5rem .1rem; }
  .line-bay { border-radius: 8px; }
  .line-rack-body { gap: 2px; padding: 4px 3px; border-radius: 5px; }
  .line-rack-body i::after { display: none; }
  .line-node { margin: 10px 0 5px; }
  .line-track { top: calc(var(--lane) + var(--bay-h) + 19px); }
  .line-name, .line-tag { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .line-stop { padding-bottom: .45rem; }
  .line-loop { border-radius: 12px 12px 0 0; }
  .line-loop-label { left: calc(100% + 10px); }
  .line-loop-label span { display: none; }
  .line-bar { padding: .9rem 1.1rem 1rem; }
}
@media (min-width: 640px) and (max-width: 999px) {
  .line.is-live { --bay-w: 56px; --bay-h: 80px; --rack-w: 40px; --rack-h: 58px; }
  .line-name { font-size: .78rem; min-height: 2.6em; }
}

/* ----- motion ----- */
@keyframes cable { to { stroke-dashoffset: -24; } }
@keyframes checking { 50% { box-shadow: 0 0 0 4px var(--accent-soft); } }
@keyframes stage-in { from { opacity: 0; translate: 0 10px; } }
@keyframes caret { 50% { opacity: 0; } }
@keyframes logline { from { opacity: 0; transform: translateY(4px); } }
@keyframes bay-scan { 0% { transform: translateY(-100%); opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { transform: translateY(225%); opacity: 0; } }
@keyframes rack-led { 0%, 100% { opacity: 1; } 50% { opacity: .15; } }
@keyframes rack-shake { 0%, 100% { transform: none; } 15% { transform: translateX(-5px) rotate(-3deg); } 30% { transform: translateX(5px) rotate(3deg); } 45% { transform: translateX(-4px) rotate(-2deg); } 60% { transform: translateX(3px) rotate(1deg); } 80% { transform: translateX(-1px); } }
@keyframes lamp { 50% { opacity: .35; } }
@keyframes fail-ring { from { opacity: .9; transform: scale(.6); } to { opacity: 0; transform: scale(2.2); } }
@keyframes line-in { from { opacity: 0; transform: translateY(26px) scale(.985); } }
@keyframes rail-draw { from { transform: scaleX(0); } }
@keyframes bay-in { from { opacity: 0; transform: translateY(18px) scale(.9); } }
@keyframes rack-drop { 0% { opacity: 0; transform: translateY(-46px); } 60% { opacity: 1; transform: translateY(3px); } 100% { opacity: 1; transform: none; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: no-preference) {
  .line.is-live .stage:not([hidden]) .netfig .cables path { animation: cable 1.2s linear infinite; }
  .line.is-live.has-fault .stage:not([hidden]) .netfig .cables path.bad { animation: none; }
  .checks li.now::before { animation: checking 1s ease-in-out infinite; }
  .stage.enter { animation: stage-in .6s var(--ease) both; }
  .line-row { animation: logline .25s var(--ease) both; }
  .line-row.is-typing > span::after { content: ""; display: inline-block; width: .5em; height: 1em; margin-left: 2px; vertical-align: -.15em; background: currentColor; animation: caret .8s steps(1) infinite; }
  .line-stop.is-run .line-bay::after { animation: bay-scan 1.5s ease-in-out infinite; }
  .line[data-state="run"] .line-rack-body i::after { animation: rack-led 1s ease-in-out infinite; }
  .line[data-state="run"] .line-rack-body i:nth-child(2n)::after { animation-delay: -.35s; }
  .line[data-state="run"] .line-rack-body i:nth-child(3n)::after { animation-delay: -.7s; }
  .line[data-state="run"] .line-state-ico::after { animation: lamp 1.1s ease-in-out infinite; }
  .line.has-fault .line-rack-body { animation: rack-shake .6s var(--ease) 1; }
  .line-stop.is-fail .line-node::before { content: ""; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--fail); animation: fail-ring 1.6s var(--ease) infinite; }
  /* stopped while the visitor has paused it, or it is off screen, or the tab is hidden */
  .line.is-paused *, .line.is-paused *::before, .line.is-paused *::after,
  .line.is-off *, .line.is-off *::before, .line.is-off *::after,
  .tab-hidden .line *, .tab-hidden .line *::before, .tab-hidden .line *::after { animation-play-state: paused; }

  /* entrance: line.js adds .pre until the floor scrolls into view, then .is-on for the power-on */
  .line.pre { opacity: 0; }
  .line.is-on { animation: line-in .8s var(--ease) both; }
  .line.is-on .line-track { animation: rail-draw .9s var(--ease) .25s both; transform-origin: 0 50%; }
  .line.is-on .line-stop { animation: bay-in .6s var(--ease) calc(.3s + var(--i) * 70ms) both; }
  .line.is-on .line-rack-body { animation: rack-drop .7s var(--ease) .95s both; }
  .line.is-on .line-loop-label, .line.is-on .line-bar > *, .line.is-on .line-body > * { animation: fade-up .7s var(--ease) .75s both; }
}
@media print { .line.pre { opacity: 1; } }

/* ---------- The failure, walked through: six steps on a rail ---------- */
.draft-note { margin: 0 0 1rem; }
.flow-5 li { font-size: .86rem; }
.story-wrap { display: grid; gap: 1.5rem; margin-top: clamp(3.5rem, 9vh, 5.5rem); }
.story-head .sub { margin: 0 0 .75rem; font-family: var(--display); font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; text-transform: none; color: var(--text); }
.story-intro { margin: 0; max-width: 44rem; color: var(--muted); }
@media (min-width: 900px) {
  .story-wrap { grid-template-columns: minmax(0, 19rem) minmax(0, 1fr); gap: 4rem; }
  .story-head { position: sticky; top: calc(var(--nav-h) + 2rem); align-self: start; }
}
.story { display: grid; max-width: 46rem; counter-reset: s; }
.story li { counter-increment: s; position: relative; display: grid; gap: .3rem; padding: 0 0 1.75rem 3.25rem; color: var(--muted); }
.story li:last-child { padding-bottom: 0; }
.story li::before { /* the step number */
  content: counter(s); position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%;
  font-family: var(--mono); font-size: .8rem; font-weight: 500; color: var(--muted); background: var(--bg); border: 1.5px solid var(--line-strong);
}
.story li::after { content: ""; position: absolute; left: calc(1rem - 1px); top: 2.4rem; bottom: .4rem; width: 2px; border-radius: 2px; background: var(--line); }
.story li:last-child::after { display: none; }
.story li:first-child::before { color: var(--fail); border-color: var(--fail); background: var(--fail-soft); } /* where it failed */
.story li:first-child::after { background: linear-gradient(180deg, var(--fail-line), var(--line)); }
.story li:last-child::before { color: var(--bg); border-color: var(--accent); background: var(--accent); } /* where it stays fixed */
.story li > strong { padding-top: .2rem; font-family: var(--display); font-size: 1.15rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; color: var(--text); }
.story li:first-child > strong { color: var(--fail); }
.story-wrap + .links { margin-top: 2.25rem; }

/* very narrow phones (360px Androids, iPhone SE): keep all five nav links on screen */
@media (max-width: 380px) {
  .nav-inner { gap: .5rem; }
  .nav ul { gap: .5rem; }
  .nav li a { font-size: .72rem; }
}
