:root {
  --bg: #edf1f3;
  --bg-deep: #e4e9ed;
  --glass: rgba(255,255,255,.62);
  --glass-strong: rgba(255,255,255,.84);
  --line: rgba(28,37,45,.08);
  --line-strong: rgba(28,37,45,.14);
  --text: #172028;
  --muted: #5a646d;
  --accent: #6b8098;
  --accent-ink: #4d6480;
  --accent-soft: rgba(107,128,152,.13);

  /* Close is the only destructive-feeling action here. Muted brick rather
     than a pure red, so it sits in a cool palette without shouting. */
  --close: #c2544f;
  --close-soft: rgba(194,84,79,.10);
  --close-line: rgba(194,84,79,.30);

  --shadow: 0 24px 80px rgba(45,56,68,.10);
  --shadow-small: 0 12px 40px rgba(45,56,68,.07);

  --radius-lg: 30px;
  --radius-md: 22px;
  --radius-sm: 14px;

  --sans: "Inter", sans-serif;
  --mono: "JetBrains Mono", monospace;

  /* Type scale — 1.25 ratio from a 16px base.
     The mid-range steps (20/25/31) are what keep headings and body
     in the same system instead of two disconnected clusters. */
  --t-micro: .6875rem;  /* 11 */
  --t-xs:    .8125rem;  /* 13 */
  --t-sm:    .875rem;   /* 14 */
  --t-base:  1rem;      /* 16 */
  --t-md:    1.25rem;   /* 20 */
  --t-lg:    1.5625rem; /* 25 */
  --t-xl:    1.9375rem; /* 31 */
  --t-2xl:   2.4375rem; /* 39 */
  --t-3xl:   3.0625rem; /* 49 */

  /* Fluid display steps, each capped at a scale value */
  --t-hero:  clamp(2.75rem, 5.4vw, 5.25rem);
  --t-panel: clamp(1.9375rem, 3vw, 2.4375rem);
  --t-card:  clamp(1.5625rem, 2.1vw, 1.9375rem);
  --t-lead:  clamp(1.5625rem, 2.5vw, 2.4375rem);

  /* Spacing — 4px base */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;

  --ease-out: cubic-bezier(.2,.8,.2,1);
  /* Overshoots on its own, so a settle needs no extra keyframes. */
  --ease-settle: cubic-bezier(.34,1.4,.64,1);

  /* Surfaces — every glass value is a token, so the dark theme is a token
     swap rather than a second stylesheet. */
  --pane-edge: rgba(255,255,255,.8);
  --pane-a: rgba(255,255,255,.76);
  --pane-b: rgba(255,255,255,.45);
  --card-edge: rgba(255,255,255,.78);
  --card-a: rgba(255,255,255,.62);
  --card-b: rgba(255,255,255,.3);
  --fill-soft: rgba(255,255,255,.42);
  --fill-softer: rgba(255,255,255,.36);
  --fill-chip: rgba(255,255,255,.46);
  --dock-bg: rgba(255,255,255,.55);
  --dock-edge: rgba(255,255,255,.8);
  --chip-alpha: .72;
  --label-bg: rgba(255,255,255,.88);
  --close-bg: rgba(255,255,255,.55);
  --detail-bg: rgba(248,250,251,.9);
  --detail-edge: rgba(255,255,255,.82);
  --watermark: rgba(23,32,40,.05);
  --selection: #ced7e2;
  --track: rgba(28,37,45,.16);
  --scrim: rgba(23,32,40,.22);

  --shadow: 0 24px 80px rgba(45,56,68,.10);
  --shadow-small: 0 12px 40px rgba(45,56,68,.07);
  --shadow-dock: 0 16px 54px rgba(45,56,68,.11);
  --shadow-detail: -30px 30px 90px rgba(45,56,68,.16);
  --grain-opacity: .014;

  /* Pointer light */
  --lit-core: rgba(255,255,255,.85);
  --lit-mid: rgba(190,207,224,.28);
  --lit-edge: rgba(190,207,224,0);
  --ring-core: rgba(107,128,152,.7);
  --ring-mid: rgba(107,128,152,.25);
  --ring-edge: rgba(107,128,152,0);
  --accent-fill: rgba(107,128,152,.22);

  /* Ground */
  --page-bg:
    radial-gradient(circle at 14% 8%, rgba(255,255,255,.95), transparent 28rem),
    radial-gradient(circle at 80% 20%, rgba(168,183,202,.22), transparent 29rem),
    radial-gradient(circle at 72% 86%, rgba(207,216,225,.5), transparent 31rem),
    linear-gradient(180deg, #f2f5f6 0%, #e8edf0 100%);
  --ambient-a: rgba(255,255,255,.72);
  --ambient-b: rgba(154,173,194,.14);
  --visual-glow: rgba(255,255,255,.9);
  --visual-a: rgba(194,207,220,.55);
  --visual-b: rgba(255,255,255,.44);

  /* Layout */
  --dock-space: 108px;
  --frame-x: 40px;
  --frame-top: 34px;
}

/* Dark. The inline head script resolves `system` to a concrete value and
   writes data-theme before first paint, so this needs no media-query twin
   and there is no flash. All page content is rendered from script.js, so a
   no-JS dark fallback would have nothing to colour anyway. */
:root[data-theme="dark"] {
  --bg: #10151a;
  --bg-deep: #0b1015;
  --line: rgba(255,255,255,.09);
  --line-strong: rgba(255,255,255,.17);
  --text: #e9eef3;
  --muted: #9aa7b4;
  --accent: #8ba3be;
  --accent-ink: #a9bed7;
  --accent-soft: rgba(139,163,190,.16);

  --close: #ea8a84;
  --close-soft: rgba(234,138,132,.13);
  --close-line: rgba(234,138,132,.34);

  --pane-edge: rgba(255,255,255,.10);
  --pane-a: rgba(255,255,255,.075);
  --pane-b: rgba(255,255,255,.035);
  --card-edge: rgba(255,255,255,.08);
  --card-a: rgba(255,255,255,.06);
  --card-b: rgba(255,255,255,.025);
  --fill-soft: rgba(255,255,255,.045);
  --fill-softer: rgba(255,255,255,.04);
  --fill-chip: rgba(255,255,255,.05);
  --dock-bg: rgba(31,39,49,.62);
  --dock-edge: rgba(255,255,255,.11);
  --chip-alpha: .11;
  --label-bg: rgba(40,49,60,.95);
  --close-bg: rgba(255,255,255,.06);
  --detail-bg: rgba(18,24,30,.93);
  --detail-edge: rgba(255,255,255,.10);
  --watermark: rgba(255,255,255,.045);
  --selection: #33465c;
  --track: rgba(255,255,255,.18);
  --scrim: rgba(0,0,0,.5);

  --shadow: 0 24px 80px rgba(0,0,0,.46);
  --shadow-small: 0 12px 40px rgba(0,0,0,.3);
  --shadow-dock: 0 16px 54px rgba(0,0,0,.42);
  --shadow-detail: -30px 30px 90px rgba(0,0,0,.52);
  --grain-opacity: .022;

  --lit-core: rgba(255,255,255,.13);
  --lit-mid: rgba(150,180,215,.07);
  --lit-edge: rgba(150,180,215,0);
  --ring-core: rgba(175,200,228,.55);
  --ring-mid: rgba(175,200,228,.16);
  --ring-edge: rgba(175,200,228,0);
  --accent-fill: rgba(139,163,190,.3);

  --page-bg:
    radial-gradient(circle at 14% 8%, rgba(92,114,140,.20), transparent 28rem),
    radial-gradient(circle at 80% 20%, rgba(58,76,98,.28), transparent 29rem),
    radial-gradient(circle at 72% 86%, rgba(32,44,58,.55), transparent 31rem),
    linear-gradient(180deg, #121821 0%, #0c1117 100%);
  --ambient-a: rgba(120,150,190,.10);
  --ambient-b: rgba(80,105,135,.13);
  --visual-glow: rgba(255,255,255,.10);
  --visual-a: rgba(70,90,115,.5);
  --visual-b: rgba(255,255,255,.04);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--t-base);
  line-height: 1.6;
  overflow: hidden;
  background: var(--page-bg);
}

button,
a {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
  text-align: inherit;
}

::selection {
  background: var(--selection);
}

:where(a, button, [tabindex]):focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 3px;
}

