/* ===========================================================================
   Zheyu Zhuang - portfolio stylesheet
   Design tokens first, then components. Every colour, size, weight, radius
   and rhythm value below comes from a token; no raw values in components.
   =========================================================================== */

:root {
  color-scheme: light;

  /* --- Colour ------------------------------------------------------------
     Warm cream ground rather than pure white: same lightness family, far
     less glare. Ink and lines carry the same warm hue so nothing reads grey
     against the paper. The blue accent stays cool for contrast.           */
  --page:        #faf8f4;   /* page ground - cream off-white               */
  --tint:        #f3efe7;   /* alternating band                            */
  --ink:         #24221e;   /* primary text                                */
  --ink-soft:    #4a463f;   /* lead paragraphs                             */
  --muted:       #6b6459;   /* body prose, meta            5.5:1 on --page */
  --line:        #e2dcd0;

  --accent:      #245ea8;   /*                             6.1:1 on --page */
  --accent-dark: #194b8a;
  --accent-soft: #e9eff7;   /* hover wash                                  */
  --on-accent:   #fdfcfa;   /* text on accent fills                        */

  /* Inverted block - the Approach section. In light mode it drops to near
     black; in dark mode it lifts to a raised surface instead, because there
     is nothing left to invert to.                                         */
  --invert-bg:      #24221e;
  --invert-fg:      #f6f3ee;
  --invert-fg-soft: #c3bdb2;
  --invert-accent:  #92b8e6;
  --invert-line:    rgb(246 243 238 / .1);

  /* Figure wells. Six of the paper figures carry a white background baked
     into the file and one is transparent with dark ink, so these stay light
     in BOTH themes: the figures sit on a plate rather than glaring.        */
  --plate:       #efeae0;   /* project + dialog figure wells               */
  --plate-line:  #ebe6dc;
  --plate-bleed: transparent; /* wide figure that needs no plate on cream  */
  --photo-bg:    #f3efe7;   /* placeholder behind photographs              */

  --ink-rgb:  36 34 30;     /* shadows and scrims                          */
  --page-rgb: 250 248 244;  /* translucent sticky nav                      */

  --icon-sun:  none;        /* the toggle shows the theme you'd switch to  */
  --icon-moon: block;

  /* --- Type scale --------------------------------------------------------
     Ten steps replacing the twenty ad-hoc sizes this file used to carry.  */
  --fs-micro:  .6875rem;    /* 11px - tags, image hint                     */
  --fs-label:  .75rem;      /* 12px - eyebrows, section index, footer      */
  --fs-small:  .8125rem;    /* 13px - links, meta values, pub authors      */
  --fs-body-s: .9375rem;    /* 15px - card prose                           */
  --fs-body:   1rem;        /* 16px - main prose                           */
  --fs-lede:   1.0625rem;   /* 17px - hero intro, section ledes            */
  --fs-h4:     1.125rem;    /* 18px - card headings                        */
  --fs-h3:     1.375rem;    /* 22px - system story headings                */
  --fs-h3-lg:  clamp(1.3rem, 1.7vw, 1.55rem);   /* project headings        */
  --fs-h2:     clamp(1.75rem, 2.6vw, 2.375rem);
  --fs-h1:     clamp(2.25rem, 3.6vw, 3.125rem);

  /* --- Weight ------------------------------------------------------------
     Four standard weights. The old 560/620/650/680/750 values only render
     as distinct on variable system fonts (macOS); elsewhere they snapped
     to 400/600/700 and the hierarchy collapsed.                           */
  --fw-regular: 400;
  --fw-medium:  500;
  --fw-semi:    600;
  --fw-bold:    700;

  /* --- Rhythm ------------------------------------------------------------ */
  --lh-tight:   1.14;
  --lh-snug:    1.3;
  --lh-normal:  1.45;
  --lh-relaxed: 1.65;
  --ls-caps:    .07em;
  --ls-h1:      -.03em;
  --ls-h2:      -.02em;

  /* --- Space ------------------------------------------------------------- */
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  /* --- Layout ------------------------------------------------------------ */
  --shell:       1160px;    /* outer container                             */
  --pad-x:       1.5rem;    /* container inset - the page's left edge       */
  --rail:        150px;     /* section-index column                         */
  --gutter:      2.5rem;    /* rail to content                             */
  --section-pad: clamp(3.5rem, 5.5vw, 5rem);
  --nav-h:       3.5rem;
  --plate-pad:   1rem;      /* inset of hoverable rows; bled back out      */
  --measure:     68ch;      /* prose line length                           */
  --measure-narrow: 46ch;
  --media-ratio: 4 / 3;

  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;
  --shadow-sm: 0 2px 8px rgb(var(--ink-rgb) / .16);
  --shadow-md: 0 10px 26px rgb(var(--ink-rgb) / .12);
  --shadow-lg: 0 28px 90px rgb(var(--ink-rgb) / .3);

  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;

  --ease: cubic-bezier(.22, .72, .28, 1);
}

