/* ============================================
   Shreyo Debnath — Portfolio Design System
   ============================================ */

/* HK Grotesk is declared in assets/fonts/hkgrotesk.css, loaded before this
   file. Display tier only — see the .intro-h1 group below. */

:root {
  --bg: #080810;
  --surface: #0F0F1E;
  --surface-2: #14142A;
  --border: #1A1A2E;
  --text: #E6E6F2;
  --muted: #7878A2;
  --dim: #4A4A70;
  --accent: #F53640;
  --accent-dim: rgba(240, 32, 42, 0.10);
  --accent-glow: rgba(240, 32, 42, 0.20);
  --nav-bg: rgba(8, 8, 16, 0.72);

  --ff: system-ui, -apple-system, 'Helvetica Neue', 'Segoe UI', Arial, sans-serif;
  --ff-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  /* Display tier. Falls back to the system stack if the woff2 never arrives. */
  --ff-display: 'HK Grotesk', system-ui, -apple-system, 'Helvetica Neue', 'Segoe UI', Arial, sans-serif;

  --gutter: clamp(20px, 5vw, 64px);
  --max: 1080px;
  --max-read: 680px;
  --r: 6px;
}

/* Light palette, applied by OS preference only when no explicit choice is stored */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #F5F5FA;
    --surface: #FFFFFF;
    --surface-2: #EDEDF6;
    --border: #DCDCEE;
    --text: #080810;
    --muted: #66668E;
    --dim: #9898B8;
    --accent: #C81019;
    --accent-dim: rgba(200, 16, 25, 0.07);
    --accent-glow: rgba(200, 16, 25, 0.16);
    --nav-bg: rgba(245, 245, 250, 0.72);
  }
}

:root[data-theme="dark"] {
  --bg: #080810;
  --surface: #0F0F1E;
  --surface-2: #14142A;
  --border: #1A1A2E;
  --text: #E6E6F2;
  --muted: #7878A2;
  --dim: #4A4A70;
  --accent: #F53640;
  --accent-dim: rgba(240, 32, 42, 0.10);
  --accent-glow: rgba(240, 32, 42, 0.20);
  --nav-bg: rgba(8, 8, 16, 0.72);
}

:root[data-theme="light"] {
  --bg: #F5F5FA;
  --surface: #FFFFFF;
  --surface-2: #EDEDF6;
  --border: #DCDCEE;
  --text: #080810;
  --muted: #66668E;
  --dim: #9898B8;
  --accent: #C81019;
  --accent-dim: rgba(200, 16, 25, 0.07);
  --accent-glow: rgba(200, 16, 25, 0.16);
  --nav-bg: rgba(245, 245, 250, 0.72);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* The display tier, and only the display tier. Body copy, meta cells and the
   mono label tier are deliberately excluded, as is .f-sig — the Bengali
   signature has no glyphs in a Latin subset and must stay on the system stack.
   Family only — each element keeps the tracking already tuned for it below. */
.intro-h1,
.h-title,
.s-h,
.b-h2,
.pname,
.nextup-title,
.pull,
.stat-n,
.f-mark {
  font-family: var(--ff-display);
}

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

::selection { background: var(--accent); color: #fff; }

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

/* Thin themed scrollbar. Firefox first, then WebKit. */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--dim) transparent;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border: 3px solid var(--bg);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: var(--dim); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  font-size: 13px;
  z-index: 100;
  border-radius: 0 0 var(--r) 0;
}
.skip-link:focus { left: 0; }

/* ============================================
   NAV
   ============================================ */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gutter);
  z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.35s;
}

.nav.scrolled { border-bottom-color: var(--border); }

.nav-name {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--text);
  transition: color 0.2s;
}
a.nav-name:hover { color: var(--accent); }

.nav-back {
  font-size: 13px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.005em;
  transition: color 0.2s, transform 0.2s;
}
.nav-back:hover { color: var(--text); transform: translateX(-2px); }
.nav-back::before { content: "\2190"; font-size: 15px; }

.nav-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-links {
  display: flex;
  gap: 24px;
  list-style: none;
}

