/* ==========================================================================
   Jannifer Durairajan — portfolio
   1 fonts · 2 tokens · 3 base · 4 themes · 5 layout · 6 type · 7 components
   8 sections · 9 enhanced states · 10 responsive · 11 reduced motion
   ========================================================================== */

/* 1. Fonts ---------------------------------------------------------------- */
@font-face {
  font-family: "Archivo";
  src: url("assets/fonts/archivo-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Martian Mono";
  src: url("assets/fonts/martian-mono-variable.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

/* 2. Tokens --------------------------------------------------------------- */
:root {
  --graphite: #171C1A;
  --forest: #29332E;
  --emerald: #16A36A;
  --mint: #A3D9B1;
  --paper: #F1F5F2;
  --emerald-deep: #0E7A4E;
  --muted-dark: #9DB0A5;
  --muted-light: #55625B;
  --line-dark: rgba(163, 217, 177, 0.16);
  --line-light: rgba(23, 28, 26, 0.16);

  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Martian Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --margin: clamp(20px, 5vw, 80px);
  --gutter: clamp(16px, 2vw, 32px);
  --maxw: 100rem;              /* scales with the root size, so large displays keep the same proportions */
  --edge: max(var(--margin), calc((100vw - var(--maxw)) / 2 + var(--margin)));  /* viewport edge to content edge */
  --pad: clamp(5rem, 13vh, 10rem);
  --chamfer: 12px;
  --cut: clamp(24px, 4vw, 64px);
  --header-h: clamp(56px, 7svh, 76px);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-io: cubic-bezier(0.65, 0, 0.35, 1);
}

/* 3. Base ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
/* everything is sized in rem, so the whole layout scales up on large displays (limited by width and by height);
   never below the visitor's own default size */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; font-size: clamp(100%, min(0.5vw + 0.55rem, 1.1vh + 0.55rem), 175%); }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: clip; }
body {
  margin: 0;
  background: var(--graphite);
  color: var(--paper);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }
p { text-wrap: pretty; }
::selection { background: var(--emerald); color: var(--graphite); }
:focus-visible { outline: 2px solid var(--focus, var(--mint)); outline-offset: 3px; }
code { font-family: var(--mono); font-size: 0.86em; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: fixed; left: 12px; top: 12px; z-index: 300; padding: 0.75rem 1rem;
  background: var(--paper); color: var(--graphite); font-weight: 600;
  transform: translateY(-200%);
}
.skip:focus { transform: none; }

/* 4. Themes --------------------------------------------------------------- */
[data-theme] { background: var(--bg); color: var(--fg); }
[data-theme="graphite"] { --bg: var(--graphite); --fg: var(--paper); --muted: var(--muted-dark); --line: var(--line-dark); --accent-text: var(--mint); --focus: var(--mint); }
[data-theme="forest"]   { --bg: var(--forest);   --fg: var(--paper); --muted: #B4C4BA; --line: rgba(163, 217, 177, 0.2); --accent-text: var(--mint); --focus: var(--mint); }
[data-theme="paper"]    { --bg: var(--paper);    --fg: var(--graphite); --muted: var(--muted-light); --line: var(--line-light); --accent-text: var(--emerald-deep); --focus: var(--graphite); }
[data-theme="emerald"]  { --bg: var(--emerald);  --fg: var(--graphite); --muted: var(--graphite); --line: rgba(23, 28, 26, 0.28); --accent-text: var(--graphite); --focus: var(--graphite); }

/* 5. Layout --------------------------------------------------------------- */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--margin); }
main > section { position: relative; }
/* sections whose colour differs from the one above get a chamfered leading corner */
.mission, .pillars, .story, .toolkit, .work, .contact, .foot {
  margin-top: calc(var(--cut) * -1);
  clip-path: polygon(var(--cut) 0, 100% 0, 100% 100%, 0 100%, 0 var(--cut));
}
.telemetry, .mission, .pillars, .story, .toolkit, .work, .contact { padding-bottom: var(--cut); }

/* 6. Type ----------------------------------------------------------------- */
.t-xl { font-size: clamp(2.1rem, 5vw, 5.25rem); font-weight: 600; line-height: 1.04; letter-spacing: -0.02em; text-wrap: balance; }
.t-l  { font-size: clamp(1.55rem, 2.9vw, 2.9rem); font-weight: 600; line-height: 1.1; letter-spacing: -0.015em; text-wrap: balance; }
.t-m  { font-size: clamp(1.15rem, 1.6vw, 1.5rem); font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
.t-body-l { font-size: clamp(1.1rem, 1.3vw, 1.35rem); line-height: 1.5; }
.t-readout { font-family: var(--mono); font-size: 0.75rem; line-height: 1.4; font-weight: 400; }

/* 7. Components ----------------------------------------------------------- */
/* buttons */
.btn {
  --b-bg: var(--emerald); --b-fg: var(--graphite); --b-fill: var(--mint); --b-fill-fg: var(--graphite);
  position: relative; isolation: isolate; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 1.75rem;
  font: 600 1rem/1 var(--font); letter-spacing: 0; white-space: nowrap; text-decoration: none;
  color: var(--b-fg); background: var(--b-bg); border: 0; cursor: pointer;
  clip-path: polygon(var(--chamfer) 0, 100% 0, 100% calc(100% - var(--chamfer)), calc(100% - var(--chamfer)) 100%, 0 100%, 0 var(--chamfer));
  transition: color 0.25s;
}
.btn::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: var(--b-fill);
  clip-path: circle(0% at 0 0); transition: clip-path 0.45s var(--ease-out);
}
.btn:hover, .btn:focus-visible { color: var(--b-fill-fg); }
.btn:hover::before, .btn:focus-visible::before { clip-path: circle(150% at 0 0); }
.btn:focus-visible { outline: 0; box-shadow: inset 0 0 0 3px var(--graphite); }
.btn--ghost, .btn--outline { --b-bg: currentColor; }
.btn--ghost { --b-fg: var(--paper); --b-fill: var(--paper); --b-fill-fg: var(--graphite); --b-in: var(--graphite); background: rgba(241, 245, 242, 0.45); }
.btn--outline { --b-fg: var(--graphite); --b-fill: var(--graphite); --b-fill-fg: var(--paper); --b-in: var(--emerald); background: var(--graphite); }
.btn--ghost::after, .btn--outline::after {
  content: ""; position: absolute; inset: 1.5px; z-index: -2; background: var(--b-in);
  clip-path: polygon(calc(var(--chamfer) - 0.6px) 0, 100% 0, 100% calc(100% - var(--chamfer) + 0.6px), calc(100% - var(--chamfer) + 0.6px) 100%, 0 100%, 0 calc(var(--chamfer) - 0.6px));
}
.btn--ghost:focus-visible { box-shadow: inset 0 0 0 3px var(--mint); }
.btn--outline:focus-visible { box-shadow: inset 0 0 0 3px var(--paper); }
.btn--dark { --b-bg: var(--graphite); --b-fg: var(--paper); --b-fill: var(--paper); --b-fill-fg: var(--graphite); }
.btn--dark:focus-visible { box-shadow: inset 0 0 0 3px var(--mint); }