/* ---------------------------------------------------------------------------
   Dark theme
   Two selectors, one palette - keep them in sync. The media query carries the
   system preference but yields to an explicit light choice; the attribute
   selector carries the manual toggle. Only colour tokens change: the type,
   space and layout scales are shared by both themes.
   --------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  color-scheme: dark;

  --page:        #191712;
  --tint:        #211e18;
  --ink:         #f1ede4;
  --ink-soft:    #cfc9bd;
  --muted:       #a39c8e;   /*                             6.6:1 on --page */
  --line:        #35312a;

  --accent:      #92b8e6;   /*                             8.7:1 on --page */
  --accent-dark: #b3cdee;
  --accent-soft: rgb(146 184 230 / .13);
  --on-accent:   #191712;

  --invert-bg:      #2a2721;   /* lifts instead of dropping */
  --invert-fg:      #f1ede4;
  --invert-fg-soft: #b9b2a4;
  --invert-accent:  #92b8e6;
  --invert-line:    rgb(241 237 228 / .1);

  /* Unchanged on purpose: the paper figures have white baked in. */
  --plate:       #ece7dd;
  --plate-line:  #dcd6ca;
  --plate-bleed: #ece7dd;   /* now needs a plate - the page is dark */
  --photo-bg:    #211e18;

  --ink-rgb:  0 0 0;
  --page-rgb: 25 23 18;

  --shadow-sm: 0 2px 8px rgb(0 0 0 / .5);
  --shadow-md: 0 10px 26px rgb(0 0 0 / .55);
  --shadow-lg: 0 28px 90px rgb(0 0 0 / .7);

  --icon-sun:  block;
  --icon-moon: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --page:        #191712;
  --tint:        #211e18;
  --ink:         #f1ede4;
  --ink-soft:    #cfc9bd;
  --muted:       #a39c8e;   /*                             6.6:1 on --page */
  --line:        #35312a;

  --accent:      #92b8e6;   /*                             8.7:1 on --page */
  --accent-dark: #b3cdee;
  --accent-soft: rgb(146 184 230 / .13);
  --on-accent:   #191712;

  --invert-bg:      #2a2721;   /* lifts instead of dropping */
  --invert-fg:      #f1ede4;
  --invert-fg-soft: #b9b2a4;
  --invert-accent:  #92b8e6;
  --invert-line:    rgb(241 237 228 / .1);

  /* Unchanged on purpose: the paper figures have white baked in. */
  --plate:       #ece7dd;
  --plate-line:  #dcd6ca;
  --plate-bleed: #ece7dd;   /* now needs a plate - the page is dark */
  --photo-bg:    #211e18;

  --ink-rgb:  0 0 0;
  --page-rgb: 25 23 18;

  --shadow-sm: 0 2px 8px rgb(0 0 0 / .5);
  --shadow-md: 0 10px 26px rgb(0 0 0 / .55);
  --shadow-lg: 0 28px 90px rgb(0 0 0 / .7);

  --icon-sun:  block;
  --icon-moon: none;
}

