/* Marco De Vecchi — CV website
   Tokens and rules come from the "Marco DeVecchi" design system:
   neutral-first, one brand green, hairlines instead of shadows, Inter throughout,
   with a system mono for the drafting-style annotations. */

:root {
  color-scheme: light dark;

  /* Colour (light theme) */
  --surface: #FAF8F3;
  --surface-raised: #FFFFFF;
  --ink: #1A1F1C;
  --ink-muted: #5B635E;
  --brand: #1F4D3A;
  --brand-soft: #DCE8E0;
  --on-brand: #FAF8F3;
  --accent: #9A7535;
  --line: #E3E0D8;
  --danger: #B3261E;

  /* Type */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  /* Spacing (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --measure: 66ch;
  --page: 1200px;
  --gutter: var(--space-4);

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

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface: #141815;
    --surface-raised: #1C211E;
    --ink: #ECEFEA;
    --ink-muted: #A3ABA5;
    --brand: #8FC4A6;
    --brand-soft: #22362C;
    --on-brand: #141815;
    --accent: #D2B27A;
    --line: #2C332F;
    --danger: #F2A7A1;
  }
}

:root[data-theme="dark"] {
  --surface: #141815;
  --surface-raised: #1C211E;
  --ink: #ECEFEA;
  --ink-muted: #A3ABA5;
  --brand: #8FC4A6;
  --brand-soft: #22362C;
  --on-brand: #141815;
  --accent: #D2B27A;
  --line: #2C332F;
  --danger: #F2A7A1;
}

/* ---------- Base ---------- */

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

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
/* Anchors land below the sticky top bar */
[id] { scroll-margin-top: 80px; }

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 24px;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
ul { margin: 0; padding: 0; list-style: none; }

.skip-link {
  position: absolute; left: var(--space-4); top: -100px;
  padding: var(--space-2) var(--space-4);
  background: var(--brand); color: var(--on-brand);
  border-radius: var(--radius-sm); z-index: 10;
}
.skip-link:focus { top: var(--space-4); }

.wrap {
  width: 100%;
  max-width: var(--page);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}
@media (min-width: 720px) {
  :root { --gutter: var(--space-8); }
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4);
  min-height: 64px;
}
.wordmark {
  font-weight: 600; letter-spacing: -0.02em; color: var(--ink);
  text-decoration: none; white-space: nowrap;
}
.wordmark small {
  display: block; font-size: 12px; line-height: 16px; font-weight: 500;
  color: var(--ink-muted); letter-spacing: 0;
}
.nav { display: none; gap: var(--space-6); }
.nav a {
  position: relative;
  color: var(--ink-muted); text-decoration: none; font-size: 14px; line-height: 20px;
  transition: color 160ms ease;
}
.nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 1px;
  background: var(--brand);
  transform: scaleX(0); transform-origin: left;
  transition: transform 200ms var(--ease-out);
}
.nav a[aria-current] { color: var(--ink); }
.nav a[aria-current]::after { transform: scaleX(1); }
@media (hover: hover) and (pointer: fine) {
  .nav a:hover { color: var(--brand); }
  .nav a:hover::after { transform: scaleX(1); }
}
@media (min-width: 720px) { .nav { display: flex; } }
/* Narrow phones: the name alone, so the download button always fits */
@media (max-width: 399.98px) { .wordmark small { display: none; } }

/* Buttons, as the design system's Website section describes them */
.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font: inherit; font-size: 14px; line-height: 20px; font-weight: 500;
  border-radius: var(--radius-sm);
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform 160ms var(--ease-out), filter 160ms ease, border-color 160ms ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--brand); color: var(--on-brand); border: 1px solid var(--brand); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { border-color: var(--ink-muted); }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: square; }
.btn-arrow { transition: transform 200ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover .btn-arrow { transform: translateY(1.5px); }
}

/* ---------- Hero ---------- */

