/* ==========================================================================
   Tokens
   Palette: the validated dataviz reference palette (light + dark selected,
   not flipped). Motion: strong custom curves; UI motion stays under 300ms.
   ========================================================================== */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6d68;
  --axis-ink: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.1);
  --ring-strong: rgba(11, 11, 11, 0.18);
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-wash: rgba(42, 120, 214, 0.07);
  --accent-ring: rgba(42, 120, 214, 0.38);
  --shadow: 0 0 0 1px var(--ring), 0 1px 2px rgba(11, 11, 11, 0.04), 0 6px 16px -8px rgba(11, 11, 11, 0.08);
  --header-bg: rgba(249, 249, 247, 0.72);

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  --radius: 14px;
  --radius-sm: 8px;
  --gutter: 16px;
  --header-h: 60px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --line-a: 0.3;
    --line-b: 0.18;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #222220;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #9a988f;
    --axis-ink: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --ring: rgba(255, 255, 255, 0.1);
    --ring-strong: rgba(255, 255, 255, 0.18);
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --accent-wash: rgba(57, 135, 229, 0.1);
    --accent-ring: rgba(57, 135, 229, 0.45);
    --shadow: 0 0 0 1px var(--ring), 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
    --header-bg: rgba(13, 13, 13, 0.72);
  }
}
:root[data-theme="dark"] {
  --line-a: 0.3;
  --line-b: 0.18;
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #222220;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #9a988f;
  --axis-ink: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --ring: rgba(255, 255, 255, 0.1);
  --ring-strong: rgba(255, 255, 255, 0.18);
  --accent: #3987e5;
  --accent-ink: #86b6ef;
  --accent-wash: rgba(57, 135, 229, 0.1);
  --accent-ring: rgba(57, 135, 229, 0.45);
  --shadow: 0 0 0 1px var(--ring), 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  --header-bg: rgba(13, 13, 13, 0.72);
}

@media (min-width: 640px) {
  :root { --gutter: 24px; }
}

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

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

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 1rem/1.6 var(--font);
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, ol, dl, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }

a { color: inherit; }
:where(p, li) a {
  color: var(--accent-ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

button { font: inherit; color: inherit; }

/* Controls: instant press feedback, no long-press text selection, no tap delay */
button, a, [role="button"] { touch-action: manipulation; }
button, .btn, .chip { user-select: none; -webkit-user-select: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left, 0px)) max(var(--gutter), env(safe-area-inset-right, 0px));
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--page);
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus { top: 12px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ==========================================================================
   Header — translucent material, content scrolls underneath
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  backdrop-filter: blur(16px) saturate(180%);
}
/* Scroll-edge effect instead of a hard divider: only once content is under it */
.site-header::after {
  content: "";
  position: absolute;
  inset: 100% 0 auto;
  height: 16px;
  pointer-events: none;
  background: linear-gradient(to bottom, var(--ring), transparent);
  opacity: 0;
  transition: opacity 200ms ease;
}
.site-header[data-scrolled]::after { opacity: 1; }

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

.nav {
  display: none;
  gap: 4px;
  margin-left: auto;
}
.nav a {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 0.9375rem;
  text-decoration: none;
  transition: color 150ms ease, background-color 150ms ease;
}
@media (min-width: 760px) {
  .nav { display: flex; }
}

/* Language and theme toggles, after PRS: round, one press, nothing to choose
   from. Every state is stacked in one box; the one on show sits upright, the
   others are faded and spun out, so a press turns one into the other. */
.toggles {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}
@media (min-width: 760px) {
  .toggles { margin-left: 8px; }
}
.toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  line-height: 0;
  cursor: pointer;
  transition: background-color 180ms ease, transform 160ms var(--ease-out);
}
.toggle:active { transform: scale(0.94); }

.locale-icon { display: grid; place-items: center; }
.locale-code {
  grid-area: 1 / 1;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
  opacity: 0;
  transform: rotate(-70deg) scale(0.5);
}
.locale-code.is-shown { opacity: 1; transform: none; }
/* The leaving code turns one way and the arriving one comes in from the other */
.locale-code.is-shown ~ .locale-code { transform: rotate(70deg) scale(0.5); }

