/* Layout: editorial grid. A narrow sticky rail carries each section's label and one fact about it;
   the wide column carries the content. The hero pairs the name with an API-response card. */
:root {
  /* Color. Light is a soft pastel theme: warm paper, lavender accents and tinted panels. */
  --paper: #fbf8f3;
  --sheet: #ffffff;
  --ink: #2b2640;
  --ink-2: #534e68;
  --ink-3: #6b6680;
  --rule: #ebe4f2;
  --rule-strong: #d8cee8;
  --accent: #6447b8;
  --accent-hover: #523599;
  --accent-soft: #ede6fc;
  --on-accent: #ffffff;
  --btn-bg: #6447b8;
  --btn-bg-hover: #523599;
  --btn-fg: #ffffff;
  --solid-bg: #d8cbf6;
  --solid-fg: #2b2640;
  --chip-bg: #f2edfa;
  --chip-border: transparent;
  --chip-fg: #4b4661;
  /* Pastel panels: lilac, mint, peach, sky */
  --tint-1: #f1ebfc;
  --tint-2: #e4f4ec;
  --tint-3: #fdebe0;
  --tint-4: #e4eefb;
  --group-pad: 1.1rem 1.25rem 1.25rem;
  --group-radius: var(--radius);
  --group-rule: transparent;
  --group-gap: 1rem;
  --code-bg: #f5f1fc;
  --code-line: #e6def3;
  --code-fg: #3a3550;
  --code-dim: #857f9b;
  --code-key: #5b3fae;
  --code-str: #2c7553;
  --code-num: #a9542a;
  --code-method-bg: rgb(169 84 42 / 0.1);
  --media-bg: #0e1626;
  --overlay-bg: rgb(9 13 22 / 0.62);
  --overlay-fg: #ffffff;
  --scrim: rgb(43 38 64 / 0.55);
  /* Floating surfaces get one elevation cue: a shadow in light, an edge in dark. */
  --float-border: transparent;
  --float-shadow: 0 1px 2px rgb(60 40 110 / 0.05), 0 24px 48px -22px rgb(60 40 110 / 0.28);
  --img-edge: oklch(0 0 0 / 0.08);

  /* Type */
  --font-display: 'Newsreader', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --font-body: 'Schibsted Grotesk', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  --step--1: 0.8125rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: clamp(1.375rem, 1.22rem + 0.7vw, 1.75rem);
  --step-h2: clamp(1.5rem, 1.15rem + 1.3vw, 2.25rem);
  --step-3: clamp(1.75rem, 1.3rem + 2vw, 2.75rem);
  --step-4: clamp(3rem, 1.5rem + 6.2vw, 6.75rem);

  /* Space */
  --wrap: 76rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --header-h: 4rem;
  --radius: 12px;

  /* Motion */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-icon: cubic-bezier(0.2, 0, 0, 1);

  /* `only` stops browsers that force pages dark (Opera GX "Force dark pages", Chrome auto dark)
     from repainting the light theme grey. The page has its own dark theme for dark systems. */
  color-scheme: only light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0b1019;
    --sheet: #121a27;
    --ink: #e7ebf2;
    --ink-2: #aab3c4;
    --ink-3: #8690a4;
    --rule: #202a3a;
    --rule-strong: #2f3b50;
    --accent: #8db4ff;
    --accent-hover: #b3ccff;
    --accent-soft: #152340;
    --on-accent: #0b1019;
    --btn-bg: #8db4ff;
    --btn-bg-hover: #b3ccff;
    --btn-fg: #0b1019;
    --solid-bg: #e7ebf2;
    --solid-fg: #0b1019;
    --chip-bg: transparent;
    --chip-border: #2f3b50;
    --chip-fg: #aab3c4;
    --code-bg: #0f1724;
    --code-line: #222d42;
    --code-fg: #d6dcea;
    --code-dim: #7b869c;
    --code-key: #93b8ff;
    --code-str: #9fdcb1;
    --code-num: #f0c27f;
    --code-method-bg: rgb(240 194 127 / 0.14);
    --scrim: rgb(3 6 12 / 0.82);
    --float-border: #26324a;
    --float-shadow: none;
    --img-edge: oklch(1 0 0 / 0.1);
    /* The dark theme keeps plain ruled groups: `initial` makes these fall back to it. */
    --tint-1: initial;
    --tint-2: initial;
    --tint-3: initial;
    --tint-4: initial;
    --group-pad: initial;
    --group-radius: initial;
    --group-rule: initial;
    --group-gap: initial;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0b1019;
  --sheet: #121a27;
  --ink: #e7ebf2;
  --ink-2: #aab3c4;
  --ink-3: #8690a4;
  --rule: #202a3a;
  --rule-strong: #2f3b50;
  --accent: #8db4ff;
  --accent-hover: #b3ccff;
  --accent-soft: #152340;
  --on-accent: #0b1019;
  --btn-bg: #8db4ff;
  --btn-bg-hover: #b3ccff;
  --btn-fg: #0b1019;
  --solid-bg: #e7ebf2;
  --solid-fg: #0b1019;
  --chip-bg: transparent;
  --chip-border: #2f3b50;
  --chip-fg: #aab3c4;
  --code-bg: #0f1724;
  --code-line: #222d42;
  --code-fg: #d6dcea;
  --code-dim: #7b869c;
  --code-key: #93b8ff;
  --code-str: #9fdcb1;
  --code-num: #f0c27f;
  --code-method-bg: rgb(240 194 127 / 0.14);
  --scrim: rgb(3 6 12 / 0.82);
  --float-border: #26324a;
  --float-shadow: none;
  --img-edge: oklch(1 0 0 / 0.1);
  /* The dark theme keeps plain ruled groups: `initial` makes these fall back to it. */
  --tint-1: initial;
  --tint-2: initial;
  --tint-3: initial;
  --tint-4: initial;
  --group-pad: initial;
  --group-radius: initial;
  --group-rule: initial;
  --group-gap: initial;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1.5rem);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--rule-strong) transparent;
}
html:has(dialog[open]) { overflow: hidden; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--step-0)/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  caret-color: var(--accent);
  overflow-x: clip;
}

