/* ==========================================================================
   Nick Williams — flagship portfolio
   Modern CSS throughout: light-dark(), color-mix(), container queries,
   @property, :has(), scroll-driven animations and view transitions.
   Everything animated degrades to a static page (see the reduced-motion and
   @supports blocks at the bottom).
   ========================================================================== */

/* ---------- Tokens ---------- */
@property --angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

:root {
  color-scheme: dark;

  --bg:        light-dark(#F4F1EA, #08090B);
  --bg-2:      light-dark(#ECE7DC, #0D0F13);
  --surface:   light-dark(#FFFFFF, #12141A);
  --surface-2: light-dark(#F8F5EE, #181B22);
  --line:      light-dark(#DAD3C3, #22252D);
  --line-2:    light-dark(#BDB5A2, #343844);
  --text:      light-dark(#14161A, #F2EFE8);
  --text-2:    light-dark(#4A4F57, #B4B0A6);
  --text-3:    light-dark(#6E737B, #7D8189);

  --accent:     light-dark(#C2540A, #FF7A1A);
  --accent-ink: light-dark(#FFFFFF, #130C05);

  --it:   light-dark(#2F5D7C, #5BB0FF);
  --road: light-dark(#C2540A, #FF8A3D);
  --biz:  light-dark(#3F6B4F, #4FE0A0);
  --side: light-dark(#6A4FA3, #B592FF);

  --font-head: "Space Grotesk", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --gutter: clamp(20px, 4vw, 52px);
  --max: 1280px;
  --radius: 22px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

/* Browsers without light-dark(): plain dark tokens, light overrides below */
@supports not (color: light-dark(#000, #fff)) {
  :root {
    --bg: #08090B; --bg-2: #0D0F13; --surface: #12141A; --surface-2: #181B22;
    --line: #22252D; --line-2: #343844; --text: #F2EFE8; --text-2: #B4B0A6; --text-3: #7D8189;
    --accent: #FF7A1A; --accent-ink: #130C05;
    --it: #5BB0FF; --road: #FF8A3D; --biz: #4FE0A0; --side: #B592FF;
  }
  :root[data-theme="light"] {
    --bg: #F4F1EA; --bg-2: #ECE7DC; --surface: #FFFFFF; --surface-2: #F8F5EE;
    --line: #DAD3C3; --line-2: #BDB5A2; --text: #14161A; --text-2: #4A4F57; --text-3: #6E737B;
    --accent: #C2540A; --accent-ink: #FFFFFF;
    --it: #2F5D7C; --road: #C2540A; --biz: #3F6B4F; --side: #6A4FA3;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 96px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-2);
  font: 400 clamp(16px, 1.05vw, 17.5px)/1.65 var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.03em;
  color: var(--text);
  text-wrap: balance;
}
p { margin: 0; text-wrap: pretty; }
ul { list-style: none; margin: 0; padding: 0; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.wrap { width: min(100% - var(--gutter) * 2, var(--max)); margin-inline: auto; }
.mono { font-family: var(--font-mono); }
.skip {
  position: fixed; left: 16px; top: -60px; z-index: 300;
  padding: 10px 16px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
  transition: top .2s var(--ease);
}
.skip:focus { top: 16px; }

kbd {
  font: 500 11px/1 var(--font-mono);
  padding: 4px 6px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 6px;
  color: var(--text-2);
  background: color-mix(in oklab, var(--surface) 70%, transparent);
}

/* Page transitions between documents (home, blog, posts) */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: fade-out .25s ease both; }
::view-transition-new(root) { animation: fade-in .35s ease .05s both; }
@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }

/* Scroll progress (scroll-driven; JS fallback sets --p) */
.progress {
  position: fixed; inset: 0 0 auto 0; z-index: 120; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--it));
  transform-origin: 0 50%;
  transform: scaleX(var(--p, 0));
}
@supports (animation-timeline: scroll()) {
  .progress { transform: scaleX(0); animation: grow-x linear both; animation-timeline: scroll(root); }
}
@keyframes grow-x { to { transform: scaleX(1); } }

/* ---------- Buttons ---------- */
.btn {
  --h: 52px;
  position: relative; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: var(--h); padding: 0 26px;
  border: 1px solid transparent; border-radius: 999px;
  font: 500 15.5px/1 var(--font-body);
  cursor: pointer; white-space: nowrap;
  transition: translate .45s var(--ease), background-color .25s, border-color .25s, color .25s;
}
.btn svg { width: 17px; height: 17px; transition: transform .35s var(--ease); }
.btn:hover svg { transform: translateX(3px); }
.btn-sm { --h: 40px; padding: 0 18px; font-size: 14px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in oklab, var(--accent), var(--text) 14%); }
.btn-ghost { border-color: var(--line-2); color: var(--text); background: color-mix(in oklab, var(--surface) 55%, transparent); backdrop-filter: blur(8px); }
.btn-ghost:hover { border-color: var(--text); }

/* Rotating light around a button (registered @property angle) */
.btn-glow::before {
  content: ""; position: absolute; inset: -2px; z-index: -1; border-radius: inherit; padding: 2px;
  background: conic-gradient(from var(--angle), transparent 0 55%, var(--accent) 78%, color-mix(in oklab, var(--accent), white 50%) 86%, transparent 94%);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude; -webkit-mask-composite: xor;
  animation: spin 3.6s linear infinite;
}
@keyframes spin { to { --angle: 360deg; } }

.icon-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px; background: transparent; cursor: pointer;
  color: var(--text-2); transition: border-color .2s, color .2s, background-color .2s;
}
.icon-btn:hover { border-color: var(--line-2); color: var(--text); background: color-mix(in oklab, var(--surface) 70%, transparent); }
.icon-btn svg { width: 17px; height: 17px; flex: none; }
.icon-btn .label { font-size: 13.5px; }
[data-theme-toggle] { width: 40px; padding: 0; justify-content: center; }
[data-theme-toggle] .sun { display: none; }
:root[data-theme="light"] [data-theme-toggle] .sun { display: block; }
:root[data-theme="light"] [data-theme-toggle] .moon { display: none; }

/* ---------- Navigation ---------- */
.nav {
  position: fixed; z-index: 100; top: 14px; left: 50%; translate: -50% 0;
  width: min(100% - 24px, 920px);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 8px 7px 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: color-mix(in oklab, var(--bg) 62%, transparent);
  backdrop-filter: blur(18px) saturate(1.6);
  box-shadow: 0 10px 40px -18px rgb(0 0 0 / .55);
  view-transition-name: site-nav;
  transition: background-color .3s, box-shadow .3s;
}
.nav.scrolled { background: color-mix(in oklab, var(--bg) 82%, transparent); }
.nav-brand { display: inline-flex; align-items: center; gap: 10px; font: 600 15.5px var(--font-head); color: var(--text); letter-spacing: -.01em; }
.mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font: 700 12px var(--font-head); letter-spacing: 0;
}
.nav-links { display: flex; gap: 4px; }
.nav-links a { padding: 8px 14px; border-radius: 999px; font-size: 14.5px; color: var(--text-2); transition: color .2s, background-color .2s; }
.nav-links a:hover { color: var(--text); background: color-mix(in oklab, var(--surface) 80%, transparent); }
.nav-tools { display: flex; align-items: center; gap: 8px; }

/* ---------- Hero ---------- */
.hero {
  position: relative; isolation: isolate;
  min-height: 100svh;
  display: grid; grid-template-rows: 1fr auto;
  padding-top: 120px;
  overflow: clip;
}
/* One fixed background layer behind the whole page (the shader, or a CSS pattern if WebGL2 is missing) */
.bg-fx { position: fixed; top: 0; left: 0; width: 100%; height: 100vh; height: 100lvh; z-index: -1; pointer-events: none; transition: opacity .4s; }
.hero-canvas, .hero-fallback { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-fallback {
  background:
    radial-gradient(60% 50% at 75% 20%, color-mix(in oklab, var(--accent) 22%, transparent), transparent 70%),
    repeating-radial-gradient(circle at 70% 25%, transparent 0 26px, color-mix(in oklab, var(--accent) 16%, transparent) 27px 28px);
}
body:has(.prose) .bg-fx { opacity: .4; } /* keep long-form reading calm */
.hero-inner { align-self: end; padding-bottom: clamp(36px, 7vh, 72px); }
.pill {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 9px 18px 9px 14px; margin-bottom: clamp(22px, 4vh, 38px);
  border: 1px solid var(--line-2); border-radius: 999px;
  background: color-mix(in oklab, var(--surface) 55%, transparent); backdrop-filter: blur(10px);
  font: 500 12.5px/1 var(--font-mono); letter-spacing: .04em; color: var(--text-2);
}
.dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.dot::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--accent); animation: ping 2.2s ease-out infinite; }
@keyframes ping { to { transform: scale(3.2); opacity: 0; } }

.hero h1 {
  font-size: clamp(2.7rem, 8.4vw, 8.2rem);
  line-height: .93; letter-spacing: -.045em; font-weight: 600;
  max-width: 14ch;
}
.hero h1 .hl { color: var(--accent); }
.hero h1 .ol { color: transparent; -webkit-text-stroke: 1.5px color-mix(in oklab, var(--text) 85%, transparent); }
.w { display: inline-block; overflow: clip; vertical-align: top; padding-bottom: .08em; margin-bottom: -.08em; }
.w > span { display: inline-block; }
.js .w > span { transform: translateY(112%); animation: rise 1s var(--ease) forwards; animation-delay: calc(.15s + var(--i) * .07s); }
@keyframes rise { to { transform: none; } }

.hero-bottom { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: clamp(28px, 5vw, 80px); align-items: end; margin-top: clamp(28px, 5vh, 52px); }
.lede { font-size: clamp(1.02rem, 1.35vw, 1.22rem); color: var(--text-2); max-width: 52ch; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line-2); }
.stat { padding: 18px 0 0; }
.stat + .stat { padding-left: clamp(14px, 2vw, 26px); border-left: 1px solid var(--line); }
.stat .num { font: 600 clamp(2rem, 4.2vw, 3.6rem)/1 var(--font-head); letter-spacing: -.04em; color: var(--text); font-variant-numeric: tabular-nums; }
.stat .num sup { font-size: .45em; color: var(--accent); margin-left: 2px; vertical-align: top; position: relative; top: .35em; }
.stat .lbl { margin-top: 8px; font: 500 11.5px/1.4 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }

/* ---------- Marquee ---------- */
.marquee { border-block: 1px solid var(--line); background: color-mix(in oklab, var(--bg-2) 72%, transparent); backdrop-filter: blur(6px); overflow: clip; mask: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent); }
.marquee-track { display: flex; width: max-content; animation: marquee 48s linear infinite; }
.marquee:hover .marquee-track { animation-play-state: paused; }
.mq-item { display: inline-flex; align-items: center; gap: 14px; padding: 18px 22px; font: 500 13.5px/1 var(--font-mono); letter-spacing: .05em; text-transform: uppercase; color: var(--text-2); white-space: nowrap; }
.mq-item::before { content: ""; width: 7px; height: 7px; rotate: 45deg; background: var(--c, var(--accent)); }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Sections ---------- */
.section { padding-block: clamp(72px, 12vw, 160px); }
.section-head { display: grid; gap: 18px; margin-bottom: clamp(44px, 7vw, 88px); max-width: 880px; }
.eyebrow { font: 500 12.5px/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.section-head h2 { font-size: clamp(2.2rem, 5.6vw, 5rem); letter-spacing: -.04em; line-height: .98; }
.section-head p { font-size: 1.1rem; max-width: 56ch; }

/* ---------- Work: bento ---------- */
.chapter { --c: var(--accent); margin-top: clamp(56px, 8vw, 112px); }
.chapter:first-of-type { margin-top: 0; }
.g-it { --c: var(--it); } .g-road { --c: var(--road); } .g-biz { --c: var(--biz); } .g-side { --c: var(--side); }
.chapter-head { display: flex; align-items: flex-end; gap: clamp(16px, 3vw, 36px); margin-bottom: 26px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.chap-num { font: 600 clamp(3.6rem, 9vw, 8rem)/.8 var(--font-head); letter-spacing: -.06em; color: transparent; -webkit-text-stroke: 1.5px var(--c); }
.chapter-head h3 { font-size: clamp(1.4rem, 2.6vw, 2.2rem); letter-spacing: -.03em; }
.chapter-head p { margin-top: 8px; font: 500 12.5px/1.4 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--c); }

.bento { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.cell { container-type: inline-size; grid-column: span 4; min-width: 0; }
.s5 { grid-column: span 5; } .s6 { grid-column: span 6; } .s7 { grid-column: span 7; } .s8 { grid-column: span 8; } .s12 { grid-column: span 12; }

.card {
  --mx: 50%; --my: 0%; --rx: 0deg; --ry: 0deg;
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; height: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  transform: perspective(1000px) rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform .5s var(--ease), border-color .3s, opacity .4s, filter .4s, box-shadow .4s;
  will-change: transform;
}
.card::before { /* cursor spotlight */
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0;
  background: radial-gradient(420px circle at var(--mx) var(--my), color-mix(in oklab, var(--c) 22%, transparent), transparent 60%);
  transition: opacity .3s;
}
.card::after { /* cursor-lit border */
  content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none; border-radius: inherit; padding: 1px; opacity: 0;
  background: radial-gradient(320px circle at var(--mx) var(--my), var(--c), transparent 65%);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask-composite: exclude; -webkit-mask-composite: xor;
  transition: opacity .3s;
}
.card:hover { box-shadow: 0 30px 60px -30px color-mix(in oklab, var(--c) 45%, transparent); }
.card:hover::before, .card:hover::after { opacity: 1; }
.card.is-live { transition: transform .12s linear, border-color .3s, opacity .4s, filter .4s, box-shadow .4s; }

.card-media { position: relative; overflow: hidden; background: var(--bg-2); border-bottom: 1px solid var(--line); aspect-ratio: 16 / 10; }
.card-media img { width: 100%; height: 100%; object-fit: cover; object-position: top left; transition: transform .8s var(--ease); }
.card:hover .card-media img { transform: scale(1.05); }
.card-media::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, color-mix(in oklab, var(--surface) 40%, transparent), transparent 40%); }
.card-body { display: flex; flex-direction: column; gap: 10px; padding: clamp(20px, 2.2vw, 28px); }
.tag { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; font: 500 11.5px/1 var(--font-mono); letter-spacing: .09em; text-transform: uppercase; color: var(--c); }
.tag::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--c); }
.card h3 { font-size: clamp(1.2rem, 1.7vw, 1.5rem); letter-spacing: -.025em; line-height: 1.1; }
.card p { font-size: .98rem; color: var(--text-2); }
.cta { margin-top: auto; padding-top: 10px; display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--c); }
.cta svg { width: 17px; height: 17px; transition: transform .35s var(--ease); }
.card:hover .cta svg { transform: translate(4px, -3px); }

/* Wide cells lay their card out sideways, driven by the cell's own width */
@container (min-width: 640px) {
  .card { grid-template-columns: 1.15fr 1fr; }
  .card-media { aspect-ratio: auto; min-height: 280px; border-bottom: 0; border-right: 1px solid var(--line); }
  .card-body { justify-content: center; padding: clamp(28px, 3.6vw, 52px); }
  .card h3 { font-size: clamp(1.6rem, 2.6vw, 2.3rem); }
  .card p { font-size: 1.05rem; max-width: 42ch; }
}

/* Focus mode: dim the neighbours of the card under the cursor */
@media (hover: hover) {
  .bento:has(.card:hover) .card:not(:hover) { opacity: .5; filter: saturate(.6); }
}

/* Cards rest a little smaller and grow when the pointer is over them (mouse devices only).
   Uses the individual `scale` property so it composes with the tilt transform in main.js. */
@media (hover: hover) and (min-width: 761px) and (prefers-reduced-motion: no-preference) {
  .card {
    scale: .88;
    transition: transform .5s var(--ease), scale .45s var(--ease), border-color .3s, opacity .4s, filter .4s, box-shadow .4s;
  }
  .card.is-live {
    transition: transform .12s linear, scale .45s var(--ease), border-color .3s, opacity .4s, filter .4s, box-shadow .4s;
  }
  .card:hover, .card:focus-visible { scale: 1.04; }
  .cell { position: relative; }
  .cell:hover, .cell:focus-within { z-index: 5; }
}

/* ---------- About ---------- */
.about { background: color-mix(in oklab, var(--bg-2) 62%, transparent); border-block: 1px solid var(--line); }
.about-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: clamp(36px, 7vw, 110px); align-items: start; }
.about-intro { position: sticky; top: 120px; display: grid; gap: 30px; }
.about-intro .section-head { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 9px 15px; border: 1px solid var(--line-2); border-radius: 999px; font: 500 12.5px/1 var(--font-mono); letter-spacing: .03em; color: var(--text-2); background: var(--surface); }
.photo {
  display: grid; place-items: center; text-align: center; padding: 24px; aspect-ratio: 4 / 3;
  border: 1px dashed var(--line-2); border-radius: var(--radius);
  background: repeating-linear-gradient(135deg, transparent 0 14px, color-mix(in oklab, var(--line) 60%, transparent) 14px 15px);
  font: 500 12.5px/1.5 var(--font-mono); color: var(--text-3); letter-spacing: .04em;
}

.timeline { position: relative; display: grid; gap: clamp(40px, 7vw, 88px); padding-left: clamp(34px, 5vw, 64px); }
.rail { position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: var(--line-2); border-radius: 2px; }
.rail-fill { position: absolute; inset: 0; background: linear-gradient(to bottom, var(--it), var(--accent)); border-radius: inherit; transform-origin: top; }
@supports (animation-timeline: view()) {
  .rail-fill { transform: scaleY(0); animation: grow-y linear both; animation-timeline: view(); animation-range: entry 35% cover 75%; }
}
@keyframes grow-y { to { transform: scaleY(1); } }
.step { position: relative; }
.step::before { content: ""; position: absolute; left: calc(clamp(34px, 5vw, 64px) * -1 + 1px); top: 10px; width: 14px; height: 14px; border-radius: 50%; background: var(--bg-2); border: 2px solid var(--accent); }
.step-meta { font: 500 12.5px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin-bottom: 14px; }
.step h3 { font-size: clamp(1.7rem, 3.4vw, 2.8rem); letter-spacing: -.035em; margin-bottom: 14px; }
.step p { max-width: 52ch; }
.about-actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---------- Blog rows ---------- */
.posts { border-top: 1px solid var(--line-2); }
.post-row {
  position: relative; isolation: isolate;
  display: grid; grid-template-columns: minmax(120px, .28fr) minmax(0, 1fr) auto; gap: clamp(14px, 3vw, 44px); align-items: center;
  padding: clamp(22px, 3vw, 36px) clamp(4px, 1vw, 12px);
  border-bottom: 1px solid var(--line-2);
  transition: padding-inline .45s var(--ease);
}
.post-row { background: color-mix(in oklab, var(--bg) 58%, transparent); }
.post-row::before { content: ""; position: absolute; inset: 0; z-index: -1; background: color-mix(in oklab, var(--accent) 9%, transparent); transform: scaleY(0); transform-origin: bottom; transition: transform .45s var(--ease); }
.post-row:hover, .post-row:focus-visible { padding-inline: clamp(14px, 2vw, 28px); }
.post-row:hover::before, .post-row:focus-visible::before { transform: scaleY(1); }
.post-meta { font: 500 12px/1.6 var(--font-mono); letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); }
.post-meta b { display: block; font-weight: 500; color: var(--accent); }
.post-row h3 { font-size: clamp(1.3rem, 2.8vw, 2.3rem); letter-spacing: -.035em; line-height: 1.08; }
.post-row p { margin-top: 8px; max-width: 58ch; font-size: .98rem; }
.post-arrow { width: clamp(38px, 4vw, 54px); aspect-ratio: 1; display: grid; place-items: center; border: 1px solid var(--line-2); border-radius: 50%; color: var(--text); transition: background-color .3s, color .3s, rotate .45s var(--ease), border-color .3s; }
.post-arrow svg { width: 40%; }
.post-row:hover .post-arrow { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); rotate: -45deg; }
.section-link { display: inline-flex; align-items: center; gap: 8px; margin-top: 32px; font-weight: 500; color: var(--text); }
.section-link svg { width: 17px; transition: transform .35s var(--ease); }
.section-link:hover svg { transform: translateX(4px); }
.empty-state { padding: 40px 0; color: var(--text-3); }

/* ---------- Contact band ---------- */
.contact { position: relative; isolation: isolate; overflow: clip; text-align: center; border-top: 1px solid var(--line); }
.contact::before { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(50% 70% at 50% 100%, color-mix(in oklab, var(--accent) 28%, transparent), transparent 70%); }
.contact h2 { font-size: clamp(2.4rem, 8vw, 7.4rem); letter-spacing: -.05em; line-height: .94; max-width: 14ch; margin-inline: auto; }
.contact p { margin: 26px auto 38px; max-width: 46ch; font-size: 1.1rem; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); padding-block: 34px 44px; font-size: 14px; color: var(--text-3); }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 28px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 22px; }
.footer-links a { color: var(--text-2); transition: color .2s; }
.footer-links a:hover { color: var(--accent); }
.footer .hint { font-family: var(--font-mono); font-size: 12px; letter-spacing: .04em; }

/* ---------- Command palette ---------- */
.palette { border: 0; padding: 0; background: transparent; color: var(--text); width: min(680px, calc(100% - 24px)); margin: 12vh auto auto; max-height: 76vh; overflow: visible; }
.palette::backdrop { background: color-mix(in oklab, black 48%, transparent); backdrop-filter: blur(8px) saturate(1.2); animation: fade-in .2s ease both; }
.palette[open] .pal-box { animation: pop .3s var(--ease) both; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.97); } }
.pal-box { display: flex; flex-direction: column; max-height: 76vh; background: var(--surface); border: 1px solid var(--line-2); border-radius: 20px; box-shadow: 0 40px 100px -20px rgb(0 0 0 / .7); overflow: hidden; }
.pal-input { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.pal-input svg { width: 20px; height: 20px; color: var(--text-3); flex: none; }
.pal-input input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font: 400 1.1rem var(--font-body); color: var(--text); }
.pal-input input::placeholder { color: var(--text-3); }
#pal-list { overflow-y: auto; padding: 8px; overscroll-behavior: contain; }
.pal-group { padding: 12px 12px 6px; font: 500 11px/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); }
.pal-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; cursor: pointer; }
.pal-item i { width: 8px; height: 8px; border-radius: 2px; background: var(--c, var(--accent)); }
.pal-item b { display: block; font-weight: 500; color: var(--text); line-height: 1.3; }
.pal-item small { display: block; font-size: 13px; color: var(--text-3); line-height: 1.4; }
.pal-item .go { font: 500 11px var(--font-mono); color: var(--text-3); opacity: 0; }
.pal-item[aria-selected="true"] { background: var(--surface-2); outline: 1px solid var(--line-2); }
.pal-item[aria-selected="true"] .go { opacity: 1; }
.pal-empty { padding: 28px; text-align: center; color: var(--text-3); }
.pal-foot { display: flex; gap: 18px; padding: 11px 18px; border-top: 1px solid var(--line); font: 500 11.5px var(--font-mono); color: var(--text-3); }