.nav-links a {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.01em;
  transition: color 0.2s;
}
.nav-links a:hover,
.nav-links a[aria-current="page"] { color: var(--text); }

/* THEME TOGGLE */
.theme-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.2s, color 0.2s, transform 0.2s;
  flex-shrink: 0;
}
.theme-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: rotate(18deg);
}
.theme-btn svg { width: 14px; height: 14px; display: block; }
.theme-btn .i-moon { display: none; }
.theme-btn .i-sun  { display: block; }
:root[data-theme="light"] .theme-btn .i-moon { display: block; }
:root[data-theme="light"] .theme-btn .i-sun  { display: none; }

/* ============================================
   LAYOUT
   ============================================ */
.wrap {
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--gutter);
  flex: 1;
}
.read { max-width: var(--max-read); }

/* ============================================
   SHARED TYPE
   ============================================ */
.s-label,
.s-eyebrow {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
}
.s-eyebrow { display: block; margin-bottom: 20px; }

.s-head {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.s-h {
  font-size: clamp(26px, 3.4vw, 40px);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.08;
  margin-bottom: 28px;
  max-width: 620px;
  text-wrap: balance;
}

.body-p {
  font-size: 16.5px;
  color: var(--text);
  line-height: 1.72;
  letter-spacing: -0.005em;
  margin-bottom: 22px;
  max-width: var(--max-read);
  text-wrap: pretty;
}
.body-p.muted { color: var(--muted); }
.body-p em { font-style: normal; color: var(--accent); }
.body-p code,
.inline-code {
  font-family: var(--ff-mono);
  font-size: 0.88em;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 2px 6px;
  border-radius: 4px;
}

.pull {
  font-size: clamp(20px, 2.4vw, 26px);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.32;
  color: var(--text);
  padding: 28px 0 28px 24px;
  border-left: 2px solid var(--accent);
  margin: 36px 0 44px;
  max-width: var(--max-read);
  text-wrap: balance;
}

/* ============================================
   HOMEPAGE: INTRO
   ============================================ */
.intro {
  padding-top: 148px;
  padding-bottom: 88px;
}
.intro-tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: 20px;
  opacity: 0;
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.06s both;
}
.intro-h1 {
  font-size: clamp(36px, 5.4vw, 66px);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.05;
  max-width: 620px;
  margin-bottom: 22px;
  text-wrap: balance;
  opacity: 0;
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.16s both;
}
.intro-sub {
  font-size: 15px;
  color: var(--muted);
  letter-spacing: -0.01em;
  max-width: 480px;
  opacity: 0;
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.28s both;
}

/* ============================================
   HOMEPAGE: PROJECT ROWS
   ============================================ */
.work { margin-bottom: 96px; }

.project-row {
  position: relative;
  display: grid;
  grid-template-columns: 92px 1fr 28px;
  gap: 0 20px;
  align-items: start;
  padding: 26px 14px;
  margin: 0 -14px;
  border-bottom: 1px solid var(--border);
  border-radius: var(--r);
  color: inherit;
  cursor: pointer;
  transition: opacity 0.4s ease, transform 0.4s ease, background 0.18s, border-color 0.18s;
}
/* Entrance is JS-gated, so the index still lists every project without it. */
.js .project-row { opacity: 0; transform: translateY(12px); }
.js .project-row.in { opacity: 1; transform: none; }
.project-row::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
  transform: scaleY(0);
  transform-origin: 50% 0;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.project-row:hover::before,
.project-row:focus-visible::before { transform: scaleY(1); }
.project-row:hover { background: var(--accent-dim); border-bottom-color: transparent; }
.project-row:hover .pname { color: var(--accent); }
.project-row:hover .arrow { transform: translate(3px, -3px); opacity: 0.7; }

.pmeta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 5px;
}
.pyear {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}
.ptag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 3px;
  width: fit-content;
}
.project-row:hover .ptag { border-color: var(--accent); color: var(--accent); }