img, video, iframe { display: block; max-width: 100%; }
a { color: inherit; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
button { font: inherit; color: inherit; }
a, button { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
h1, h2, h3, h4 { text-wrap: balance; }
p { text-wrap: pretty; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--accent); color: var(--on-accent); }

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

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 0.75rem; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Monospace is kept for code and timecodes (the API card, video durations); labels use the body face. */
.label {
  font: 600 0.75rem/1.4 var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.85rem 1.25rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font: 600 0.95rem/1 var(--font-body);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.16s var(--ease-out);
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--btn-bg); color: var(--btn-fg); }
.btn-primary:hover { background: var(--btn-bg-hover); }
.btn-ghost { border-color: var(--rule-strong); color: var(--ink); background: transparent; }
.btn-ghost:hover { border-color: var(--ink); }
.btn-small { padding: 0.6rem 0.9rem; font-size: 0.85rem; }
.btn-note {
  font: 500 0.75rem/1 var(--font-body);
  letter-spacing: 0.04em;
  color: var(--ink-3);
}

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.375rem;
  height: 2.375rem;
  padding: 0;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, transform 0.16s var(--ease-out);
}
.icon-btn:hover { border-color: var(--ink); }
.icon-btn:active, .copy-btn:active, .out-link:active, .lang-switch button:active { transform: scale(0.96); }

