/* ==========================================================================
   Alexey Velásquez · AI Engineer — terra, two themes (night default)
   ========================================================================== */

:root {
  /* night terra */
  --bg:        oklch(16% 0.018 40);
  --bg-deep:   oklch(13% 0.015 40);
  --surface:   oklch(20% 0.022 42);
  --line:      oklch(34% 0.035 45 / 0.5);
  --line-strong: oklch(44% 0.055 45 / 0.75);
  --ink:       oklch(94% 0.015 65);
  --ink-dim:   oklch(77% 0.025 55);
  --terra:      oklch(68% 0.15 40);
  --terra-hot:  oklch(77% 0.13 55);
  --terra-deep: oklch(58% 0.14 38);
  --terra-text: oklch(62% 0.14 38); /* terra-deep lifted for small text — AA on --bg */
  --terra-ink:  oklch(20% 0.045 40);
  /* the light is champagne gold; matter stays terracotta */
  --gold:     oklch(86% 0.105 87);
  --gold-hot: oklch(94% 0.06 96);
  --btn-bg:  var(--terra);
  --btn-ink: var(--terra-ink);
  --spot-alpha: 0.12;
  --haze: oklch(21% 0.035 42);
  /* 2.5D flow panels — elevation that reads in the dark */
  --panel-top: oklch(25% 0.026 44);
  --panel-bot: oklch(18% 0.02 40);
  --panel-shadow: 0 44px 76px -34px oklch(4% 0.005 40 / 0.95),
                  0 18px 44px -22px oklch(68% 0.15 40 / 0.16),
                  inset 0 1px 0 oklch(72% 0.04 55 / 0.16);
  --node-bg: oklch(27.5% 0.028 43);
  --node-line: oklch(48% 0.055 45 / 0.8);
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-mono: "Martian Mono", ui-monospace, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --z-nav: 100;
  --z-aura: 90;
  --z-skip: 200;
  color-scheme: dark;
}

:root[data-theme="light"] {
  /* clear terra */
  --bg:        oklch(95% 0.012 55);
  --bg-deep:   oklch(91.5% 0.016 55);
  --surface:   oklch(98% 0.006 55);
  --line:      oklch(52% 0.05 45 / 0.3);
  --line-strong: oklch(48% 0.07 45 / 0.55);
  --ink:       oklch(24% 0.03 40);
  --ink-dim:   oklch(42% 0.035 42);
  --terra:      oklch(52% 0.15 40);
  --terra-hot:  oklch(62% 0.16 45);
  --terra-deep: oklch(46% 0.13 38);
  --terra-text: oklch(46% 0.13 38);
  --terra-ink:  oklch(97.5% 0.008 60);
  --gold:     oklch(58% 0.115 80);
  --gold-hot: oklch(50% 0.12 74);
  --btn-bg:  oklch(52% 0.15 40);
  --btn-ink: oklch(97.5% 0.008 60);
  --spot-alpha: 0.1;
  --haze: oklch(89% 0.03 50);
  --panel-top: oklch(99% 0.004 55);
  --panel-bot: oklch(93.5% 0.015 55);
  --panel-shadow: 0 34px 60px -34px oklch(35% 0.06 40 / 0.5),
                  inset 0 1px 0 oklch(100% 0 0 / 0.9);
  --node-bg: var(--surface);
  --node-line: var(--line-strong);
  color-scheme: light;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}