.ambient {
  position: fixed;
  border-radius: 50%;
  filter: blur(55px);
  pointer-events: none;
  z-index: 0;
}

.ambient-a {
  width: 430px;
  height: 430px;
  left: -110px;
  top: -80px;
  background: var(--ambient-a);
}

.ambient-b {
  width: 520px;
  height: 520px;
  right: -130px;
  bottom: -160px;
  background: var(--ambient-b);
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.78' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}

.workspace {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100vh;
  padding: var(--frame-top) var(--frame-x) var(--dock-space);
  overflow: hidden;
}

.workspace-brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-6);
  position: relative;
  z-index: 3;
}

.workspace-brand h1 {
  margin: var(--s-1) 0 0;
  font-size: var(--t-md);
  line-height: 1.1;
  letter-spacing: -.02em;
  font-weight: 600;
}

.mini-label {
  margin: 0;
  color: var(--muted);
  font: 500 var(--t-micro)/1.4 var(--mono);
  letter-spacing: .06em;
}

.workspace-meta {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  color: var(--muted);
  font-size: var(--t-sm);
}

/* Portfolio demo: the way back to the current portfolio */
.demo-return {
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--accent-ink);
  font-weight: 500;
  text-decoration: none;
  transition: background .2s ease, border-color .2s ease;
}

.demo-return:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* On phones the meta row wraps, so the way back gets a line of its own */
@media (max-width: 680px) {
  .demo-return-wrap {
    flex-basis: 100%;
    margin-bottom: var(--s-1);
  }

  .demo-return-dot {
    display: none;
  }
}

.meta-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

/* Flex, not inline text flow — mixing an inline-flex key with a plain
   text node in one ordinary line box left the text sitting 3-4px above
   the key's visual centre. Flex centring is what already keeps .key
   aligned correctly inside .help-row; this uses the same mechanism. */
.meta-hint {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: 500 var(--t-micro)/1.4 var(--mono);
}

/* ---------- Intro ---------- */

.desktop-intro {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  width: min(940px, calc(100vw - (var(--frame-x) * 2)));
  transform: translate(-50%, -54%);
  text-align: center;
}

.intro-copy h2 {
  margin: 0 auto;
  max-width: 17ch;
  font-size: var(--t-hero);
  line-height: 1;
  letter-spacing: -.035em;
  font-weight: 620;
  text-wrap: balance;
}

.intro-copy h2 span {
  color: var(--accent);
  font-weight: inherit;
}

.intro-lead {
  max-width: 52ch;
  margin: var(--s-5) auto 0;
  color: var(--muted);
  font-size: var(--t-md);
  line-height: 1.6;
  text-wrap: pretty;
}

/* A small keycap, distinct from .tag's full pill — squared-off corners
   read as a physical key rather than a category label. Reused inside the
   help window so every shortcut is written the same way once. */
.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  margin: 0 1px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--fill-chip);
  color: var(--text);
  font: 500 var(--t-micro)/1 var(--mono);
}

/* ---------- Dock ---------- */

.dock-wrap {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: var(--s-5);
  transform: translateX(-50%);
}

.dock {
  display: flex;
  align-items: end;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--dock-edge);
  border-radius: 24px;
  background: var(--dock-bg);
  box-shadow: var(--shadow-dock);
  backdrop-filter: blur(28px) saturate(120%);
  -webkit-backdrop-filter: blur(28px) saturate(120%);
}

.dock-item {
  /* Two separate signals, deliberately.

     --lift is continuous proximity: how near the pointer is. It drives the
     chip, the scale and the rise, so attention spreads across neighbours.
     Bounded by the dock's 10px padding — a chip that breaks the container
     edge looks like a bug, not magnification.

     --focus is targeting: this is the one slot the pointer is actually on.
     It drives the glyph's moving parts. A slider that slides because you
     are pointing at the icon *beside* it reads as the wrong thing
     responding, so glyph motion never runs on a neighbour. */
  --lift: 0;
  --focus: 0;
  --press: 1;
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 17px;
  cursor: pointer;
  background: rgba(255, 255, 255, calc(var(--lift) * var(--chip-alpha)));
  transform:
    translateY(calc(var(--lift) * -4px))
    scale(calc((1 + var(--lift) * .08) * var(--press)));
  transition:
    transform .3s var(--ease-out),
    background .3s var(--ease-out);
}

.dock-item:active {
  --press: .94;
  transition-duration: .09s;
}

/* Resting values for when the pointer script isn't driving these:
   reduced motion, touch, or keyboard. JS overrides them inline. */
.dock-item.is-active {
  --lift: .62;
  --focus: 1;
}

.dock-item:focus-visible {
  --lift: .85;
  --focus: 1;
}

/* Program-driven landing focus (focusWithoutRing) — see script.js. Kills
   the lift and label below too, not just the outline; :focus-visible
   still matches, only the outline is unset inline, so without this the
   chip and tooltip would stay stuck open right after a panel closes. */
.dock-item.focus-landed:focus-visible {
  --lift: 0;
  --focus: 0;
}

@media (hover: hover) {
  .dock-item:hover {
    --lift: .9;
    --focus: 1;
  }
}

@media (hover: none) {
  /* :hover sticks after a tap on touch, so selection is declared last. */
  .dock-item:hover {
    --lift: .8;
    --focus: 1;
  }

  .dock-item.is-active {
    --lift: 1;
    --focus: 1;
  }
}

.dock-label {
  position: absolute;
  bottom: calc(100% + var(--s-3));
  left: 50%;
  transform: translate(-50%, 6px);
  opacity: 0;
  pointer-events: none;
  padding: var(--s-2) var(--s-3);
  border-radius: 10px;
  background: var(--label-bg);
  box-shadow: var(--shadow-small);
  color: var(--text);
  font-size: var(--t-xs);
  white-space: nowrap;
  transition: opacity .18s ease, transform .18s ease;
}