/* Icon swaps cross-fade: the outgoing icon shrinks and blurs out as the other one comes in. */
.icon-swap { display: inline-grid; flex: none; }
.icon-swap > svg, #theme-toggle > svg {
  grid-area: 1 / 1;
  transition: opacity 0.3s var(--ease-icon), transform 0.3s var(--ease-icon), filter 0.3s var(--ease-icon);
}
.icon-swap > svg:last-child, .is-done .icon-swap > svg:first-child {
  opacity: 0;
  transform: scale(0.25);
  filter: blur(4px);
}
.is-done .icon-swap > svg:last-child { opacity: 1; transform: none; filter: none; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.site-header.is-scrolled { border-bottom-color: var(--rule); }

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  height: var(--header-h);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-right: auto;
  min-width: 0;
  text-decoration: none;
}
.brand:focus-visible { outline-offset: 4px; border-radius: 8px; }
.brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 7px;
  background: var(--solid-bg);
  color: var(--solid-fg);
  /* Caps have no descenders, so the line box sits low; nudge the letters down to look centred. */
  padding-top: 0.12em;
  font: 500 0.8125rem/1 var(--font-display);
  letter-spacing: 0.01em;
}
.brand-name { font-weight: 600; font-size: 0.95rem; letter-spacing: -0.01em; white-space: nowrap; }

.site-nav { display: flex; gap: 0.15rem; }
.site-nav a {
  position: relative;
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  color: var(--ink-2);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="location"] { color: var(--ink); }
.site-nav a[aria-current="location"]::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 0.1rem;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--accent);
}

.header-actions { display: flex; align-items: center; gap: 0.5rem; }

.lang-switch {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
}
.lang-switch button {
  padding: 0.5rem 0.6rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-3);
  font: 600 0.75rem/1 var(--font-body);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, transform 0.16s var(--ease-out);
}
.lang-switch button:hover { color: var(--ink); }
.lang-switch button[aria-pressed="true"] { background: var(--solid-bg); color: var(--solid-fg); }

.theme-switching *:not(#theme-toggle > svg) { transition: none !important; }

.icon-sun, :root[data-theme="dark"] .icon-moon { opacity: 0; transform: scale(0.25); filter: blur(4px); }
:root[data-theme="dark"] .icon-sun { opacity: 1; transform: none; filter: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { opacity: 1; transform: none; filter: none; }
  :root:not([data-theme="light"]) .icon-moon { opacity: 0; transform: scale(0.25); filter: blur(4px); }
}

.menu-btn { display: none; }

/* Brand, six links and the actions need ~1060px; below that the links move into the menu. */
@media (max-width: 1099px) {
  .menu-btn { display: inline-grid; }
  .site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    gap: 0;
    padding: 0.5rem var(--gutter) 1rem;
    background: var(--paper);
    border-bottom: 1px solid var(--float-border);
    box-shadow: var(--float-shadow);
  }
  .site-header.nav-open .site-nav { display: flex; }
  .site-nav a { padding: 0.8rem 0; border-bottom: 1px solid var(--rule); border-radius: 0; font-size: 1rem; }
  .site-nav a:last-child { border-bottom: 0; }
  .site-nav a[aria-current="location"]::after { left: auto; right: 0; top: 50%; bottom: auto; margin: -2px 0 0; }
}
@media (max-width: 560px) {
  .brand-name { display: none; }
  .header-actions { gap: 0.4rem; }
}

/* ---------- Hero ---------- */
.hero { padding-block: clamp(3rem, 8vw, 6.5rem) clamp(3.5rem, 8vw, 6rem); }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: clamp(2.5rem, 5vw, 4.5rem);
  align-items: end;
}
.hero-copy { min-width: 0; }

.hero-photo {
  width: 4.5rem;
  height: 4.5rem;
  margin-bottom: 1.5rem;
  border-radius: 50%;
  object-fit: cover;
  outline: 1px solid var(--img-edge);
  outline-offset: -1px;
}

.hero-name {
  margin-bottom: 1.5rem;
  font-family: var(--font-display);
  font-size: var(--step-4);
  font-weight: 400;
  font-optical-sizing: auto;
  line-height: 0.94;
  letter-spacing: -0.03em;
}
.hero-stop { color: var(--accent); }

