/* ════════════════════════════════════════════════════════════════
   Ben Crow — portfolio · "night route", roost edition
   The page continues the hero shader: a real indigo night, a pale
   periwinkle glow, and coral used only as the glint (now, focus,
   the agent). Crow plumage is iridescent, so a blue-teal-violet
   sheen shows only where light would catch it: hover, focus and
   the present. One bold element — the career route, with a crow
   that flies it as you scroll — and everything else quiet.

   Type: Familjen Grotesk for names and navigation, Literata for
   reading, Fira Code only for the hero prompt and code.

   Progressive enhancement is unchanged: view transitions, anchor
   positioning, scroll-state() and scroll timelines are all gated
   with @supports; the site is fully usable without them.
   ════════════════════════════════════════════════════════════════ */

/* ── Registered custom properties (no-ops where unsupported) ── */
@property --hero-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 135deg;
}
@property --hero-x {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 72%;
}
@property --hero-y {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 24%;
}

/* ── Design tokens ─────────────────────────────────────────────
   Follows <meta name="color-scheme"> ("light dark", "light", "dark")
   using CSS color-scheme + light-dark(), with a prefers-color-scheme
   fallback for browsers without light-dark(). Zero JS dependency:
   if JS never runs, the site follows the system preference. */
:root {
  /* brand primitives (theme-independent) */
  --coral: #f95f5b; /* the glint */
  --indigo: #0a2463; /* hero shader indigo */
  --indigo-bright: #3d63c0;
  --indigo-deep: #101b3e;
  --ink: #0d0221; /* hero shader ink */

  /* fixed night tokens (chat panel / tooltips / code blocks stay dark in both themes) */
  --d-bg: #151739;
  --d-surface: #1d2049;
  --d-surface-2: #262956;
  --d-text: #eceef9;
  --d-muted: #a3a9c5;
  --d-border: rgba(236, 238, 249, 0.13);

  /* daylight defaults (fallback for browsers without light-dark()) */
  --bg: #f3f6fd;
  --surface: #e8ecf9;
  --surface-2: #dde3f5;
  --tint: #e8ecf9;
  --text: #16193e;
  --text-2: #2d3254;
  --muted: #535977;
  --border: #cad0e5;
  --accent: #3c54a3; /* periwinkle glow, darkened for daylight */
  --accent-2: #535977;
  --coral-text: #ba3535;
  --trail: #7f90cf;
  --focus-ring: rgba(249, 95, 91, 0.45);
  /* crow plumage: the sheen light catches on hover, focus and the present */
  --sheen-1: #3044c9;
  --sheen-2: #0e7470;
  --sheen-3: #6a39c2;
  --crow: #141629;
  --moon-opacity: 0;

  /* hero (CSS fallback gradient + scrim) */
  --hero-a: #f3f6fd;
  --hero-b: #c9d4f2;
  --scrim-base: #f3f6fd;

  /* legacy aliases still referenced by writing.css / ask-ben.js */
  --nav-bg: var(--bg);
  --card-bg: var(--surface);
  --chip-bg: var(--surface);
  --section-bg: var(--bg);
  --section-deep: var(--surface);
  --footer-bg: var(--bg);
  --contrast: var(--coral);
  --text-muted: var(--muted);

  /* typography */
  --font-display: "Familjen Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Literata", "Iowan Old Style", Georgia, serif;
  --font-sans: var(--font-display);
  --font-mono: "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* scale: 14 · 17/18 · 21 · 24 · 36 · 48 · hero */
  --step--1: clamp(0.82rem, 0.8rem + 0.1vw, 0.875rem);
  --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  --step-1: clamp(1.15rem, 1.07rem + 0.35vw, 1.3125rem);
  --step-2: clamp(1.3rem, 1.17rem + 0.55vw, 1.5rem);
  --step-3: clamp(1.75rem, 1.45rem + 1.3vw, 2.25rem);
  --step-4: clamp(2.25rem, 1.75rem + 2.2vw, 3rem);
  --step-5: clamp(2.9rem, 1.7rem + 6vw, 6rem);

  --nav-h: 60px;
  --gutter: clamp(1.25rem, 5vw, 3rem);
  --measure: 40rem;
  --radius: 14px;

  color-scheme: light dark;
  accent-color: var(--coral);
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) {
  color-scheme: dark;
}
:root:has(> head > meta[name="color-scheme"][content="light"]) {
  color-scheme: light;
}

/* Fallback palettes for browsers without light-dark() or CSS nesting */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151739;
    --surface: #1d2049;
    --surface-2: #262956;
    --tint: #1d2049;
    --text: #eceef9;
    --text-2: #cdd0e2;
    --muted: #a3a9c5;
    --border: #393e67;
    --accent: #acbaf5;
    --accent-2: #a3a9c5;
    --coral-text: var(--coral);
    --trail: #8696dc;
    --sheen-1: #6d7cff;
    --sheen-2: #3fd0c9;
    --sheen-3: #a77aff;
    --crow: #05060f;
    --moon-opacity: 0.9;
    --hero-a: var(--ink);
    --hero-b: var(--indigo);
    --scrim-base: var(--ink);
  }
}

@supports not (color: light-dark(white, black)) {
  :root:has(> head > meta[name="color-scheme"][content="light"]) {
    --bg: #f3f6fd;
    --surface: #e8ecf9;
    --surface-2: #dde3f5;
    --tint: #e8ecf9;
    --text: #16193e;
    --text-2: #2d3254;
    --muted: #535977;
    --border: #cad0e5;
    --accent: #3c54a3;
    --accent-2: #535977;
    --coral-text: #ba3535;
    --trail: #7f90cf;
    --sheen-1: #3044c9;
    --sheen-2: #0e7470;
    --sheen-3: #6a39c2;
    --crow: #141629;
    --moon-opacity: 0;
    --hero-a: #f3f6fd;
    --hero-b: #c9d4f2;
    --scrim-base: #f3f6fd;
  }

  :root:has(> head > meta[name="color-scheme"][content="dark"]) {
    --bg: #151739;
    --surface: #1d2049;
    --surface-2: #262956;
    --tint: #1d2049;
    --text: #eceef9;
    --text-2: #cdd0e2;
    --muted: #a3a9c5;
    --border: #393e67;
    --accent: #acbaf5;
    --accent-2: #a3a9c5;
    --coral-text: var(--coral);
    --trail: #8696dc;
    --sheen-1: #6d7cff;
    --sheen-2: #3fd0c9;
    --sheen-3: #a77aff;
    --crow: #05060f;
    --moon-opacity: 0.9;
    --hero-a: var(--ink);
    --hero-b: var(--indigo);
    --scrim-base: var(--ink);
  }
}