@media (hover: hover) {
  .dock-item:hover .dock-label {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.dock-item:focus-visible .dock-label {
  opacity: 1;
  transform: translate(-50%, 0);
}

.dock-item.focus-landed:focus-visible .dock-label {
  opacity: 0;
  transform: translate(-50%, 6px);
}

.dock-icon {
  position: relative;
  z-index: 1;
  width: 28px;
  height: 28px;
  display: block;
}

/* Each glyph animates its own parts off --focus, so only the slot the
   pointer is actually on moves. Every travel distance below is checked
   against the 28px glyph box.

   The set is built so the four silhouettes stay distinct at 28px: split
   panes, a figure, horizontal tracks, one bubble. Shared 1.5px stroke. */
.dock-icon span {
  transition: transform .34s var(--ease-out);
}

/* Work — the asymmetric project grid the panel actually shows.

   Sliding the panes apart was a position change with nothing behind it.
   This instead runs light across the grid: each pane dips and catches the
   accent in turn, echoing how a surface lights as it opens from the dock.
   One shot on arrival rather than a held pose — the chip already carries
   the held state. */
.icon-work span {
  position: absolute;
  border: 1.5px solid var(--text);
}

.icon-work span:nth-child(1) {
  left: 3px;
  top: 5px;
  bottom: 5px;
  width: 11px;
  border-radius: 4px;
}

.icon-work span:nth-child(2),
.icon-work span:nth-child(3) {
  right: 3px;
  width: 8px;
  height: 8px;
  border-radius: 3px;
}

.icon-work span:nth-child(2) { top: 5px; }
.icon-work span:nth-child(3) { bottom: 5px; }

.dock-item.is-target .icon-work span,
.dock-item:focus-visible .icon-work span {
  animation: pane-catch .58s var(--ease-out) backwards;
}

.dock-item.is-target .icon-work span:nth-child(2),
.dock-item:focus-visible .icon-work span:nth-child(2) {
  animation-delay: .08s;
}

.dock-item.is-target .icon-work span:nth-child(3),
.dock-item:focus-visible .icon-work span:nth-child(3) {
  animation-delay: .16s;
}

@keyframes pane-catch {
  0%, 100% {
    transform: translateY(0) scale(1);
    background-color: transparent;
    border-color: var(--text);
  }
  40% {
    transform: translateY(-2.5px) scale(.94);
    background-color: var(--accent-fill);
    border-color: var(--accent);
  }
}

/* About — the figure nods. Head dips, shoulders take the squash, then it
   comes back up through a small overshoot. Rising straighter was just the
   figure getting taller; a nod is a person noticing you. */
.icon-about span:first-child {
  position: absolute;
  left: 50%;
  top: 4px;
  width: 8px;
  height: 8px;
  border: 1.5px solid var(--text);
  border-radius: 50%;
  transform: translateX(-50%);
}

.icon-about span:last-child {
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 18px;
  height: 10px;
  border: 1.5px solid var(--text);
  border-radius: 9px 9px 4px 4px;
  transform: translateX(-50%);
}

.dock-item.is-target .icon-about span:first-child,
.dock-item:focus-visible .icon-about span:first-child {
  animation: head-nod .62s var(--ease-out) backwards;
}

.dock-item.is-target .icon-about span:last-child,
.dock-item:focus-visible .icon-about span:last-child {
  animation: shoulders-give .62s var(--ease-out) .04s backwards;
}

/* translateX(-50%) is the centring, not part of the motion — every frame
   has to carry it or the figure jumps to the left edge mid-nod. */
@keyframes head-nod {
  0%   { transform: translateX(-50%) translateY(0); }
  28%  { transform: translateX(-50%) translateY(1.5px); }
  62%  { transform: translateX(-50%) translateY(-2.5px); }
  100% { transform: translateX(-50%) translateY(0); }
}

@keyframes shoulders-give {
  0%   { transform: translateX(-50%) scaleX(1); }
  28%  { transform: translateX(-50%) scaleX(1.07); }
  62%  { transform: translateX(-50%) scaleX(.97); }
  100% { transform: translateX(-50%) scaleX(1); }
}

/* Toolkit — three sliders being set. One gesture: each bar slides to its
   mark and springs, staggered down the stack. An earlier version ran a
   keyframe cascade with explicit overshoots; three bars darting out and
   snapping back read as a glitch at 28px rather than as controls moving.
   --ease-settle gives the overshoot for free, in both directions. */
.icon-stack span {
  position: absolute;
  left: 50%;
  width: 22px;
  height: 7px;
  border: 1.5px solid var(--text);
  border-radius: 7px;
  transform: translateX(calc(-50% + var(--settle, 0px) * var(--focus)));
  transition: transform .44s var(--ease-settle);
}

.icon-stack span:nth-child(1) {
  top: 2px;
  --settle: 1.5px;
}

.icon-stack span:nth-child(2) {
  top: 10px;
  width: 18px;
  --settle: -3px;
  transition-delay: .05s;
}

.icon-stack span:nth-child(3) {
  top: 18px;
  width: 14px;
  --settle: 3.5px;
  transition-delay: .1s;
}

/* Contact — the message completes. The short line extends to meet the
   long one and springs into place. It used to wipe both lines to nothing
   and redraw them; content vanishing and reappearing reads as a rendering
   fault, not as typing. */
.icon-contact span:first-child {
  position: absolute;
  left: 3px;
  right: 3px;
  top: 5px;
  height: 16px;
  border: 1.5px solid var(--text);
  border-radius: 6px 6px 6px 2px;
}

.icon-contact span:nth-child(2),
.icon-contact span:nth-child(3) {
  position: absolute;
  left: 7px;
  height: 1.5px;
  background: var(--text);
  border-radius: 999px;
  transform-origin: left;
}

.icon-contact span:nth-child(2) {
  top: 10px;
  width: 14px;
}

.icon-contact span:nth-child(3) {
  top: 14.5px;
  width: 8px;
  transform: scaleX(calc(1 + var(--focus) * .75));
  transition: transform .44s var(--ease-settle) .06s;
}

/* Profile — a small ID card: frame, avatar dot, name line. Plain
   --focus-driven transitions, same recipe as Toolkit/Contact, no keyframes
   needed for a dot and a line. */
.icon-profile span:first-child {
  position: absolute;
  inset: 2px 1px;
  border: 1.5px solid var(--text);
  border-radius: 6px;
}

.icon-profile span:nth-child(2) {
  position: absolute;
  left: 6px;
  top: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text);
  transform: scale(calc(1 + var(--focus) * .25));
  transition: transform .4s var(--ease-settle);
}

.icon-profile span:last-child {
  position: absolute;
  left: 15px;
  top: 9.5px;
  width: 7px;
  height: 1.5px;
  background: var(--text);
  border-radius: 999px;
  transform-origin: left;
  transform: scaleX(calc(1 + var(--focus) * .7));
  transition: transform .4s var(--ease-settle) .05s;
}

/* Display — a circle half filled, not a gear. It states the current theme
   rather than naming a category, it is the only circular glyph in the set,
   and at 28px it survives where gear teeth would not. On focus it rotates
   through the change it performs. */
.icon-appearance {
  width: 22px;
  height: 22px;
}

.icon-appearance span {
  position: absolute;
  inset: 0;
  border: 1.5px solid var(--text);
  border-radius: 50%;
  overflow: hidden;
  transform: rotate(calc(var(--focus) * 180deg));
  transition: transform .5s var(--ease-settle);
}

.icon-appearance span::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--text);
  clip-path: inset(0 50% 0 0);
}

:root[data-theme="dark"] .icon-appearance span::after {
  clip-path: inset(0 0 0 50%);
}

.dock-divider {
  align-self: center;
  width: 1px;
  height: 26px;
  margin-inline: 3px;
  background: var(--line-strong);
}

/* Same 58px hit target as its neighbours — only the glyph is smaller, so
   the utility reads as a different class of thing without becoming a
   smaller touch target. */
.dock-utility .dock-icon {
  width: 22px;
  height: 22px;
}

/* ---------- Settings ---------- */