/* text links */
main a:not(.btn), .foot a, .menu a:not(.btn) {
  text-decoration: none;
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
  transition: background-size 0.45s var(--ease-out);
}
main a:not(.btn):hover, .foot a:hover, .menu a:not(.btn):hover { background-size: 0% 1px; background-position: 100% 100%; }

/* header */
.head {
  --head-fg: var(--paper); --head-bg: var(--graphite);
  position: fixed; inset: 0 0 auto 0; z-index: 60; height: var(--header-h);
  display: flex; align-items: center; gap: clamp(1rem, 2.5vw, 2.5rem);
  padding-inline: var(--edge); color: var(--head-fg);
  transition: transform 0.5s var(--ease-out), color 0.3s;
}
.head[data-head="paper"] { --head-fg: var(--graphite); --head-bg: var(--paper); }
.head[data-head="emerald"] { --head-fg: var(--graphite); --head-bg: var(--emerald); }
.head[data-head="forest"] { --head-bg: var(--forest); }
.head::before {
  content: ""; position: absolute; inset: 0 0 -28px 0; z-index: -1; pointer-events: none;
  background: linear-gradient(var(--head-bg) 30%, transparent); opacity: 0.94; transition: opacity 0.3s;
}
.head.is-hidden { transform: translateY(-130%); }
.mono {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none;
  background: var(--head-fg); color: var(--head-bg); text-decoration: none;
  font-weight: 800; font-size: 0.95rem; letter-spacing: -0.02em; font-variation-settings: "wght" 800, "wdth" 112;
  clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%, 0 10px);
  transition: background-color 0.3s, color 0.3s;
}
.head__nav { margin-left: auto; display: flex; gap: clamp(1.25rem, 2.4vw, 2.5rem); }
.head__nav a { font-weight: 500; font-size: 0.95rem; text-decoration: none; padding: 0.75rem 0; background: linear-gradient(currentColor, currentColor) 0 78% / 0% 1px no-repeat; transition: background-size 0.4s var(--ease-out); }
.head__nav a:hover, .head__nav a[aria-current="true"] { background-size: 100% 1px; }
.head__cta { min-height: 44px; padding: 0 1.25rem; font-size: 0.95rem; }
.head[data-head="emerald"] .head__cta { --b-bg: var(--graphite); --b-fg: var(--paper); --b-fill: var(--paper); --b-fill-fg: var(--graphite); }
.head__menu {
  display: none; margin-left: auto; min-height: 44px; padding: 0 0.25rem; background: none; border: 0; cursor: pointer;
  font-weight: 600; font-size: 0.95rem;
}

/* menu overlay */
.menu {
  position: fixed; inset: 0; z-index: 55; background: var(--graphite); color: var(--paper);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: calc(var(--header-h) + 2rem) var(--margin) 2rem; overflow: auto;
}
.menu[hidden] { display: none; }
.menu__nav { display: grid; gap: 0.25rem; }
.menu__nav a { font-size: clamp(2.2rem, 11vw, 4rem); font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; text-decoration: none; background: none !important; padding: 0.15em 0; }
.menu__foot { display: grid; gap: 1rem; justify-items: start; margin-top: 2rem; }
.menu-open .head { --head-fg: var(--paper); --head-bg: var(--graphite); transform: none; }