.theme-icon { position: relative; display: block; width: 20px; height: 20px; }
.theme-icon svg {
  position: absolute;
  inset: 0;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* The icon states the mode you are in: sun in light, moon in dark */
.theme-icon .icon-moon { opacity: 0; transform: rotate(-70deg) scale(0.5); }
.theme-icon.is-dark .icon-sun { opacity: 0; transform: rotate(70deg) scale(0.5); }
.theme-icon.is-dark .icon-moon { opacity: 1; transform: none; }

.toggles[data-ready] .locale-code,
.toggles[data-ready] .theme-icon svg {
  transition: opacity 240ms var(--ease-out), transform 380ms var(--ease-out);
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 0.9375rem;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 160ms var(--ease-out), background-color 150ms ease, box-shadow 150ms ease;
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.btn-primary {
  background: var(--ink);
  color: var(--page);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 6px 16px -8px rgba(0, 0, 0, 0.35);
}

/* Copy button: label crossfades with a touch of blur so it reads as one morph */
.btn-label { display: inline-flex; align-items: center; gap: inherit; transition: filter 200ms ease, opacity 200ms ease; }
.btn[data-swapping] .btn-label { filter: blur(2px); opacity: 0; }

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  padding-block: clamp(48px, 9vw, 112px) clamp(40px, 6vw, 72px);
}

/* Photo and name side by side; the photo scales down on narrow screens so the
   name keeps room beside it (it wraps onto two lines on phones). */
.hero-id {
  display: flex;
  align-items: center;
  gap: clamp(16px, 4vw, 32px);
  margin-bottom: clamp(20px, 3vw, 28px);
}
.avatar {
  position: relative;
  flex-shrink: 0;
  width: clamp(112px, 26vw, 176px);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: var(--accent-wash);
  box-shadow: 0 0 0 1px var(--ring), 0 12px 32px -16px rgba(11, 11, 11, 0.35);
}
.avatar-initials {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--accent-ink);
  font-size: clamp(2.25rem, 7vw, 3.5rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}
.avatar img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero h1 {
  font-size: clamp(2.5rem, 7vw, 4.25rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 650;
}
.hero-role {
  margin-top: 12px;
  color: var(--ink-2);
  font-size: clamp(1.125rem, 2.4vw, 1.375rem);
  line-height: 1.35;
  letter-spacing: -0.01em;
}
.hero-summary {
  margin-top: 24px; /* full content width, aligned with the cards below */
  color: var(--ink-2);
  font-size: 1.0625rem;
  text-wrap: pretty;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 32px;
}
.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-top: 28px;
  color: var(--ink-2);
  font-size: 0.9375rem;
}
.facts li { display: flex; align-items: center; gap: 8px; min-width: 0; }
.facts svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--muted); }

/* Hero entrance: the one choreographed moment, seen once per visit.
   Name leads; support follows with shrinking gaps and smaller travel;
   decoration only fades. Nothing waits on it — everything is clickable at once. */
@keyframes enter {
  from { opacity: 0; transform: translateY(var(--rise, 8px)); }
}
@keyframes enter-fade {
  from { opacity: 0; }
}
.hero [data-enter] {
  animation: enter 600ms var(--ease-out) both;
  animation-delay: var(--d, 0ms);
}
.hero [data-enter="fade"] { animation-name: enter-fade; animation-duration: 500ms; }
.no-enter .hero [data-enter] { animation: none; }

/* ==========================================================================
   Sections
   ========================================================================== */
.section { padding-block: clamp(56px, 8vw, 96px) 0; }
.section-head { margin-bottom: 28px; }
.section-head h2 {
  font-size: clamp(1.625rem, 3.4vw, 2.125rem);
  line-height: 1.15;
  letter-spacing: -0.025em;
  font-weight: 620;
}
.section-head p {
  margin-top: 10px; /* full content width, like the hero summary */
  color: var(--ink-2);
  text-wrap: pretty;
}

/* ==========================================================================
   Experience
   ========================================================================== */
/* One card per period on a continuous rail: the line runs between the dates
   and the cards, with a node per role (filled for the current one). --rail is
   the line's x inside each row. */