.hero-role {
  font-weight: 600;
  font-size: var(--step-1);
  line-height: 1.35;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.hero-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin-top: 0.5rem;
  padding: 0;
  list-style: none;
  color: var(--ink-2);
}
.hero-facts li { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.hero-facts svg { flex: none; color: var(--accent); }
.hero-lead {
  max-width: 34em;
  margin-top: 1.25rem;
  font-size: var(--step-1);
  line-height: 1.55;
  color: var(--ink-2);
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2.25rem; }

/* API card */
.api-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--float-border);
  border-radius: 14px;
  background: var(--code-bg);
  color: var(--code-fg);
  box-shadow: var(--float-shadow);
  font: 400 0.8125rem/1.75 var(--font-mono);
}
.api-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--code-line);
  font-size: 0.75rem;
}
.api-method {
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  background: var(--code-method-bg);
  color: var(--code-num);
  font-weight: 500;
}
.api-path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.api-status { display: flex; align-items: center; gap: 0.4rem; color: var(--code-str); white-space: nowrap; }
.api-status::before {
  content: '';
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--code-str);
}
.api-body { margin: 0; padding: 1rem 1.15rem 1.15rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.api-body:focus-visible { outline-offset: -2px; }
/* One block per JSON line; wrapped lines hang under their key. */
.j-line { display: block; padding-left: calc(var(--d, 0) * 2ch + 2ch); text-indent: -2ch; }
.j-key { color: var(--code-key); }
.j-str { color: var(--code-str); }
.j-num { color: var(--code-num); }
.j-p { color: var(--code-dim); }

/* Load sequence. The class is added on the first rendered frame, so the hero is never stuck hidden. */
.motion .anim { animation: rise 0.8s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 90ms); }
@keyframes rise { from { transform: translateY(14px); filter: blur(4px); } }

/* ---------- Sections ---------- */
.section { padding-block: clamp(3.5rem, 8vw, 6rem); border-top: 1px solid var(--rule); }

.section-grid {
  display: grid;
  grid-template-columns: minmax(0, 12rem) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 4rem);
}
.section-body { min-width: 0; }

.rail {
  position: sticky;
  top: calc(var(--header-h) + 2rem);
  align-self: start;
  display: grid;
  gap: 0.5rem;
}
.rail h2 {
  font-family: var(--font-display);
  font-size: var(--step-h2);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.rail-meta {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--ink-3);
}
.rail-meta:empty { display: none; }

.lede {
  max-width: 24ch;
  font-family: var(--font-display);
  font-size: var(--step-3);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.022em;
  text-wrap: balance;
}
.lede-text { max-width: 58ch; font-family: var(--font-body); font-size: var(--step-1); line-height: 1.6; letter-spacing: 0; text-wrap: pretty; }
.intro { max-width: 60ch; margin-top: 1rem; color: var(--ink-2); }
.intro-lead { max-width: 44ch; margin-top: 0; font-size: var(--step-1); line-height: 1.5; }

@media (max-width: 860px) {
  .section-grid { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
  .rail { position: static; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 1rem; }
}

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0; list-style: none; }
.chips li {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--chip-border);
  border-radius: 6px;
  background: var(--chip-bg);
  color: var(--chip-fg);
  font: 500 0.8125rem/1 var(--font-body);
}

/* ---------- Projects ---------- */
.projects { display: grid; gap: clamp(2rem, 4vw, 3rem); } /* spacing above comes from the section grid gap */
#project-featured:empty, .project-grid:empty { display: none; }

.player {
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--media-bg);
  outline: 1px solid var(--img-edge);
  outline-offset: -1px;
}
.player > video, .player > iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--media-bg);
  object-fit: contain;
}