body {
  margin: 0;
  background-color: #1b120d;
  background:
    radial-gradient(1100px 700px at 72% -8%, var(--haze), transparent 62%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.0625rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
:root[data-theme="light"] body { background-color: #f2e7dd; }

/* smooth theme swap — class is applied briefly by JS during toggle */
html.theming body,
html.theming .nav, html.theming .btn, html.theming .chips li,
html.theming .tile, html.theming .shot, html.theming .flow-diagram,
html.theming .contact {
  transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}

::selection { background: var(--terra); color: var(--terra-ink); }

h1, h2, h3 { text-wrap: balance; margin: 0; }
p { margin: 0; text-wrap: pretty; }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }

.mono { font-family: var(--font-mono); }
.arrow { display: inline-block; transition: transform 0.35s var(--ease-out); }

/* tactile titles: JS wraps letters in .word/.ch spans */
.word { display: inline-block; white-space: nowrap; }
.ch { display: inline-block; will-change: transform; }

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

.skip-link {
  position: fixed;
  top: 0.75rem; left: 0.75rem;
  z-index: var(--z-skip);
  background: var(--terra);
  color: var(--terra-ink);
  font-weight: 700;
  padding: 0.6em 1.1em;
  border-radius: 999px;
  text-decoration: none;
  transform: translateY(-300%);
}
.skip-link:focus { transform: none; }

/* --------------------------------------------------------------------------
   Cursor aura (fine pointer only — enabled by JS)
   -------------------------------------------------------------------------- */
.cursor-aura {
  position: fixed;
  top: 0; left: 0;
  width: 34rem; height: 34rem;
  margin: -17rem 0 0 -17rem;
  border-radius: 50%;
  background: radial-gradient(circle,
    oklch(68% 0.15 40 / 0.12),
    oklch(68% 0.15 40 / 0.045) 42%,
    transparent 70%);
  mix-blend-mode: screen;
  pointer-events: none;
  z-index: var(--z-aura);
  opacity: 0;
  transition: opacity 0.6s ease;
}
:root[data-theme="light"] .cursor-aura {
  mix-blend-mode: multiply;
  background: radial-gradient(circle,
    oklch(55% 0.15 40 / 0.09),
    oklch(55% 0.15 40 / 0.03) 42%,
    transparent 70%);
}
body.aura-on .cursor-aura { opacity: 1; }

/* --------------------------------------------------------------------------
   Lumen — a hidden circuit lattice the falling lamp reveals as it passes
   -------------------------------------------------------------------------- */
.lumen {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(circle,
    color-mix(in oklab, var(--gold) 65%, transparent) 1.1px, transparent 1.6px);
  background-size: 26px 26px;
  opacity: 0.55;
  -webkit-mask-image: radial-gradient(230px circle at var(--lx, -500px) var(--ly, -500px),
    rgb(0 0 0 / 0.85), transparent 72%);
  mask-image: radial-gradient(230px circle at var(--lx, -500px) var(--ly, -500px),
    rgb(0 0 0 / 0.85), transparent 72%);
}
:root[data-theme="light"] .lumen { opacity: 0.45; }

/* --------------------------------------------------------------------------
   Training console — big in the hero's open right side, then it shrinks
   and docks into the top-right corner as the run advances
   -------------------------------------------------------------------------- */
.trainer {
  position: fixed;
  top: clamp(13rem, 30vh, 19rem);
  right: clamp(3rem, 9vw, 12rem);
  z-index: 80;
  display: grid;
  gap: 0.65em;
  min-width: 19.5rem;
  padding: 1.5em 1.7em;
  font-size: 0.98rem;
  line-height: 1.4;
  color: var(--ink-dim);
  background: color-mix(in oklab, var(--bg-deep) 55%, transparent);
  border: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  transition: top 0.75s var(--ease-out), right 0.75s var(--ease-out),
              min-width 0.75s var(--ease-out), font-size 0.75s var(--ease-out),
              padding 0.75s var(--ease-out), gap 0.75s var(--ease-out),
              opacity 0.9s ease;
}
.trainer b { color: var(--terra); font-weight: 500; }
.tr-title { font-size: 0.74em; opacity: 0.7; letter-spacing: 0.05em; }
.tr-row { display: flex; justify-content: space-between; gap: 2em; }
.tr-bar {
  height: 4px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--line) 55%, transparent);
  overflow: hidden;
  margin-top: 0.15em;
}
.tr-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--terra-deep), var(--terra-hot));
}
.tr-pct { justify-self: end; font-size: 0.85em; }
.trainer.done .tr-pct { color: var(--terra); }
.trainer.docked {
  top: 4.3rem;
  right: 1rem;
  min-width: 10rem;
  font-size: 0.6rem;
  padding: 0.8em 1em;
  gap: 0.4em;
}
@media (max-width: 720px) {
  .trainer.docked { min-width: 8.5rem; font-size: 0.55rem; }
}