.jobs { --rail: 9px; }
.job {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  column-gap: 16px;
  row-gap: 8px;
  padding-bottom: 20px;
}
.job > * { grid-column: 2; }
.job:last-child { padding-bottom: 0; }
.job::before {
  content: "";
  position: absolute;
  left: calc(var(--rail) - 0.75px);
  top: 0;
  bottom: 0;
  width: 1.5px;
  background: var(--grid);
}
.job:first-child::before { top: 12px; }
.job:last-child::before { background: linear-gradient(var(--grid) 60%, transparent); }
.job::after {
  content: "";
  position: absolute;
  left: calc(var(--rail) - 6px);
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--page);
  box-shadow: inset 0 0 0 2px var(--axis);
}
.job:first-child::after {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-wash);
}
.job-card {
  padding: 22px 24px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.job.is-compact .job-card { padding-block: 18px; }
@media (min-width: 860px) {
  .jobs { --rail: 197px; }
  .job { grid-template-columns: 172px 18px minmax(0, 1fr); }
  .job > * { grid-column: 3; }
  /* The date sits level with the card's title */
  .job .job-when { grid-column: 1; grid-row: 1; padding-top: 22px; text-align: right; }
  .job.is-compact .job-when { padding-top: 18px; }
  .job::after { top: 29px; }
  .job.is-compact::after { top: 25px; }
  .job:first-child::before { top: 35px; }
}

/* Swipe in, once per card, as it scrolls into view (JS + motion only) */
.jobs[data-pending] .job-card {
  transition: opacity 450ms var(--ease-out), transform 600ms var(--ease-out);
}
.jobs[data-pending] .job-when { transition: opacity 450ms var(--ease-out) 60ms; }
.jobs[data-pending] .job::after { transition: transform 400ms var(--ease-out) 160ms; }
.jobs[data-pending] .job:not(.is-in) .job-card { opacity: 0; transform: translateX(40px); }
.jobs[data-pending] .job:not(.is-in) .job-when { opacity: 0; }
.jobs[data-pending] .job:not(.is-in)::after { transform: scale(0); }

.job-when {
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.6;
}
.job-company { display: block; color: var(--ink-2); font-weight: 550; }
.job h3 {
  font-size: 1.125rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
  font-weight: 620;
  overflow-wrap: break-word;
}
.job-intro { max-width: 70ch; margin-top: 6px; color: var(--ink-2); text-wrap: pretty; }
.job-bullets { display: grid; gap: 10px; max-width: 75ch; margin-top: 16px; }
.job-bullets li {
  position: relative;
  padding-left: 18px;
  color: var(--ink-2);
  font-size: 0.9688rem;
  text-wrap: pretty;
}
.job-bullets li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.72em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--axis);
}
.job-bullets strong { color: var(--ink); font-weight: 600; }

/* ==========================================================================
   Skills matrix
   ========================================================================== */
/* Modelled on the PRS filter: a caption, one chip per depth (with its dots, so
   the chips double as the legend) at half strength until chosen, and a
   "Show all" link while one is on. Exclusive: one depth at a time. */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.filters-label {
  margin-right: 4px;
  color: var(--ink-2);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.filters-clear {
  appearance: none;
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.8125rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.filters-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}
.filters-clear[hidden], .area[hidden], .skill[hidden], .matrix-empty[hidden] { display: none; }

/* Search: first in the bar, full width on phones */
.filters-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 100%;
}
@media (min-width: 700px) { .filters-search { flex: 0 1 240px; margin-right: 8px; } }
.filters-search svg {
  position: absolute;
  left: 11px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}
.filters-search input {
  appearance: none;
  width: 100%;
  height: 32px;
  padding: 0 12px 0 33px;
  border: 1px solid var(--ring-strong);
  border-radius: 999px;
  background: var(--page);
  color: var(--ink);
  font: inherit;
  font-size: 1rem; /* 16px keeps iOS from zooming in on focus */
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
@media (min-width: 700px) { .filters-search input { font-size: 0.875rem; } }
.filters-search input::placeholder { color: var(--muted); opacity: 1; }
.filters-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.skill-name mark {
  border-radius: 3px;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: inherit;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
}
.matrix-empty {
  padding: 28px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--muted);
  text-align: center;
}

.chip {
  --tag-color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  border: 1px solid color-mix(in srgb, var(--tag-color) 55%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--tag-color) 16%, transparent);
  color: color-mix(in srgb, var(--tag-color) 55%, var(--ink));
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  padding: 0 14px;
  font-family: inherit;
  font-size: 0.8125rem;
  opacity: 0.55;
  cursor: pointer;
  transition: opacity 150ms ease, background-color 150ms ease, border-color 150ms ease,
    box-shadow 150ms ease, transform 160ms var(--ease-out);
}
.chip:active { transform: scale(0.96); }
.chip .meter i { background: currentColor; }
.chip .meter i.off { background: transparent; box-shadow: inset 0 0 0 1.25px currentColor; opacity: 0.5; }
/* Chosen reads at a glance: a solid fill, a full-strength edge and a ring */
.chip[aria-pressed="true"] {
  opacity: 1;
  background: color-mix(in srgb, var(--tag-color) 42%, transparent);
  border-color: var(--tag-color);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tag-color) 55%, transparent);
  color: var(--ink);
}