.facade {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  width: 100%;
  padding: 0;
  border: 0;
  background: var(--media-bg);
  cursor: pointer;
}
.facade img, .thumb img, .thumb video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.play-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  background: var(--overlay-bg);
  color: var(--overlay-fg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.25) inset;
  transition: transform 0.2s var(--ease-out), background-color 0.2s;
}
.play-icon svg { margin-left: 4px; }
.facade:focus-visible .play-icon { transform: scale(1.06); background: var(--accent); color: var(--on-accent); }
.facade:active .play-icon { transform: scale(0.96); }

/* Empty state: a viewfinder frame */
.frame-empty {
  --c: var(--rule-strong);
  --l: 22px;
  --w: 2px;
  --o: 14px;
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.6rem;
  padding: 1rem;
  text-align: center;
  color: var(--ink-3);
  background:
    linear-gradient(var(--c) 0 0) var(--o) var(--o) / var(--l) var(--w),
    linear-gradient(var(--c) 0 0) var(--o) var(--o) / var(--w) var(--l),
    linear-gradient(var(--c) 0 0) calc(100% - var(--o)) var(--o) / var(--l) var(--w),
    linear-gradient(var(--c) 0 0) calc(100% - var(--o)) var(--o) / var(--w) var(--l),
    linear-gradient(var(--c) 0 0) var(--o) calc(100% - var(--o)) / var(--l) var(--w),
    linear-gradient(var(--c) 0 0) var(--o) calc(100% - var(--o)) / var(--w) var(--l),
    linear-gradient(var(--c) 0 0) calc(100% - var(--o)) calc(100% - var(--o)) / var(--l) var(--w),
    linear-gradient(var(--c) 0 0) calc(100% - var(--o)) calc(100% - var(--o)) / var(--w) var(--l),
    var(--sheet);
  background-repeat: no-repeat;
}
.frame-empty-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font: 600 0.72rem/1.3 var(--font-body);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.frame-empty-label::before {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  border: 1.5px solid currentColor;
}
.frame-empty-tc {
  position: absolute;
  right: calc(var(--o) + 0.75rem);
  bottom: calc(var(--o) + 0.6rem);
  font: 400 0.7rem/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Featured project */
.project-feature {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 3vw, 2.5rem);
  align-items: start;
}
.project-info { display: grid; gap: 1rem; min-width: 0; }
.project-title {
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.012em;
}
.project-feature .project-title { font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.1rem); }
.project-text { color: var(--ink-2); }

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.9rem;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--ink-3);
}
.badge {
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font: 600 0.6875rem/1 var(--font-body);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.badge-draft { background: transparent; border: 1px dashed var(--rule-strong); color: var(--ink-3); }

.highlights { display: grid; gap: 0.45rem; padding: 0; list-style: none; color: var(--ink-2); }
.highlights li { position: relative; padding-left: 1.4rem; }
.highlights li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.8em;
  width: 0.7rem;
  height: 1px;
  background: var(--accent);
}

.text-links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; padding: 0; list-style: none; }
.text-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.text-links a:hover { text-decoration: underline; }
.theater-main .text-links { margin-top: 0.25rem; }
.theater-main .text-links a {
  padding: 0.6rem 0.95rem;
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 0.92rem;
  transition: background-color 0.15s, transform 0.16s var(--ease-out);
}
.theater-main .text-links a:hover { text-decoration: none; background: color-mix(in srgb, var(--accent-soft), var(--accent) 12%); }
.theater-main .text-links a:active { transform: scale(0.97); }