.settings {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: calc(100% + 14px);
  width: min(310px, calc(100vw - (var(--frame-x) * 2)));
  padding: var(--s-5);
  display: grid;
  gap: var(--s-5);
  border: 1px solid var(--pane-edge);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, var(--pane-a), var(--pane-b));
  box-shadow: var(--shadow);
  backdrop-filter: blur(34px) saturate(118%);
  -webkit-backdrop-filter: blur(34px) saturate(118%);
  opacity: 0;
  transform: translateY(8px) scale(.97);
  transform-origin: bottom right;
  pointer-events: none;
  transition:
    opacity .22s ease,
    transform .3s var(--ease-out);
}

.settings.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
}

.settings-text {
  display: grid;
  gap: 2px;
}

.settings-label {
  font-size: var(--t-sm);
  font-weight: 500;
}

.settings-hint {
  color: var(--muted);
  font-size: var(--t-micro);
  line-height: 1.4;
}

.segmented {
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--fill-softer);
}

.segmented button {
  padding: 6px 9px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: 500 var(--t-micro)/1 var(--mono);
  transition: background .2s ease, color .2s ease;
}

.segmented button[aria-checked="true"] {
  background: var(--glass-strong);
  color: var(--text);
  box-shadow: var(--shadow-small);
}

:root[data-theme="dark"] .segmented button[aria-checked="true"] {
  background: rgba(255,255,255,.13);
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 23px;
  border-radius: 999px;
  background: var(--track);
  cursor: pointer;
  transition: background .24s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.28);
  transition: transform .28s var(--ease-settle);
}

.switch[aria-checked="true"] {
  background: var(--accent);
}

.switch[aria-checked="true"]::after {
  transform: translateX(17px);
}

.settings-note {
  margin: 0;
  color: var(--muted);
  font: 500 var(--t-micro)/1.5 var(--mono);
}

.settings-note:empty {
  display: none;
}

/* No cursor, no pointer light — the control would do nothing here, and an
   inert switch is worse than one that isn't offered. */
@media (hover: none) {
  .settings-row-pointer {
    display: none;
  }
}

@media (max-width: 680px) {
  .settings {
    right: 50%;
    transform: translate(50%, 8px) scale(.97);
    transform-origin: bottom center;
  }

  .settings.is-open {
    transform: translate(50%, 0);
  }
}

/* ---------- Help ----------
   Keyboard-only entry point (H) — there's no dock button for it to grow
   from, so it doesn't try to. A centered dialog with a scrim is a
   different kind of thing from the anchored panels: the one place here
   that behaves like a classic blocking modal, and it's styled to read
   that way rather than forced into the dock-grow pattern. */

.help-scrim {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--scrim);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s ease;
}

.help-scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

.help {
  position: fixed;
  z-index: 91;
  left: 50%;
  top: 50%;
  width: min(360px, calc(100vw - (var(--frame-x) * 2)));
  transform: translate(-50%, -50%) scale(.96);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity .22s ease,
    transform .3s var(--ease-out);
}

.help.is-open {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.help-shell {
  border: 1px solid var(--pane-edge);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, var(--pane-a), var(--pane-b));
  box-shadow: var(--shadow);
  backdrop-filter: blur(34px) saturate(118%);
  -webkit-backdrop-filter: blur(34px) saturate(118%);
  overflow: hidden;
}

.help-shell .surface-header {
  padding: var(--s-5) var(--s-5) var(--s-4);
}

.help-shell .surface-header h3 {
  font-size: var(--t-lg);
}

.help-list {
  display: grid;
  gap: 2px;
  padding: var(--s-3) var(--s-5) var(--s-5);
}

.help-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 7px 0;
  font-size: var(--t-sm);
}

.help-row .key {
  flex: 0 0 auto;
  min-width: 26px;
}

@media (max-width: 680px) {
  .help-shell .surface-header {
    padding: var(--s-4) var(--s-4) var(--s-3);
  }

  .help-list {
    padding: var(--s-2) var(--s-4) var(--s-4);
  }
}

/* ---------- Light ----------
   One idea applied in three places: glass catches the pointer. A diffuse
   wash across the pane, a specular line along its edge, and — on the dock —
   proximity lift driven by the same pointer position. */

[data-lit] {
  position: relative;
}

[data-lit]::before,
[data-lit]::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity .5s ease;
}

/* A white bloom is invisible on near-white glass, so the wash carries a
   cool tint at its edge — bright core, cool falloff, like light through glass. */
[data-lit]::before {
  z-index: 0;
  background: radial-gradient(
    var(--lit-size, 320px) circle at var(--mx, 50%) var(--my, 50%),
    var(--lit-core) 0%,
    var(--lit-mid) 42%,
    var(--lit-edge) 72%
  );
}

/* Gradient-border trick: the 1px ring picks up the accent nearest the
   pointer. Tinting reads here where a brighter white would not. */
[data-lit]::after {
  z-index: 3;
  padding: 1px;
  background: radial-gradient(
    var(--lit-size, 320px) circle at var(--mx, 50%) var(--my, 50%),
    var(--ring-core) 0%,
    var(--ring-mid) 38%,
    var(--ring-edge) 62%
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
}

[data-lit].is-lit::before,
[data-lit].is-lit::after {
  opacity: 1;
}

/* Content sits above the wash */
.surface-header,
.surface-scroll,
.project-card > *,
.detail-inner {
  position: relative;
  z-index: 1;
}

/* ---------- Surfaces ---------- */

.surface-layer {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

.surface {
  --origin-x: 50%;
  --origin-y: calc(100% - 70px);
  position: absolute;
  inset: 88px var(--frame-x) var(--dock-space);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform:
    translate(
      calc(var(--origin-x) - 50%),
      calc(var(--origin-y) - 50%)
    )
    scale(.16);
  transform-origin: var(--origin-x) var(--origin-y);
  filter: blur(18px);
  pointer-events: none;
  transition:
    opacity .34s ease,
    transform .62s cubic-bezier(.16,.82,.23,1),
    filter .45s ease;
}

.surface.is-open {
  opacity: 1;
  transform: translate(0,0) scale(1);
  filter: blur(0);
  pointer-events: auto;
}

/* Height follows content, capped at the frame — so short sections
   (Toolkit, Contact) read as panels, not half-empty boxes. */
.surface-shell {
  width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--pane-edge);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(145deg, var(--pane-a), var(--pane-b));
  box-shadow: var(--shadow);
  backdrop-filter: blur(34px) saturate(118%);
  -webkit-backdrop-filter: blur(34px) saturate(118%);
  overflow: hidden;
}

.compact-shell {
  width: min(1000px, 100%);
  margin-inline: auto;
}

.contact-shell {
  width: min(940px, 100%);
  margin-inline: auto;
}

.surface-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--s-6);
  padding: var(--s-6) var(--s-6) var(--s-5);
  border-bottom: 1px solid var(--line);
}

.surface-header h3 {
  text-wrap: balance;
  margin: var(--s-2) 0 0;
  font-size: var(--t-panel);
  letter-spacing: -.03em;
  line-height: 1.05;
  font-weight: 620;
}

.surface-close,
.detail-close,
.site-close {
  position: relative;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 13px;
  background: var(--close-bg);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform .2s ease, background .2s ease, border-color .2s ease;
}

/* :hover only, deliberately not :focus-visible. Every panel moves keyboard
   focus straight to its own close button on open, and a JS-triggered
   .focus() call is treated as focus-visible by the browser — so pairing
   this with :focus-visible meant every panel opened already looking red,
   rotated, and double-ringed (the blue focus outline plus this) before
   anyone had touched anything. The plain outline already says "focused";
   the red stays reserved for an actual pointer over the button. */
.surface-close:hover,
.detail-close:hover,
.site-close:hover {
  transform: rotate(3deg);
  background: var(--close-soft);
  border-color: var(--close-line);
}