/* ---------------------------------------------------------------------------
   Theme toggle
   --------------------------------------------------------------------------- */
.theme-toggle {
  flex: 0 0 auto;
  width: 34px; height: 34px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: var(--r-sm);
  background: transparent; color: inherit; cursor: pointer;
  transition: color .18s ease, border-color .18s ease, background .18s ease;
}
.theme-toggle:hover { border-color: var(--line); color: var(--accent); }
.theme-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .icon-sun  { display: var(--icon-sun); }
.theme-toggle .icon-moon { display: var(--icon-moon); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Base
   --------------------------------------------------------------------------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + var(--space-4)); }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: var(--lh-relaxed);
}
section[id] { scroll-margin-top: calc(var(--nav-h) + var(--space-4)); }
img { max-width: 100%; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; }
a { color: inherit; }
:where(a, button):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.skip-link {
  position: fixed; top: -5rem; left: var(--space-4); z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--invert-bg); color: var(--invert-fg);
}
.skip-link:focus { top: var(--space-4); }

/* Shared uppercase micro-label. One size, one weight, one tracking. */
.eyebrow, .section-index, .project-meta, .skill-number,
.system-story-meta, .evidence-list article > span, .hero-facts dt {
  font-size: var(--fs-label);
  font-weight: var(--fw-bold);
  line-height: var(--lh-normal);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
}

/* ---------------------------------------------------------------------------
   Sticky section nav
   --------------------------------------------------------------------------- */
.signal-strip {
  position: sticky; top: 0; z-index: 20;
  width: 100%; min-height: var(--nav-h);
  margin: 0;
  padding-block: var(--space-2);
  padding-inline: max(var(--pad-x), calc((100% - var(--shell)) / 2 + var(--pad-x)));
  display: flex; align-items: center; justify-content: flex-end; gap: var(--space-5);
  border-bottom: 1px solid transparent;
  background: rgb(var(--page-rgb) / .92);
  color: var(--muted);
  font-size: var(--fs-label); font-weight: var(--fw-semi);
  letter-spacing: var(--ls-caps); text-transform: uppercase;
  backdrop-filter: blur(12px);
  transition: background-color .35s ease, border-color .35s ease, box-shadow .35s ease;
}
.signal-strip.is-scrolled {
  border-bottom-color: var(--line);
  background: rgb(var(--page-rgb) / .97);
  box-shadow: 0 8px 24px rgb(var(--ink-rgb) / .06);
}
.signal-strip a { color: inherit; text-decoration: none; transition: color .18s ease; }
.signal-links { flex: 1 1 auto; display: flex; align-items: center; justify-content: flex-end; gap: clamp(var(--space-4), 3vw, var(--space-7)); }
.signal-links a { position: relative; min-height: 34px; display: inline-flex; align-items: center; }
.signal-links a::after {
  content: ""; position: absolute; right: 0; bottom: 2px; left: 0; height: 2px;
  border-radius: 2px; background: var(--accent);
  transform: scaleX(0); transform-origin: center;
  transition: transform .28s var(--ease);
}
.signal-links a:hover, .signal-links a[aria-current] { color: var(--accent); }
.signal-links a:hover::after, .signal-links a[aria-current]::after { transform: scaleX(1); }

/* ---------------------------------------------------------------------------
   Hero
   --------------------------------------------------------------------------- */
/* The portrait sits inside .hero-copy, between the eyebrow and the headline, so
   that narrow screens can simply float it beside the headline (see breakpoints).
   Here `display: contents` lifts the copy's children into the hero grid: they
   auto-place down column one while the portrait holds column two. Row gap is 0
   because the copy spaces itself with margins, as it did when it was a block. */