/* signal rail */
.rail {
  position: fixed; z-index: 50; left: clamp(10px, 2.3vw, 38px); top: calc(var(--header-h) + 3svh); bottom: 6svh; width: 14px;
  color: var(--paper); pointer-events: none; transition: color 0.3s, opacity 0.4s;
}
html[data-chrome="paper"] .rail { color: var(--graphite); }
html[data-chrome="emerald"] .rail { color: var(--graphite); }
.rail__track { position: absolute; left: 6.5px; top: 0; bottom: 0; width: 1px; background: currentColor; opacity: 1; }
.rail__track { background: color-mix(in srgb, currentColor 24%, transparent); }
.rail__fill { position: absolute; left: -0.5px; top: 0; width: 2px; height: 100%; background: var(--emerald); transform: scaleY(0); transform-origin: 50% 0; }
html[data-chrome="emerald"] .rail__fill { background: var(--graphite); }
.rail__ticks { position: absolute; inset: 0; }
.rail__ticks li { position: absolute; left: 0; width: 14px; height: 14px; margin-top: -7px; }
.rail__ticks a {
  display: block; width: 100%; height: 100%; pointer-events: auto; position: relative;
}
.rail__ticks a::before {
  content: ""; position: absolute; left: 3.5px; top: 6px; width: 7px; height: 1.5px; background: currentColor; opacity: 0.55;
  transition: transform 0.25s, opacity 0.25s; transform-origin: 50% 50%;
}
.rail__ticks a:hover::before, .rail__ticks a[aria-current="true"]::before { opacity: 1; transform: scaleX(1.7); }
.rail__ticks a span {
  position: absolute; left: 22px; top: 50%; transform: translateY(-50%); padding: 0.2rem 0.5rem; white-space: nowrap;
  font-size: 0.78rem; font-weight: 500; background: var(--graphite); color: var(--paper); opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.rail__ticks a:hover span, .rail__ticks a:focus-visible span { opacity: 1; }
.rail__label {
  position: absolute; left: 20px; top: 0; writing-mode: vertical-rl; font-size: 0.72rem; font-weight: 500; letter-spacing: 0.02em; white-space: nowrap;
  opacity: 0.8; transition: transform 0.5s var(--ease-out);
}

/* grain */
.grain {
  position: fixed; inset: -128px; z-index: 90; pointer-events: none;
  background: url("assets/img/grain.png") 0 0 / 160px 160px;
  opacity: 0.3; will-change: transform; animation: grain 0.9s steps(1) infinite;
}
@keyframes grain {
  0% { transform: translate3d(0, 0, 0); } 12.5% { transform: translate3d(-48px, 31px, 0); }
  25% { transform: translate3d(37px, -62px, 0); } 37.5% { transform: translate3d(-91px, -18px, 0); }
  50% { transform: translate3d(64px, 77px, 0); } 62.5% { transform: translate3d(-22px, -96px, 0); }
  75% { transform: translate3d(103px, 12px, 0); } 87.5% { transform: translate3d(-70px, 58px, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

/* cursor */
.cursor {
  position: fixed; left: 0; top: 0; z-index: 120; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%;
  background: #fff; mix-blend-mode: difference; pointer-events: none; opacity: 0;
  display: grid; place-items: center;
  transition: width 0.3s var(--ease-out), height 0.3s var(--ease-out), margin 0.3s var(--ease-out), opacity 0.3s;
}
.cursor.is-on { opacity: 1; }
.cursor.is-link { width: 44px; height: 44px; margin: -22px 0 0 -22px; }
.cursor.is-label { width: 64px; height: 64px; margin: -32px 0 0 -32px; }
.cursor__label { font-size: 0.72rem; font-weight: 600; color: #000; opacity: 0; transition: opacity 0.2s; }
.cursor.is-label .cursor__label { opacity: 1; }

/* loader */
.loader {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: var(--graphite); color: var(--paper);
  animation: loader-failsafe 0.01s 7s forwards;
}
.no-js .loader { display: none; }
.loader.is-done { display: none; }
@keyframes loader-failsafe { to { visibility: hidden; opacity: 0; } }
.loader__inner { display: grid; gap: 0.9rem; justify-items: start; width: min(78vw, 420px); }
.loader__name { font-weight: 600; font-size: 1rem; }
.loader__bar { display: block; width: 100%; height: 1px; background: var(--line-dark); position: relative; }
.loader__fill { position: absolute; inset: -0.5px 0; height: 2px; background: var(--emerald); transform: scaleX(0); transform-origin: 0 50%; }
.loader__pct { color: var(--muted-dark); }

/* 8. Sections ------------------------------------------------------------- */

/* --- hero (static fallback first; staged layout further down) --- */
.hero__pin {
  position: relative; min-height: 100svh; overflow: clip;
  display: flex; flex-direction: column; justify-content: flex-end; gap: clamp(1.5rem, 4vh, 3rem);
  padding: calc(var(--header-h) + 2rem) var(--edge) clamp(1.5rem, 4vh, 3rem);
  background: linear-gradient(rgba(23, 28, 26, 0.45), rgba(23, 28, 26, 0.92) 62%), url("assets/img/poster-grip.webp") 50% 0 / min(120%, 1400px) auto no-repeat;
}
.hero__name {
  font-size: clamp(3rem, 13.5vw, 12.5rem); line-height: 0.84; font-weight: 800; text-transform: uppercase;
  letter-spacing: -0.02em; font-variation-settings: "wght" 800, "wdth" 68;
}
.hero__line { display: block; white-space: nowrap; }
.hero__canvas { display: none; }
.hero__beat { font-size: clamp(1.15rem, 1.9vw, 1.75rem); font-weight: 500; line-height: 1.25; color: var(--mint); text-wrap: balance; }
.hero__foot { display: grid; gap: 1.25rem; }
.hero__role { color: var(--muted); font-size: 0.95rem; font-weight: 500; }
.hero__lead { font-size: clamp(1.1rem, 1.55vw, 1.5rem); font-weight: 500; line-height: 1.3; max-width: 24em; text-wrap: balance; }
.hero__readout { display: none; color: var(--muted); }
.hero__actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

/* staged hero: JS has sized the canvas and positions the name between the jaws */
.has-stage .hero__pin { display: block; padding: 0; height: 100svh; background: none; }
.has-stage .hero__canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
.has-stage .hero__name {
  position: absolute; left: 0; top: 0; z-index: 1; text-align: center; letter-spacing: 0; font-size: 1rem;
  will-change: transform; transform: translate3d(0, 0, 0);
}
.has-stage .hero__line { font-variation-settings: "wght" 800, "wdth" var(--wdth, 125); transform-origin: 50% 50%; }
.has-stage .hero__beat {
  position: absolute; z-index: 3; left: 50%; top: var(--beat-y, 72%); width: min(90vw, 34em); text-align: center;
  transform: translate(-50%, calc(-50% + (1 - var(--beat, 0)) * 18px)); opacity: var(--beat, 0);
}
.has-stage .hero__foot {
  position: absolute; z-index: 3; left: 0; right: 0; bottom: 0;
  grid-template-columns: minmax(0, 1fr) auto auto; align-items: end; gap: clamp(1rem, 3vw, 3rem);
  padding: 0 var(--edge) clamp(14px, 3.4svh, 36px);
}
.has-stage .hero__readout { display: grid; gap: 0.1rem; min-width: 13.5em; padding-bottom: 0.15rem; }
.has-stage .hero__state { color: var(--mint); }
.is-enhanced .hero { height: 360svh; }
.is-enhanced .hero__pin { position: sticky; top: 0; }

/* --- telemetry --- */
.telemetry { padding-top: clamp(3rem, 8vh, 6rem); padding-bottom: calc(clamp(4rem, 10vh, 8rem) + var(--cut)); }
.stats { display: grid; grid-template-columns: 5fr 3.2fr 2fr 2fr; gap: var(--gutter); }
.stat { display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 0.9rem; padding-top: 1.4rem; border-top: 1px solid var(--line); position: relative; }
.stat::before { content: ""; position: absolute; left: 0; top: -1px; width: 100%; height: 2px; background: var(--emerald); transform: scaleX(0); transform-origin: 0 50%; }
.stat.is-live::before { animation: stat-pulse 1.1s var(--ease-io) forwards; }
@keyframes stat-pulse { 0% { transform: scaleX(0); transform-origin: 0 50%; } 55% { transform: scaleX(1); transform-origin: 0 50%; } 56% { transform: scaleX(1); transform-origin: 100% 50%; } 100% { transform: scaleX(0); transform-origin: 100% 50%; } }
.stat__num {
  font-size: clamp(2.5rem, 5.3vw, 5.6rem); line-height: 1; font-weight: 700; letter-spacing: -0.025em; white-space: nowrap;
  font-variation-settings: "wght" 700, "wdth" 112; font-variant-numeric: tabular-nums lining-nums;
}
.stat__label { color: var(--muted); font-size: 0.98rem; line-height: 1.4; max-width: 17em; }
.odo { display: inline-flex; vertical-align: top; }
.odo__d { display: inline-block; height: 1.02em; overflow: hidden; }
.odo__col { display: flex; flex-direction: column; will-change: transform; }
.odo__col span { height: 1.02em; line-height: 1.02; display: block; text-align: center; }

/* --- mission --- */
.mission { padding-top: calc(var(--pad) + var(--cut)); padding-bottom: calc(var(--pad) + var(--cut)); }
.mission__h { color: var(--muted); margin-bottom: clamp(1.5rem, 4vh, 3rem); }
.mission__statement { max-width: 15.5em; }
.mission__statement .w { display: inline-block; }
.mission__cols { display: grid; grid-template-columns: 5fr 1fr 6fr; margin-top: clamp(3rem, 9vh, 7rem); align-items: start; }
.mission__body { grid-column: 3; max-width: 34em; }
.mission__list div { display: grid; grid-template-columns: 8rem 1fr; gap: 1rem; padding: 1.1rem 0; border-top: 1px solid var(--line); }
.mission__list div:last-child { border-bottom: 1px solid var(--line); }
.mission__list dt { font-weight: 700; }
.mission__list dd { color: var(--muted); }

/* --- pillars (stacked by default; horizontal when enhanced on desktop) --- */
.pillars { padding-top: var(--cut); }
.pillars__top { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; padding-top: clamp(3rem, 8vh, 5rem); padding-bottom: 1rem; }
.pillars__top h2 { color: var(--muted); }
.pillars__tabs { display: none; gap: clamp(1rem, 2vw, 2rem); }
.pillars__tab { background: none; border: 0; padding: 0.75rem 0; cursor: pointer; font-weight: 500; font-size: 0.95rem; color: var(--muted); position: relative; transition: color 0.3s; }
.pillars__tab::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0.45rem; height: 2px; background: var(--emerald); transform: scaleX(0); transform-origin: 0 50%; transition: transform 0.45s var(--ease-out); }
.pillars__tab[aria-current="true"] { color: var(--fg); }
.pillars__tab[aria-current="true"]::after { transform: scaleX(1); }
.pillar { position: relative; padding-block: clamp(2.5rem, 7vh, 4.5rem); border-top: 1px solid var(--line); overflow: clip; }
.pillar__word {
  position: relative; width: max-content; font-size: clamp(4.5rem, 21vw, 15rem); line-height: 0.82; font-weight: 800; letter-spacing: -0.03em; white-space: nowrap;
  font-variation-settings: "wght" 800, "wdth" 125; margin-left: var(--margin); margin-bottom: clamp(1.5rem, 4vh, 3rem);
}
.pillar__stroke { color: transparent; -webkit-text-stroke: 1.5px rgba(163, 217, 177, 0.55); }
.pillar__fill { position: absolute; inset: 0; color: var(--mint); clip-path: inset(0 calc(100% - var(--fill, 100%)) 0 0); }
.pillar__body { display: grid; grid-template-columns: 5fr 1fr 6fr; align-items: end; row-gap: 2rem; }
.pillar__lead h3 { margin-bottom: 1rem; }
.pillar__lead p { color: var(--muted); max-width: 26em; }
.pillar__list { grid-column: 3; }
.pillar__list li { padding: 0.8rem 0; border-top: 1px solid var(--line); font-weight: 500; }
.pillar__list li:last-child { border-bottom: 1px solid var(--line); }

/* --- story --- */
.story { padding-top: calc(var(--pad) + var(--cut)); padding-bottom: calc(var(--pad) + var(--cut)); }
.story__grid { display: grid; grid-template-columns: 5fr 7fr; column-gap: calc(var(--gutter) * 3); align-items: start; }
.story__side { position: sticky; top: calc(var(--header-h) + 1.5rem); display: grid; gap: clamp(1rem, 2.6svh, 1.75rem); justify-items: start; }
.story__portrait { height: min(23.5rem, 44svh); aspect-ratio: 4 / 5; clip-path: polygon(0 0, calc(100% - 28px) 0, 100% 28px, 100% 100%, 0 100%); background: var(--forest); }
.story__portrait img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; }
.route { width: min(100%, 20rem); }
.route svg { width: 100%; height: auto; overflow: visible; }
.route__ghost { stroke: var(--line); stroke-width: 1.5; stroke-dasharray: 3 5; }
.route__arc { stroke: var(--emerald); stroke-width: 2; stroke-dasharray: 1; stroke-dashoffset: 0; }
.route__dot { fill: var(--paper); }
.route figcaption { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--muted); margin-top: 0.4rem; }
.route__km { color: var(--mint); }
.chapter { padding-block: clamp(1.75rem, 5vh, 3.25rem); border-top: 1px solid var(--line); transition: opacity 0.45s; }
.chapter:last-child { border-bottom: 1px solid var(--line); }
.chapter__meta { display: flex; align-items: baseline; gap: 0.9rem; color: var(--muted); font-size: 0.95rem; font-weight: 500; margin-bottom: 0.9rem; }
.chapter__n { font-family: var(--mono); font-size: 0.75rem; color: var(--mint); min-width: 1.2em; }
.chapter h3 { margin-bottom: 1rem; }
.chapter p:last-child { color: var(--muted); max-width: 35em; }

/* --- toolkit --- */
.toolkit { padding-top: calc(var(--pad) + var(--cut)); padding-bottom: calc(var(--pad) + var(--cut)); }
.toolkit__head { display: grid; grid-template-columns: 7fr 5fr; column-gap: calc(var(--gutter) * 2); align-items: end; margin-bottom: clamp(2.5rem, 7vh, 5rem); }
.toolkit__head p { color: var(--muted); max-width: 28em; }
.pinout { display: grid; gap: 2rem; }
.pinout__title { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.8rem; }
.pinout__group ul { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pin {
  min-height: 44px; padding: 0.5rem 0.9rem; background: none; border: 1px solid var(--line); cursor: pointer;
  font-size: 0.95rem; font-weight: 500; line-height: 1.2; text-align: left; transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.pin:hover { border-color: var(--fg); }
.pin[aria-pressed="true"] { background: var(--graphite); color: var(--paper); border-color: var(--graphite); }
.chip { display: none; }
.pindesc {
  display: grid; grid-template-columns: 2fr 3fr 5fr 4fr; column-gap: var(--gutter); row-gap: 0.4rem; align-items: baseline;
  margin-top: clamp(2rem, 5vh, 3.5rem); padding: 1.25rem 0; border-top: 1px solid var(--fg); border-bottom: 1px solid var(--line);
}
.pindesc__k { color: var(--muted); font-size: 0.9rem; }
.pindesc__name strong { font-weight: 700; margin-right: 0.6rem; }
.pindesc__name span { color: var(--muted); font-size: 0.9rem; }
.pindesc__link { justify-self: start; color: var(--accent-text); font-weight: 600; }
.toolkit__extra { margin-top: clamp(2.5rem, 6vh, 4rem); }
.toolkit__extra div { display: grid; grid-template-columns: 2fr 10fr; column-gap: var(--gutter); padding: 0.95rem 0; border-top: 1px solid var(--line); }
.toolkit__extra div:last-child { border-bottom: 1px solid var(--line); }
.toolkit__extra dt { font-weight: 700; }
.toolkit__extra dd { color: var(--muted); max-width: 46em; }
.toolkit__cta { margin-top: clamp(2rem, 5vh, 3rem); }

/* --- work --- */
.work { padding-top: calc(var(--pad) + var(--cut)); padding-bottom: calc(var(--pad) + var(--cut)); }
.work__head { margin-bottom: clamp(2rem, 6vh, 4rem); }
.case__pin { display: flex; align-items: center; padding-block: clamp(1.5rem, 4vh, 3rem); }
.case__grid { display: grid; grid-template-columns: 5fr 7fr; column-gap: calc(var(--gutter) * 2); align-items: center; }
.case__text { font-size: clamp(0.9rem, 1.95svh, 1.0625rem); }
.case__context { color: var(--muted); font-size: 0.9em; margin-bottom: 0.9em; max-width: 30em; }
.case__text h3 { font-size: clamp(1.4rem, min(2.5vw, 4.4svh), 2.5rem); margin-bottom: 0.7em; }
.case__summary { color: var(--muted); max-width: 33em; margin-bottom: 1.2em; }
.case__steps { border-bottom: 1px solid var(--line); }
.case__step { border-top: 1px solid var(--line); }
.case__label {
  display: flex; align-items: center; gap: 0.75em; width: 100%; padding: 0.62em 0; background: none; border: 0; cursor: pointer; text-align: left;
  font-weight: 600; color: var(--muted); transition: color 0.3s;
}
.case__label::before { content: ""; width: 0.55em; height: 0.55em; flex: none; background: currentColor; opacity: 0.5; transition: background-color 0.3s, opacity 0.3s; }
.case__note p { color: var(--muted); max-width: 34em; padding: 0 0 0.9em 1.3em; }
.case__note code { color: var(--mint); }
.case__stack { margin-top: 1.1em; font-size: 0.86em; color: var(--muted); }
.case__stage { position: relative; justify-self: center; width: min(100%, calc(88svh - var(--header-h))); aspect-ratio: 1; }
.case__canvas { display: none; position: absolute; inset: 0; width: 100%; height: 100%; }
.case__canvas, .case__poster { -webkit-mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent); mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent); }
.case__poster { width: 100%; height: 100%; object-fit: contain; }
.result { width: calc(100% - 1.3em); margin: 0 0 1em 1.3em; border-collapse: collapse; font-size: 0.86em; font-variant-numeric: tabular-nums; }
.result caption { text-align: left; color: var(--muted); padding-bottom: 0.5em; font-size: 0.95em; }
.result th, .result td { text-align: left; font-weight: 500; padding: 0.4em 0.8em 0.55em 0; border-top: 1px solid var(--line); position: relative; white-space: nowrap; }
.result thead th { color: var(--muted); font-weight: 500; }
.result tbody th { font-weight: 700; width: 4.2em; }
.result td::after { content: ""; position: absolute; left: 0; bottom: 0.2em; height: 3px; width: calc((100% - 0.8em) * var(--s, 1)); max-width: calc((100% - 0.8em)); background: var(--emerald); transform: scaleX(calc(var(--vn, 1))); transform-origin: 0 50%; }
.result td { --vn: 1; }
.result td::after { width: calc((100% - 0.8em) * 1); clip-path: inset(0 calc(100% - var(--v)) 0 0); }

.rows { margin-top: clamp(2rem, 6vh, 4rem); border-bottom: 1px solid var(--line); }
.row { border-top: 1px solid var(--line); scroll-margin-top: calc(var(--header-h) + 1rem); }
.row__btn {
  display: grid; grid-template-columns: 7fr 4fr 24px; column-gap: var(--gutter); align-items: baseline; width: 100%;
  padding: clamp(1.2rem, 3.2vh, 2rem) 0; background: none; border: 0; cursor: pointer; text-align: left; font-weight: 400;
}
.row__title { font-size: clamp(1.3rem, 2.3vw, 2.25rem); font-weight: 600; line-height: 1.15; letter-spacing: -0.015em; text-wrap: balance; transition: color 0.3s; }
.row__btn:hover .row__title, .row.is-open .row__title { color: var(--mint); }
.row__ctx { color: var(--muted); font-size: 0.95rem; line-height: 1.4; }
.row__icon { position: relative; width: 18px; height: 18px; align-self: center; justify-self: end; }
.row__icon::before, .row__icon::after { content: ""; position: absolute; left: 0; top: 8px; width: 18px; height: 2px; background: currentColor; transition: transform 0.4s var(--ease-out); }
.row__icon::after { transform: rotate(90deg); }
.row.is-open .row__icon::after { transform: rotate(0deg); }
.row__panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.5s var(--ease-out); }
.row.is-open .row__panel { grid-template-rows: 1fr; }
.row__inner { min-height: 0; overflow: hidden; display: grid; grid-template-columns: 7fr 5fr; column-gap: var(--gutter); align-items: start; visibility: hidden; transition: visibility 0s 0.5s; }
.row.is-open .row__inner { visibility: visible; transition-delay: 0s; }
.row__copy { padding-bottom: clamp(1.5rem, 4vh, 2.5rem); max-width: 38em; }
.row__copy p:first-child { font-size: 1.08rem; }
.row__stack { margin-top: 0.9rem; color: var(--muted); font-size: 0.92rem; }
.row__img { width: min(100%, 20rem); height: auto; justify-self: end; margin-bottom: clamp(1.5rem, 4vh, 2.5rem); }
.peek {
  position: fixed; left: 0; top: 0; z-index: 70; width: 16.25rem; padding: 0.875rem; background: var(--forest); pointer-events: none; opacity: 0;
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 0 100%); transition: opacity 0.25s; will-change: transform;
}
.peek.is-on { opacity: 1; }
.peek img { width: 100%; height: auto; }