/* Project cards */
.projects { container-type: inline-size; grid-column: 1 / -1; }
#proyectos .rail { position: static; } /* a sticky rail would slide down over the full-width cards */
/* Three across; a single column once three would get too narrow (no 2 + 1 orphan row). */
.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1.75rem, 3vw, 2.5rem) clamp(1.25rem, 2.5vw, 2rem);
  padding-top: clamp(2rem, 4vw, 3rem);
  border-top: 1px solid var(--rule);
}
#project-featured:empty + .project-grid { padding-top: 0; border-top: 0; }
@container (max-width: 680px) {
  .project-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Subgrid lines up thumb, meta, title, text and chips across the cards of a row. */
.card { position: relative; display: grid; grid-row: span 5; grid-template-rows: subgrid; gap: 0.9rem; align-content: start; min-width: 0; }
.card .meta-row, .card .chips { align-content: start; } /* rows are as tall as the tallest card's; don't spread wrapped lines */
.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  max-width: 100%;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--sheet);
  outline: 1px solid var(--img-edge);
  outline-offset: -1px;
}
.thumb img, .thumb video { transition: transform 0.5s var(--ease-out); pointer-events: none; }
.thumb .thumb-preview { opacity: 0; transition: opacity 0.3s var(--ease-out), transform 0.5s var(--ease-out); }
.thumb.is-previewing .thumb-preview { opacity: 1; }
.thumb-chip {
  position: absolute;
  left: 0.75rem;
  bottom: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.65rem 0.35rem 0.45rem;
  border-radius: 999px;
  background: var(--overlay-bg);
  color: var(--overlay-fg);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  font: 500 0.72rem/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
  transition: background-color 0.2s, color 0.2s;
}
.thumb-chip svg { flex: none; }

.card-open {
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.card-open::after { content: ''; position: absolute; inset: 0; z-index: 1; border-radius: var(--radius); }
.card-open:focus-visible { outline: none; }
.card-open:focus-visible::after { outline: 2px solid var(--accent); outline-offset: 6px; }
.card .project-title { transition: color 0.15s; }
.card .project-text { font-size: 0.98rem; }
.card-body { display: grid; gap: 0.6rem; align-content: start; }
/* Sits above the .card-open overlay so the link opens the site instead of the video. */
.card .text-links { position: relative; z-index: 2; font-size: 0.95rem; }

/* Hover motion only where a real pointer can hover; touch taps would trigger it falsely. */
@media (hover: hover) and (pointer: fine) {
  .facade:hover .play-icon { transform: scale(1.06); background: var(--accent); color: var(--on-accent); }
  .card:hover .thumb img, .card:hover .thumb video { transform: scale(1.035); }
  .card:hover .thumb-chip { background: var(--accent); color: var(--on-accent); }
  .card:hover .project-title { color: var(--accent); }
}

@media (max-width: 1100px) {
  .project-feature { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Theater dialog ---------- */
.theater {
  width: min(68rem, calc(100% - 2rem));
  max-width: none;
  max-height: calc(100dvh - 2rem);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--float-border);
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--float-shadow);
  overscroll-behavior: contain;
}
/* No backdrop blur: without GPU acceleration the browser re-blurs the whole page for every video
   frame, which halved the dialog's frame rate. A darker scrim does the same job. */
.theater::backdrop { background: var(--scrim); }
.theater[open] { animation: pop 0.28s var(--ease-out) both; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(0.985); } }

.theater-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0.85rem 0.75rem 1.25rem;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.theater-title {
  min-width: 0;
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.012em;
}
.theater-media .player { border-radius: 0; outline: 0; }
.theater-body {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 3vw, 2.5rem);
  padding: clamp(1.25rem, 3vw, 2rem) clamp(1.25rem, 3vw, 2rem) clamp(1.5rem, 3vw, 2.25rem);
}
.theater-main, .theater-side { display: grid; gap: 1rem; align-content: start; min-width: 0; }
.theater-side { gap: 1.5rem; }
.theater-side > div { display: grid; gap: 0.6rem; }

@media (max-width: 720px) {
  .theater {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }
  .theater-body { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Profile ---------- */
.profile-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2rem clamp(1.5rem, 4vw, 3rem);
  margin-top: clamp(2rem, 4vw, 2.75rem);
}
.profile-col { display: grid; gap: 0.9rem; align-content: start; }

.link-rows { padding: 0; list-style: none; border-top: 1px solid var(--rule); }
.link-rows a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.8rem;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  transition: color 0.15s;
}
.link-rows a:hover { color: var(--accent); }
.link-rows .handle { font-size: 0.875rem; color: var(--ink-3); }
.link-rows strong { font-weight: 600; }