.hero {
  max-width: var(--shell); margin: 0 auto;
  padding: var(--section-pad) var(--pad-x);
  padding-top: clamp(var(--space-5), 2vw, var(--space-7));
  display: grid; grid-template-columns: minmax(0, 1fr) 280px;
  column-gap: clamp(var(--space-6), 4vw, 4.5rem); row-gap: 0;
}
.hero-copy { display: contents; }
.hero-copy > :not(.hero-portrait) { grid-column: 1; max-width: 46rem; }
.eyebrow { display: flex; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-5); color: var(--muted); }
.hero h1 {
  margin: 0;
  font-size: var(--fs-h1); line-height: var(--lh-tight);
  letter-spacing: var(--ls-h1); font-weight: var(--fw-semi);
}
.hero h1 em { color: var(--accent); font-style: normal; font-weight: inherit; }
.hero-intro {
  max-width: var(--measure); margin: var(--space-5) 0 0;
  color: var(--muted); font-size: var(--fs-lede); line-height: var(--lh-relaxed);
}
.hero-facts {
  margin: var(--space-6) 0 0; padding-top: var(--space-4);
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-5);
  align-items: start;
  border-top: 1px solid var(--line);
}
.hero-facts div { min-width: 0; }
.hero-facts dt { margin-bottom: var(--space-1); color: var(--accent); }
.hero-facts dd {
  margin: 0; color: var(--ink);
  font-size: var(--fs-body); font-weight: var(--fw-medium); line-height: var(--lh-normal);
  text-wrap: balance;
}
.hero-actions { margin-top: var(--space-6); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); }
.hero-actions a { text-decoration: none; }
.hero-contact { margin: var(--space-3) 0 0; }
.hero-email { color: var(--accent); font-size: var(--fs-small); font-weight: var(--fw-semi); text-decoration: none; }
.hero-email:hover { text-decoration: underline; text-underline-offset: 3px; }
.hero-profiles { display: flex; gap: var(--space-4); }
.hero-profiles a { padding: var(--space-2) 0; color: var(--muted); font-size: var(--fs-small); font-weight: var(--fw-semi); }
.hero-actions a:not(.button):hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.button {
  display: inline-flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--ink); border-radius: var(--r-sm);
  font-size: var(--fs-small); font-weight: var(--fw-semi); text-decoration: none;
  transition: color .2s ease, background .2s ease, border-color .2s ease, transform .2s ease;
}
/* Base .button is the secondary variant; .button-primary overrides it below.
   Equal specificity, so the primary's own hover wins by source order. */
.button:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--accent); }
.button-primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.button-primary:hover { border-color: var(--accent-dark); background: var(--accent-dark); }

/* Spans well past the copy so every row of it stays in column one; the surplus
   rows are empty and, with no row gap, add no height. */
.hero-portrait { grid-column: 2; grid-row: 1 / span 20; align-self: center; }
.portrait-frame {
  overflow: hidden; border-radius: var(--r-lg);
  background: var(--photo-bg); box-shadow: var(--shadow-md);
}
/* One photographic treatment for every photo on the page. */
.portrait-frame img, .hobby-card img, .system-story-media img { filter: saturate(.88); }
.portrait-frame img { display: block; width: 100%; height: auto; }

/* ---------------------------------------------------------------------------
   Section system
   Every section: a --rail index column + heading block, then a full-width body.
   Blocks alternate page / tint down the page; Approach takes the dark
   treatment in its tinted slot. Tone alone separates them, so no rules.

   Full-bleed sections add --pad-x on top of the centring calc so their text
   lands on exactly the same left and right edges as the contained sections.
   --------------------------------------------------------------------------- */
.section { max-width: var(--shell); margin: 0 auto; padding: var(--section-pad) var(--pad-x); }
.section--tint, .section--dark {
  max-width: none;
  padding-block: var(--section-pad);
  padding-inline: max(var(--pad-x), calc((100% - var(--shell)) / 2 + var(--pad-x)));
}
.section--tint { background: var(--tint); }
.section--dark { background: var(--invert-bg); color: var(--invert-fg); }