/* --- contact --- */
.contact { padding-top: calc(var(--pad) + var(--cut)); padding-bottom: calc(var(--pad) + var(--cut)); }
.contact__display {
  font-size: clamp(2.6rem, 9.2vw, 9.5rem); line-height: 0.86; font-weight: 800; text-transform: uppercase; letter-spacing: -0.02em;
  font-variation-settings: "wght" 800, "wdth" var(--wdth, 100);
}
.contact__display span { display: block; white-space: nowrap; width: max-content; }
.contact__grid { display: grid; grid-template-columns: 5fr 7fr; column-gap: calc(var(--gutter) * 2); row-gap: 2rem; margin-top: clamp(2.5rem, 7vh, 5rem); align-items: start; }
.contact__lead { max-width: 24em; font-weight: 500; }
.contact__reach { display: grid; gap: 1.5rem; justify-items: start; }
.contact__mail { font-size: clamp(1.25rem, 2.6vw, 2.5rem); font-weight: 700; letter-spacing: -0.015em; line-height: 1.2; overflow-wrap: anywhere; }
.contact__actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.contact__links { display: flex; gap: 1.75rem; font-weight: 600; }

/* --- footer --- */
.foot { padding-top: calc(clamp(3rem, 7vh, 5rem) + var(--cut)); padding-bottom: 2rem; }
.foot__grid { display: grid; grid-template-columns: 5fr 3fr 4fr; column-gap: var(--gutter); row-gap: 2rem; align-items: start; }
.foot__id { color: var(--muted); }
.foot__id strong { color: var(--fg); font-weight: 700; }
.foot__nav, .foot__links { display: grid; gap: 0.55rem; justify-items: start; }
.foot__legal { margin-top: clamp(2.5rem, 6vh, 4rem); color: var(--muted); font-size: 0.9rem; }