.pname {
  font-size: clamp(19px, 2.6vw, 29px);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.08;
  margin-bottom: 7px;
  transition: color 0.18s;
}
.pdesc {
  font-size: 13.5px;
  color: var(--muted);
  letter-spacing: -0.01em;
  line-height: 1.55;
  max-width: 450px;
}
.arrow {
  font-size: 16px;
  color: var(--muted);
  opacity: 0.3;
  padding-top: 7px;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.18s;
  user-select: none;
}

/* ============================================
   HOMEPAGE: BUILDER
   ============================================ */
.builder {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  padding: 52px 0;
  margin-bottom: 80px;
  border-top: 1px solid var(--border);
}
.b-h2 {
  font-size: clamp(22px, 2.8vw, 32px);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 18px;
  text-wrap: balance;
}
.b-copy {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
  letter-spacing: -0.01em;
}
.b-right {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 20px;
}
.tool-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ============================================
   CHIPS
   ============================================ */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 100px;
  letter-spacing: -0.01em;
  transition: border-color 0.18s, background 0.18s, color 0.18s;
  cursor: default;
}
.chip:hover { border-color: var(--accent); background: var(--accent-dim); }
.chip.mono { font-family: var(--ff-mono); font-size: 12.5px; padding: 5px 12px; }
.chip.on { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ============================================
   BIO STRIP
   ============================================ */
.bio {
  display: flex;
  border-top: 1px solid var(--border);
  margin-bottom: 88px;
  flex-wrap: wrap;
}
.bio-cell {
  flex: 1;
  min-width: 160px;
  padding: 28px 32px 28px 0;
  border-right: 1px solid var(--border);
  margin-right: 32px;
}
.bio-cell:last-child { border-right: none; margin-right: 0; padding-right: 0; }
.bio-k {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
}
.bio-v {
  font-size: 14px;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.45;
}
.bio-v a { color: var(--accent); }
.bio-v a:hover { text-decoration: underline; }

/* ============================================
   CASE STUDY: HEADER
   ============================================ */
.header {
  padding-top: 132px;
  padding-bottom: 56px;
}
.h-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 22px;
  display: block;
  opacity: 0;
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.06s both;
}
.h-title {
  font-size: clamp(38px, 6vw, 74px);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 1.02;
  max-width: 780px;
  margin-bottom: 26px;
  text-wrap: balance;
  opacity: 0;
  animation: slideUp 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.14s both;
}
.h-lede {
  font-size: 18px;
  color: var(--muted);
  letter-spacing: -0.012em;
  max-width: 560px;
  line-height: 1.55;
  opacity: 0;
  animation: slideUp 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.24s both;
}

/* META STRIP */
.meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 40px 0 72px;
  opacity: 0;
  animation: slideUp 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.36s both;
}
.meta-cell {
  padding: 22px 24px 22px 0;
  border-right: 1px solid var(--border);
}
.meta-cell:last-child { border-right: none; }
.meta-cell:not(:first-child) { padding-left: 24px; }
.meta-k {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.meta-v {
  font-size: 13.5px;
  color: var(--text);
  letter-spacing: -0.005em;
  line-height: 1.4;
}
.meta-note {
  display: inline-block;
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0;
}

/* ============================================
   CASE STUDY: HERO VISUAL
   ============================================ */
.hero {
  position: relative;
  height: clamp(320px, 46vw, 520px);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background:
    radial-gradient(120% 80% at 82% -10%, var(--accent-glow), transparent 60%),
    radial-gradient(80% 60% at 12% 110%, var(--accent-dim), transparent 60%),
    linear-gradient(180deg, var(--surface), var(--surface-2));
  margin-bottom: 96px;
  opacity: 0;
  animation: slideUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.48s both;
}
.hero-grid {
  position: absolute;
  inset: 40px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 14px;
}
.hero-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}
.hero-card::before {
  content: "";
  position: absolute; top: 10px; left: 10px; right: 10px;
  height: 4px;
  background: var(--dim);
  border-radius: 2px;
  opacity: 0.4;
}
.hero-card::after {
  content: "";
  position: absolute; top: 22px; left: 10px;
  width: 40%; height: 3px;
  background: var(--dim);
  border-radius: 2px;
  opacity: 0.25;
}
.hero-card.accent {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 32px -8px var(--accent-glow);
}
.hero-card.accent::before { background: var(--accent); opacity: 0.9; }
.hero-card.tall { grid-row: span 2; }
.hero-card.wide { grid-column: span 2; }