@supports (color: light-dark(white, black)) {
  :root {
    --bg: light-dark(#f3f6fd, #151739);
    --surface: light-dark(#e8ecf9, #1d2049);
    --surface-2: light-dark(#dde3f5, #262956);
    --tint: light-dark(#e8ecf9, #1d2049);
    --text: light-dark(#16193e, #eceef9);
    --text-2: light-dark(#2d3254, #cdd0e2);
    --muted: light-dark(#535977, #a3a9c5);
    --border: light-dark(#cad0e5, #393e67);
    --accent: light-dark(#3c54a3, #acbaf5);
    --accent-2: light-dark(#535977, #a3a9c5);
    --coral-text: light-dark(#ba3535, var(--coral));
    --trail: light-dark(#7f90cf, #8696dc);
    --sheen-1: light-dark(#3044c9, #6d7cff);
    --sheen-2: light-dark(#0e7470, #3fd0c9);
    --sheen-3: light-dark(#6a39c2, #a77aff);
    --crow: light-dark(#141629, #05060f);
    --hero-a: light-dark(#f3f6fd, var(--ink));
    --hero-b: light-dark(#c9d4f2, var(--indigo));
    --scrim-base: light-dark(#f3f6fd, var(--ink));
  }
  :root:has(> head > meta[name="color-scheme"][content="light"]) {
    --moon-opacity: 0;
  }
  :root:has(> head > meta[name="color-scheme"][content="dark"]) {
    --moon-opacity: 0.9;
  }
}

/* Iridescence: feature-detect oklch gradient interpolation so blue -> teal ->
   violet stays vivid without muddy sRGB midpoints. Each var() above stays a
   light-dark() token until used, resolving against the element's theme. */
:root {
  --in-oklch: ;
}
@supports (background: linear-gradient(in oklch, white, black)) {
  :root {
    --in-oklch: in oklch;
  }
}
:root {
  --sheen: linear-gradient(
    115deg var(--in-oklch),
    var(--sheen-1),
    var(--sheen-2) 50%,
    var(--sheen-3)
  );
  --ring: linear-gradient(var(--border), var(--border));
  --crow-perch-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M62 20C58.5 17.4 54.6 14.6 50.6 13.2C48.4 8.2 41.6 7.4 38.2 12C35 16.2 31.2 19.4 26.2 24.2C20.2 30.2 13.2 38.4 3 50L8.2 53L17.4 46.6C22.4 49.6 30.4 50.4 35.4 47.4C43.2 43.4 49 36.4 50 27.4C50.4 24.4 51 22.6 52.2 21.8Z'/%3E%3Cpath fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' d='M33.4 49L32.4 58M39.4 46.4L40.2 58M28.6 58.2H35.4M37 58.2H43.6'/%3E%3C/svg%3E");
}

/* ── Cross-document view transitions ──────────────────────────────
   Opt in with the standardized @view-transition at-rule; every
   same-origin page loads this stylesheet. */
@view-transition {
  navigation: auto;
}
@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.32s;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* The sticky nav is its own group so it stays put and cross-fades. */
::view-transition-group(site-nav) {
  animation-duration: 0.32s;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Writing titles morph between the home page, /writing/ and the
   article <h1>; one class tunes every one of those morphs. */
.writing-card :is(h3, h4),
.article-title,
.article-header h1 {
  view-transition-class: vt-title;
}
::view-transition-group(.vt-title) {
  animation-duration: 0.45s;
  animation-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

/* Directional slides from view-transitions.js (forwards / backwards). */
@media (prefers-reduced-motion: no-preference) {
  :root:active-view-transition-type(forwards)::view-transition-old(root) {
    animation: vt-exit-left 0.32s both cubic-bezier(0.4, 0, 0.2, 1);
  }
  :root:active-view-transition-type(forwards)::view-transition-new(root) {
    animation: vt-enter-right 0.36s both cubic-bezier(0.2, 0, 0.2, 1);
  }
  :root:active-view-transition-type(backwards)::view-transition-old(root) {
    animation: vt-exit-right 0.32s both cubic-bezier(0.4, 0, 0.2, 1);
  }
  :root:active-view-transition-type(backwards)::view-transition-new(root) {
    animation: vt-enter-left 0.36s both cubic-bezier(0.2, 0, 0.2, 1);
  }
}
@keyframes vt-exit-left {
  to {
    opacity: 0;
    transform: translateX(-2.5rem);
  }
}
@keyframes vt-enter-right {
  from {
    opacity: 0;
    transform: translateX(2.5rem);
  }
}
@keyframes vt-exit-right {
  to {
    opacity: 0;
    transform: translateX(2.5rem);
  }
}
@keyframes vt-enter-left {
  from {
    opacity: 0;
    transform: translateX(-2.5rem);
  }
}

/* ── Base ── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  font-family: var(--font-serif);
  font-size: var(--step-0);
  font-size-adjust: from-font;
  line-height: 1.65;
  font-optical-sizing: auto;
  background-color: var(--bg);
  color: var(--text);
  overflow-x: clip;
  transition: background-color 0.3s, color 0.3s;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-size-adjust: from-font;
  text-wrap: balance;
}
p {
  text-wrap: pretty;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover {
  color: var(--coral-text);
}
::selection {
  background: var(--coral);
  color: #fff;
}
:focus-visible {
  outline: 2px solid var(--coral-text);
  outline-offset: 3px;
}

[id] {
  scroll-margin-top: calc(var(--nav-h) + 16px);
}

main:focus {
  outline: none;
}

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link:is(:focus-visible, :active) {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 200;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  border: 2px solid var(--coral);
  font-family: var(--font-display);
  font-size: var(--step--1);
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(6, 4, 20, 0.35);
}

.wrap {
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ── Reading progress (scroll-driven; articles mostly) ── */
.scroll-progress {
  display: none;
}
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: scroll(root)) {
    .scroll-progress {
      display: block;
      position: fixed;
      inset: 0 0 auto 0;
      height: 2px;
      z-index: 99;
      background: var(--coral);
      transform-origin: 0 50%;
      animation: progress-grow linear both;
      animation-timeline: scroll(root);
      pointer-events: none;
    }
  }
}
@keyframes progress-grow {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

/* ── Hero ─────────────────────────────────────────────────────
   Unchanged composition. WebGL2 shader canvas (JS adds .webgl);
   the CSS fallback is an animated gradient. The scrim now fades
   into the page background so the night continues below. */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow: clip;
  text-align: center;
  color: var(--text);
  background:
    radial-gradient(80% 100% at var(--hero-x) var(--hero-y), rgba(61, 99, 192, 0.38), transparent 64%),
    radial-gradient(55% 70% at 18% 82%, rgba(254, 95, 85, 0.09), transparent 62%),
    linear-gradient(var(--hero-angle), var(--hero-a), var(--hero-b));
}
@media (prefers-reduced-motion: no-preference) {
  .hero {
    animation: hero-drift 32s ease-in-out infinite alternate;
  }
}
@keyframes hero-drift {
  to {
    --hero-angle: 210deg;
    --hero-x: 30%;
    --hero-y: 62%;
  }
}
.hero.webgl {
  animation: none;
}

.hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
}
.hero.webgl .hero-canvas {
  display: block;
}

.hero-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(78% 62% at 50% 52%, color-mix(in srgb, var(--scrim-base) 40%, transparent), transparent 72%),
    linear-gradient(
      to bottom,
      color-mix(in srgb, var(--scrim-base) 32%, transparent),
      transparent 30%,
      transparent 62%,
      color-mix(in srgb, var(--bg) 70%, transparent) 90%,
      var(--bg)
    );
}

.hero-content {
  position: relative;
  z-index: 1;
  padding: 2rem 1.25rem;
}
.hero h1 {
  margin: 0;
  font-size: var(--step-5);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1;
  text-shadow: 0 2px 24px color-mix(in srgb, var(--scrim-base) 45%, transparent);
}
.hero h1 em {
  font-style: normal;
  color: var(--coral-text);
}
@supports (background-clip: text) or (-webkit-background-clip: text) {
  .hero h1 em {
    color: transparent;
    background: var(--sheen);
    -webkit-background-clip: text;
    background-clip: text;
    text-shadow: none;
  }
}
.hero h2 {
  margin: 1.1rem 0 0;
  font-size: var(--step-2);
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--text);
  opacity: 0.94;
  text-shadow: 0 1px 16px color-mix(in srgb, var(--scrim-base) 45%, transparent);
}
.hero-prompt {
  margin: 2.4rem auto 0;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-size-adjust: from-font;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.hero-prompt .prompt-glyph {
  color: var(--coral);
}
.prompt-caret {
  display: inline-block;
  width: 0.55em;
  height: 1.05em;
  margin-left: 0.35em;
  background: var(--coral);
  vertical-align: text-bottom;
  opacity: 0.85;
}
@media (prefers-reduced-motion: no-preference) {
  .prompt-caret {
    animation: caret-blink 1.1s steps(2, jump-none) infinite;
  }
}
@keyframes caret-blink {
  50% {
    opacity: 0;
  }
}
.hero:is(.is-paused, .is-offscreen),
.hero:is(.is-paused, .is-offscreen) :is(.prompt-caret, .hero-flyer, .hero-flyer svg) {
  animation-play-state: paused;
}

/* The roost: a branch of crows along the bottom of the hero and a few
   more crossing the upper sky. Silhouettes in --crow; one eye holds the glint. */
.hero-roost {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.hero-branch {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: clamp(120px, 18.5vw, 250px);
  color: var(--crow);
}
.hero-moon {
  position: absolute;
  right: 15%;
  top: 14%;
  width: clamp(64px, 10vw, 124px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, #fff, #cdd5ff 62%);
  box-shadow: 0 0 70px 18px rgba(205, 213, 255, 0.32);
  opacity: var(--moon-opacity);
}
.hero-flyer {
  position: absolute;
  left: 0;
  color: var(--crow);
}
.hero-flyer svg {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: 50% 60%;
}
.hero-flyer.f1 {
  top: 16%;
  width: 40px;
  translate: 8vw 0;
  opacity: 0.72;
}
.hero-flyer.f2 {
  top: 22%;
  width: 28px;
  translate: 74vw 0;
  opacity: 0.58;
}
.hero-flyer.f3 {
  top: 10%;
  width: 22px;
  translate: 40vw 0;
  opacity: 0.45;
}
@media (prefers-reduced-motion: no-preference) {
  .hero-flyer {
    animation: crow-drift linear infinite;
  }
  .hero-flyer svg {
    animation: crow-flap 0.5s ease-in-out infinite alternate;
  }
  .hero-flyer.f1 {
    animation-duration: 28s;
    animation-delay: -4s;
  }
  .hero-flyer.f2 {
    animation-duration: 36s;
    animation-delay: -19s;
  }
  .hero-flyer.f3 {
    animation-duration: 44s;
    animation-delay: -30s;
  }
}
@keyframes crow-drift {
  from {
    translate: -80px 16px;
  }
  50% {
    translate: 55vw -10px;
  }
  to {
    translate: calc(100vw + 80px) 8px;
  }
}
@keyframes crow-flap {
  to {
    scale: 1 0.55;
  }
}

.hero-motion-toggle {
  position: absolute;
  right: var(--gutter);
  bottom: 1.5rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  min-block-size: 36px;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background-color 0.2s;
}
.hero-motion-toggle:hover,
.hero-motion-toggle:focus-visible {
  border-color: var(--coral);
  color: var(--text);
}
.hero-motion-toggle svg {
  width: 13px;
  height: 13px;
}
.hero-motion-toggle .icon-play {
  display: none;
}
.hero.is-paused .hero-motion-toggle .icon-pause {
  display: none;
}
.hero.is-paused .hero-motion-toggle .icon-play {
  display: block;
}
@media (prefers-reduced-motion: reduce) {
  .hero-motion-toggle {
    display: none;
  }
}

/* ── Nav ──────────────────────────────────────────────────────
   Sticky; picks up a translucent blur once stuck (scroll-state()),
   with an always-translucent fallback. */
nav {
  position: sticky;
  top: 0;
  z-index: 50;
  anchor-name: --navbar;
  view-transition-name: site-nav;
}

.nav-surface {
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  transition: background-color 0.3s;
}
@supports (container-type: scroll-state) {
  nav {
    container-type: scroll-state;
    container-name: navbar;
  }
  .nav-surface {
    background: var(--bg);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .contrast-bar {
    opacity: 0;
  }
  @container navbar scroll-state(stuck: top) {
    .nav-surface {
      background: color-mix(in srgb, var(--bg) 92%, transparent);
      -webkit-backdrop-filter: blur(14px) saturate(1.3);
      backdrop-filter: blur(14px) saturate(1.3);
    }
    .contrast-bar {
      opacity: 1;
    }
  }
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-h);
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
  position: relative;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}
.nav-brand:visited {
  color: var(--text);
}
.nav-brand::before {
  content: "";
  flex: none;
  width: 1.65rem;
  aspect-ratio: 1;
  margin-top: -0.2rem;
  background: currentColor;
  -webkit-mask: var(--crow-perch-mask) center / contain no-repeat;
  mask: var(--crow-perch-mask) center / contain no-repeat;
  forced-color-adjust: none;
}
.nav-brand:is(:hover, :focus-visible)::before {
  background: var(--sheen);
}

.nav-toggle {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px 6px;
  z-index: 11;
}
.nav-toggle .nav-toggle-bar {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--text);
  border-radius: 2px;
  transition: opacity 0.2s;
}
@media (prefers-reduced-motion: no-preference) {
  .nav-toggle .nav-toggle-bar {
    transition: transform 0.3s, opacity 0.3s;
  }
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Mobile menu — native popover where supported, .open fallback. */
.nav-links {
  display: none;
  flex-direction: column;
  align-items: stretch;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: var(--bg);
  padding: 0.5rem var(--gutter) 1.25rem;
  border-bottom: 1px solid var(--border);
}
.nav-links.open {
  display: flex;
}
@supports selector(:popover-open) {
  #nav-links[popover] {
    position: fixed;
    inset: auto 0 auto 0;
    top: var(--nav-h);
    top: anchor(--navbar bottom, var(--nav-h));
    width: 100%;
    margin: 0;
    border: 0;
    border-bottom: 1px solid var(--border);
    color: inherit;
    opacity: 0;
    transition-property: opacity, display, overlay;
    transition-duration: 0.2s;
    transition-timing-function: ease-out;
    transition-behavior: allow-discrete;
  }
  @media (prefers-reduced-motion: no-preference) {
    #nav-links[popover] {
      translate: 0 -0.5rem;
      transition-property: opacity, translate, display, overlay;
    }
  }
  @media (prefers-reduced-motion: reduce) {
    #nav-links[popover] {
      transition-duration: 0.1s;
    }
  }
  #nav-links:popover-open {
    display: flex;
    opacity: 1;
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    @starting-style {
      opacity: 0;
    }
  }
  @media (prefers-reduced-motion: no-preference) {
    #nav-links:popover-open {
      translate: 0 0;
      @starting-style {
        translate: 0 -0.5rem;
      }
    }
  }
  #nav-links::backdrop {
    background: rgba(6, 4, 20, 0);
    transition-property: background-color, display, overlay;
    transition-duration: 0.2s;
    transition-timing-function: ease-out;
    transition-behavior: allow-discrete;
  }
  #nav-links:popover-open::backdrop {
    background: rgba(6, 4, 20, 0.35);
    @starting-style {
      background: rgba(6, 4, 20, 0);
    }
  }
}

.nav-links a {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--text);
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
  transition: color 0.2s;
}
.nav-links a:first-child {
  border-top: 0;
}
.nav-links a:visited {
  color: var(--text);
}
.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--coral-text);
}
.nav-links a[aria-current="page"] {
  color: var(--coral-text);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.3em;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  margin: 0.75rem 0 0;
  transition: border-color 0.2s, color 0.2s;
}
.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: var(--coral);
  color: var(--coral-text);
}
.theme-toggle svg {
  width: 17px;
  height: 17px;
}
/* Icon shows the active <meta name="color-scheme"> state without JS dependency:
   system ("light dark", default), light (sun), or dark (moon). */
.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}
.theme-toggle .icon-system {
  display: block;
}
:root:has(> head > meta[name="color-scheme"][content="light"]) .theme-toggle .icon-sun {
  display: block;
}
:root:has(> head > meta[name="color-scheme"][content="light"]) .theme-toggle .icon-system {
  display: none;
}
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-toggle .icon-moon {
  display: block;
}
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-toggle .icon-system {
  display: none;
}

/* Hairline under the nav (appears once stuck where supported). */
.contrast-bar {
  height: 1px;
  background: var(--border);
  transition: opacity 0.3s;
}

/* Desktop nav + anchor-positioned hover indicator */
@media (min-width: 900px) {
  .nav-toggle {
    display: none;
  }
  .nav-links,
  #nav-links[popover] {
    display: flex;
    flex-direction: row;
    align-items: center;
    position: static;
    inset: auto;
    width: auto;
    opacity: 1;
    translate: none;
    transition: none;
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    padding: 0;
    border: 0;
    gap: 0.25rem;
  }
  .nav-links a {
    font-size: 0.98rem;
    padding: 0.5rem 0.8rem;
    border: 0;
  }
  .theme-toggle {
    margin: 0 0 0 0.75rem;
  }

  @supports (anchor-name: --a) {
    .nav-links {
      position: relative;
    }
    .nav-links > a:nth-of-type(1) {
      anchor-name: --nav-1;
    }
    .nav-links > a:nth-of-type(2) {
      anchor-name: --nav-2;
    }
    .nav-links > a:nth-of-type(3) {
      anchor-name: --nav-3;
    }
    .nav-links > a:nth-of-type(4) {
      anchor-name: --nav-4;
    }
    .nav-links::before {
      content: "";
      position: absolute;
      position-anchor: --nav-1;
      inset-block-start: calc(anchor(bottom) - 4px);
      inset-inline-start: calc(anchor(left) + 0.8rem);
      inset-inline-end: calc(anchor(right) + 0.8rem);
      block-size: 2px;
      background: var(--sheen);
      border-radius: 2px;
      opacity: 0;
      pointer-events: none;
    }
    @media (prefers-reduced-motion: no-preference) {
      .nav-links::before {
        transition: inset 0.25s, opacity 0.2s;
      }
    }
    .nav-links:has(> a:is(:hover, :focus-visible))::before {
      opacity: 1;
    }
    .nav-links:has(> a:nth-of-type(1):is(:hover, :focus-visible))::before {
      position-anchor: --nav-1;
    }
    .nav-links:has(> a:nth-of-type(2):is(:hover, :focus-visible))::before {
      position-anchor: --nav-2;
    }
    .nav-links:has(> a:nth-of-type(3):is(:hover, :focus-visible))::before {
      position-anchor: --nav-3;
    }
    .nav-links:has(> a:nth-of-type(4):is(:hover, :focus-visible))::before {
      position-anchor: --nav-4;
    }
  }
}

/* ── Sections ─────────────────────────────────────────────────── */
main > section {
  padding-block: clamp(4.5rem, 11vh, 8rem) 0;
}
main > section:last-child {
  padding-bottom: clamp(5rem, 14vh, 9rem);
}

.section-title {
  margin: 0 0 1.75rem;
  font-size: var(--step-4);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.05;
}
.section-tagline {
  margin: -0.75rem 0 2.75rem;
  max-width: var(--measure);
  font-size: var(--step-1);
  line-height: 1.5;
  color: var(--muted);
}
.sub-title {
  margin: 0 0 1.5rem;
  font-size: var(--step-2);
  font-weight: 650;
  letter-spacing: -0.02em;
}

/* ── About ── */
.intro-container {
  display: flex;
  flex-direction: column-reverse;
  gap: 1.75rem;
}
.intro-copy {
  max-width: 44rem;
}
.intro-copy p {
  margin: 0 0 1.1rem;
  color: var(--text-2);
}
.intro-copy .lead {
  margin-bottom: 1.6rem;
  font-size: var(--step-3);
  font-weight: 400;
  line-height: 1.28;
  letter-spacing: -0.012em;
  color: var(--text);
}
.intro-copy .lead a {
  color: inherit;
  text-decoration-color: var(--coral);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.16em;
}
.intro-copy .lead a:hover {
  color: var(--coral-text);
}

.avatar-container {
  width: 7.5rem;
  aspect-ratio: 1;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface);
}
.avatar-container picture,
.project-image-container picture {
  display: contents;
}
.avatar-container img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (min-width: 900px) {
  .intro-container {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 4rem;
  }
  .avatar-container {
    width: 13rem;
    margin-top: 0.5rem;
  }
}

/* ── The route ─────────────────────────────────────────────────
   Career waypoints joined by a wandering, dotted trail. JS draws
   the trail through each waypoint (websitescripts.js) and adds
   .has-trail; without it a straight dotted line stands in.
   The trail is revealed once as it scrolls into view — the only
   scroll-triggered motion on the page. */
.route {
  margin-top: clamp(4rem, 9vh, 6rem);
}
.route .sub-title {
  margin-bottom: 3.75rem; /* headroom for the crow perched on "now" */
}

.route-list {
  /* mobile: trail gutter on the left, everything else stacked */
  --trail-col: 2.75rem;
  --trail-x: calc(var(--trail-col) / 2);
  --trail-reach: 16; /* max control-point swing in px, read by JS */
  --dot-y: 1.05rem;
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 60rem;
}
.route-list::before {
  content: "";
  position: absolute;
  left: calc(var(--trail-x) - 1px);
  top: var(--dot-y);
  bottom: 2.5rem;
  border-left: 2px dotted var(--trail);
}
.route-list.has-trail::before {
  display: none;
}

.route-line {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.route-line path {
  fill: none;
  stroke: url(#route-sheen) var(--trail);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 0.1 7.5;
}

.route-stop {
  position: relative;
  display: grid;
  grid-template-columns: var(--trail-col) minmax(0, 1fr);
  grid-template-areas:
    ". when"
    ". role"
    ". org"
    ". note";
  padding-bottom: 2.5rem;
}
.route-stop:last-child {
  padding-bottom: 0;
}

/* waypoint: a small diamond */
.route-stop::before {
  content: "";
  position: absolute;
  left: calc(var(--trail-x) - 6px);
  top: calc(var(--dot-y) - 6px);
  width: 12px;
  height: 12px;
  border-radius: 2px;
  rotate: 45deg;
  background: var(--bg);
  border: 2px solid var(--accent);
  z-index: 1;
}
.route-stop.is-turn::before {
  background: var(--accent);
}
.route-stop.is-now::before {
  background: var(--coral);
  border-color: var(--coral);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--coral) 22%, transparent),
    0 0 24px 6px color-mix(in srgb, var(--coral) 38%, transparent);
}

.route-when {
  grid-area: when;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.route-year {
  font-size: var(--step-3);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--accent);
}
.route-range {
  font-size: var(--step--1);
  font-weight: 500;
  white-space: nowrap;
  color: var(--muted);
}
.route-stop.is-now .route-year {
  color: var(--coral-text);
}
.route-role {
  grid-area: role;
  margin: 0;
  font-size: var(--step-1);
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.25;
}
.route-org {
  grid-area: org;
  margin: 0.1rem 0 0.5rem;
  font-style: italic;
  color: var(--muted);
}
.route-note {
  grid-area: note;
  margin: 0;
  max-width: var(--measure);
  font-size: 0.95em;
  color: var(--text-2);
}

/* desktop: big start-years | trail | the stop */
@media (min-width: 760px) {
  .route-list {
    --year-col: 8.75rem;
    --trail-col: 5.5rem;
    --trail-x: calc(var(--year-col) + var(--trail-col) / 2);
    --trail-reach: 30;
    --dot-y: 1.15rem;
  }
  .route-stop {
    grid-template-columns: var(--year-col) var(--trail-col) minmax(0, 1fr);
    grid-template-areas:
      "when . role"
      "when . org"
      "when . note";
    padding-bottom: 3rem;
  }
  .route-when {
    flex-direction: column;
    align-items: flex-end;
    gap: 0.4rem;
    margin: 0;
    text-align: right;
  }
  .route-year {
    font-size: var(--step-4);
  }
  .route-role {
    padding-top: 0.25rem;
  }
}

/* ── The route crow ───────────────────────────────────────────
   websitescripts.js adds the crow and hands it the trail: --crow-x0/y0
   and --crow-x1/y1 are the first and last waypoints, and the flyer's
   offset-path is the trail itself. Static, the crow perches on "now".
   Where scroll timelines and motion paths exist, it takes off as "now"
   crosses the middle of the screen, flies the trail as you scroll (the
   trail drawing in behind it, one wingbeat per stretch of scroll) and
   lands on the last stop. Scrolling back up flies it home. */
.route-crow {
  --crow-w: 40px;
  --fly-w: 34px;
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  color: var(--text);
  --eye: var(--coral);
  opacity: 0;
}
.route-list.has-trail .route-crow {
  opacity: 1;
}
.route-crow svg {
  display: block;
  overflow: visible;
}
.route-crow-perch,
.route-crow-land {
  position: absolute;
  width: var(--crow-w);
  height: var(--crow-w);
  left: calc(var(--crow-x0) - var(--crow-w) * 0.567);
  top: calc(var(--crow-y0) - 9px - var(--crow-w) * 0.91);
  filter: drop-shadow(0 0 12px color-mix(in oklab, var(--coral) 40%, transparent));
}
.route-crow-land {
  left: calc(var(--crow-x1) - var(--crow-w) * 0.567);
  top: calc(var(--crow-y1) - 9px - var(--crow-w) * 0.91);
}
.route-crow-flyer,
.route-crow-land {
  display: none;
}
.route-crow-flyer {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--fly-w);
  offset-anchor: 50% 50%;
  offset-rotate: auto 90deg; /* the silhouette's head points up */
}
.route-crow-flyer svg {
  width: 100%;
  height: auto;
}
@media (min-width: 760px) {
  .route-crow {
    --crow-w: 46px;
    --fly-w: 48px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) and (animation-range: 0% 100%) and (offset-path: path("M 0 0")) {
    .route-list {
      view-timeline: --route block;
    }
    .route-list.has-trail .route-line,
    .route-crow > *,
    .route-crow-flyer svg {
      animation-duration: auto;
      animation-timing-function: linear;
      animation-fill-mode: both;
      animation-timeline: --route;
      /* from "now" at mid-screen to the last stop at mid-screen */
      animation-range: cover calc(50vh + var(--crow-y0, 0px)) cover calc(50vh + var(--crow-y1, 0px));
    }
    .route-list.has-trail .route-line {
      animation-name: trail-follow;
    }
    .route-crow-perch {
      animation-name: crow-take-off;
    }
    .route-crow-flyer {
      display: block;
      animation-name: crow-fly-route;
    }
    .route-crow-land {
      display: block;
      animation-name: crow-land;
    }
    .route-crow-flyer svg {
      animation-name: crow-wingbeat;
      animation-iteration-count: 26;
    }
  }
}
@keyframes trail-follow {
  from {
    clip-path: inset(0 0 calc(100% - var(--crow-y0, 0px)) 0);
  }
  to {
    clip-path: inset(0 0 calc(100% - var(--crow-y1, 100%)) 0);
  }
}
@keyframes crow-take-off {
  0% {
    opacity: 1;
    translate: 0 0;
  }
  4%,
  100% {
    opacity: 0;
    translate: 6px -14px;
  }
}
@keyframes crow-fly-route {
  0% {
    offset-distance: 0%;
    opacity: 0;
    scale: 0.6;
  }
  4%,
  96% {
    opacity: 1;
    scale: 1;
  }
  100% {
    offset-distance: 100%;
    opacity: 0;
    scale: 0.6;
  }
}
@keyframes crow-land {
  0%,
  96% {
    opacity: 0;
    translate: -6px -14px;
  }
  100% {
    opacity: 1;
    translate: 0 0;
  }
}
@keyframes crow-wingbeat {
  50% {
    scale: 0.58 1;
  }
}

/* ── Tools ── */
.tech-grid-wrapper {
  margin-top: clamp(4rem, 9vh, 6rem);
}
.tech-grid {
  display: grid;
  border-top: 1px solid var(--border);
  max-width: 52rem;
}
.tech-category {
  display: grid;
  gap: 0.25rem 1.5rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.tech-category h4 {
  margin: 0;
  font-size: var(--step-0);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.tech-category ul {
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--text-2);
}
.tech-category li {
  position: relative;
  display: inline-block;
  margin-right: 0.5em;
}
/* separators sit outside each item's box so an agent highlight wraps
   just the technology, not its comma */
.tech-category li:not(:last-child)::after {
  content: ",";
  content: "," / "";
  position: absolute;
  left: calc(100% + 1px);
}
@media (min-width: 760px) {
  .tech-category {
    grid-template-columns: 12rem 1fr;
    align-items: baseline;
  }
}

/* ── Projects ── */
.project-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: clamp(3.5rem, 8vh, 5.5rem);
}
.project-card {
  display: grid;
  gap: 1.5rem;
  align-items: start;
}
.project-image-container {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 10;
  padding: clamp(0.75rem, 2vw, 1.25rem);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--ring) border-box;
  overflow: hidden;
  translate: 0 0;
}
.project-card:is(:hover, :focus-within) .project-image-container {
  --ring: var(--sheen);
  box-shadow: 0 20px 44px -28px color-mix(in oklab, var(--sheen-1) 65%, transparent);
}
@media (prefers-reduced-motion: no-preference) {
  .project-image-container {
    transition: translate 200ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 200ms ease-out;
  }
  .project-card:is(:hover, :focus-within) .project-image-container {
    translate: 0 -2px;
  }
}
.project-image-container img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 6px;
}
.project-card .card-header h3 {
  margin: 0 0 0.75rem;
  font-size: var(--step-3);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.project-description {
  margin: 0 0 1rem;
  max-width: var(--measure);
  color: var(--text-2);
}
.project-tags {
  margin: 0 0 1.25rem;
  font-family: var(--font-display);
  font-size: var(--step--1);
  font-weight: 500;
  color: var(--muted);
}
.project-tags span:not(:last-child)::after {
  content: ", ";
  content: ", " / "";
}
.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}
.project-links a {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--step-0);
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, currentColor 40%, transparent);
  text-underline-offset: 0.25em;
}
.project-links a:visited {
  color: var(--accent);
}
.project-links a:hover {
  color: var(--coral-text);
  text-decoration-color: currentColor;
}
.project-links a[target="_blank"]::after {
  content: " ↗";
  content: " ↗" / "";
}