/* 9. Enhanced states (only when script.js adds .is-enhanced) --------------- */
.is-enhanced .pillar__word { --fill: 0%; }
.has-stage:not(.is-enhanced) .hero__cue { display: none; }
.has-stage:not(.is-enhanced) .hero__pin { --beat: 1; }
.is-enhanced .mission__statement .w { opacity: 0.18; }
.is-enhanced .chapter { opacity: 0.38; }
.is-enhanced .chapter.is-active { opacity: 1; }
.is-enhanced .route__arc { stroke-dashoffset: 1; }
.is-enhanced .route__km { opacity: 0; transition: opacity 0.5s; }
.is-enhanced .route.is-drawn .route__km { opacity: 1; }

/* case study: sticky stage with stepped notes (any viewport, when scripted) */
.has-case .case { height: 600svh; }
.has-case .case__pin { position: sticky; top: 0; height: 100svh; padding-block: calc(var(--header-h) + 0.5rem) 1rem; }
.has-case .case__grid { height: 100%; }
.has-case .case__canvas { display: block; }
.has-case .case__poster { display: none; }
.has-case .case__note, .has-case .case__summary-wrap { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.5s var(--ease-out); }
.has-case .case__note > div, .has-case .case__summary-wrap > div { min-height: 0; overflow: hidden; }
.has-case .case__step.is-active .case__note { grid-template-rows: 1fr; }
.has-case .case:not(.has-step) .case__summary-wrap { grid-template-rows: 1fr; }
.has-case .case__step.is-active .case__label { color: var(--fg); }
.has-case .case__step.is-active .case__label::before { background: var(--emerald); opacity: 1; }
.has-case .case__step.is-done .case__label::before { background: var(--mint); opacity: 0.9; }
.has-case .result td::after { clip-path: inset(0 100% 0 0); transition: clip-path 0.9s var(--ease-out) 0.25s; }
.has-case .case__step.is-active .result td::after { clip-path: inset(0 calc(100% - var(--v)) 0 0); }