.surface-close span,
.detail-close span,
.site-close span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 1.5px;
  background: var(--text);
  border-radius: 999px;
  transition: background .2s ease;
}

.surface-close:hover span,
.detail-close:hover span,
.site-close:hover span {
  background: var(--close);
}

.surface-close span:first-child,
.detail-close span:first-child,
.site-close span:first-child {
  transform: translate(-50%,-50%) rotate(45deg);
}

.surface-close span:last-child,
.detail-close span:last-child,
.site-close span:last-child {
  transform: translate(-50%,-50%) rotate(-45deg);
}

.surface-scroll {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: var(--s-5) var(--s-6) var(--s-6);
}

/* ---------- Work ---------- */

.project-list {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--s-3);
}

.project-card {
  min-height: 232px;
  grid-column: span 6;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: var(--s-5);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius-md);
  background:
    linear-gradient(145deg, var(--card-a), var(--card-b));
  box-shadow: var(--shadow-small);
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease;
}

/* Alternating 7/5 then 5/7 — each row totals 12, so no orphan gap. */
.project-card:nth-child(4n+1),
.project-card:nth-child(4n+4) {
  grid-column: span 7;
}

.project-card:nth-child(4n+2),
.project-card:nth-child(4n+3) {
  grid-column: span 5;
}

.project-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.project-top {
  display: flex;
  justify-content: space-between;
  gap: var(--s-5);
  color: var(--muted);
  font: 500 var(--t-micro)/1.4 var(--mono);
  letter-spacing: .04em;
}

.project-copy {
  display: block;
  margin-top: auto;
}

.project-title {
  display: block;
  margin-bottom: var(--s-3);
  font-size: var(--t-card);
  line-height: 1.05;
  letter-spacing: -.025em;
  font-weight: 620;
}

.project-summary {
  display: block;
  max-width: 44ch;
  color: var(--muted);
  line-height: 1.6;
  font-size: var(--t-sm);
}

.project-tags,
.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.project-tags {
  margin-top: var(--s-4);
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 var(--s-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--fill-softer);
  font: 500 var(--t-micro)/1 var(--mono);
}

/* ---------- About ---------- */

.about-grid {
  display: grid;
  grid-template-columns: 1.08fr .92fr;
  gap: var(--s-3);
  align-content: start;
}

.about-lead,
.about-note,
.timeline {
  border: 1px solid var(--card-edge);
  border-radius: var(--radius-md);
  background: var(--fill-soft);
}

.about-lead {
  padding: var(--s-6);
  display: flex;
  align-items: flex-end;
}

.about-lead p {
  text-wrap: balance;
  max-width: 26ch;
  margin: 0;
  font-size: var(--t-lead);
  line-height: 1.12;
  letter-spacing: -.03em;
}

/* No overflow:hidden here — it zeroes a grid item's automatic minimum size,
   which lets the shorter lead card dictate the row and clip this one. The
   watermark is positioned to stay inside the box instead. */
.about-note {
  position: relative;
  padding: var(--s-6);
}

.about-index {
  position: absolute;
  right: var(--s-5);
  top: var(--s-2);
  color: var(--watermark);
  font-size: 6rem;
  line-height: 1;
  font-weight: 650;
}

.about-note h4 {
  text-wrap: balance;
  position: relative;
  z-index: 1;
  margin: 0 0 var(--s-3);
  max-width: 22ch;
  font-size: var(--t-lg);
  line-height: 1.15;
  letter-spacing: -.02em;
}

.about-note p {
  position: relative;
  z-index: 1;
  max-width: 46ch;
  margin: 0;
  color: var(--muted);
  font-size: var(--t-base);
  line-height: 1.65;
}

.timeline {
  grid-column: 1 / -1;
  padding: var(--s-2) var(--s-5);
}

.timeline-item {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: var(--s-6);
  padding: var(--s-5) var(--s-1);
  border-bottom: 1px solid var(--line);
}

.timeline-item:last-child {
  border-bottom: 0;
}

.timeline-year {
  color: var(--accent-ink);
  font: 500 var(--t-micro)/1.6 var(--mono);
}

.timeline-item h4 {
  margin: 0 0 var(--s-1);
  font-size: var(--t-base);
  letter-spacing: -.01em;
}

.timeline-org {
  font-weight: 400;
  color: var(--muted);
}

.timeline-item p {
  max-width: 62ch;
  margin: 0;
  color: var(--muted);
  font-size: var(--t-sm);
  line-height: 1.6;
}

/* ---------- Profile (exploratory alternative to About) ---------- */

.profile-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: var(--s-5);
  align-items: start;
}

.profile-sidebar {
  position: sticky;
  top: 0;
}

.profile-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  padding: var(--s-6);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius-md);
  background: var(--fill-soft);
  overflow: hidden;
}

.profile-banner {
  height: 88px;
  margin: calc(var(--s-6) * -1) calc(var(--s-6) * -1) 0;
  background: linear-gradient(135deg, var(--card-a), var(--accent-soft));
  border-bottom: 1px solid var(--line);
}

.profile-card-top {
  display: flex;
  align-items: flex-end;
  gap: var(--s-4);
  margin-top: -40px;
}

.profile-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 84px;
  height: 84px;
  overflow: hidden;
  border: 1px solid var(--card-edge);
  border-radius: 50%;
  background: linear-gradient(160deg, var(--card-a), var(--card-b));
  font: 600 var(--t-md)/1 var(--mono);
  letter-spacing: -.02em;
}

.profile-avatar.has-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-id h4 {
  margin: 0;
  font-size: var(--t-lg);
  letter-spacing: -.02em;
}

.profile-handle {
  margin: var(--s-1) 0 0;
  color: var(--accent-ink);
  font: 500 var(--t-micro)/1.4 var(--mono);
  letter-spacing: .02em;
  text-transform: uppercase;
}

.profile-bio {
  max-width: 60ch;
  margin: 0;
  color: var(--muted);
  font-size: var(--t-base);
  line-height: 1.65;
}

.profile-meta,
.profile-languages {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  padding-top: var(--s-5);
  border-top: 1px solid var(--line);
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-1) 0;
  text-decoration: none;
  font-size: var(--t-sm);
}

.meta-row-label {
  color: var(--muted);
}

.meta-row-value {
  max-width: 60%;
  color: var(--accent-ink);
  font: 500 var(--t-xs)/1.4 var(--mono);
  text-align: right;
  overflow-wrap: break-word;
}

.meta-row:hover .meta-row-value {
  text-decoration: underline;
}

.lang-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--s-1) 0;
  font-size: var(--t-sm);
}

.lang-level {
  color: var(--accent-ink);
  font: 500 var(--t-micro)/1.4 var(--mono);
  text-transform: uppercase;
  letter-spacing: .02em;
}

.profile-card .site-stats {
  margin: 0;
  padding-top: var(--s-5);
  border-top: 1px solid var(--line);
}

.feed {
  border: 1px solid var(--card-edge);
  border-radius: var(--radius-md);
  background: var(--fill-soft);
  padding: var(--s-2) var(--s-5);
}

.feed-item {
  width: 100%;
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-1);
  border-bottom: 1px solid var(--line);
}

.feed-item:last-child {
  border-bottom: 0;
}

.feed-item-project {
  cursor: pointer;
  background: transparent;
  border-radius: var(--radius-sm);
  transition: background .2s ease;
}

.feed-item-project:hover {
  background: var(--fill-softer);
}

.feed-dot {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--accent-ink);
}

.feed-meta {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-1);
}