.matrix { columns: 1; column-gap: 16px; }
/* Until the matrix first scrolls into view (JS + motion only); see playCards() */
.matrix[data-pending] .area { opacity: 0; }
@media (min-width: 700px)  { .matrix { columns: 2; } }
@media (min-width: 1040px) { .matrix { columns: 3; } }

.area {
  break-inside: avoid;
  margin-bottom: 16px;
  padding: 16px 12px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.area h3 {
  padding: 0 8px 12px;
  font-size: 1rem;
  letter-spacing: -0.01em;
  font-weight: 620;
}
.skill {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 6px 8px;
}

.meter {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}
.meter i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.meter i.off {
  background: transparent;
  box-shadow: inset 0 0 0 1.25px var(--axis);
}
.skill-num {
  flex-shrink: 0;
  min-width: 1.6em;
  color: var(--muted);
  font: 500 0.8125rem/1 var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.skill-name {
  flex: 1;
  min-width: 0;
  font-size: 0.9375rem;
  line-height: 1.35;
  overflow-wrap: break-word;
}
}


/* ==========================================================================
   Education
   ========================================================================== */
.edu { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.edu li {
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.edu-year { color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.edu-title { margin-top: 4px; font-weight: 600; line-height: 1.35; }
.edu-school { margin-top: 4px; color: var(--ink-2); font-size: 0.9375rem; }

/* ==========================================================================
   Contact + footer
   ========================================================================== */
.contact {
  margin-top: clamp(56px, 8vw, 96px);
  padding: clamp(28px, 5vw, 48px);
  border-radius: calc(var(--radius) + 6px);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.contact h2 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 640;
}
.contact p { margin-top: 10px; color: var(--ink-2); }
.contact .hero-actions { margin-top: 24px; }

.site-footer { padding-block: 40px calc(40px + env(safe-area-inset-bottom, 0px)); }
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  color: var(--muted);
  font-size: 0.875rem;
}
.footer-inner a { color: inherit; text-underline-offset: 3px; }

.noscript { padding-block: 64px; }
.noscript p { margin-top: 12px; }

/* ==========================================================================
   Floating "back to top" — appears as soon as the page leaves the top
   ========================================================================== */
.to-top {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow), 0 10px 24px -12px rgba(11, 11, 11, 0.25);
  color: var(--ink);
  opacity: 0;
  transform: translateY(10px) scale(0.92);
  visibility: hidden; /* out of the tab order and the a11y tree while hidden */
  transition: opacity 200ms var(--ease-out), transform 260ms var(--ease-out),
    visibility 0s linear 260ms, background-color 180ms ease;
}
.to-top[data-shown] {
  opacity: 1;
  transform: none;
  visibility: visible;
  transition-delay: 0s;
}
.to-top:active { transform: scale(0.94); }
.to-top svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ==========================================================================
   Background line art (after psi-site): draw in once, then sway
   ========================================================================== */
/* Line art spans the viewport and experience cards start 40px off to the side:
   neither may widen the page. clip, not hidden, so nothing becomes a scroller. */
body, main { overflow-x: clip; }
.has-lines { position: relative; isolation: isolate; }
.lines {
  position: absolute;
  z-index: -1;
  top: -48px;
  left: 50%;
  width: 100vw;
  margin-left: -50vw;
  height: min(calc(100% + 96px), 1000px);
  pointer-events: none;
}
.lines--bottom { top: auto; bottom: -48px; }
.lines path, .lines circle {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.1;
  opacity: var(--line-a, 0.22);
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
.lines .soft { opacity: var(--line-b, 0.13); }
.lines.drawn path, .lines.drawn circle {
  animation: draw 3.4s var(--ease-out) forwards;
  animation-delay: calc(var(--i, 0) * 0.28s);
}
.no-enter .lines path, .no-enter .lines circle { animation: none; stroke-dashoffset: 0; }
.sway { transform-box: fill-box; transform-origin: center; animation: sway 18s ease-in-out infinite alternate; }
.sway--b { animation-duration: 23s; animation-delay: -6s; }
.sway--c { animation-duration: 28s; animation-delay: -12s; }
.sway:has(path) { animation-name: wind-drift; translate: var(--wind-x, 0px) var(--wind-y, 0px); }
.sway--b:has(path) { translate: calc(var(--wind-x, 0px) * 0.65) calc(var(--wind-y, 0px) * -0.6); }
.sway--c:has(path) { translate: calc(var(--wind-x, 0px) * -0.55) calc(var(--wind-y, 0px) * 0.75); }
.sway:has(circle) { translate: calc(var(--wind-x, 0px) * 0.18) calc(var(--wind-y, 0px) * 0.18); }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes sway {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); }
  50%  { transform: translate3d(-18px, 9px, 0) rotate(0.7deg); }
  100% { transform: translate3d(15px, -7px, 0) rotate(-0.5deg); }
}
@keyframes wind-drift {
  0%   { transform: translate3d(-22px, 2px, 0) rotate(-0.6deg); }
  35%  { transform: translate3d(-7px, -10px, 0) rotate(0.15deg); }
  68%  { transform: translate3d(16px, -3px, 0) rotate(0.85deg); }
  100% { transform: translate3d(28px, 8px, 0) rotate(-0.3deg); }
}

/* ==========================================================================
   Hover — only for devices that really hover
   ========================================================================== */
@media (hover: hover) and (pointer: fine) {
  .nav a:hover { color: var(--ink); background: var(--surface-2); }
  .toggle:hover, .to-top:hover { background: var(--surface-2); }
  .btn:hover { box-shadow: 0 0 0 1px var(--ring-strong), 0 1px 2px rgba(11, 11, 11, 0.06), 0 8px 20px -10px rgba(11, 11, 11, 0.18); }
  .btn-primary:hover { background: color-mix(in oklab, var(--ink) 86%, var(--page)); }
  .chip:hover { opacity: 1; }
  .filters-clear:hover { color: var(--ink); }
}

/* ==========================================================================
   Accessibility preferences
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  /* Collapse the choreography: no travel, no delays, keep a short fade */
  .hero [data-enter] { animation: enter-fade 200ms ease both; animation-delay: 0ms; }
  .lines path, .lines circle { animation: none !important; stroke-dashoffset: 0; }
  .sway { animation: none; translate: none !important; }
  .btn:active, .chip:active, .toggle:active, .to-top:active { transform: none; }
  .to-top { transform: none; }
  .toggles[data-ready] .locale-code, .toggles[data-ready] .theme-icon svg { transition: opacity 200ms ease; }
  .locale-code, .theme-icon svg { transform: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .site-header { background: var(--page); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --ring: rgba(11, 11, 11, 0.45); --ring-strong: rgba(11, 11, 11, 0.7); --muted: var(--ink-2); }
  .site-header { background: var(--page); backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: 0 1px 0 var(--ring); }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --ring: rgba(255, 255, 255, 0.45); --ring-strong: rgba(255, 255, 255, 0.7); }
}
@media (forced-colors: active) {
  .lines { display: none; }
  .meter i { forced-color-adjust: none; background: CanvasText; }
  .meter i.off { background: Canvas; box-shadow: inset 0 0 0 1px CanvasText; }
  .chip[aria-pressed="true"] { outline: 2px solid Highlight; outline-offset: 2px; }
  .filters-search input:focus { outline: 2px solid Highlight; }
  .skill-name mark { forced-color-adjust: none; background: Mark; color: MarkText; }
  .job::before, .job::after { forced-color-adjust: none; background: CanvasText; box-shadow: none; }
}

/* ==========================================================================
   Print — a clean one-pager-ish copy of the page
   ========================================================================== */
@media print {
  .matrix[data-pending] .area { opacity: 1; }
  .jobs[data-pending] .job .job-card, .jobs[data-pending] .job .job-when { opacity: 1; transform: none; }
  .jobs[data-pending] .job::after { transform: none; }
  .to-top, .lines, .site-header, .filters, .hero-actions, .contact .hero-actions, .skip-link { display: none !important; }
  body { background: #fff; color: #000; }
  .job-card, .area, .edu li, .contact { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .hero [data-enter] { animation: none; }
  .job { break-inside: avoid; }
}