/* --------------------------------------------------------------------------
   Nav
   -------------------------------------------------------------------------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: var(--z-nav);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 0.8rem clamp(1.25rem, 4vw, 2.75rem);
  transition: background-color 0.4s ease, border-color 0.4s ease,
              backdrop-filter 0.4s ease, opacity 0.9s ease;
  border-bottom: 1px solid transparent;
}
.nav.scrolled {
  background: color-mix(in oklab, var(--bg-deep) 86%, transparent);
  backdrop-filter: blur(14px);
  border-bottom-color: var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 750;
  font-size: 1.05rem;
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand-glyph { width: 2.4rem; height: auto; color: var(--terra); flex: none; }
.nav-links {
  display: flex;
  gap: clamp(0.9rem, 2.2vw, 1.7rem);
  font-size: 0.95rem;
  font-weight: 550;
}
.nav-links a {
  color: var(--ink-dim);
  text-decoration: none;
  padding: 0.2em 0;
  background: linear-gradient(var(--terra), var(--terra)) bottom left / 0% 2px no-repeat;
  transition: color 0.3s ease, background-size 0.35s var(--ease-out);
}
.nav-links a:hover { color: var(--ink); background-size: 100% 2px; }
.nav-actions { display: flex; align-items: center; gap: 0.7rem; }

.theme-toggle {
  position: relative;
  width: 2.5rem; height: 2.5rem;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.3s ease, color 0.3s ease, transform 0.45s var(--ease-out);
}
.theme-toggle:hover { border-color: var(--terra); color: var(--terra); transform: rotate(18deg); }
.theme-toggle svg {
  position: absolute;
  inset: 0;
  width: 1.15rem; height: 1.15rem;
  margin: auto;
  transition: opacity 0.35s ease, transform 0.45s var(--ease-out);
}
.theme-toggle .icon-sun  { opacity: 1; transform: none; }
.theme-toggle .icon-moon { opacity: 0; transform: rotate(-60deg) scale(0.6); }
:root[data-theme="light"] .theme-toggle .icon-sun  { opacity: 0; transform: rotate(60deg) scale(0.6); }
:root[data-theme="light"] .theme-toggle .icon-moon { opacity: 1; transform: none; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  padding: 0.78em 1.45em;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  letter-spacing: 0.005em;
  transition: transform 0.45s var(--ease-out), background-color 0.3s ease,
              color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  will-change: transform;
}
.btn-fire {
  background: var(--btn-bg);
  color: var(--btn-ink);
}
.btn-fire:hover {
  background: var(--terra-hot);
  box-shadow: 0 0 26px oklch(68% 0.15 40 / 0.4);
}
:root[data-theme="light"] .btn-fire:hover { color: var(--terra-ink); }
.btn-ghost {
  border: 1px solid var(--line-strong);
  color: var(--ink);
}
.btn-ghost:hover { border-color: var(--terra); color: var(--terra); }
.btn:hover .arrow { transform: translate(3px, -2px); }
.btn[href^="#"]:hover .arrow { transform: translateY(3px); }
.btn-nav { padding: 0.55em 1.1em; font-size: 0.92rem; }
.btn-big { padding: 0.95em 1.8em; font-size: 1.12rem; }

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */
.hero {
  position: relative;
  min-height: clamp(34rem, 78svh, 50rem);
  display: grid;
  align-items: center;
}
#spine {
  position: absolute;
  top: 0; left: 0;
  z-index: 0; /* the light travels beneath the page, glowing through */
  pointer-events: none;
}
main, .footer { position: relative; z-index: 1; }

.spine-base {
  fill: none;
  stroke: var(--line);
  stroke-width: 1.5;
}
.spine-lit {
  fill: none;
  stroke: color-mix(in oklab, var(--gold) 68%, transparent);
  stroke-width: 1.3;
  stroke-linecap: round;
}
.spine-head {
  fill: var(--gold-hot);
  filter: drop-shadow(0 0 12px oklch(90% 0.08 90 / 1));
}
:root[data-theme="light"] .spine-head {
  filter: drop-shadow(0 0 10px oklch(70% 0.12 80 / 0.8));
}
/* intro: the point charging with the mandala's energy */
.spine-head.charging {
  filter: drop-shadow(0 0 20px oklch(93% 0.06 95 / 1))
          drop-shadow(0 0 55px oklch(85% 0.095 88 / 0.8));
}
/* intro: the page holds its breath until the flash */
html.introing .load-rise { animation-play-state: paused; }
html.introing .nav,
html.introing .trainer {
  opacity: 0;
  pointer-events: none;
}
/* mandalas — engraved golden linework behind the page. Three line
   weights read as craft: hairline (fine), body (line), accent (ray).
   The pulse classes are the energy: a wave that converges at the intro,
   then a faint heartbeat forever after. Text stays crisp a layer above */
.man-layer { opacity: 0.95; }
:root[data-theme="light"] .man-layer { opacity: 0.7; }
.man-line { fill: none; stroke: var(--gold); stroke-width: 1; }
.man-fine { fill: none; stroke: color-mix(in oklab, var(--gold) 78%, transparent); stroke-width: 0.7; }
.man-ray {
  fill: none;
  stroke: var(--gold-hot);
  stroke-width: 1.2;
  stroke-linecap: round;
}
.man-gem { fill: var(--gold); }
.man-node {
  fill: var(--terra-hot);
  filter: drop-shadow(0 0 6px color-mix(in oklab, var(--terra-hot) 90%, transparent));
}
.man-spark {
  fill: var(--gold-hot);
  filter: drop-shadow(0 0 3px color-mix(in oklab, var(--gold-hot) 80%, transparent));
}
/* the intro pulse — a ring of light that falls into the point,
   and the shockwave the point releases */