/* The kind pill is the one accent-colored thing per row; year and org
   stay plain so they read as metadata rather than competing for it. */
.feed-kind {
  padding: 2px var(--s-2);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font: 600 var(--t-micro)/1.4 var(--mono);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.feed-year,
.feed-org {
  color: var(--muted);
  font: 500 var(--t-micro)/1.6 var(--mono);
}

.feed-body h4 {
  margin: 0 0 var(--s-1);
  font-size: var(--t-base);
  letter-spacing: -.01em;
}

.feed-body p {
  max-width: 62ch;
  margin: 0;
  color: var(--muted);
  font-size: var(--t-sm);
  line-height: 1.6;
}

.feed-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-3);
}

/* ---------- Toolkit ---------- */

.stack-grid {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: var(--s-3);
}

.stack-group {
  display: flex;
  flex-direction: column;
  padding: var(--s-5);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius-md);
  background: var(--fill-soft);
}

.stack-group header {
  display: flex;
  justify-content: space-between;
  gap: var(--s-5);
  align-items: baseline;
  margin-bottom: var(--s-5);
}

.stack-group h4 {
  margin: 0;
  font-size: var(--t-lg);
  line-height: 1.1;
  letter-spacing: -.02em;
}

.stack-group header span {
  color: var(--accent-ink);
  font: 500 var(--t-micro)/1 var(--mono);
}

.stack-items {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.stack-chip {
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--fill-chip);
  color: var(--muted);
  font: 500 var(--t-xs)/1 var(--mono);
}

/* ---------- Contact ---------- */

.contact-layout {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: var(--s-8);
  align-items: center;
}

.contact-layout > p {
  text-wrap: balance;
  max-width: 22ch;
  margin: 0;
  font-size: var(--t-xl);
  line-height: 1.15;
  letter-spacing: -.025em;
}

.contact-links {
  display: grid;
  gap: 0;
}

.contact-link {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-5);
  padding: var(--s-4) var(--s-1);
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  font-size: var(--t-base);
}

.contact-link:first-child {
  border-top: 1px solid var(--line);
}

.contact-value {
  display: inline-flex;
  align-items: baseline;
  gap: var(--s-2);
  color: var(--muted);
  font-size: var(--t-sm);
}

.contact-arrow {
  transition: transform .22s cubic-bezier(.2,.7,.2,1);
}

.contact-link:hover .contact-arrow,
.contact-link:focus-visible .contact-arrow {
  transform: translate(2px, -2px);
}

/* ---------- Project detail ---------- */

.project-detail {
  position: fixed;
  z-index: 95;
  inset: var(--s-5) var(--s-5) var(--s-5) auto;
  width: min(760px, calc(100vw - (var(--s-5) * 2)));
  transform: translateX(calc(100% + 50px)) scale(.98);
  opacity: 0;
  border: 1px solid var(--detail-edge);
  border-radius: 28px;
  background: var(--detail-bg);
  box-shadow: var(--shadow-detail);
  backdrop-filter: blur(34px);
  transition:
    transform .48s cubic-bezier(.2,.8,.2,1),
    opacity .28s ease;
  overflow: hidden;
}

.project-detail.is-open {
  transform: translateX(0) scale(1);
  opacity: 1;
}

.detail-close {
  position: absolute;
  right: var(--s-5);
  top: var(--s-5);
  z-index: 3;
}

.detail-inner {
  height: 100%;
  overflow: auto;
  padding: var(--s-8) var(--s-6) var(--s-7);
}

.detail-meta {
  display: flex;
  gap: var(--s-4);
  max-width: 560px;
}

.detail-meta span:last-child {
  color: var(--accent-ink);
}

.detail-inner > h3 {
  text-wrap: balance;
  margin: var(--s-3) 0 var(--s-4);
  max-width: 14ch;
  font-size: var(--t-3xl);
  line-height: 1;
  letter-spacing: -.035em;
  font-weight: 620;
}

.detail-summary {
  max-width: 50ch;
  margin: 0;
  color: var(--muted);
  font-size: var(--t-md);
  line-height: 1.6;
}

.detail-tags {
  margin: var(--s-5) 0 var(--s-6);
}

.detail-visual {
  /* 2:1 keeps the story section peeking above the fold, so it reads as
     scrollable rather than as the end of the panel. */
  aspect-ratio: 2 / 1;
  display: grid;
  place-items: center;
  margin-bottom: var(--s-6);
  overflow: hidden;
  border: 1px solid var(--card-edge);
  border-radius: var(--radius-md);
  background:
    radial-gradient(circle at 28% 22%, var(--visual-glow), transparent 24%),
    linear-gradient(135deg, var(--visual-a), var(--visual-b));
  color: var(--muted);
  font: 500 var(--t-micro)/1 var(--mono);
  letter-spacing: .06em;
}

.detail-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.detail-story {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: var(--s-4);
}

.detail-story article {
  padding: var(--s-4) 0 0;
  border-top: 1px solid var(--line-strong);
}

.detail-story article > span {
  color: var(--accent-ink);
  font: 500 var(--t-micro)/1 var(--mono);
}

.detail-story h4 {
  margin: var(--s-3) 0 var(--s-2);
  font-size: var(--t-base);
  letter-spacing: -.01em;
}

.detail-story p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: var(--t-sm);
}

/* ---------- Project site ---------- */

.project-site {
  --origin-x: 50%;
  --origin-y: 50%;
  position: fixed;
  /* Same top/side/bottom insets as .surface, not edge-to-edge — the
     windows inside would otherwise start exactly under the page header
     (workspace-brand) instead of clearing it the way every other panel
     already does. */
  inset: 88px var(--frame-x) var(--dock-space);
  z-index: 100;
  display: flex;
  flex-direction: column;
  opacity: 0;
  /* No fill of its own — this is a positioning/motion wrapper, not a
     page. The two windows inside carry the actual glass; the desktop
     (ambient blobs, grain, dock) stays visible and blurs through them
     exactly like any other surface. */
  transform:
    translate(
      calc(var(--origin-x) - 50%),
      calc(var(--origin-y) - 50%)
    )
    scale(.16);
  transform-origin: var(--origin-x) var(--origin-y);
  filter: blur(18px);
  pointer-events: none;
  transition:
    opacity .34s ease,
    transform .62s cubic-bezier(.16,.82,.23,1),
    filter .45s ease;
}

.project-site.is-open {
  opacity: 1;
  transform: translate(0,0) scale(1);
  filter: blur(0);
  pointer-events: auto;
}

/* The two windows converge from opposite sides on open and split back
   apart on close — reinforcing that they're independent panes, not one
   page, in the same beat that already staggers their fade-in. */
.site-nav,
.site-content {
  opacity: 0;
  transition: opacity .4s var(--ease-out), transform .4s var(--ease-out);
}

/* Closing reverses the open order too, not just the direction: the nav
   arrived first and leaves last, content arrived second and leaves
   first — the same stagger played back to front. */
.site-nav {
  transform: translateX(calc(-1 * var(--s-6)));
  transition-delay: .08s;
}

.site-content {
  transform: translateX(var(--s-6));
  transition-delay: 0s;
}

/* Delayed well past the frame's own opacity/blur settling (.34s/.45s)
   rather than starting near .08s/.16s like the old vertical fade did —
   measured against real frames, a slide that starts that early spends
   almost its whole distance hidden behind 10px+ of blur and has already
   arrived by the time the frame is clear enough to actually see it move.
   Closing doesn't have this problem (blur grows from 0, so an early exit
   is the visible part), so only these two open-state delays change. */