@media (min-width: 900px) {
  .project-card {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    gap: 3.5rem;
    align-items: center;
  }
}

/* ── Writing ── */
.writing-card-link {
  position: relative;
  display: block;
  height: 100%;
  padding: 4.75rem 1.4rem 1.5rem;
  color: inherit;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  translate: 0 0;
}
@media (prefers-reduced-motion: no-preference) {
  .writing-card-link {
    transition: border-color 200ms ease-out, translate 200ms cubic-bezier(0.22, 1, 0.36, 1);
  }
}
@media (hover: hover) {
  .writing-card-link:hover {
    translate: 0 -2px;
    border-color: color-mix(in oklab, var(--accent) 50%, transparent);
  }
}
.writing-card-link:visited {
  color: inherit;
}
.writing-card-link:focus-visible {
  outline-offset: 4px;
}
.writing-card .card-header :is(h3, h4) {
  margin: 0 0 0.6rem;
  font-size: var(--step-2);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
  transition: color 0.2s;
}
.writing-card-link:focus-visible .card-header :is(h3, h4) {
  color: var(--coral-text);
}
/* hover colour only where hover is real, so a tap on a phone
   doesn't leave the title stuck in coral */
@media (hover: hover) {
  .writing-card-link:hover .card-header :is(h3, h4) {
    color: var(--coral-text);
  }
}
.writing-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0 0 0.6rem;
  font-family: var(--font-display);
  font-size: var(--step--1);
  font-weight: 500;
  color: var(--muted);
}
.writing-card-excerpt {
  margin: 0;
  color: var(--text-2);
}