.section-head {
  display: grid; grid-template-columns: var(--rail) minmax(0, 1fr);
  gap: var(--gutter); margin-bottom: var(--space-7);
}
.section-index { margin: var(--space-1) 0 0; color: var(--accent); }
.section--dark .section-index { color: var(--invert-accent); }
.section-head h2 {
  max-width: var(--measure); margin: 0;
  font-size: var(--fs-h2); line-height: var(--lh-tight);
  letter-spacing: var(--ls-h2); font-weight: var(--fw-semi);
}
.section-lede {
  max-width: var(--measure); margin: var(--space-4) 0 0;
  color: var(--muted); font-size: var(--fs-lede); line-height: var(--lh-relaxed);
}
.section--dark .section-lede { color: var(--invert-fg-soft); }

.about-columns {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4) var(--gutter);
  color: var(--ink-soft);
}
.about-columns p { margin: 0; }

/* ---------------------------------------------------------------------------
   Research projects
   Rows carry --plate-pad so the hover plate has breathing room; the list is
   pulled back by the same amount so the text still sits on the page rail.
   --------------------------------------------------------------------------- */
.projects { display: grid; gap: var(--space-2); margin-inline: calc(var(--plate-pad) * -1); }
.project {
  padding: var(--space-5) var(--plate-pad);
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "media meta" "media copy";
  column-gap: var(--space-5); row-gap: var(--space-2);
  align-items: start;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  background: transparent; color: var(--ink);
  /* Accent bar as an inset shadow, not a border: a border would push the row's
     content 3px off the page rail that everything else is aligned to. */
  box-shadow: inset 3px 0 0 transparent;
  transition: background .22s ease, box-shadow .22s ease;
}
.project:hover { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.project-meta { grid-area: meta; display: flex; flex-direction: column; gap: var(--space-1); color: var(--accent); }

.project-media {
  grid-area: media; aspect-ratio: var(--media-ratio);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden; padding: 0;
  border: 1px solid var(--plate-line); border-radius: var(--r-md);
  background: var(--plate); color: var(--accent); text-align: center;
}
.project-media-live img {
  display: block; width: 100%; height: 100%; object-fit: contain;
  transition: transform .35s var(--ease);
}
.project-media-square img {
  width: auto; max-width: none; height: 100%; flex: 0 0 auto;
  object-fit: cover; object-position: center;
}
.project-media-mirrorduo { padding: var(--space-1); }
.project-media-mirrorduo img { width: 100%; height: 100%; object-fit: contain; object-position: center; }
.project-media-zoom {
  position: relative; appearance: none; font: inherit; cursor: zoom-in;
  transition: box-shadow .25s ease, transform .25s ease;
}
.project-media-zoom:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.project-media-zoom:hover img { transform: scale(1.012); }
.project-media-zoom.project-media-square:hover img { transform: none; }
.project-media-zoom:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.media-zoom-hint {
  position: absolute; right: var(--space-2); bottom: var(--space-2);
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--r-sm);
  background: rgb(var(--ink-rgb) / .88); color: var(--invert-fg);
  font-size: var(--fs-micro); font-weight: var(--fw-bold);
  letter-spacing: var(--ls-caps); text-transform: uppercase;
  box-shadow: var(--shadow-sm);
}
.media-zoom-hint b { font-size: var(--fs-small); font-weight: var(--fw-regular); }