.man-wave {
  fill: none;
  stroke: var(--gold-hot);
  filter: drop-shadow(0 0 9px color-mix(in oklab, var(--gold-hot) 85%, transparent));
}
.man-wave-halo { fill: none; stroke: color-mix(in oklab, var(--gold) 45%, transparent); }
.man-shock {
  fill: none;
  stroke: var(--gold-hot);
  filter: drop-shadow(0 0 14px color-mix(in oklab, var(--gold-hot) 80%, transparent));
}
/* idle heartbeat — every few seconds a faint ring converges to the heart */
.man-idle { opacity: 0; transform-box: fill-box; transform-origin: center; }
.man-iring {
  fill: none;
  stroke: var(--gold);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}
.mandala.alive .man-idle {
  animation: man-converge var(--ipd, 8s) cubic-bezier(0.5, 0, 0.75, 0.5) var(--idel, 0s) infinite;
}
html.introing .man-idle { animation: none; }
@keyframes man-converge {
  0%   { transform: scale(1); opacity: 0; }
  7%   { opacity: var(--imax, 0.25); }
  42%  { transform: scale(0.03); opacity: 0; }
  100% { transform: scale(0.03); opacity: 0; }
}
.mandala { transform-box: fill-box; transform-origin: center; }
.mandala.spin { animation: man-spin 150s linear infinite; }
.mandala.man-hero.spin { animation-duration: 320s; }
@keyframes man-spin { to { transform: rotate(360deg); } }
.spine-glow { text-shadow: 0 0 28px oklch(68% 0.15 40 / 0.45); }
:root[data-theme="light"] .spine-glow { text-shadow: 0 0 26px oklch(55% 0.15 40 / 0.35); }
.hero-inner {
  position: relative;
  z-index: 1;
  width: min(1560px, 100%);
  margin-inline: auto;
  padding: clamp(5.5rem, 13vh, 8rem) clamp(1.25rem, 4vw, 2.75rem) clamp(3rem, 7vh, 5rem);
}
.hero-hello {
  font-size: 0.78rem;
  color: var(--terra);
  margin-bottom: 1.3rem;
}
.hero-name {
  font-size: clamp(3rem, 10.5vw, 6rem);
  font-weight: 800;
  line-height: 0.98;
  letter-spacing: -0.03em;
}
.hero-name .line { display: block; }
.hero-name em { font-style: normal; color: var(--terra); }
.hero-role {
  max-width: 44rem;
  margin-top: 1.7rem;
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
  line-height: 1.6;
  color: var(--ink-dim);
}
.hero-role em { font-style: normal; color: var(--terra); font-weight: 650; }
.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2.2rem;
}
.hero-stats {
  margin-top: 1.5rem;
  font-size: 0.78rem;
  color: var(--ink-dim);
  letter-spacing: 0.01em;
}
.hero-stats strong { color: var(--terra); font-weight: 500; }
.hero-status {
  margin-top: 2.3rem;
  font-size: 0.78rem;
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  gap: 0.6em;
}
.pulse-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--terra);
  position: relative;
  flex: none;
}
.pulse-dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--terra);
  animation: dot-ring 2.2s var(--ease-out) infinite;
}
@keyframes dot-ring {
  0%   { transform: scale(0.5); opacity: 0.9; }
  100% { transform: scale(1.9); opacity: 0; }
}

/* hero load choreography — pure CSS, runs without JS */
.load-rise {
  animation: rise 0.95s var(--ease-out) both;
  animation-delay: calc(var(--l, 0) * 115ms + 120ms);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(26px); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Sections, shared
   -------------------------------------------------------------------------- */
section { padding-block: clamp(2.75rem, 6vw, 4.5rem); }
.section-head,
.ml-rows, .about-inner, .contact-inner,
.timeline, .stack-groups, .stack-readout {
  width: min(1560px, 100%);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 2.75rem);
}
.section-head { margin-bottom: clamp(1.5rem, 3.5vw, 2.5rem); }
.section-head h2,
.about-inner h2,
.contact-inner h2 {
  font-size: clamp(2rem, 4.5vw, 3.4rem);
  font-weight: 750;
  letter-spacing: -0.025em;
  line-height: 1.1;
}
.section-head p {
  margin-top: 0.9rem;
  color: var(--ink-dim);
  font-size: 1.1rem;
  max-width: 40rem;
}