/* Both writing sets are real three-part series, so they get numbers. */
.writing-series {
  padding: 0;
}
.writing-series + .writing-series {
  margin-top: clamp(2.5rem, 6vh, 3.5rem);
}
.series-heading {
  margin: 0 0 1.25rem;
  font-size: var(--step-3);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.series-heading span {
  display: block;
  margin-top: 0.35rem;
  font-size: var(--step-0);
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
}
.series-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
  counter-reset: part;
}
.series-list .writing-card {
  counter-increment: part;
  position: relative;
}
/* Outlined part numbers inside the link so they lift with the card on hover
   and never get occluded by its stacking context; the sheen fills them on
   hover and focus. */
.series-list .writing-card-link::before {
  content: counter(part, decimal-leading-zero);
  content: counter(part, decimal-leading-zero) / "";
  position: absolute;
  left: 1.4rem;
  top: 1.3rem;
  font-family: var(--font-display);
  font-size: 2.75rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: transparent;
  -webkit-text-stroke: 1px var(--muted);
  pointer-events: none;
}
.series-list .writing-card:first-child .writing-card-link::before {
  -webkit-text-stroke-color: var(--coral-text);
}
.series-list .writing-card-link:is(:hover, :focus-visible)::before {
  -webkit-text-stroke-color: transparent;
  background: var(--sheen);
  -webkit-background-clip: text;
  background-clip: text;
}
@media (min-width: 900px) {
  .series-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
  }
}