.media-dialog {
  width: min(1000px, 94vw); max-width: none; margin: auto;
  padding: 0; overflow: hidden;
  border: 0; border-radius: var(--r-lg);
  background: var(--page); color: var(--ink);
  box-shadow: var(--shadow-lg);
}
.media-dialog-portrait { width: min(720px, 94vw); }
.media-dialog[open] { animation: dialog-in .24s var(--ease); }
.media-dialog::backdrop { background: rgb(var(--ink-rgb) / .7); backdrop-filter: blur(4px); animation: backdrop-in .2s ease-out; }
.media-dialog-shell { display: grid; }
.media-dialog-head {
  min-height: var(--nav-h);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  border-bottom: 1px solid var(--line);
}
.media-dialog-head > div { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
.media-dialog-head strong { font-size: var(--fs-body); font-weight: var(--fw-semi); }
.media-dialog-head span { color: var(--muted); font-size: var(--fs-small); }
.media-dialog-close {
  min-height: 38px; padding: var(--space-2) var(--space-3);
  display: inline-flex; align-items: center; gap: var(--space-1);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--page); color: var(--ink);
  font: var(--fw-semi) var(--fs-small) / 1 var(--sans);
  cursor: pointer;
}
.media-dialog-close:hover { border-color: var(--accent); color: var(--accent); }
.media-dialog-close span { color: inherit; font-size: var(--fs-body); font-weight: var(--fw-regular); }
.media-dialog-shell > img {
  display: block; width: auto; max-width: 100%; height: auto;
  max-height: calc(92vh - var(--nav-h)); margin: 0 auto;
  object-fit: contain; background: var(--plate);
}
@keyframes dialog-in { from { opacity: 0; transform: scale(.985) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }

.project-copy { grid-area: copy; margin: 0; }
.project-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); }
.project h3 {
  margin: 0; font-size: var(--fs-h3-lg); line-height: var(--lh-snug);
  letter-spacing: var(--ls-h2); font-weight: var(--fw-semi);
}
.project-highlight {
  max-width: var(--measure); margin: var(--space-3) 0 0;
  color: var(--ink-soft); font-size: var(--fs-body);
  line-height: var(--lh-normal); font-weight: var(--fw-medium);
}
.project-summary {
  max-width: var(--measure); margin: var(--space-2) 0 0;
  color: var(--muted); font-size: var(--fs-body-s); line-height: var(--lh-relaxed);
}
.project-summary strong { color: var(--ink); font-weight: var(--fw-semi); }
.project-links { display: flex; flex: 0 0 auto; gap: var(--space-4); margin: 0; }
.project-links a { padding: var(--space-1) 0; color: var(--accent); font-size: var(--fs-small); font-weight: var(--fw-semi); text-decoration: none; }
.project-links a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------------------------------------------------------------------------
   Approach (dark)
   --------------------------------------------------------------------------- */
.skills-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-7) var(--space-6); }
.skill-number { color: var(--invert-accent); }
.skill-card h3 { margin: var(--space-3) 0 var(--space-2); font-size: var(--fs-h4); line-height: var(--lh-snug); font-weight: var(--fw-semi); }
.skill-card p { margin: 0; color: var(--invert-fg-soft); font-size: var(--fs-body-s); line-height: var(--lh-relaxed); }
.skill-tags { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-4); }
.skill-tags span {
  padding: var(--space-1) var(--space-2); border-radius: var(--r-sm);
  background: var(--invert-line); color: var(--invert-fg-soft);
  font-size: var(--fs-micro); line-height: var(--lh-normal);
}

/* ---------------------------------------------------------------------------
   Systems
   --------------------------------------------------------------------------- */
.systems-stories { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-7); }
.system-story-media { position: relative; height: clamp(190px, 22vw, 255px); overflow: hidden; border-radius: var(--r-md); background: var(--photo-bg); }
.system-story-media img { display: block; border-radius: var(--r-md); }
.system-story-media-wide { display: flex; justify-content: center; overflow: visible; border-radius: 0; background: var(--plate-bleed); }
.system-story-media-wide img { width: auto; max-width: 100%; height: 100%; object-fit: contain; }
.system-story-media-pair { display: flex; gap: var(--space-2); }
.system-story-media-pair img { width: calc(50% - var(--space-1)); height: 100%; object-fit: cover; }
.system-story-copy { padding-top: var(--space-5); }
.system-story-meta { margin: 0 0 var(--space-2); color: var(--accent); }
.system-story h3 { margin: 0; font-size: var(--fs-h3); line-height: var(--lh-snug); letter-spacing: var(--ls-h2); font-weight: var(--fw-semi); }
.system-story-copy > p:not(.system-story-meta) {
  max-width: var(--measure-narrow); margin: var(--space-3) 0 0;
  color: var(--muted); font-size: var(--fs-body-s); line-height: var(--lh-relaxed);
}
.system-story-copy > a, .system-story-links a {
  display: inline-block; margin-top: var(--space-3);
  color: var(--accent); font-size: var(--fs-small); font-weight: var(--fw-semi); text-decoration: none;
}
.system-story-copy > a:hover, .system-story-links a:hover { text-decoration: underline; text-underline-offset: 3px; }
.system-story-links { display: flex; flex-wrap: wrap; gap: 0 var(--space-4); }