/* ---------- Reveal on scroll ---------- */
.js .reveal { opacity: 0; transform: translateY(34px); transition: opacity .9s var(--ease), transform .9s var(--ease); transition-delay: calc(var(--d, 0) * 90ms); }
.js .reveal.in { opacity: 1; transform: none; }

/* ---------- Blog + post pages ---------- */
.page-hero { padding: clamp(130px, 18vw, 220px) 0 clamp(36px, 6vw, 72px); position: relative; isolation: isolate; }
.page-hero::before { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(60% 80% at 80% 0%, color-mix(in oklab, var(--accent) 18%, transparent), transparent 70%); }
.page-hero h1 { font-size: clamp(2.6rem, 8vw, 7rem); letter-spacing: -.045em; line-height: .95; max-width: 14ch; margin-top: 18px; }
.page-hero p { margin-top: 22px; max-width: 54ch; font-size: 1.12rem; }
.post-head { padding: clamp(130px, 16vw, 200px) 0 36px; }
.post-head h1 { font-size: clamp(2.2rem, 6.4vw, 5.2rem); letter-spacing: -.045em; line-height: .98; max-width: 18ch; margin-top: 16px; }
.post-info { font: 500 12.5px/1.6 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.post-info b { color: var(--accent); font-weight: 500; }
.back { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text-2); margin-bottom: 28px; }
.back:hover { color: var(--accent); }
.prose { width: min(100% - var(--gutter) * 2, var(--max)); margin: 0 auto; padding-bottom: clamp(70px, 10vw, 140px); font-size: 1.1rem; color: var(--text-2); }
.prose > * { max-width: 720px; }
.prose p { margin-bottom: 1.35em; }
.prose h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); margin: 2.2em 0 .7em; }
.prose h3 { font-size: 1.35rem; margin: 1.8em 0 .6em; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.prose ul, .prose ol { margin: 0 0 1.35em; padding-left: 1.3em; list-style: revert; }
.prose li { margin-bottom: .5em; }
.prose blockquote { margin: 1.6em 0; padding: 4px 0 4px 22px; border-left: 3px solid var(--accent); color: var(--text); font-style: italic; }
.prose code { padding: 2px 7px; border-radius: 6px; background: var(--surface-2); font: .9em var(--font-mono); }
.prose pre { padding: 20px; margin: 0 0 1.35em; overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.prose pre code { padding: 0; background: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
  /* Flex-wrap so a lone card on the last row stretches to fill it */
  .bento { display: flex; flex-wrap: wrap; }
  .cell { grid-column: auto; flex: 1 1 calc(50% - 8px); }
  .s7, .s8, .s12 { flex-basis: 100%; }
  .about-grid { grid-template-columns: 1fr; }
  .about-intro { position: static; }
  .hero-bottom { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .nav-links, .nav .btn, .icon-btn .label, .icon-btn kbd { display: none; }
  .nav { padding-right: 8px; }
  .icon-btn.kbd-btn { width: 40px; padding: 0; justify-content: center; }
  .cell, .s7, .s8, .s12 { flex-basis: 100%; }
  .post-row { grid-template-columns: 1fr auto; }
  .post-meta { grid-column: 1 / -1; display: flex; gap: 12px; }
  .post-meta b { display: inline; }
  .chapter-head { align-items: center; }
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .marquee-track { animation: none; flex-wrap: wrap; width: auto; }
  .js .reveal { opacity: 1; transform: none; }
  .js .w > span { transform: none; }
  .card { transform: none !important; }
}