@media (max-height: 800px) {
  .has-case .case__stack, .has-case .case.has-step .case__context { display: none; }
  .has-case .case__label { padding: 0.46em 0; }
}

/* 10. Responsive ----------------------------------------------------------- */

/* pinout diagram */
@media (min-width: 1100px) {
  .pinout {
    grid-template-columns: minmax(0, 1fr) clamp(26rem, 36vw, 34rem) minmax(0, 1fr);
    grid-template-areas: "left chip right" ". bottom ."; gap: 0; align-items: stretch;
  }
  .pinout__group--left { grid-area: left; text-align: right; }
  .pinout__group--right { grid-area: right; }
  .pinout__group--bottom { grid-area: bottom; display: flex; flex-direction: column-reverse; align-items: center; }
  .pinout__group--left .pinout__title, .pinout__group--right .pinout__title { height: 2rem; margin: 0; padding-inline: calc(clamp(28px, 4vw, 72px) + 0.9rem); }
  .pinout__group--bottom .pinout__title { margin: 0.9rem 0 0; }
  .pinout__group--left ul, .pinout__group--right ul { flex-direction: column; flex-wrap: nowrap; gap: 0; }
  .pinout .pin { border: 0; padding: 0; min-height: 44px; background: none !important; color: var(--fg) !important; display: flex; align-items: center; gap: 0.9rem; width: 100%; }
  .pinout__group--left .pin { justify-content: flex-end; text-align: right; }
  .pinout__group--left .pin::after, .pinout__group--right .pin::before {
    content: ""; flex: none; width: clamp(28px, 4vw, 72px); height: 1px; background: currentColor; opacity: 0.3;
    transition: background-color 0.2s, opacity 0.2s, height 0.2s;
  }
  .pinout .pin[aria-pressed="true"] { font-weight: 700; }
  .pinout .pin[aria-pressed="true"]::after, .pinout .pin[aria-pressed="true"]::before, .pinout .pin:hover::after, .pinout .pin:hover::before { background: var(--emerald); opacity: 1; height: 3px; }
  .pinout__group--bottom ul { flex-wrap: nowrap; gap: 0; width: 100%; justify-content: space-around; padding-inline: 3%; }
  .pinout__group--bottom li { width: 0; display: flex; justify-content: center; }
  .pinout__group--bottom .pin { flex-direction: column; width: max-content; gap: 0.5rem; text-align: center; font-size: 0.86rem; line-height: 1.15; max-width: 7.2em; align-items: center; justify-content: flex-start; }
  .pinout__group--bottom .pin::before { content: ""; flex: none; width: 1px; height: 22px; background: currentColor; opacity: 0.3; transition: background-color 0.2s, opacity 0.2s, width 0.2s; }
  .pinout__group--bottom li:nth-child(even) .pin::before { height: 62px; }
  .pinout__group--bottom .pin[aria-pressed="true"]::before, .pinout__group--bottom .pin:hover::before { width: 3px; height: 22px; }
  .pinout__group--bottom li:nth-child(even) .pin[aria-pressed="true"]::before, .pinout__group--bottom li:nth-child(even) .pin:hover::before { height: 62px; }
  .chip {
    grid-area: chip; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 0.35rem;
    margin-top: 2rem; padding: clamp(1.25rem, 2.4vw, 2.25rem); background: var(--graphite); color: var(--paper);
    clip-path: polygon(44px 0, 100% 0, 100% 100%, 0 100%, 0 44px); position: relative;
  }
  .chip::before { content: ""; position: absolute; left: 22px; top: 62px; width: 10px; height: 10px; border-radius: 50%; background: var(--emerald); }
  .chip__mark { font-size: clamp(4rem, 8vw, 8rem); font-weight: 800; line-height: 0.8; letter-spacing: -0.04em; font-variation-settings: "wght" 800, "wdth" 125; color: var(--mint); margin-bottom: 0.25em; }
  .chip__name { font-weight: 700; }
  .chip__role { color: var(--muted-dark); font-size: 0.9rem; }
}