/* scroll reveals — hidden state only when JS is present */
html.js .reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.85s var(--ease-out), transform 0.85s var(--ease-out);
  transition-delay: calc(var(--d, 0) * 90ms);
}
html.js .reveal.in { opacity: 1; transform: none; }

/* --------------------------------------------------------------------------
   AI Projects gallery — iPod-style Cover Flow. The front cover faces the
   reader; the rest recede left and right in 3D. Until the script marks the
   deck ready (or when JS is off) the covers rest as a plain labeled grid.
   -------------------------------------------------------------------------- */
.gallery { padding-bottom: clamp(1rem, 2.5vw, 2rem); }
.deck {
  --deck-w: clamp(17rem, 34vw, 26rem);   /* front cover width */
  width: min(1560px, 100%);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 3rem);
}
.deck-card { text-decoration: none; }
.deck-card img {
  width: 100%;
  aspect-ratio: 2 / 1;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  box-shadow: var(--panel-shadow);
}
/* resting layout — no JS, or the script hasn't initialized the deck */
.deck:not(.ready) .deck-stage {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1.4rem;
}
.deck:not(.ready) .deck-card::after {
  content: attr(data-label);
  display: block;
  margin-top: 0.6rem;
  font-size: 0.72rem;
  color: var(--terra-text);
  letter-spacing: 0.02em;
  font-family: var(--font-mono);
}

/* the 3D deck */
.deck.ready .deck-stage {
  position: relative;
  height: calc(var(--deck-w) / 2 + 5.5rem);  /* 2:1 cover + reflection room */
  perspective: 1200px;
  touch-action: pan-y;                       /* vertical page scroll stays native */
}
.deck.ready .deck-card {
  position: absolute;
  left: 50%;
  top: 0;
  width: var(--deck-w);
  margin-left: calc(var(--deck-w) / -2);
  transition: transform 0.5s var(--ease-out);
  will-change: transform;
}
.deck.ready .deck-card img {
  -webkit-box-reflect: below 10px linear-gradient(transparent 62%, rgba(0, 0, 0, 0.28));
  transition: border-color 0.3s ease;
}
.deck.ready .deck-card.front:hover img,
.deck.ready .deck-card.front:focus-visible img { border-color: var(--terra); }
.deck.ready .deck-card:not(.front) { cursor: pointer; }
/* animated covers: a muted loop over the still cover, played only on the front card */
.deck-card { position: relative; }
.deck-motion {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  aspect-ratio: 2 / 1;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  opacity: 0;
  transition: opacity 0.45s ease, border-color 0.3s ease;
  pointer-events: none;
}
.deck.ready .deck-motion {
  -webkit-box-reflect: below 10px linear-gradient(transparent 62%, rgba(0, 0, 0, 0.28));
}
.deck-card.front.playing .deck-motion { opacity: 1; }
.deck.ready .deck-card.front:hover .deck-motion { border-color: var(--terra); }
@media (prefers-reduced-motion: reduce) { .deck-motion { display: none; } }
@media (max-width: 900px) {
  .deck { --deck-w: clamp(15rem, 64vw, 19rem); }
}
@media (prefers-reduced-motion: reduce) {
  .deck.ready .deck-card { transition: none; }
}

/* deck HUD — arrows, numbers, counter, caption */
.deck-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: clamp(0.4rem, 1.2vw, 0.8rem);
  margin-top: 1.4rem;
}
.deck-arrow {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-dim);
  font: inherit;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.25s ease, border-color 0.25s ease, opacity 0.25s ease;
}
.deck-arrow:hover:not(:disabled) { color: var(--gold); border-color: var(--terra); }
.deck-arrow:disabled { opacity: 0.35; cursor: default; }
.deck-index {
  display: flex;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.deck-index button {
  min-width: 1.9rem;
  height: 1.9rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-dim);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.25s ease, background-color 0.25s ease;
}
.deck-index button:hover { color: var(--terra-hot); }
.deck-index button.on { background: var(--terra); color: var(--terra-ink); }
.deck-count { font-size: 0.75rem; color: var(--ink-dim); margin-left: 0.4rem; }
.deck-caption {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55em;
  margin-top: 0.9rem;
  min-height: 1.3em;                 /* caption swaps must not shift layout */
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--terra-text);
}
.deck-caption::before {
  content: "";
  width: 7px; height: 7px;
  background: var(--terra);
  transform: rotate(45deg);
  flex: none;
}

/* --------------------------------------------------------------------------
   Featured work
   -------------------------------------------------------------------------- */
.work { padding-inline: 0; }
.case {
  width: min(1560px, 100%);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 2.75rem);
  display: grid;
  grid-template-columns: minmax(0, 10fr) minmax(0, 11fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
}
.case + .case { margin-top: clamp(2.5rem, 5vw, 4rem); }
.case-flip .case-media { order: -1; }