.project-site.is-open .site-nav {
  opacity: 1;
  transform: translateX(0);
  transition-delay: .3s;
}

.project-site.is-open .site-content {
  opacity: 1;
  transform: translateX(0);
  transition-delay: .42s;
}

/* .site-stage centers the window pair in whatever room is available —
   same trick as .surface centering .surface-shell — so the pair is only
   ever as tall as its taller member, never stretched to fill the
   viewport regardless of how little a section has to say. */
.site-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-2) var(--s-6) var(--s-6);
}

.site-body {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: var(--s-5);
  width: 100%;
  max-width: 1360px;
  max-height: 100%;
}

/* .site-nav and .site-content are their own floating windows — same
   translucent glass, blur, and shadow as .surface-shell, so the desktop
   behind (ambient blobs, dock) shows and lights through them instead of
   a page painted over everything. Content sets the height; each panel
   scrolls internally only if it runs past the available room. */

.site-nav {
  flex: 0 0 240px;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: var(--s-4);
  max-height: 100%;
  overflow-y: auto;
  border: 1px solid var(--pane-edge);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, var(--pane-a), var(--pane-b));
  box-shadow: var(--shadow);
  backdrop-filter: blur(34px) saturate(118%);
}

/* The project's own title, doing the job the topbar used to — one line,
   living with its own nav instead of a bar shared with the content pane. */
.site-nav-title {
  margin: 0;
  padding: 0 var(--s-4);
  font-size: var(--t-md);
  font-weight: 620;
  letter-spacing: -.01em;
}

.site-nav-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.site-nav button {
  display: block;
  width: 100%;
  padding: var(--s-3) var(--s-4);
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font: 500 var(--t-xs)/1 var(--sans);
  letter-spacing: -.01em;
  white-space: nowrap;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.site-nav button:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.site-nav button.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-ink);
  color: var(--accent-ink);
}

.site-nav button:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 2px;
}

.site-content {
  position: relative;
  flex: 1;
  min-width: 0;
  max-height: 100%;
  overflow: hidden;
  border: 1px solid var(--pane-edge);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, var(--pane-a), var(--pane-b));
  box-shadow: var(--shadow);
  backdrop-filter: blur(34px) saturate(118%);
}

/* Close lives on the content window it belongs to, same as .detail-close
   sitting inside .project-detail rather than a shared bar above it. */
.site-close {
  position: absolute;
  right: var(--s-5);
  top: var(--s-5);
  z-index: 3;
}

.site-sections {
  height: 100%;
  overflow: auto;
  padding: var(--s-7) var(--s-6) var(--s-8);
}

/* One continuous column, not a panel swapped per topic — the nav jumps
   to a section or just highlights whichever one scroll has reached. */
.site-section {
  max-width: 720px;
  margin: 0 auto;
}

.site-section + .site-section {
  margin-top: var(--s-8);
  padding-top: var(--s-7);
  border-top: 1px solid var(--line-strong);
}

.site-section-label {
  margin: 0;
  color: var(--accent-ink);
  font: 500 var(--t-micro)/1 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.site-section-title {
  margin: var(--s-2) 0 var(--s-4);
  font-size: var(--t-2xl);
  letter-spacing: -.02em;
  line-height: 1.1;
}

.site-section-body {
  margin: 0 0 var(--s-6);
  color: var(--muted);
  font-size: var(--t-base);
  line-height: 1.7;
}

.site-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-5);
  margin: var(--s-5) 0 var(--s-6);
}

.site-stat {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.site-stat-value {
  font: 600 var(--t-xl)/1 var(--mono);
  letter-spacing: -.02em;
}

.site-stat-label {
  color: var(--muted);
  font-size: var(--t-xs);
}

/* Deep-dive diagrams — small, quiet, one per section, on the existing
   card/token palette so they read as part of the system, not an insert. */

.diagram {
  margin-top: var(--s-2);
}

.diagram-vat {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-4);
}

.vat-countries {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.vat-chip {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--card-edge);
  border-radius: var(--radius-sm);
  background: linear-gradient(160deg, var(--card-a), var(--card-b));
  font: 600 var(--t-xs)/1 var(--mono);
}

.vat-arrow {
  color: var(--accent-ink);
  font-size: var(--t-lg);
}

.vat-types {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.vat-type {
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--accent-ink);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font: 500 var(--t-micro)/1 var(--mono);
  white-space: nowrap;
}

.diagram-pdf {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--s-5);
}

.pdf-mock {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  width: 130px;
  padding: var(--s-4);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius-sm);
  background: linear-gradient(160deg, var(--card-a), var(--card-b));
}

.pdf-mock-title {
  font: 600 var(--t-sm)/1 var(--mono);
  letter-spacing: .02em;
}

.pdf-mock-line {
  height: 6px;
  border-radius: 3px;
  background: var(--line-strong);
}

.pdf-mock-line.short {
  width: 60%;
}

.pdf-note {
  color: var(--accent-ink);
  font: 500 var(--t-micro)/1 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.diagram-i18n {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  max-width: 360px;
}

.i18n-row {
  display: flex;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius-sm);
  background: linear-gradient(160deg, var(--card-a), var(--card-b));
}

.i18n-country {
  color: var(--muted);
  font-size: var(--t-sm);
}

.i18n-field {
  font: 600 var(--t-sm)/1 var(--mono);
  letter-spacing: .02em;
}

.diagram-security {
  display: flex;
  justify-content: flex-start;
}

.rls-outer {
  padding: var(--s-5);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, var(--card-a), var(--card-b));
}

.rls-inner {
  margin-top: var(--s-4);
  padding: var(--s-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
}

.rls-core {
  margin-top: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font: 600 var(--t-xs)/1 var(--mono);
  text-align: center;
}

.rls-label {
  display: block;
  color: var(--muted);
  font: 500 var(--t-micro)/1 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.diagram-tiers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-3);
}

.tier-step {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-4);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius-sm);
  background: linear-gradient(160deg, var(--card-a), var(--card-b));
}

.tier-step-pro {
  border-color: var(--accent-ink);
  background: var(--accent-soft);
}

.tier-name {
  font: 600 var(--t-sm)/1 var(--mono);
}

.tier-feature {
  color: var(--muted);
  font-size: var(--t-xs);
  line-height: 1.4;
}

.diagram-testing {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-5);
}

.test-stat {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.test-stat-value {
  font: 600 var(--t-2xl)/1 var(--mono);
  letter-spacing: -.02em;
}

.test-stat-label {
  color: var(--muted);
  font-size: var(--t-xs);
}

.test-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 40px;
}

.test-bars span {
  width: 6px;
  border-radius: 3px;
  background: var(--accent);
}

.test-bars span:nth-child(1) { height: 45%; }
.test-bars span:nth-child(2) { height: 62%; }
.test-bars span:nth-child(3) { height: 55%; }
.test-bars span:nth-child(4) { height: 78%; }
.test-bars span:nth-child(5) { height: 70%; }
.test-bars span:nth-child(6) { height: 88%; }
.test-bars span:nth-child(7) { height: 82%; }
.test-bars span:nth-child(8) { height: 100%; }

/* ---------- States ---------- */

body.surface-open .desktop-intro {
  transform: translate(-50%, -54%) scale(.97);
  opacity: .12;
  filter: blur(7px);
  transition: transform .4s ease, opacity .4s ease, filter .4s ease;
}

body.surface-open .workspace-brand {
  opacity: .42;
  transition: opacity .3s ease;
}