.hero { position: relative; padding: var(--space-12) 0; border-bottom: 1px solid var(--line); overflow: clip; }
/* Drafting grid, fading out towards the text; a brighter copy follows the pointer */
.hero-grid, .hero-grid::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--grid, var(--line)) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid, var(--line)) 1px, transparent 1px);
  background-size: 32px 32px;
}
.hero-grid {
  -webkit-mask-image: linear-gradient(to left, #000, transparent 80%);
  mask-image: linear-gradient(to left, #000, transparent 80%);
}
.hero-grid::after {
  --grid: var(--brand);
  opacity: 0; transition: opacity 300ms ease;
  -webkit-mask-image: radial-gradient(circle 220px at var(--mx, 50%) var(--my, 50%), #000, transparent);
  mask-image: radial-gradient(circle 220px at var(--mx, 50%) var(--my, 50%), #000, transparent);
}
.hero-cross, .hero-coords { opacity: 0; pointer-events: none; transition: opacity 200ms ease; }
.hero-cross i { position: absolute; top: 0; left: 0; background: var(--brand); opacity: 0.4; }
.hero-cross i:first-child { width: 1px; height: 100%; }
.hero-cross i:last-child { width: 100%; height: 1px; }
.hero-coords {
  position: absolute; top: var(--space-4); right: var(--gutter);
  font-family: var(--font-mono); font-size: 12px; line-height: 16px; letter-spacing: 0.08em;
  color: var(--brand); font-variant-numeric: tabular-nums;
}
@media (hover: hover) and (pointer: fine) {
  .hero[data-pointer] :is(.hero-cross, .hero-coords),
  .hero[data-pointer] .hero-grid::after { opacity: 1; }
}
.hero .wrap { position: relative; display: grid; gap: var(--space-8); }

.hero-name { font-size: 40px; line-height: 44px; letter-spacing: -0.02em; }
.hero-role {
  font-family: var(--font-mono); font-size: 13px; line-height: 20px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--brand);
}
.hero-role::before {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-right: var(--space-2);
  background: var(--accent);
}
.hero-tagline {
  margin-top: var(--space-2);
  font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -0.01em;
  max-width: 24ch;
}
.hero-summary { max-width: var(--measure); color: var(--ink); }
.hero-summary + .hero-summary { margin-top: var(--space-4); }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-8); }

/* Cover art: the design system's modular blocks, drawn as the system diagram they stand for */
.hero-art { display: none; }
.hero-art svg { display: block; width: 100%; height: auto; overflow: visible; }
.hero-art text {
  font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: 0.1em;
  fill: var(--ink-muted);
}
.hero-art .brand rect { fill: var(--brand); }
.hero-art .tint rect { fill: var(--brand-soft); }
.hero-art .deep rect { fill: var(--ink); }
.hero-art .accent rect { fill: var(--accent); }
.hero-art .tint text { fill: var(--ink); }
.hero-art :is(.brand, .accent) text { fill: var(--on-brand); }
.hero-art .deep text { fill: var(--surface); }
.hero-art .deep text + text { opacity: 0.6; }
.hero-art .led { fill: var(--accent); }
.hero-art .wire { fill: none; stroke: var(--ink-muted); stroke-width: 1.5; }

@media screen {
  /* The name is set to fill the measure exactly: 7.7 is its width in ems at this tracking, plus a little air */
  .hero-name {
    font-size: calc((min(100vw, var(--page)) - 2 * var(--gutter)) / 7.7);
    line-height: 0.9; letter-spacing: -0.05em; white-space: nowrap;
  }
  /* Each word sits in its own mask so it can rise into view */
  .hero-name .word {
    display: inline-block; overflow: hidden; vertical-align: bottom;
    padding: 0.06em 0.05em 0.06em 0; margin: -0.06em -0.05em -0.06em 0;
  }
  .hero-name .word > span { display: inline-block; }
  .hero-tagline { font-size: clamp(24px, 3.2vw, 40px); line-height: 1.1; letter-spacing: -0.02em; max-width: 20ch; }
}
@media screen and (min-width: 880px) {
  .hero { display: flex; align-items: flex-end; min-height: min(calc(100dvh - 65px), 880px); padding: var(--space-16) 0; }
  .hero .wrap {
    grid-template-columns: minmax(0, 1fr) 400px;
    grid-template-areas: "lede art" "name name" "body body";
    gap: var(--space-12) var(--space-8); align-items: end;
  }
  .hero-name { grid-area: name; }
  .hero-lede { grid-area: lede; }
  .hero-art { display: block; grid-area: art; }
  .hero-body {
    grid-area: body;
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-8); align-items: end;
  }
  .hero-actions { margin-top: 0; }
}