.case-tag {
  font-size: 0.72rem;
  color: var(--terra);
  margin-bottom: 1rem;
}
.case h3 {
  font-size: clamp(1.5rem, 2.6vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.22;
}
.case-story {
  margin-top: 1.1rem;
  color: var(--ink-dim);
  max-width: 60ch;
}
.case-results {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}
.case-results li {
  position: relative;
  padding-left: 1.35rem;
  color: var(--ink-dim);
  line-height: 1.5;
}
.case-results li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.52em;
  width: 8px; height: 8px;
  background: var(--terra);
  transform: rotate(45deg);
}
.case-results strong {
  color: var(--terra);
  font-weight: 500;
  font-size: 1.02em;
}
.case-results code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  color: var(--ink);
  background: var(--surface);
  padding: 0.15em 0.4em;
  border-radius: 5px;
}
.chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.5rem 0 0;
  padding: 0;
}
.chips li {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4em 0.85em;
  transition: color 0.25s ease, border-color 0.25s ease, transform 0.25s var(--ease-out);
}
.chips li:hover {
  color: var(--terra);
  border-color: var(--terra-deep);
  transform: translateY(-2px);
}
.case-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  margin-top: 1.7rem;
  font-weight: 700;
  color: var(--terra);
  text-decoration: none;
  background: linear-gradient(var(--terra), var(--terra)) bottom left / 0% 2px no-repeat;
  transition: background-size 0.35s var(--ease-out);
  padding-bottom: 0.15em;
}
.case-link:hover { background-size: 100% 2px; }
.case-link:hover .arrow { transform: translate(3px, -2px); }
.case-link + .case-link { margin-left: 1.6rem; }
/* private-work note — sits where a repo link would, but is not a link */
.case-note {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  margin-top: 1.7rem;
  font-size: 0.78rem;
  color: var(--ink-dim);
}
.case-note::before {
  content: "";
  width: 7px; height: 7px;
  background: var(--gold);
  transform: rotate(45deg);
  flex: none;
}

/* media frames */
.case-media { position: relative; border-radius: 14px; }
.shot {
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  transition: transform 0.6s var(--ease-out), border-color 0.4s ease;
}
.case-media:hover .shot { border-color: var(--terra-deep); }
/* flow graphs — n8n-style pipelines in 2.5D */
.case-media.flow {
  transform: perspective(1100px) rotateX(5deg) rotateY(-5deg);
  transform-style: preserve-3d;
  will-change: transform;
  border-radius: 16px;
  background:
    radial-gradient(28rem 20rem at 50% 0%, var(--haze), transparent 72%),
    linear-gradient(168deg, var(--panel-top), var(--panel-bot));
  box-shadow: var(--panel-shadow);
  padding: clamp(0.75rem, 2vw, 1.5rem);
}
.case-flip .case-media.flow { transform: perspective(1100px) rotateX(5deg) rotateY(5deg); }
/* specular sheen — a soft light that travels with the cursor, so the
   tilt reads as a surface catching light */
.case-media.flow::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(22rem circle at var(--fx, 62%) var(--fy, 10%),
    oklch(85% 0.05 55 / 0.08), transparent 62%);
  pointer-events: none;
}
:root[data-theme="light"] .case-media.flow::after {
  background: radial-gradient(22rem circle at var(--fx, 62%) var(--fy, 10%),
    oklch(100% 0 0 / 0.35), transparent 62%);
}
.fg { width: 100%; height: auto; display: block; }
.fg-node rect {
  fill: var(--node-bg);
  stroke: var(--node-line);
  stroke-width: 1.2;
  transition: fill 0.45s ease, stroke 0.45s ease;
}
.fg-node .fg-t {
  fill: var(--ink);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 650;
}
.fg-node .fg-s {
  fill: var(--ink-dim);
  font-family: var(--font-mono);
  font-size: 8.5px;
}
.fg-node .fg-sock {
  fill: var(--bg);
  stroke: var(--line-strong);
  stroke-width: 1.5;
  transition: fill 0.45s ease, stroke 0.45s ease;
}
.fg-node.on rect {
  stroke: var(--terra);
  fill: color-mix(in oklab, var(--terra) 13%, var(--surface));
  filter: drop-shadow(0 0 10px oklch(68% 0.15 40 / 0.5));
}
.fg-node.on .fg-t { fill: var(--terra-hot); }
.fg-node.on .fg-sock { fill: var(--terra); stroke: var(--terra-hot); }
.fg-edge {
  fill: none;
  stroke: var(--line);
  stroke-width: 1.6;
  transition: stroke 0.45s ease;
}
.fg-edge.on {
  stroke: var(--terra);
  stroke-dasharray: 6 8;
  animation: dash-flow 1.2s linear infinite;
  filter: drop-shadow(0 0 5px oklch(68% 0.15 40 / 0.6));
}
@keyframes dash-flow { to { stroke-dashoffset: -14; } }
/* data packets — bright drops that travel each edge once it is lit */
.fg-packet {
  fill: var(--gold-hot);
  opacity: 0;
  transition: opacity 0.45s ease;
  filter: drop-shadow(0 0 4px oklch(90% 0.08 90 / 0.9));
}
.fg-packet.on { opacity: 1; }