.writing-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem 3rem;
  margin-top: 2.5rem;
}
.process-note {
  margin: 0;
  max-width: 38rem;
  font-size: 0.9em;
  font-style: italic;
  color: var(--muted);
}
.writing-view-all {
  margin: 0;
}
.writing-view-all a {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--accent);
}
.writing-view-all a:visited {
  color: var(--accent);
}
.writing-view-all a:hover {
  color: var(--coral-text);
}

/* ── Contact ── */
.contact-lead {
  margin: 0 0 0.5rem;
  font-size: var(--step-1);
  color: var(--text-2);
}
.contact-email {
  margin: 0 0 2.5rem;
}
.contact-email a {
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 0.9rem + 3.6vw, 3.25rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.15;
  color: var(--text);
  text-decoration: none;
  padding-bottom: 0.08em;
  background:
    var(--sheen) 0 100% / 0% 3px no-repeat,
    linear-gradient(var(--coral), var(--coral)) 0 100% / 100% 3px no-repeat;
  overflow-wrap: anywhere;
}
@media (prefers-reduced-motion: no-preference) {
  .contact-email a {
    transition: background-size 220ms cubic-bezier(0.22, 1, 0.36, 1), color 180ms ease-out;
  }
}
.contact-email a:is(:hover, :focus-visible) {
  background-size: 100% 3px, 100% 3px;
}
.contact-email a:visited {
  color: var(--text);
}
.contact-email a:hover {
  color: var(--text);
}
.contact-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 2rem;
}
.contact-resume {
  margin: 0;
  color: var(--text-2);
}