/* Hero carrying a real screenshot instead of the placeholder grid */
.hero.shot {
  height: auto;
  background: var(--surface);
  line-height: 0;
}
.hero.shot img {
  display: block;
  width: 100%;
  height: auto;
}

/* ============================================
   CASE STUDY: FIGURES
   ============================================ */
.figure {
  margin: 64px 0 0;
}
.figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.figure-cap {
  margin: 16px 0 0;
  max-width: var(--max-read);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--muted);
}
.figure-cap strong {
  color: var(--text);
  font-weight: 500;
}
/* A caption belongs to the figure above it. When prose follows it needs a gap
   wider than the 22px between paragraphs, or the two tiers read as one block. */
.figure-cap + .read,
.figure-cap + .body-p { margin-top: 34px; }
.figures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin-top: 64px;
}
.figures .figure { margin: 0; }

/* Row of app screens. Phone shots are 375px wide, so they sit on a
   tinted bed rather than stretching to the column width. */
.screens {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 20px;
  margin: 64px 0 0;
  padding: 32px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.screens img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}
/* One shot on its own: cap at native width so it never upscales. */
.screens.solo {
  grid-template-columns: minmax(0, var(--shot-w, 375px));
  justify-content: center;
  padding: 40px 28px;
}
.screens + .figure-cap { margin-top: 16px; }
.screen-cap {
  margin: 10px 0 0;
  font-family: var(--ff-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  line-height: 1.5;
  color: var(--muted);
}

/* ============================================
   CASE STUDY: VIDEO
   Same tinted bed as .screens, because a clip of a
   tool being used is the same tier of evidence as a
   screenshot of it sitting still.

   Every clip ships two encodes. VP9/WebM is the small
   one and covers Chrome, Firefox, Edge and Safari 14.1+.
   The H.264 .mp4 is the floor for older iOS. Both are
   local files: the whole site has to survive being
   unzipped and opened over file://, so nothing streams.
   ============================================ */
.vidfig {
  margin: 64px 0 0;
  padding: 32px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.vidfig video {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
/* A clip narrower than the column sits centred rather than upscaled —
   the Sauron capture is 1280px and blurs if it is stretched past that. */
.vidfig.solo video {
  max-width: var(--vid-w, 100%);
  margin: 0 auto;
}
.vidfig + .figure-cap { margin-top: 16px; }

/* Mono note under a clip that is doing the work of a caption plus a
   playback instruction. Matches .screen-cap so the tier reads as furniture. */
.vid-note {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 14px 0 0;
  font-family: var(--ff-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  line-height: 1.5;
  color: var(--muted);
}
.vid-note span::before {
  content: "/ ";
  color: var(--dim);
}

/* Slot for artwork not yet supplied. Renders as a labelled dashed bed. */
.slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  aspect-ratio: var(--ar, 16 / 10);
  padding: 24px;
  text-align: center;
  border: 1px dashed var(--dim);
  border-radius: 10px;
  background: var(--accent-dim);
}
.slot-k {
  font-family: var(--ff-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.slot-t {
  max-width: 42ch;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.slot-d {
  font-family: var(--ff-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

@media (max-width: 720px) {
  .figures { grid-template-columns: 1fr; gap: 40px; }
  .screens { grid-template-columns: 1fr 1fr; padding: 20px 16px; gap: 14px; }
  .screens.solo { grid-template-columns: 1fr; padding: 20px 16px; }
}

/* ============================================
   CASE STUDY: SECTIONS
   ============================================ */
section.chunk { padding: 40px 0 88px; }
section.chunk + section.chunk {
  border-top: 1px solid var(--border);
  padding-top: 88px;
}

/* STATS */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin: 8px 0 40px;
}
.stat {
  padding: 24px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  transition: border-color 0.2s, transform 0.2s;
}
.stat:hover { border-color: var(--accent); transform: translateY(-2px); }
.stat-n {
  font-size: clamp(28px, 3.6vw, 40px);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  margin-bottom: 10px;
}
.stat-k {
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: -0.005em;
  line-height: 1.45;
}

/* STACK */
.stack { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 28px; }

/* STEPS */
.steps {
  counter-reset: step;
  display: flex;
  flex-direction: column;
  margin: 12px 0 32px;
  max-width: var(--max-read);
}
.step {
  counter-increment: step;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 18px;
  padding: 22px 0;
  border-top: 1px solid var(--border);
}
.step:last-child { border-bottom: 1px solid var(--border); }
.step::before {
  content: "0" counter(step);
  font-family: var(--ff-mono);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.04em;
  padding-top: 3px;
}
.step-h {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.015em;
  margin-bottom: 8px;
  color: var(--text);
}
.step-p {
  font-size: 14.5px;
  color: var(--muted);
  line-height: 1.62;
  letter-spacing: -0.005em;
}

/* SPLIT CARDS */
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 20px 0 40px;
}
.split-card {
  padding: 26px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  min-height: 160px;
}
.split-card.after { background: var(--accent-dim); border-color: var(--accent); }
.split-tag {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
  display: block;
}
.split-card.after .split-tag { color: var(--accent); }
.split-t {
  font-size: 15.5px;
  color: var(--text);
  line-height: 1.55;
  letter-spacing: -0.005em;
}

/* DIAGRAM */
.diagram {
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 24px 0 44px;
}
.diagram-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  align-items: center;
}
.diagram-row.five { grid-template-columns: repeat(5, 1fr); }
.diagram-row.three { grid-template-columns: repeat(3, 1fr); align-items: stretch; }
.node {
  padding: 18px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
}
.node.accent { border-color: var(--accent); background: var(--accent-dim); }
.node-k {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.node.accent .node-k { color: var(--accent); }
.node-v {
  font-family: var(--ff-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  letter-spacing: -0.01em;
}
.diagram-caption {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-align: center;
  margin-top: 20px;
  font-family: var(--ff-mono);
}

/* SNIPPET */
.snippet {
  padding: 22px 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: var(--r);
  margin: 22px 0 40px;
  font-family: var(--ff-mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
  overflow-x: auto;
  max-width: var(--max-read);
  white-space: pre;
}
.snippet .k { color: var(--accent); }
.snippet .t { color: var(--text); }

/* NEXT UP */
.nextup {
  padding: 48px 0 24px;
  border-top: 1px solid var(--border);
  margin-top: 48px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
}
.nextup-l .s-eyebrow { margin-bottom: 14px; }
.nextup-title {
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
  transition: color 0.2s;
}
.nextup:hover .nextup-title { color: var(--accent); }
.nextup-arrow {
  font-size: 22px;
  color: var(--muted);
  transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s;
}
.nextup:hover .nextup-arrow { transform: translate(4px, -4px); color: var(--accent); }

/* WIP NOTICE */
.wip {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 18px 22px;
  border: 1px dashed var(--accent);
  background: var(--accent-dim);
  border-radius: var(--r);
  margin: 0 0 56px;
  max-width: var(--max-read);
}
.wip-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 8px;
  flex-shrink: 0;
  animation: pulse 2.2s ease-in-out infinite;
}
.wip-t {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  letter-spacing: -0.005em;
}
.wip-t strong { font-weight: 600; }

/* ============================================
   ABOUT PAGE
   ============================================ */
.timeline { margin: 12px 0 24px; max-width: var(--max-read); }
.tl-item {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 24px;
  padding: 26px 0;
  border-top: 1px solid var(--border);
  position: relative;
}
.tl-item:last-child { border-bottom: 1px solid var(--border); }
.tl-when {
  font-family: var(--ff-mono);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.02em;
  padding-top: 3px;
}
.tl-what {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.tl-where {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
  letter-spacing: -0.005em;
}
.tl-desc {
  font-size: 14.5px;
  color: var(--muted);
  line-height: 1.62;
  letter-spacing: -0.005em;
}

.skill-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin: 12px 0 32px;
}
.skill-col-h {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.skill-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.skill-list li {
  font-size: 14.5px;
  color: var(--muted);
  letter-spacing: -0.005em;
  line-height: 1.5;
}

/* ============================================
   NOTATION
   Anything that names, numbers, or tags a thing is
   monospace. Prose never is.
   ============================================ */
.s-label,
.s-eyebrow,
.h-eyebrow,
.meta-k,
.bio-k,
.node-k,
.split-tag,
.tool-label,
.skill-col-h,
.pyear,
.ptag {
  font-family: var(--ff-mono);
  font-weight: 500;
  letter-spacing: 0.06em;
}

/* Section ordinal inside an eyebrow: 01 / The problem */
.s-n { color: var(--accent); }

/* [ bracketed label ] */
.bracket::before { content: "[\00a0"; }
.bracket::after { content: "\00a0]"; }

/* Underline for emphasis inside prose */
.body-p u,
.step-p u,
.split-t u,
.wip-t u {
  text-decoration: none;
  border-bottom: 1px solid var(--muted);
}

/* Attribution beneath a quote */
.attrib {
  display: block;
  margin-top: 20px;
  font-family: var(--ff-mono);
  font-style: italic;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

/* ============================================
   FOOTER
   ============================================ */
footer {
  max-width: var(--max);
  width: 100%;
  margin: 40px auto 0;
  padding: 40px var(--gutter) 44px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  gap: 16px;
}
.f-mark {
  font-size: clamp(48px, 9vw, 110px);
  font-weight: 600;
  letter-spacing: -0.058em;
  line-height: 0.86;
  color: var(--text);
  opacity: 0.055;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  max-width: 68%;
}
.f-links {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.f-links a {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.01em;
  transition: color 0.2s;
}
.f-links a:hover { color: var(--text); }
.f-sig {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin-top: 12px;
}
.f-copy {
  font-size: 11px;
  color: var(--muted);
  opacity: 0.55;
  letter-spacing: 0.03em;
  margin-top: 4px;
}

/* ============================================
   READ PROGRESS
   Hairline at the very top of long pages.
   ============================================ */
.progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 100%;
  z-index: 60;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: var(--accent);
  pointer-events: none;
}

/* ============================================
   MOTION
   ============================================ */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Hidden only when JS is present to reveal them again. Without JS the
   page is static but fully readable, rather than blank. */
.js .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.js .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .js .reveal, .js .project-row { opacity: 1; transform: none; }
  .lightbox { transition: none; }
}

/* ============================================
   SECTION ANCHORS
   Every numbered section is directly linkable, so
   a specific argument can be sent on its own.
   ============================================ */
section.chunk { scroll-margin-top: 96px; }

.s-anchor {
  margin-left: 10px;
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.25s ease, color 0.25s ease;
}
.s-eyebrow:hover .s-anchor,
.s-anchor:focus-visible { opacity: 1; }
.s-anchor:hover { color: var(--accent); }

/* A linked-to section keeps its anchor showing, so the target is obvious. */
section.chunk:target .s-anchor { opacity: 1; color: var(--accent); }

/* ============================================
   LIGHTBOX
   The Figma boards are 1600px wide. Inline they
   are a thumbnail; this makes them readable.
   ============================================ */
.zoomable { cursor: zoom-in; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: color-mix(in srgb, var(--bg) 88%, #000);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s;
}
.lightbox.open { opacity: 1; visibility: visible; }

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  transform: scale(0.97);
  transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.lightbox.open img { transform: scale(1); }

.lightbox-close {
  position: absolute;
  top: 22px;
  right: 26px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.lightbox-close:hover { color: var(--accent); border-color: var(--accent); }

.lightbox-hint {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--ff-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

@media (max-width: 700px) {
  .lightbox { padding: 16px; }
  .lightbox-close { top: 12px; right: 14px; }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 820px) {
  .meta { grid-template-columns: repeat(2, 1fr); }
  .meta-cell:nth-child(2) { border-right: none; }
  .meta-cell:nth-child(3), .meta-cell:nth-child(4) { border-top: 1px solid var(--border); }
  .stats { grid-template-columns: 1fr; gap: 12px; }
  .split { grid-template-columns: 1fr; }
  .diagram-row, .diagram-row.five { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .diagram-row.three { grid-template-columns: 1fr; gap: 12px; }
  .diagram { padding: 22px; }
  .hero-grid { inset: 20px; gap: 8px; }
  .skill-grid { grid-template-columns: 1fr; gap: 28px; }
}

@media (max-width: 680px) {
  .project-row { grid-template-columns: 1fr auto; }
  .pmeta { flex-direction: row; align-items: center; gap: 10px; grid-column: 1; order: -1; }
  .pcontent { grid-column: 1; }
  /* Sits level with the year and title rather than floating mid-paragraph */
  .arrow { grid-column: 2; grid-row: 1 / 3; align-self: start; }
  .builder { grid-template-columns: 1fr; gap: 40px; }
  .f-mark { font-size: 40px; }
  .tl-item { grid-template-columns: 1fr; gap: 8px; }
}

/* Images fade in once decoded. .loaded is set by app.js; without JS the
   :not() fallback below keeps everything visible. */
.js .figure img,
.js .screens img,
.js .hero.shot img { opacity: 0; transition: opacity 0.45s ease; }
.js .figure img.loaded,
.js .screens img.loaded,
.js .hero.shot img.loaded { opacity: 1; }

@media (max-width: 520px) {
  .nav-right { gap: 14px; }
  .nav-links { gap: 14px; }
  .meta { grid-template-columns: 1fr; }
  .meta-cell { border-right: none; padding: 18px 0; }
  .meta-cell:not(:first-child) { padding-left: 0; border-top: 1px solid var(--border); }
  .bio { flex-direction: column; }
  .bio-cell { border-right: none; border-bottom: 1px solid var(--border); padding: 20px 0; margin: 0; }
  .bio-cell:last-child { border-bottom: none; }
  .nextup { grid-template-columns: 1fr; }
  .hero-grid { grid-template-columns: repeat(4, 1fr); }
  .step { grid-template-columns: 32px 1fr; gap: 12px; }
}

/* ============================================
   PRINT
   Someone will export this to PDF. Make that
   version readable rather than accidental.
   ============================================ */
@media print {
  /* must out-specify :root:not([data-theme]) in the light-scheme block */
  :root,
  :root:not([data-theme]),
  :root[data-theme="light"],
  :root[data-theme="dark"] {
    --bg: #fff; --surface: #fff; --surface-2: #fff;
    --border: #c8c8d4; --text: #000; --muted: #4a4a5a; --dim: #8a8a9a;
    --accent: #B00E16; --accent-dim: transparent; --accent-glow: transparent;
  }
  html { font-size: 11pt; }
  .nav, .theme-btn, .skip-link, .progress, .nextup, .arrow, .f-mark,
  .lightbox, .s-anchor { display: none !important; }
  .zoomable { cursor: default; }
  .reveal, .project-row, .intro-tag, .intro-h1, .intro-sub,
  .h-eyebrow, .h-title, .h-lede, .meta, .hero {
    opacity: 1 !important; transform: none !important; animation: none !important;
  }
  .js .figure img, .js .screens img, .js .hero.shot img { opacity: 1 !important; }
  .header, .intro { padding-top: 0; }
  section.chunk { padding: 18px 0 26px; break-inside: avoid; }
  .figure, .screens, .diagram, .stats, .split, .steps, .pull, .wip,
  .vidfig { break-inside: avoid; }
  /* A video prints as its poster frame. The playback note below it is an
     instruction for a medium that does not exist on paper, so it goes. */
  .vid-note { display: none !important; }
  .h-title { font-size: 24pt; }
  .s-h { font-size: 15pt; }
  .body-p { font-size: 10.5pt; }
  .hero:not(.shot) { display: none; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; color: var(--muted); }
  footer { border-top: 1px solid var(--border); }
}