/* a terra diamond snaps in beside a title when the light reaches it */
.section-head h2, .about-inner h2, .case h3 { position: relative; }
.section-head h2::before, .about-inner h2::before, .case h3::before {
  content: "";
  position: absolute;
  left: -1.35rem;
  top: calc(0.62em - 5px);
  width: 9px; height: 9px;
  background: var(--terra);
  opacity: 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.6s var(--ease-out), opacity 0.35s ease;
}
.section-head h2.spine-glow::before,
.about-inner h2.spine-glow::before,
.case h3.spine-glow::before {
  opacity: 1;
  transform: rotate(45deg) scale(1);
}
@media (max-width: 720px) {
  .section-head h2::before, .about-inner h2::before, .case h3::before { display: none; }
}

/* key words ignite when the light reaches their zone */
.kw { transition: color 0.6s ease, text-shadow 0.6s ease; }
.zone-on .kw,
.entry.lit .kw {
  color: var(--terra);
  text-shadow: 0 0 18px oklch(68% 0.15 40 / 0.35);
}

/* cursor spotlight */
[data-spotlight] { position: relative; overflow: hidden; }
[data-spotlight]::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(20rem circle at var(--mx, 50%) var(--my, 50%),
    oklch(68% 0.15 40 / var(--spot-alpha)), transparent 65%);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  z-index: 2;
}
[data-spotlight]:hover::after { opacity: 1; }
.case-media[data-spotlight] { overflow: visible; }
.case-media[data-spotlight]::after { display: none; }
.case-media .shot { position: relative; }

/* (project media are flow graphs, styled above) */

/* --------------------------------------------------------------------------
   Experience timeline
   -------------------------------------------------------------------------- */
.timeline {
  list-style: none;
  position: relative;
  margin: 0 auto;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}
.entry {
  position: relative;
  padding: 1.05rem 0 1.05rem 2.4rem;
  max-width: 46rem;
}
@media (min-width: 901px) {
  .entry {
    width: calc(50% - 4.5rem);
    padding-left: 0;
  }
  .entry:nth-child(even) {
    margin-left: calc(50% + 4.5rem);
  }
}
.entry-when {
  font-size: 0.7rem;
  color: var(--terra-text);
  margin-bottom: 0.45rem;
  transition: color 0.4s ease;
}
.entry.lit .entry-when { color: var(--terra); }
.entry h3 {
  font-size: clamp(1.15rem, 1.9vw, 1.45rem);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.entry-where {
  font-size: 0.68rem;
  color: var(--ink-dim);
  margin-top: 0.3rem;
}
.entry-points {
  list-style: none;
  margin: 0.9rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}
.entry-points li {
  position: relative;
  padding-left: 1.2rem;
  color: var(--ink-dim);
  font-size: 0.97rem;
  line-height: 1.55;
}
.entry-points li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.55em;
  width: 6px; height: 6px;
  background: var(--terra-deep);
  transform: rotate(45deg);
}
.entry-points strong { color: var(--terra); font-weight: 500; }
.entry-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  margin-top: 0.9rem;
  font-size: 0.72rem;
  color: var(--terra);
  text-decoration: none;
  background: linear-gradient(var(--terra), var(--terra)) bottom left / 0% 1px no-repeat;
  transition: background-size 0.35s var(--ease-out);
  padding-bottom: 0.15em;
}
.entry-link:hover { background-size: 100% 1px; }
.entry-link:hover .arrow { transform: translate(3px, -2px); }
.entry-edu { padding-bottom: 0.5rem; }
.entry-edu h3 { font-size: 1.05rem; }

/* --------------------------------------------------------------------------
   Tech stack
   -------------------------------------------------------------------------- */