.icon-bar {
  display: flex;
  gap: 0.75rem;
}
.icon-bar a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid transparent;
  background:
    linear-gradient(var(--bg), var(--bg)) padding-box,
    var(--ring) border-box;
  color: var(--text);
  scale: 1;
  transition: color 180ms ease-out, scale 140ms ease-out;
}
.icon-bar a svg {
  width: 18px;
  height: 18px;
}
.icon-bar a:is(:hover, :focus-visible) {
  --ring: var(--sheen);
  color: var(--coral-text);
}
.icon-bar a:active {
  scale: 0.95;
}

/* The mail icon's flap can open above the envelope, so let it draw
   outside the icon's box. When the guide crow lands on it (see
   websitescripts.js) the flap flicks open, snaps shut and the icon
   glows once. */
.icon-bar .mail svg {
  overflow: visible;
}
.icon-bar .mail .mail-flap {
  transform-box: view-box;
  transform-origin: 12px 6px;
}
@media (prefers-reduced-motion: no-preference) {
  .icon-bar .mail.is-sealed {
    animation: mail-glow 1.8s ease-out;
  }
  .icon-bar .mail.is-sealed .mail-flap {
    animation: mail-seal 0.9s cubic-bezier(0.3, 1.5, 0.5, 1);
  }
}
@keyframes mail-seal {
  0% {
    transform: scaleY(1);
  }
  30% {
    transform: scaleY(-1);
  }
  100% {
    transform: scaleY(1);
  }
}
@keyframes mail-glow {
  0% {
    color: var(--coral-text);
    border-color: var(--coral);
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--coral) 45%, transparent),
      0 0 26px 4px color-mix(in srgb, var(--coral) 45%, transparent);
  }
  60% {
    color: var(--coral-text);
    border-color: var(--coral);
  }
  100% {
    box-shadow: 0 0 0 16px transparent, 0 0 26px 4px transparent;
  }
}