/* ---------- Entrance ----------
   One orchestrated sequence, on first load only. `is-settled` tears the
   animations back down so they can't win specificity fights with the
   surface-open dimming later. */

.js[data-motion="full"]:not(.is-ready):not(.is-settled) .ambient,
.js[data-motion="full"]:not(.is-ready):not(.is-settled) .workspace-brand,
.js[data-motion="full"]:not(.is-ready):not(.is-settled) .intro-copy h2,
.js[data-motion="full"]:not(.is-ready):not(.is-settled) .intro-lead,
.js[data-motion="full"]:not(.is-ready):not(.is-settled) .dock-wrap {
  opacity: 0;
}

.js[data-motion="full"].is-ready:not(.is-settled) .ambient {
  animation: bloom 1.5s ease both;
}

.js[data-motion="full"].is-ready:not(.is-settled) .workspace-brand {
  animation: rise .7s var(--ease-out) .08s both;
}

.js[data-motion="full"].is-ready:not(.is-settled) .intro-copy h2 {
  animation: rise-focus .95s var(--ease-out) .18s both;
}

.js[data-motion="full"].is-ready:not(.is-settled) .intro-lead {
  animation: rise .8s var(--ease-out) .36s both;
}

.js[data-motion="full"].is-ready:not(.is-settled) .dock-wrap {
  animation: dock-in .9s var(--ease-out) .56s both;
}

@keyframes bloom {
  from { opacity: 0; transform: scale(.86); }
  to   { opacity: 1; transform: none; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* Resolves out of blur, echoing how the panels arrive from the dock. */
@keyframes rise-focus {
  from { opacity: 0; transform: translateY(20px); filter: blur(10px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

@keyframes dock-in {
  from { opacity: 0; transform: translate(-50%, 26px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  :root {
    --frame-x: 28px;
  }

  .contact-layout {
    gap: var(--s-6);
  }
}

@media (max-width: 980px) {
  :root {
    --frame-x: 22px;
  }

  .surface,
  .project-site {
    inset: 78px var(--frame-x) var(--dock-space);
  }

  .project-card,
  .project-card:nth-child(4n+1),
  .project-card:nth-child(4n+2),
  .project-card:nth-child(4n+3),
  .project-card:nth-child(4n+4) {
    grid-column: span 12;
  }

  .about-grid,
  .contact-layout,
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .profile-sidebar {
    position: static;
  }

  .about-lead p,
  .contact-layout > p {
    max-width: 34ch;
  }

  .stack-grid {
    grid-template-columns: 1fr 1fr;
  }

  .detail-story {
    grid-template-columns: 1fr;
    gap: var(--s-2);
  }

  .site-stage {
    padding: var(--s-2) var(--frame-x) var(--frame-x);
  }

  .site-nav {
    flex-basis: 200px;
  }
}

@media (max-width: 680px) {
  :root {
    --frame-x: 16px;
    --frame-top: 22px;
    --dock-space: 96px;
  }

  body {
    overflow: hidden;
  }

  .workspace-brand {
    display: block;
  }

  .workspace-meta {
    margin-top: var(--s-2);
    flex-wrap: wrap;
  }

  .desktop-intro {
    width: calc(100vw - (var(--frame-x) * 2));
  }

  .intro-copy h2 {
    font-size: clamp(2.5rem, 11.5vw, 3.5rem);
    max-width: 12ch;
  }

  .intro-lead {
    font-size: var(--t-base);
  }

  .dock {
    gap: 2px;
    padding: 6px;
    border-radius: 20px;
  }

  .dock-item {
    width: 52px;
    height: 52px;
  }

  .dock-item:hover,
  .dock-item.is-active {
    transform: translateY(-5px) scale(1.03);
  }

  .surface,
  .project-site {
    inset: 56px var(--frame-x) var(--dock-space);
  }

  /* The brand block is three lines tall here, so half-covering it behind
     the glass reads as a collision. Hand the screen to the panel instead. */
  body.surface-open .workspace-brand {
    opacity: 0;
  }

  .surface-shell {
    border-radius: var(--radius-md);
  }

  .surface-header {
    padding: var(--s-5) var(--s-5) var(--s-4);
  }

  .surface-scroll {
    padding: var(--s-4) var(--s-5) var(--s-5);
  }

  .project-card {
    min-height: 0;
    padding: var(--s-5) var(--s-4);
  }

  .project-copy {
    margin-top: var(--s-4);
  }

  .about-lead,
  .about-note,
  .stack-group,
  .profile-card {
    padding: var(--s-5);
  }

  .profile-banner {
    height: 64px;
    margin: calc(var(--s-5) * -1) calc(var(--s-5) * -1) 0;
  }

  .profile-card-top {
    gap: var(--s-3);
    margin-top: -26px;
  }

  .profile-avatar {
    width: 52px;
    height: 52px;
  }

  .about-index {
    font-size: 4.5rem;
  }

  .about-grid,
  .stack-grid {
    grid-template-columns: 1fr;
  }

  .timeline {
    grid-column: auto;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: var(--s-2);
    padding: var(--s-4) var(--s-1);
  }

  .project-detail {
    inset: var(--s-2);
    width: calc(100vw - (var(--s-2) * 2));
    border-radius: var(--radius-md);
  }

  .detail-inner {
    padding: var(--s-8) var(--s-5) var(--s-6);
  }

  .detail-inner > h3 {
    font-size: var(--t-2xl);
    max-width: 12ch;
  }

  .detail-summary {
    font-size: var(--t-base);
  }

  .site-nav-title {
    font-size: var(--t-sm);
  }

  .site-stage {
    padding: var(--s-2) var(--frame-x) var(--frame-x);
  }

  /* A fixed-width sidebar has no room on a phone screen — the section
     list becomes a horizontal scrolling strip under the title instead of
     sitting beside the content window. */
  .site-body {
    flex-direction: column;
  }

  .site-nav,
  .site-content {
    border-radius: var(--radius-md);
  }

  .site-nav {
    flex: 0 0 auto;
    padding: var(--s-3);
  }

  .site-nav-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: visible;
  }

  .site-nav button {
    width: auto;
  }

  .site-sections {
    padding: var(--s-6) var(--s-5) var(--s-7);
  }

  .diagram-tiers {
    grid-template-columns: 1fr;
  }
}

/* Motion off. The attribute is the source of truth because it lets an
   explicit choice win in both directions — including turning motion back
   on over an OS that asks to reduce it. The media query stays as a
   backstop for the window before the inline script runs. */
:root[data-motion="reduced"] *,
:root[data-motion="reduced"] *::before,
:root[data-motion="reduced"] *::after {
  transition-duration: .01ms !important;
  animation-duration: .01ms !important;
  animation-iteration-count: 1 !important;
}

@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) *,
  :root:not([data-motion="full"]) *::before,
  :root:not([data-motion="full"]) *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Pointer light off: the script stops writing positions, and these stop
   the last painted pool from lingering. */
:root[data-pointer="off"] [data-lit]::before,
:root[data-pointer="off"] [data-lit]::after {
  opacity: 0 !important;
}

/* ---------- Theme crossfade ----------
   The browser's default view-transition crossfade is a flat 0.25s ease.
   Retiming it to our own duration and easing is what makes the theme swap
   feel like it belongs to the same interaction language as everything
   else here, rather than a generic browser default. script.js gates
   *whether* this runs (skipped when data-motion isn't "full"); this block
   only ever governs *how* it looks when it does. The reduced-motion query
   stays as a backstop for the moment before that gating is in effect. */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: .5s;
  animation-timing-function: var(--ease-out);
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(root),
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
  }
}