@media (max-width: 640px) {
  .profile-cols { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Timeline (experience, education) ---------- */
.timeline { padding: 0; list-style: none; }
.entry {
  display: grid;
  grid-template-columns: 10rem minmax(0, 1fr);
  gap: 1.5rem;
  padding-block: 1.75rem;
  border-top: 1px solid var(--rule);
}
.entry:first-child { padding-top: 0; border-top: 0; }
.entry-period {
  display: grid;
  align-content: start;
  gap: 0.1rem;
  padding-top: 0.4rem;
  font: 500 0.875rem/1.5 var(--font-body);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.entry-note { font-weight: 400; color: var(--ink-3); }
.entry-main { display: grid; gap: 0.6rem; min-width: 0; }
.entry-title {
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-weight: 500;
  line-height: 1.22;
  letter-spacing: -0.012em;
}
.entry-org { margin-top: -0.35rem; color: var(--accent); font-weight: 600; }
.entry-sub { color: var(--ink-2); }
.entry ul.bullets { display: grid; gap: 0.35rem; padding-left: 1.1rem; color: var(--ink-2); }
.entry ul.bullets li::marker { color: var(--ink-3); }
.entry .chips { margin-top: 0.4rem; }
.timeline-edu .entry-title { font-size: var(--step-1); line-height: 1.35; }

@media (max-width: 560px) {
  .entry { grid-template-columns: minmax(0, 1fr); gap: 0.35rem; }
  .entry-period { display: flex; flex-wrap: wrap; gap: 0 0.75rem; padding-top: 0; }
}

/* ---------- Skills ---------- */
.skills {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--group-gap, 0) clamp(1rem, 3vw, var(--group-gap, 3rem));
}
.skill-group {
  display: grid;
  align-content: start;
  gap: 0.5rem;
  padding: var(--group-pad, 1.1rem 0 1.25rem);
  border-top: 1px solid var(--group-rule, var(--rule));
  border-radius: var(--group-radius, 0);
  background: var(--tint-1, transparent);
}
.skill-group:nth-child(4n + 2) { background: var(--tint-2, transparent); }
.skill-group:nth-child(4n + 3) { background: var(--tint-3, transparent); }
.skill-group:nth-child(4n + 4) { background: var(--tint-4, transparent); }
.skill-group:nth-child(-n + 2) { border-top-color: var(--group-rule, var(--ink)); }
.skill-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 1.1rem;
  padding: 0;
  list-style: none;
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--ink-2);
}
.skill-items .is-pro { color: var(--ink); font-weight: 500; }
.skill-items .is-pro::before, .pro-key::before {
  content: '';
  display: inline-block;
  width: 0.375rem;
  height: 0.375rem;
  margin-right: 0.45rem;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 0.15em;
}

@media (max-width: 640px) {
  .skills { grid-template-columns: minmax(0, 1fr); }
  .skill-group:nth-child(2) { border-top-color: var(--group-rule, var(--rule)); }
}

/* ---------- Languages ---------- */
.languages-title { margin-top: clamp(2.5rem, 5vw, 3.5rem); margin-bottom: 1rem; }
.languages {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding: 0;
  list-style: none;
}
.lang-card {
  display: grid;
  gap: 0.5rem;
  padding: 1.2rem 1.3rem 1.3rem;
  border: 1px solid var(--group-rule, var(--rule));
  border-radius: var(--radius);
  background: var(--tint-4, var(--sheet));
}
.lang-card:nth-child(2n) { background: var(--tint-3, var(--sheet)); }
.lang-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.lang-name { font-family: var(--font-display); font-size: var(--step-2); font-weight: 500; line-height: 1.1; }
.lang-level { font-size: 0.875rem; font-weight: 600; color: var(--accent); letter-spacing: 0.02em; }
.lang-detail { font-size: 0.95rem; color: var(--ink-2); }