/* ---------------------------------------------------------------------------
   Mentoring - reuses the section rail so its labels sit under the index
   --------------------------------------------------------------------------- */
.evidence-list { display: grid; gap: var(--space-6); }
.evidence-list article { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); column-gap: var(--gutter); }
.evidence-list article > span { grid-row: span 2; margin-top: var(--space-1); color: var(--accent); }
.evidence-list h3 { margin: 0; font-size: var(--fs-h4); line-height: var(--lh-snug); font-weight: var(--fw-semi); }
.evidence-list p { max-width: var(--measure); margin: var(--space-2) 0 0; color: var(--muted); font-size: var(--fs-body-s); line-height: var(--lh-relaxed); }
.evidence-list p a { color: var(--accent); font-weight: var(--fw-semi); text-decoration: none; }
.evidence-list p a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------------------------------------------------------------------------
   Publications - same bleed trick as .projects so titles keep the page rail
   --------------------------------------------------------------------------- */
.publication-list { display: grid; gap: 2px; margin-inline: calc(var(--plate-pad) * -1); }
.publication { padding: var(--space-3) var(--plate-pad); display: flex; flex-direction: column; gap: var(--space-1); border-radius: var(--r-sm); }
.publication:nth-child(even) { background: var(--tint); }
.pub-title { max-width: var(--measure); font-size: var(--fs-body-s); line-height: var(--lh-normal); font-weight: var(--fw-semi); }
.pub-authors { max-width: var(--measure); color: var(--muted); font-size: var(--fs-small); line-height: var(--lh-normal); }
.pub-authors strong { color: var(--accent); font-weight: var(--fw-bold); }
.publication small { color: var(--muted); font-size: var(--fs-label); line-height: var(--lh-normal); }

/* ---------------------------------------------------------------------------
   Off the clock
   --------------------------------------------------------------------------- */
.hobbies-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-6); }
.hobby-card { margin: 0; }
.hobby-card img {
  display: block; width: 100%; height: clamp(190px, 22vw, 240px);
  border-radius: var(--r-md); background: var(--photo-bg); object-fit: cover;
}
.hobby-card figcaption { margin-top: var(--space-4); }
.hobby-card h3 { margin: 0 0 var(--space-2); font-size: var(--fs-h4); line-height: var(--lh-snug); font-weight: var(--fw-semi); }
.hobby-card p { margin: 0; color: var(--muted); font-size: var(--fs-body-s); line-height: var(--lh-relaxed); }

/* ---------------------------------------------------------------------------
   Footer
   --------------------------------------------------------------------------- */