/* ── Site footer (scoped so it never hits an article's footer) ── */
body > footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
}
body > footer p {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem var(--gutter);
  font-family: var(--font-display);
  font-size: var(--step--1);
}

/* ── Back-to-top FAB ──────────────────────────────────────────
   Quiet surface button so the coral chat launcher stays the one
   accent in the corner. Scroll-timeline driven; JS fallback adds
   .no-scroll-timeline / .visible. */
.fab-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 20px -10px rgba(6, 4, 20, 0.5);
  z-index: 40;
  scale: 1;
  transition: border-color 180ms ease-out, color 180ms ease-out, scale 140ms ease-out;
}
.fab-top svg {
  width: 18px;
  height: 18px;
  translate: 0 0;
}
.fab-top:is(:hover, :focus-visible) {
  border-color: color-mix(in oklab, var(--accent) 60%, transparent);
  color: var(--coral-text);
}
.fab-top:active {
  scale: 0.95;
}
@media (prefers-reduced-motion: no-preference) {
  .fab-top svg {
    transition: translate 180ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  .fab-top:is(:hover, :focus-visible) svg {
    translate: 0 -2px;
  }
}

html.no-scroll-timeline .fab-top {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s, border-color 180ms ease-out, color 180ms ease-out, scale 140ms ease-out;
}
@media (prefers-reduced-motion: no-preference) {
  html.no-scroll-timeline .fab-top {
    translate: 0 16px;
    transition: opacity 0.22s, visibility 0.22s, translate 0.22s cubic-bezier(0.22, 1, 0.36, 1), border-color 180ms ease-out, color 180ms ease-out, scale 140ms ease-out;
  }
}
html.no-scroll-timeline .fab-top.visible {
  opacity: 1;
  visibility: visible;
  translate: 0 0;
}
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: scroll(root)) and (animation-range: 0% 100%) {
    .fab-top {
      animation: fab-in linear both;
      animation-timeline: scroll(root);
      animation-range: 90vh 150vh;
    }
  }
}
@keyframes fab-in {
  from {
    opacity: 0;
    visibility: hidden;
    translate: 0 16px;
  }
  to {
    opacity: 1;
    visibility: visible;
    translate: 0 0;
  }
}