/* Phones get their own composition rather than the desktop one squeezed: label, diagram,
   then the name stacked on two lines and set to the full width */
@media screen and (max-width: 879.98px) {
  .hero { padding: var(--space-8) 0 var(--space-12); }
  .hero .wrap { gap: var(--space-6); }
  .hero-grid {
    -webkit-mask-image: linear-gradient(to bottom, #000 30%, transparent 75%);
    mask-image: linear-gradient(to bottom, #000 30%, transparent 75%);
  }
  .hero-lede { display: contents; }
  .hero-role { order: 1; }
  .hero-art { display: block; order: 2; max-width: 440px; }
  .hero-art text { font-size: 13px; }
  .hero-name {
    order: 3; margin-top: var(--space-4);
    font-size: min(calc((100vw - 2 * var(--gutter)) / 4.6), 150px); white-space: normal;
  }
  .hero-name .word:first-child { display: block; width: max-content; }
  .hero-tagline { order: 4; margin-top: 0; font-size: clamp(24px, 7vw, 40px); max-width: 20ch; }
  .hero-body { order: 5; }
  .hero-actions .btn { flex: 1 1 100%; justify-content: center; padding: 14px var(--space-4); font-size: 16px; }
}

/* ---------- Metrics ---------- */

.metrics { padding: var(--space-8) 0; border-bottom: 1px solid var(--line); }
.metrics .wrap {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-6) var(--space-8);
}
.metric { display: flex; flex-direction: column; gap: var(--space-1); }
.metric-value {
  font-size: 32px; line-height: 40px; font-weight: 600; letter-spacing: -0.02em;
  color: var(--brand); font-variant-numeric: tabular-nums;
}
.metric-accent .metric-value { color: var(--accent); }
.metric-label { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-muted); }
@media screen {
  .metrics { position: relative; padding: var(--space-16) 0 var(--space-12); }
  /* A ruler along the top edge */
  .metrics::before {
    content: ""; position: absolute; top: 0; left: 0; right: 0; height: 12px;
    background:
      repeating-linear-gradient(90deg, var(--ink-muted) 0 1px, transparent 1px 80px) 0 0 / 100% 12px no-repeat,
      repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 8px) 0 0 / 100% 6px no-repeat;
  }
  .metrics .wrap { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .metric-value {
    display: block; overflow: hidden;
    font-size: clamp(64px, 9vw, 120px); line-height: 1; letter-spacing: -0.05em;
  }
  .metric-value > span { display: block; }
  .metric-label {
    font-family: var(--font-mono); font-size: 12px; line-height: 18px; font-weight: 400;
    letter-spacing: 0.04em; text-transform: uppercase; max-width: 24ch;
  }
}
@media screen and (max-width: 719.98px) {
  .metrics .wrap { grid-template-columns: 1fr 1fr; gap: var(--space-8) var(--space-4); }
  .metric-value { font-size: 24vw; }
}

/* ---------- Sections ---------- */

.section { padding: var(--space-12) 0 0; }
.section:last-of-type { padding-bottom: var(--space-12); }
.section .wrap {
  display: grid; gap: var(--space-4);
}
@media (min-width: 880px) {
  .section .wrap { grid-template-columns: 240px minmax(0, 1fr); gap: var(--space-8); }
}