.stack-section {
  background: color-mix(in oklab, var(--bg-deep) 88%, transparent);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.stack-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: clamp(1.75rem, 3.5vw, 2.75rem) clamp(2rem, 4vw, 3.5rem);
}
.sgroup h3 {
  font-size: 1.02rem;
  font-weight: 750;
  letter-spacing: -0.01em;
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.55em;
}
.sgroup h3::before {
  content: "";
  width: 7px; height: 7px;
  background: var(--terra);
  transform: rotate(45deg);
  flex: none;
}
.tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.tile {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55em 0.9em;
  cursor: default;
  transition: color 0.25s ease, border-color 0.25s ease,
              background-color 0.25s ease, transform 0.25s var(--ease-out);
}
.tile:hover, .tile:focus-visible, .tile.active {
  color: var(--terra);
  border-color: var(--terra-deep);
  background: color-mix(in oklab, var(--terra) 9%, transparent);
  transform: translateY(-2px);
}
.stack-readout {
  margin-top: clamp(1.75rem, 4vw, 2.5rem);
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  font-size: 0.76rem;
  line-height: 1.7;
  color: var(--terra);
  min-height: 3em;
}

/* --------------------------------------------------------------------------
   About
   -------------------------------------------------------------------------- */
.about-inner h2 { margin-bottom: 1.6rem; }
@media (min-width: 901px) {
  .about-inner {
    display: grid;
    grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
    gap: 1rem clamp(2.5rem, 5vw, 5rem);
    align-items: start;
  }
  .about-inner h2 { grid-column: 1 / -1; }
  .about-inner p + p { margin-top: 0.4rem; }
}
.about-lede {
  font-size: clamp(1.25rem, 2.2vw, 1.6rem);
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: -0.01em;
}
.about-inner p + p {
  margin-top: 1.2rem;
  color: var(--ink-dim);
  max-width: 62ch;
}

/* --------------------------------------------------------------------------
   Contact — the terra drench (both themes)
   -------------------------------------------------------------------------- */
.contact {
  /* bottom stop kept light enough that body text holds AA contrast */
  background: linear-gradient(180deg, oklch(63% 0.15 42), oklch(59% 0.145 38));
  color: oklch(16% 0.04 40);
}
.contact ::selection { background: oklch(20% 0.045 40); color: oklch(77% 0.13 55); }
.contact-inner { text-align: center; }
.contact-inner h2 { font-size: clamp(2.4rem, 6vw, 4.5rem); letter-spacing: -0.03em; }
.contact-inner > p {
  margin-top: 1rem;
  font-size: 1.2rem;
  font-weight: 550;
  opacity: 0.9;
}
.contact-cta {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2.4rem;
}
.contact .btn-fire {
  background: oklch(20% 0.045 40);
  color: oklch(77% 0.13 55);
}
.contact .btn-fire:hover {
  background: oklch(15% 0.035 40);
  box-shadow: 0 0 26px oklch(20% 0.045 40 / 0.5);
}
.contact .btn-ghost {
  border-color: oklch(20% 0.045 40 / 0.55);
  color: oklch(20% 0.045 40);
}
.contact .btn-ghost:hover { border-color: oklch(20% 0.045 40); color: oklch(20% 0.045 40); }
.contact-mail {
  margin-top: 2.2rem;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  width: min(1560px, 100%);
  margin-inline: auto;
  padding: 2rem clamp(1.25rem, 4vw, 2.75rem);
  color: var(--ink-dim);
  font-size: 0.85rem;
}
.footer-links { display: flex; gap: 1.4rem; }
.footer a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}
.footer a:hover { color: var(--terra); }
.footer a:hover .arrow { transform: translateY(-3px); }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .case { grid-template-columns: 1fr; }
  .case-flip .case-media { order: 0; }
  .case-media { max-width: 40rem; }
}
@media (max-width: 720px) {
  /* condensed nav: keep the two links that matter on a phone */
  .nav-links { gap: 1rem; font-size: 0.88rem; }
  .nav-links a:not(.keep-m) { display: none; }
  .btn-nav { display: none; }
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .load-rise { animation: none; }
  html.js .reveal { opacity: 1; transform: none; transition: none; }
  .pulse-dot::after { animation: none; opacity: 0; }
  .fg-edge.on { animation: none; stroke-dasharray: none; }
  .fg-packet { display: none; }
  .lumen { display: none; }
  .section-head h2::before, .about-inner h2::before, .case h3::before { transition: none; }
  .trainer { transition: none; }
  .mandala.spin { animation: none; }
  .mandala.alive .man-idle { animation: none; }
  .case-media.flow, .case-flip .case-media.flow { transform: none; }
  .btn, .chips li, .tile, .arrow, .theme-toggle { transition: none; }
  .cursor-aura { display: none; }
}