@media (max-width: 640px) {
  .languages { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Contact ---------- */
.contact-lede { font-size: var(--step-3); line-height: 1.05; letter-spacing: -0.025em; }
.contact-list { margin-top: clamp(2rem, 4vw, 2.75rem); border-top: 1px solid var(--ink); }
.contact-row {
  display: grid;
  grid-template-columns: 10rem minmax(0, 1fr) auto;
  grid-template-areas: "label value action";
  align-items: center;
  gap: 0.5rem 1.5rem;
  min-height: 4.25rem;
  padding-block: 0.75rem;
  border-bottom: 1px solid var(--rule);
}
.contact-row dt { grid-area: label; font: 600 0.75rem/1.4 var(--font-body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.contact-row dd {
  grid-area: value;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: clamp(1.05rem, 0.95rem + 0.6vw, 1.4rem);
  font-weight: 500;
  letter-spacing: -0.01em;
}
.contact-row dd a { text-decoration: none; }
.contact-row dd a:hover { color: var(--accent); }
.contact-row .row-action { grid-area: action; font-size: 1rem; }

.copy-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: 500 0.8125rem/1 var(--font-body);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, transform 0.16s var(--ease-out);
}
.copy-btn:hover { border-color: var(--ink); color: var(--ink); }
.copy-btn.is-done { border-color: var(--accent); color: var(--accent); }
.out-link {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink-2);
  transition: border-color 0.15s, color 0.15s, transform 0.16s var(--ease-out);
}
.out-link:hover { border-color: var(--ink); color: var(--ink); }

/* Hit areas: grow small controls to 40px (mouse) or 44px (touch) without changing their look. */
.lang-switch button, .copy-btn { position: relative; }
.lang-switch button::after { content: ''; position: absolute; inset: -6px 0; }
.copy-btn::after { content: ''; position: absolute; inset: -5px 0; }
.out-link::after { content: ''; position: absolute; inset: -2px; border-radius: inherit; }
@media (pointer: coarse) {
  .icon-btn::after { content: ''; position: absolute; inset: -3px; border-radius: inherit; }
  .out-link::after { content: ''; position: absolute; inset: -4px; border-radius: inherit; }
  .copy-btn::after { content: ''; position: absolute; inset: -7px -2px; }
  .lang-switch button { position: relative; padding-inline: 0.9rem; }
  .lang-switch button::after { content: ''; position: absolute; inset: -9px 0; }
}

@media (max-width: 560px) {
  .contact-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "label action" "value value";
    gap: 0.4rem 1rem;
    padding-block: 1rem;
  }
}

/* ---------- Footer ---------- */
.site-footer { padding-block: 2rem calc(2rem + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--rule); }
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--ink-3);
}
.footer-inner a { text-decoration: none; }
.to-top { display: inline-flex; align-items: center; gap: 0.35rem; }
.footer-inner a:hover { color: var(--ink); }

.noscript { padding: 1rem var(--gutter); text-align: center; }

/* ---------- Narrow hero ---------- */
@media (max-width: 960px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr); }
  .api-card { max-width: 34rem; }
}
@media (max-width: 420px) {
  .api-card { font-size: 0.75rem; }
  .hero-actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Print: a clean one-column CV ---------- */
@media print {
  :root { --paper: #ffffff; --ink: #000000; --ink-2: #222222; --ink-3: #555555; --rule: #cccccc; }
  body { font-size: 10.5pt; background: #ffffff; }
  .site-header, .skip-link, .hero-actions, .api-card, #proyectos, .theater, .site-footer, .copy-btn, .out-link { display: none !important; }
  .anim { animation: none; }
  .hero { padding-block: 0 1rem; }
  .hero-name { font-size: 28pt; margin-block: 0.5rem; }
  .section { padding-block: 1rem; break-inside: avoid; }
  .rail { position: static; }
  .lede { font-size: 14pt; }
  .contact-lede { display: none; }
}