/* horizontal pillars: desktop, scripted, enough height */
@media (min-width: 900px) and (min-height: 560px) {
  .is-enhanced .pillars { height: 380svh; padding-top: 0; }
  .is-enhanced .pillars__pin { position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column; overflow: clip; }
  .is-enhanced .pillars__top { padding-top: calc(var(--header-h) + var(--cut) * 0.35); flex: none; position: relative; z-index: 2; }
  .is-enhanced .pillars__tabs { display: flex; }
  .is-enhanced .pillars__track { display: flex; flex: 1; min-height: 0; will-change: transform; }
  .is-enhanced .pillar { flex: 0 0 100vw; border: 0; padding: 0 0 clamp(1.5rem, 6svh, 4.5rem); display: flex; flex-direction: column; justify-content: flex-end; overflow: visible; }
  .is-enhanced .pillar__word { position: absolute; left: 0; top: 0; margin: 0 0 0 var(--edge); font-size: min(12vw, 42svh); will-change: transform; }
  .is-enhanced .pillar__body { position: relative; z-index: 1; }
  .is-enhanced .pillar__list li { padding: clamp(0.5rem, 1.5svh, 0.85rem) 0; }
}

@media (max-width: 899px), (max-height: 559px) {
  .head__nav, .head__cta { display: none; }
  .head__menu { display: block; }
  .rail { left: 0; top: 0; bottom: 0; width: 2px; }
  .rail__track { left: 0; width: 2px; background: none; }
  .rail__fill { left: 0; }
  .rail__ticks, .rail__label { display: none; }
  .cursor, .peek { display: none; }

  .is-enhanced .hero { height: 300svh; }

  .stats { grid-template-columns: 1fr 1fr; row-gap: 2.25rem; }
  .stat--wide { grid-column: 1 / -1; }
  .stat__num { font-size: clamp(2.4rem, 11vw, 4.5rem); }

  .mission__cols, .pillar__body, .toolkit__head, .contact__grid, .story__grid { grid-template-columns: 1fr; }
  .mission__body, .pillar__list { grid-column: auto; }
  .mission__cols { row-gap: 2.5rem; }
  .mission__list { order: 2; }

  .story__side { position: static; grid-template-columns: auto 1fr; align-items: end; column-gap: 1.25rem; margin-bottom: 2.5rem; }
  .story__side h2 { grid-column: 1 / -1; }
  .story__portrait { height: auto; width: min(38vw, 190px); }
  .route { align-self: end; }

  .pindesc { grid-template-columns: 1fr; }
  .toolkit__extra div { grid-template-columns: 1fr; row-gap: 0.2rem; }

  .case__grid { grid-template-columns: 1fr; row-gap: 1.25rem; align-content: start; }
  .case__stage { order: -1; width: min(100%, 44svh); }
  .has-case .case__pin { align-items: flex-start; }
  .has-case .case__context, .has-case .case__stack { display: none; }
  .has-case .case__step:not(.is-active) { display: none; }
  .has-case .case__step { border: 0; }
  .has-case .case__steps { border: 0; }
  .has-case .case__label::after { content: attr(data-n); margin-left: auto; font-weight: 500; color: var(--muted); font-size: 0.86em; }
  .has-case .case__text h3 { font-size: clamp(1.15rem, 3.4svh, 1.6rem); }
  .has-case .case.has-step .case__text h3 { display: none; }
  .pillar__word { font-size: clamp(3.25rem, 19vw, 9rem); font-variation-settings: "wght" 800, "wdth" 72; }
  .has-case .case__note p { padding-left: 0; }
  .has-case .result { margin-left: 0; width: 100%; }

  .row__btn { grid-template-columns: 1fr 24px; row-gap: 0.4rem; }
  .row__ctx { grid-column: 1; grid-row: 2; }
  .row__icon { grid-row: 1 / span 2; }
  .row__inner { grid-template-columns: 1fr; }
  .row__img { justify-self: start; width: min(100%, 260px); }

  .foot__grid { grid-template-columns: 1fr 1fr; }
  .foot__id { grid-column: 1 / -1; }
}