.section-heading {
  padding-top: var(--space-2);
  border-top: 1px solid var(--line);
  font-size: 12px; line-height: 16px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted);
}
.section-body { max-width: var(--measure); }

/* On screen the headings become display type, numbered, and stay put while their section scrolls by */
@media screen {
  main { counter-reset: section; }
  .section { padding-top: var(--space-16); counter-increment: section; }
  .section-heading {
    overflow: hidden; padding: var(--space-4) 0 0.15em;
    font-size: clamp(32px, 4.4vw, 52px); line-height: 1.05;
    letter-spacing: -0.03em; text-transform: none; color: var(--ink);
  }
  .section .wrap { position: relative; }
  .section .wrap::before {
    content: ""; position: absolute; top: 0; left: var(--gutter); right: var(--gutter); height: 1px;
    background: var(--ink);
  }
  .section-heading, .section-body { border-top: 0; }
  .section-heading::before {
    content: counter(section, decimal-leading-zero) " / 07";
    display: block; margin-bottom: var(--space-2);
    font-family: var(--font-mono); font-weight: 500;
    font-size: 12px; line-height: 16px; letter-spacing: 0.08em;
    color: var(--accent); font-variant-numeric: tabular-nums;
  }
  .section-heading > span, .cta-heading > span { display: block; }
  .tag {
    padding: 6px 12px; border-radius: 2px;
    font-family: var(--font-mono); font-size: 12px; line-height: 20px; letter-spacing: 0.02em;
  }
  .tag-core { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
  .exp-period, .row-key, .nav a, .wordmark small, .footer {
    font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase;
  }
  .row { grid-template-columns: 88px minmax(0, 1fr); }
}
@media screen and (max-width: 879.98px) {
  .section-heading { font-size: clamp(40px, 12vw, 56px); }
  .section-body { padding-top: var(--space-2); }
}
@media screen and (min-width: 880px) {
  .section { padding-top: var(--space-20); }
  .section .wrap { grid-template-columns: minmax(240px, 30%) minmax(0, 1fr); }
  .section-heading { position: sticky; top: 88px; align-self: start; }
  .section-body { padding-top: var(--space-4); }
}

/* Experience */
.exp { padding: var(--space-6) 0; }
.exp:first-child { padding-top: 0; }
.exp + .exp { border-top: 1px solid var(--line); }
.exp-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4); flex-wrap: wrap; }
.exp-role { font-size: 18px; line-height: 26px; }
.exp-org { font-size: 14px; line-height: 20px; color: var(--ink-muted); margin-top: 2px; }
.exp-period {
  flex: none; font-size: 14px; line-height: 20px; color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.exp-current .exp-period { color: var(--brand); font-weight: 500; }
.exp-summary { margin-top: var(--space-2); }
.exp-hl { margin: var(--space-2) 0 0; padding-left: var(--space-4); list-style: disc; font-size: 14px; line-height: 20px; }
.exp-hl li { margin-top: var(--space-1); }
.exp-hl li::marker { color: var(--brand); }

/* Skills */
.tags { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.tag {
  display: inline-block; padding: 2px var(--space-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 12px; line-height: 16px; font-weight: 500;
  color: var(--ink); background: var(--surface-raised);
}
.tag-core { background: var(--brand-soft); border-color: var(--brand-soft); }
.tags + .subhead { margin-top: var(--space-6); }
.ai-lede { margin-bottom: var(--space-4); }
.print-only { display: none; }
.project + .project { margin-top: var(--space-6); }
.project-desc { font-size: 14px; line-height: 20px; }
.project .exp-org { margin-top: var(--space-1); }
.project-desc + .project-desc { margin-top: var(--space-2); }
.project .subhead a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.subhead { font-size: 14px; line-height: 20px; font-weight: 600; margin-bottom: var(--space-2); }

/* Simple definition rows: education, languages, certifications */
.rows { display: grid; gap: var(--space-4); }
.row { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: var(--space-4); align-items: baseline; }
.row-key { font-size: 14px; line-height: 20px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.row-title { font-weight: 500; }
.row-sub { font-size: 14px; line-height: 20px; color: var(--ink-muted); }

.cert-list li { display: flex; gap: var(--space-2); align-items: baseline; }
.cert-list li + li { margin-top: var(--space-2); }
.cert-list li::before {
  content: ""; flex: none; width: 8px; height: 8px; margin-top: 2px;
  background: var(--brand); border-radius: 2px; align-self: center;
}

/* Contact: the closing band */
.cta { padding-top: var(--space-12); }
.cta-heading {
  margin-bottom: var(--space-2);
  font-size: 12px; line-height: 16px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted);
}
.cta-mail svg {
  width: 0.7em; height: 0.7em; flex: none;
  stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: square;
  transition: transform 200ms var(--ease-out);
}
.cta-meta { font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.cta-meta a { color: inherit; text-underline-offset: 0.2em; }
.cta-lede { max-width: var(--measure); margin-bottom: var(--space-4); }
.print-contacts { display: none; }
@media screen {
  .cta {
    margin-top: var(--space-20); padding: var(--space-20) 0;
    background: var(--brand); color: var(--on-brand);
    position: relative; overflow: hidden;
  }
  .cta::before {
    content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.12;
    background-image:
      linear-gradient(var(--on-brand) 1px, transparent 1px),
      linear-gradient(90deg, var(--on-brand) 1px, transparent 1px);
    background-size: 32px 32px;
  }
  .cta .wrap { position: relative; }
  /* Same fitting as the name: 5.7 is this line's width in ems */
  .cta-heading {
    overflow: hidden; margin-bottom: var(--space-6); padding-bottom: 0.14em;
    font-size: calc((min(100vw, var(--page)) - 2 * var(--gutter)) / 5.7);
    line-height: 0.9; letter-spacing: -0.04em; text-transform: none; color: inherit;
    white-space: nowrap;
  }
  .cta-mail {
    display: inline-flex; align-items: center; gap: 0.4em;
    font-size: clamp(18px, 5.6vw, 36px); line-height: 1.2; font-weight: 500;
    color: inherit; text-underline-offset: 0.2em;
  }
  .cta-meta {
    margin-top: var(--space-4); color: inherit; opacity: 0.75;
    font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  }
  .cta-lede { margin-bottom: var(--space-6); font-size: 18px; line-height: 28px; opacity: 0.9; }
  .cta a:focus-visible { outline-color: currentColor; }
  .cta ::selection { background: var(--on-brand); color: var(--brand); }
  @media (max-width: 719.98px) {
    .cta { padding: var(--space-16) 0 var(--space-20); }
    .cta-heading { margin-bottom: var(--space-4); }
  }
  .footer { border-top: 0; }
}
@media (hover: hover) and (pointer: fine) {
  .cta-mail:hover svg { transform: translate(3px, -3px); }
}

/* ---------- Footer ---------- */

.footer { border-top: 1px solid var(--line); padding: var(--space-6) 0; }
.footer .wrap {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2);
  font-size: 14px; line-height: 20px; color: var(--ink-muted);
}
.footer a { color: inherit; }
.footer a:hover { color: var(--brand); }

/* ---------- Motion ----------
   Screen only, so print always gets the full page. Opacity carries every entrance;
   movement is added on top only when the reader hasn't asked for less of it. */

@keyframes enter { from { opacity: 0; transform: translate(var(--dx, 0px), var(--dy, 0px)); } }
@keyframes curtain { from { transform: scaleY(1); } }
@keyframes word-up { from { transform: translateY(110%); } }
@keyframes draw { from { stroke-dashoffset: 1; } }
@keyframes ping { to { transform: scale(3.2); opacity: 0; } }
@keyframes progress { to { transform: scaleX(1); } }
@keyframes blink { 50% { opacity: 0.15; } }
@keyframes sink { to { transform: translateY(18%); opacity: 0.15; } }

@media screen {
  /* Hero: the copy fades in after the curtain while the cover art assembles */
  .hero-name, .hero-role, .hero-tagline, .hero-summary, .hero-actions {
    animation: enter 900ms var(--ease-out) both;
  }
  .hero-name { animation-delay: 450ms; }
  .hero-role { animation-delay: 700ms; }
  .hero-tagline { animation-delay: 780ms; }
  .hero-summary { animation-delay: 860ms; }
  .hero-summary + .hero-summary { animation-delay: 920ms; }
  .hero-actions { animation-delay: 980ms; }

  .hero-art .node { animation: enter 1000ms var(--ease-out) both; }
  .hero-art .brand { animation-delay: 600ms; }
  .hero-art .tint { animation-delay: 720ms; }
  .hero-art .deep { animation-delay: 820ms; }
  .hero-art .accent { animation-delay: 940ms; }
  .hero-art .label { animation: enter 600ms var(--ease-out) 1900ms both; }

  /* Scroll reveals, switched on by the script at the end of the page */
  .js [data-reveal],
  .js [data-reveal-children] > * {
    opacity: 0;
    transition: opacity 700ms var(--ease-out), transform 900ms var(--ease-out);
  }
  .js [data-reveal-children] > * { transition-delay: calc(var(--i, 0) * 40ms); }
  .js [data-reveal][data-visible],
  .js [data-reveal-children][data-visible] > * { opacity: 1; }

  /* Experience as a timeline: a rail that fills as it is read, a marker per role */
  .timeline { position: relative; padding-left: 28px; }
  .timeline::before, .timeline-fill {
    content: ""; position: absolute; top: 8px; bottom: 0; left: 5px; width: 1px;
    background: var(--line);
  }
  .timeline-fill {
    left: 4px; width: 3px; border-radius: 2px; background: var(--brand);
    transform: scaleY(0); transform-origin: top;
  }
  .exp { position: relative; }
  .exp::before, .exp-current::after {
    content: ""; position: absolute; z-index: 1; left: -28px; top: 32px;
    width: 11px; height: 11px; border-radius: 50%;
  }
  .exp:first-child::before, .exp-current:first-child::after { top: 8px; }
  .exp::before {
    background: var(--surface); border: 2px solid var(--line);
    transition: background-color 400ms ease 300ms, border-color 400ms ease 300ms;
  }
  .js .exp[data-visible]::before, .exp-current::before { background: var(--brand); border-color: var(--brand); }
  .exp-current::after { background: var(--brand); opacity: 0; }

  /* Reading progress along the bottom edge of the top bar */
  @supports (animation-timeline: scroll()) {
    .topbar::after {
      content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
      background: var(--brand);
      transform: scaleX(0); transform-origin: left;
      animation: progress linear both;
      animation-timeline: scroll(root);
    }
  }
}

@media screen and (prefers-reduced-motion: no-preference) {
  /* A curtain in the brand colour lifts off the page on load */
  body::before {
    content: ""; position: fixed; inset: 0; z-index: 20; pointer-events: none;
    background: var(--brand);
    transform: scaleY(0); transform-origin: top;
    animation: curtain 800ms var(--ease-in-out) 100ms both;
  }

  .hero-name { animation-name: none; }
  .hero-name .word > span { animation: word-up 1100ms var(--ease-out) both; }
  .hero-name .word:nth-child(1) > span { animation-delay: 500ms; }
  .hero-name .word:nth-child(2) > span { animation-delay: 590ms; }
  .hero-name .word:nth-child(3) > span { animation-delay: 680ms; }

  .hero-role, .hero-tagline, .hero-summary, .hero-actions { --dy: 32px; }
  .hero-art .brand { --dy: 80px; }
  .hero-art .tint { --dy: -60px; }
  .hero-art .deep { --dx: 80px; }
  .hero-art .accent { --dx: -48px; --dy: -24px; }

  .hero-art .wire { stroke-dasharray: 1; animation: draw 700ms var(--ease-in-out) both; }
  .hero-art .wire:nth-of-type(1) { animation-delay: 1300ms; }
  .hero-art .wire:nth-of-type(2) { animation-delay: 1400ms; }
  .hero-art .wire:nth-of-type(3) { animation-delay: 1500ms; }
  .hero-art .wire:nth-of-type(4) { animation-delay: 1600ms; }
  .hero-art .wire:nth-of-type(5) { animation-delay: 1700ms; animation-duration: 1100ms; }
  .hero-art .led { animation: blink 1.6s steps(2, jump-none) infinite; }

  /* Rules are drawn, not shown: section lines and the ruler extend from the left */
  .js .section .wrap::before { transform: scaleX(0); transform-origin: left; transition: transform 1200ms var(--ease-in-out); }
  .js .section:has([data-visible]) .wrap::before { transform: none; }
  .js .metrics::before { clip-path: inset(0 100% 0 0); transition: clip-path 1400ms var(--ease-in-out); }
  .js .metrics:has([data-visible])::before { clip-path: inset(0); }

  /* The name sinks back and dims as the hero scrolls away */
  @supports (animation-timeline: scroll()) {
    .hero-name {
      animation: sink linear both;
      animation-timeline: scroll(root);
      animation-range: 0 100vh;
    }
  }

  .js [data-reveal] { transform: translateY(32px); }
  .js [data-reveal-children] > * { transform: translateY(16px) scale(0.85); }
  .js [data-reveal][data-visible],
  .js [data-reveal-children][data-visible] > * { transform: none; }

  @media (max-width: 719.98px) {
    .js [data-reveal], .js [data-reveal-children] > * { transition-duration: 450ms, 600ms; }
    .js [data-reveal]:not([data-visible]) { transform: translateY(20px); }
  }

  /* Headings and figures rise out of a mask instead of fading */
  .js .section-heading[data-reveal], .js .cta-heading[data-reveal], .js .metric[data-reveal] { opacity: 1; transform: none; }
  .js .section-heading > span, .js .cta-heading > span, .js .metric-value > span {
    transform: translateY(115%);
    transition: transform 1000ms var(--ease-out);
  }
  .js .metric-label { opacity: 0; transition: opacity 700ms var(--ease-out) 300ms; }
  .js .metric:nth-child(2) .metric-value > span { transition-delay: 90ms; }
  .js .metric:nth-child(3) .metric-value > span { transition-delay: 180ms; }
  .js .metric:nth-child(4) .metric-value > span { transition-delay: 270ms; }
  .js [data-visible] > span, .js [data-visible] .metric-value > span { transform: none; }
  .js [data-visible] .metric-label { opacity: 1; }

  .exp-current::after { opacity: 0.5; animation: ping 2.4s var(--ease-out) infinite; }
}

/* ---------- Print: the page becomes the CV ---------- */

@media print {
  @page { size: A4; margin: 16mm 18mm; }
  :root {
    --surface: #FFFFFF; --surface-raised: #FFFFFF; --ink: #1A1F1C; --ink-muted: #5B635E;
    --brand: #1F4D3A; --brand-soft: #DCE8E0; --on-brand: #FFFFFF; --accent: #9A7535; --line: #E3E0D8;
  }
  body { font-size: 11pt; line-height: 1.4; }
  .topbar, .hero-actions, .hero-art, .footer, .skip-link { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .hero { padding: 0 0 var(--space-4); }
  .hero-grid, .hero-cross, .hero-coords, .cta-mail svg { display: none; }
  .hero-role::before { display: none; }
  .hero-name { font-size: 24pt; line-height: 1.1; }
  .hero-tagline { font-size: 14pt; line-height: 1.3; }
  .metrics { padding: var(--space-4) 0; }
  .section { padding-top: var(--space-6); }
  .section .wrap { grid-template-columns: 1fr; gap: var(--space-2); }
  .section-body { border-top: 0; padding-top: 0; }
  .exp, .row, .cert-list li { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }

  /* The CV: two A4 pages, contacts in the header instead of the closing band */
  body { font-size: 10pt; line-height: 1.38; }
  .hero .wrap { position: relative; }
  .hero-name { font-size: 22pt; }
  .hero-tagline { max-width: none; font-size: 12pt; }
  .hero-summary, .section-body { max-width: none; }
  .print-contacts {
    display: block; position: absolute; top: 0; right: 0;
    margin: 0; padding: 0; list-style: none; text-align: right;
    font-size: 9pt; line-height: 1.5; color: var(--ink-muted);
  }
  .metrics { padding: var(--space-3, 12px) 0; }
  .metrics .wrap { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
  .metric-value { font-size: 18pt; line-height: 1.1; }
  .metric-label { font-size: 8pt; line-height: 1.3; }
  .section { padding-top: var(--space-4); }
  .exp { padding: var(--space-2) 0; }
  .cta { display: none; }

  /* One page: older roles keep title and dates only, the personal section stays on the site */
  body { font-size: 9.5pt; line-height: 1.32; }
  @page { margin: 12mm 14mm; }
  .hero { padding-bottom: var(--space-2); }
  .hero-summary + .hero-summary { margin-top: var(--space-2); }
  .metrics { padding: var(--space-2) 0; }
  .metric-value { font-size: 15pt; }
  .section { padding-top: var(--space-3, 12px); }
  .section-heading { padding-top: var(--space-1); }
  .exp { padding: var(--space-1) 0; }
  .exp-hl { font-size: 9pt; line-height: 1.3; margin-top: 2px; }
  .exp-hl li { margin-top: 1px; }
  .exp-summary { font-size: 9pt; }
  .exp-older .exp-hl, #interests { display: none; }
  .ai-lede { margin-bottom: var(--space-1); }
  .tags { gap: 4px; }
  .tag { font-size: 8pt; padding: 1px 6px; }
  .tags + .subhead { margin-top: var(--space-2); }
  .subhead { font-size: 9pt; margin-bottom: 2px; }
  .cert-list { display: flex; gap: var(--space-4); }
  .rows { display: flex; flex-wrap: wrap; gap: 0 var(--space-6); }
  .row { padding: 0; border: 0; }
  .print-skip, .metrics { display: none; }
  .exp-hl .print-only { display: list-item; }
  .hero-lede { margin-bottom: var(--space-1); }
  /* Short sections: heading on the left, content inline */
  #skills .wrap, #education .wrap, #languages .wrap { grid-template-columns: 96px minmax(0, 1fr); gap: var(--space-3, 12px); }
  .tags { display: block; }
  .tag { display: inline; padding: 0; border: 0; background: none; font-size: inherit; }
  .tag:not(:last-child)::after { content: " · "; color: var(--ink-muted); }
  .tag-core { font-weight: 500; }
  .row-sub { display: inline; }
  .row-sub::before { content: " · "; }
  .rows .row > div > p { display: inline; }
  .hero-body { margin-top: var(--space-2); }
  .exp-head > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--space-2); }
  .exp-role { font-size: 11pt; line-height: 1.3; }
  .exp-org { font-size: 9pt; margin-top: 0; }
  .exp-org::before { content: "· "; }
  .exp-period { font-size: 9pt; }
  .exp-summary { margin-top: 2px; }
  .metric-label br { display: none; }
  .cert-list { margin: 0; }
  .cert-list li + li { margin-top: 0; }
  .hero-lede { margin-bottom: 0; }
  .hero-body, .hero-copy { margin-top: 4px; padding-top: 0; }
  .tags + .subhead { margin-top: 4px; }
  .hero .wrap { gap: var(--space-2); }
}