/* ── Agent-driven focus: highlights + guide sprite ─────────────
   site-focus.js adds .is-agent-focused (+ data-agent-focus) to
   whatever the chat or an external agent is talking about; the
   guide crow flies to the same element and perches on it. Both are
   decorative — the scroll and live region carry the meaning. */
.agent-focus-live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.is-agent-focused {
  outline: 2px solid var(--coral-text);
  outline-offset: 10px;
  border-radius: var(--radius);
}
.project-card.is-agent-focused .project-image-container {
  --ring: var(--sheen);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--coral) 20%, transparent),
    0 0 36px 4px color-mix(in oklab, var(--coral) 26%, transparent);
}
.tech-category li.is-agent-focused {
  outline-offset: 2px;
  border-radius: 4px;
  color: var(--coral-text);
}
.writing-card.is-agent-focused {
  border-radius: 16px;
  outline-offset: 4px;
}
.tech-category.is-agent-focused {
  outline-offset: 0;
  border-radius: 6px;
}
.is-agent-focused[data-agent-focus="section"] {
  outline: none;
}
[data-agent-focus="section"] .section-title {
  color: var(--coral-text);
  transition: color 0.3s;
}

@media (prefers-reduced-motion: no-preference) {
  .is-agent-focused:not([data-agent-focus="section"]) {
    animation: agent-focus-pulse 1.4s cubic-bezier(0.2, 0, 0, 1) 2;
  }
}
@keyframes agent-focus-pulse {
  from {
    box-shadow: 0 0 0 0 var(--focus-ring);
  }
  to {
    box-shadow: 0 0 0 16px transparent;
  }
}

/* The guide crow's layer: fixed, click-through, under the chat panel.
   guide-sprite.js moves the flyer along an offset-path and places the
   perched crow; the coral eye and glow mark it as the agent's. */
.guide-crow {
  position: fixed;
  inset: 0;
  z-index: 58;
  overflow: hidden;
  pointer-events: none;
  color: var(--text);
  --eye: var(--coral);
}
.guide-crow svg {
  display: block;
  overflow: visible;
}
.guide-crow-flyer {
  position: absolute;
  left: 0;
  top: 0;
  width: 44px;
  opacity: 0;
  offset-anchor: 50% 50%;
  offset-rotate: auto 90deg; /* the silhouette's head points up */
}
.guide-crow-flyer svg {
  width: 100%;
  height: auto;
}
.guide-crow.is-flying .guide-crow-flyer svg {
  animation: crow-wingbeat 0.34s ease-in-out infinite;
}
.guide-crow-perch {
  position: absolute;
  left: 0;
  top: 0;
  width: 46px;
  height: 46px;
  opacity: 0;
  filter: drop-shadow(0 0 12px color-mix(in oklab, var(--coral) 50%, transparent));
}
.guide-crow-perch.is-perched {
  opacity: 1;
}

/* ── Forced Colors Mode (Windows High Contrast) ───────────────
   Gradient text, gradient rings and masked backgrounds are stripped
   by forced colors; restore system-color borders, underlines and text. */
@media (forced-colors: active) {
  .hero h1 em,
  .series-list .writing-card-link::before,
  .series-list .writing-card-link:is(:hover, :focus-visible)::before {
    color: CanvasText;
    background: none;
    -webkit-background-clip: border-box;
    background-clip: border-box;
    -webkit-text-stroke: 0;
  }
  .nav-brand::before,
  .nav-brand:is(:hover, :focus-visible)::before {
    background: currentColor;
    forced-color-adjust: none;
  }
  .nav-links::before {
    background: Highlight;
    forced-color-adjust: none;
  }
  .project-image-container,
  .icon-bar a {
    border-color: ButtonBorder;
  }
  .icon-bar a:is(:hover, :focus-visible) {
    border-color: Highlight;
  }
  .contact-email a {
    background: none;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.18em;
  }
  .is-agent-focused,
  .project-card.is-agent-focused,
  .tech-category li.is-agent-focused {
    outline: 2px solid Highlight;
  }
}