.site-footer {
  padding-block: var(--space-6);
  padding-inline: max(var(--pad-x), calc((100% - var(--shell)) / 2 + var(--pad-x)));
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--space-4);
  background: var(--tint); color: var(--muted);
  font-size: var(--fs-label); line-height: var(--lh-normal);
}
.site-footer p { margin: 0; }
.site-footer p:nth-child(2) { text-align: center; }
.site-footer a { justify-self: end; color: var(--accent); font-weight: var(--fw-semi); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------------------------------------------------------------------------
   Scroll reveal
   --------------------------------------------------------------------------- */
.reveal { opacity: 0; transform: translate3d(0, 14px, 0); transition: opacity .68s ease, transform .68s var(--ease); will-change: opacity, transform; }
.reveal.is-visible { opacity: 1; transform: translate3d(0, 0, 0); will-change: auto; }
.reveal-delay { transition-delay: .07s; }

/* ---------------------------------------------------------------------------
   Breakpoints
   --------------------------------------------------------------------------- */
@media (max-width: 1080px) {
  :root { --rail: 110px; --gutter: 2rem; }
}

@media (max-width: 850px) {
  :root { --gutter: 1.25rem; }
  /* One column: the portrait floats beside the headline and the copy wraps
     around it, so the photo never dictates a row height. Its DOM position
     (after the eyebrow) is what lines its top edge up with the headline. */
  .hero { display: block; }
  .hero-portrait {
    float: right;
    width: clamp(124px, 21vw, 168px);
    /* The nudge optically aligns the photo's top edge with the cap height of
       the headline's first line rather than with its line box. */
    margin: .3rem 0 var(--space-4) var(--space-5);
  }
  /* Keeps the rule above the facts from ever running under the photo. */
  .hero-facts { clear: right; }
  .section-head { grid-template-columns: 1fr; gap: var(--space-4); align-items: start; }
  .about-columns { grid-template-columns: 1fr; }
  .project { grid-template-columns: minmax(240px, 280px) minmax(0, 1fr); column-gap: var(--space-5); }
  .skills-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6); }
  .evidence-list article { grid-template-columns: 1fr; gap: var(--space-1); }
  .evidence-list article > span { grid-row: auto; margin-top: 0; }
  .hobbies-grid { grid-template-columns: 1fr; gap: var(--space-5); }
}

@media (max-width: 560px) {
  :root { --section-pad: 2.75rem; --plate-pad: 0px; }
  /* The headline wraps beside the portrait, so it is sized to that narrower
     measure: at the full --fs-h1, "demonstrations" alone overruns the column. */
  .hero h1 { font-size: clamp(1.375rem, 7.4vw, 2.25rem); }
  /* Tighter here so the name reads as a label on the headline, not a line of
     its own, and so the photo starts higher alongside it. */
  .eyebrow { margin-bottom: var(--space-4); }
  .hero-facts { grid-template-columns: 1fr; gap: var(--space-3); }
  .hero-facts div { display: grid; grid-template-columns: 5rem 1fr; gap: var(--space-2); align-items: baseline; }
  .hero-facts dt { margin: 0; }
  .hero-actions { align-items: flex-start; }
  .hero-profiles { width: 100%; }
  .hero-portrait { width: clamp(88px, 27vw, 116px); margin-left: var(--space-4); }
  .signal-strip { gap: var(--space-3); white-space: nowrap; }
  .signal-links { width: 100%; justify-content: space-between; gap: var(--space-2); }
  .signal-links a { font-size: var(--fs-micro); }
  .projects { gap: var(--space-6); }
  .project {
    grid-template-columns: 1fr; grid-template-rows: auto;
    grid-template-areas: "meta" "media" "copy";
    gap: var(--space-3); padding-block: 0;
  }
  .project:hover { background: transparent; box-shadow: none; }
  .project-meta { flex-direction: row; justify-content: space-between; }
  .project-media { width: 100%; max-width: none; }
  .project-title-row { align-items: flex-start; flex-direction: column; gap: var(--space-1); }
  .skills-grid { grid-template-columns: 1fr; }
  .systems-stories { grid-template-columns: 1fr; gap: var(--space-6); }
  .site-footer { grid-template-columns: 1fr auto; }
  .site-footer p:nth-child(2) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .button, .project, .signal-strip, .signal-links a::after,
  .project-media-zoom, .project-media-live img { transition: none; }
  .button:hover, .project-media-zoom:hover { transform: none; }
  .media-dialog[open], .media-dialog::backdrop { animation: none; }
}