@media (max-width: 599px) {
  .stats { grid-template-columns: 1fr; }
  .mission__list div { grid-template-columns: 6.5rem 1fr; }
  .hero__actions .btn { flex: 1 1 auto; padding: 0 1rem; }
  .contact__actions { flex-direction: column; align-items: stretch; width: 100%; }
  .contact__reach { justify-items: stretch; }
  .has-stage .hero__lead { font-size: 1.05rem; }
}

@media (max-width: 760px), (max-width: 1000px) and (min-height: 560px) {
  .has-stage .hero__foot { grid-template-columns: 1fr; gap: 0.9rem; align-items: start; }
  .has-stage .hero__readout { grid-auto-flow: column; justify-content: start; gap: 1rem; min-width: 0; order: 3; }
  .has-stage .hero__cue { display: none; }
}
@media (max-height: 559px) and (min-width: 761px) {
  .has-stage .hero__readout, .has-stage .hero__role { display: none; }
  .has-stage .hero__foot { padding-bottom: 10px; }
  .has-stage .hero__actions .btn { min-height: 44px; }
  .has-stage .hero__lead { font-size: 1rem; }
}

/* very wide screens: keep the rail close to the content column */
@media (min-width: 1760px) {
  .rail { left: calc((100vw - var(--maxw)) / 2 + 30px); }
}

@media (hover: none), (pointer: coarse) {
  .cursor, .peek { display: none; }
}

/* 11. Reduced motion ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .cursor, .peek { display: none; }
  .btn::before, .row__panel, .head, .case__note { transition: none !important; }
  .loader { display: none; }
}
