/* =============================================================================
   mhfirouznia.com · site.css  (the only stylesheet — no frameworks, no web fonts)

   COLOURS: edit the LIGHT block (:root) and the DARK block (:root[data-theme="dark"]).

   LAYOUT MODES (CSS cannot use variables inside media queries, so they are written out):
     SIDEBAR MODE  = (min-width: 64em) and (hover: hover) and (pointer: fine)
                     → laptops/desktops ≥1024px with a mouse or trackpad
     TOP-BAR MODE  = everything else → phones, tablets, narrow windows
   To give every wide screen the sidebar (including iPads in landscape), delete
   "and (hover: hover) and (pointer: fine)" from BOTH mode queries below.

   Sections: 1 tokens · 2 base · 3 shell · 4 top-bar mode · 5 sidebar mode ·
             6 components · 7 pages · 8 hover · 9 motion · 10 forced colours · 11 print
   ========================================================================== */

/* 1 · TOKENS ---------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* type */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-heading: var(--font-sans);   /* serif option: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif */
  --fs-xs:   clamp(.75rem,   .7292rem + .0926vw, .8125rem);   /* 12→13px */
  --fs-sm:   clamp(.8125rem, .7917rem + .0926vw, .875rem);    /* 13→14px */
  --fs-meta: clamp(.875rem,  .8542rem + .0926vw, .9375rem);   /* 14→15px */
  --fs-base: clamp(1rem,     .9792rem + .0926vw, 1.0625rem);  /* 16→17px */
  --fs-md:   clamp(1.125rem, 1.0833rem + .1852vw, 1.25rem);   /* 18→20px */
  --fs-lg:   clamp(1.3125rem, 1.2292rem + .3704vw, 1.5625rem);/* 21→25px */
  --fs-xl:   clamp(1.625rem, 1.4583rem + .7407vw, 2.125rem);  /* 26→34px */
  --fs-2xl:  clamp(2rem,     1.75rem + 1.1111vw, 2.75rem);    /* 32→44px */
  --measure: 68ch;
  --content-max: 50rem;

  /* colours — LIGHT */
  --bg: #ffffff;
  --surface: #f5f7fa;
  --surface-2: #eaf0f7;
  --line: #e2e8f0;
  --line-strong: #7d8da1;
  --heading: #111827;
  --text: #1f2933;
  --text-muted: #5b6672;
  --accent: #2c5a8c;          /* links, buttons, focus — 7.1:1 on white */
  --accent-strong: #1f4673;   /* hover */
  --accent-ui: #537eba;       /* decorative rules/rings only (not for small text) */
  --accent-soft: #e6eef8;
  --accent-line: #c3d3ea;
  --sb-bg: #3a6799;           /* sidebar gradient top */
  --sb-bg-2: #335d8b;         /* sidebar gradient bottom */
  --sb-fg: #ffffff;
  --sb-fg-muted: rgb(255 255 255 / .88);
  --sb-hover: rgb(0 0 0 / .16);
  --sb-active-bg: #ffffff;
  --sb-active-fg: #2c5a8c;
  --sb-active-bar: transparent;
  --sb-line: rgb(255 255 255 / .16);
  --sb-ring: rgb(255 255 255 / .9);
  --sb-chip: rgb(255 255 255 / .10);
  --sb-chip-hover: rgb(255 255 255 / .22);
  --plate: #ffffff;
  --plate-filter: none;
  --selection: #cfe0f5;
  --sh-1: 0 1px 2px rgb(16 24 40 / .06), 0 1px 3px rgb(16 24 40 / .10);
  --sh-2: 0 8px 24px -6px rgb(16 24 40 / .18);

  /* space, shape, motion, sizes */
  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem; --sp-5: 1.5rem;
  --sp-6: 2rem;   --sp-7: 3rem;  --sp-8: 4rem;   --sp-9: 6rem;
  --section-gap: clamp(2.5rem, 2rem + 2vw, 3.5rem);
  --pad-x: 1.25rem;
  --pad-top: 1.75rem;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-pill: 999px;
  --dur: 180ms;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --sidebar-w: 17rem;
  --avatar: 8.5rem;
  --avatar-bar: 2.25rem;
  --topbar-h: 3.5rem;
  --thumb-w: 11rem;
  --num-w: 2.25rem;
  --hit: 2.75rem;             /* 44px touch target */
}

/* colours — DARK (set by the inline script in <head>; without JavaScript the site stays light) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f141b;
  --surface: #161d26;
  --surface-2: #1d2631;
  --line: #263241;
  --line-strong: #5c6b7d;
  --heading: #f3f5f9;
  --text: #e3e8ee;
  --text-muted: #9ba8b6;
  --accent: #8db4e6;
  --accent-strong: #b5cdf0;
  --accent-ui: #6f95cf;
  --accent-soft: #1d2b3d;
  --accent-line: #34486a;
  --sb-bg: #172235;
  --sb-bg-2: #121b2b;
  --sb-fg-muted: #c3cedb;
  --sb-hover: rgb(255 255 255 / .06);
  --sb-active-bg: #24344d;
  --sb-active-fg: #ffffff;
  --sb-active-bar: #8db4e6;
  --sb-line: rgb(255 255 255 / .08);
  --sb-ring: rgb(141 180 230 / .55);
  --sb-chip: rgb(255 255 255 / .06);
  --sb-chip-hover: rgb(255 255 255 / .14);
  --plate: #ffffff;
  --plate-filter: brightness(.9);
  --selection: #2f4a6b;
  --sh-1: 0 0 0 1px var(--line);
  --sh-2: 0 0 0 1px var(--line);
}

@media (min-width: 37.5em) { :root { --pad-x: 2rem; } }
@media (min-width: 48em)   { :root { --pad-x: 2.5rem; --pad-top: 3rem; } }

/* 2 · BASE ------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-gutter: stable;
  -webkit-tap-highlight-color: transparent;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-base)/1.65 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
h1, h2, h3, h4 { margin: 0; color: var(--heading); font-family: var(--font-heading); line-height: 1.25; text-wrap: balance; }
p { margin: 0 0 1em; text-wrap: pretty; }
:where(ul[role="list"], ol[role="list"]) { margin: 0; padding: 0; list-style: none; }   /* :where() = zero specificity, so component classes can set margins */
figure { margin: 0; }
strong { font-weight: 600; }
a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
  text-decoration-color: rgb(83 126 186 / .55);
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
  overflow-wrap: anywhere;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
main:focus { outline: none; }
::selection { background: var(--selection); }
.vh {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1em; height: 1em; flex: none; fill: currentColor; }
.muted { color: var(--text-muted); }
[hidden] { display: none !important; }
sub, sup { line-height: 0; }
.skip-link {
  position: absolute; left: max(.75rem, env(safe-area-inset-left)); top: -6rem; z-index: 100;
  padding: .5rem .875rem; border-radius: var(--r-md);
  background: var(--bg); color: var(--accent); box-shadow: var(--sh-2);
  font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: max(.75rem, env(safe-area-inset-top)); }

/* 3 · SHELL (shared by both modes) ------------------------------------------------ */
.sidebar { color: var(--sb-fg); background: linear-gradient(180deg, var(--sb-bg), var(--sb-bg-2)); }
.sidebar :focus-visible { outline-color: #fff; outline-offset: 3px; }
.sb-bar { display: flex; align-items: center; gap: .5rem; }
.sb-id { display: flex; align-items: center; gap: .75rem; min-width: 0; color: inherit; text-decoration: none; overflow-wrap: normal; }
.sb-avatar { flex: none; border-radius: 50%; object-fit: cover; background: #dbe4ef; }
.sb-text { display: flex; flex-direction: column; min-width: 0; }
.sb-name { font-weight: 700; line-height: 1.2; letter-spacing: -.005em; }
.sb-aka, .sb-role { color: var(--sb-fg-muted); font-size: var(--fs-sm); line-height: 1.4; }
.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: var(--hit); height: var(--hit); padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: inherit;
  font-size: 1.25rem; cursor: pointer;
}
.theme-toggle .i-sun,
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
.menu-toggle .i-close,
.menu-toggle[aria-expanded="true"] .i-menu { display: none; }
.menu-toggle[aria-expanded="true"] .i-close { display: block; }
.icon-btn .icon { fill: none; }
.sb-nav a {
  display: flex; align-items: center; min-height: 2.5rem;
  padding: .55rem .875rem; border-radius: var(--r-md);
  color: var(--sb-fg); font-weight: 500; font-size: 1rem; line-height: 1.3; text-decoration: none;
}
.sb-nav a[aria-current="page"] {
  background: var(--sb-active-bg); color: var(--sb-active-fg); font-weight: 600;
  box-shadow: inset 3px 0 0 var(--sb-active-bar), 0 1px 2px rgb(8 20 40 / .18), 0 6px 14px -6px rgb(8 20 40 / .35);
}
.sb-links { display: flex; flex-wrap: wrap; gap: .5rem; }
.sb-links a {
  display: inline-grid; place-items: center; width: 2.375rem; height: 2.375rem;
  border-radius: 50%; background: var(--sb-chip); color: var(--sb-fg);
  font-size: 1.125rem; text-decoration: none;
}
.main-col { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; min-height: 100dvh; }
.content {
  width: 100%; max-width: calc(var(--content-max) + 2 * var(--pad-x));
  margin-inline: auto; padding: var(--pad-top) var(--pad-x) var(--sp-8);
  container-type: inline-size;
}
.site-footer {
  width: 100%; max-width: calc(var(--content-max) + 2 * var(--pad-x));
  margin: auto auto 0; padding: 0 var(--pad-x) max(2rem, env(safe-area-inset-bottom));
  color: var(--text-muted); font-size: var(--fs-sm);
}
.site-footer__inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .5rem 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line);
}
.site-footer p { margin: 0; }
.site-footer a { display: inline-flex; align-items: center; gap: .5rem; color: var(--text-muted); text-decoration: none; }
.site-footer .i-bsky { color: #1185fe; font-size: 1.05rem; }
/* keep text clear of the iPhone notch / Dynamic Island in landscape (viewport-fit=cover) */
.content, .site-footer {
  padding-left: max(var(--pad-x), env(safe-area-inset-left));
  padding-right: max(var(--pad-x), env(safe-area-inset-right));
}
html:not(.js) .theme-toggle { display: none; }   /* the toggle needs JavaScript */

/* 4 · TOP-BAR MODE (phones, tablets, narrow windows) ---------------------------------- */
@media not all and (min-width: 64em) and (hover: hover) and (pointer: fine) {
  :root { scroll-padding-top: calc(var(--topbar-h) + env(safe-area-inset-top) + 1rem); }
  .sidebar {
    position: sticky; top: 0; z-index: 50;
    padding: env(safe-area-inset-top) max(var(--pad-x), env(safe-area-inset-right)) 0 max(var(--pad-x), env(safe-area-inset-left));
    background: var(--sb-bg);
    box-shadow: 0 1px 0 rgb(0 0 0 / .08), 0 6px 16px -10px rgb(8 20 40 / .45);
  }
  .sb-bar { min-height: var(--topbar-h); }
  .sb-id { flex: 1; }
  .sb-avatar { width: var(--avatar-bar); height: var(--avatar-bar); box-shadow: 0 0 0 2px var(--sb-ring); }
  .sb-name { font-size: 1rem; font-weight: 600; }
  .sb-aka, .sb-role { display: none; }
  .sb-bar .icon-btn:last-child { margin-right: -.5rem; }
  .sb-nav ul { display: grid; gap: .125rem; }
  .sb-nav a { min-height: 3rem; font-size: 1.0625rem; }
  .sb-links { margin-top: .75rem; padding-top: .875rem; border-top: 1px solid var(--sb-line); }
  .sb-links a { width: var(--hit); height: var(--hit); }

  /* menu sheet (with JavaScript) */
  html.js .sb-panel {
    position: absolute; inset: 100% 0 auto;
    padding: .5rem max(var(--pad-x), env(safe-area-inset-right)) 1.25rem max(var(--pad-x), env(safe-area-inset-left));
    background: var(--sb-bg-2); border-radius: 0 0 1.25rem 1.25rem; box-shadow: var(--sh-2);
    max-height: calc(100vh - var(--topbar-h)); max-height: calc(100dvh - var(--topbar-h) - env(safe-area-inset-top));
    overflow-y: auto; overscroll-behavior: contain;
    visibility: hidden; opacity: 0; transform: translateY(-.5rem);
  }
  html.js .sidebar[data-menu-open] .sb-panel { visibility: visible; opacity: 1; transform: none; }
  html.js .sidebar[data-menu-open]::after {
    content: ""; position: fixed; inset: 0; top: calc(var(--topbar-h) + env(safe-area-inset-top));
    z-index: -1; background: rgb(10 20 35 / .35);
  }

  /* without JavaScript: static bar, links shown as a wrapping row */
  html:not(.js) .menu-toggle { display: none; }
  html:not(.js) .sidebar { position: static; }
  html:not(.js) .sb-panel { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .25rem 1rem; padding-bottom: .75rem; }
  html:not(.js) .sb-nav ul { display: flex; flex-wrap: wrap; gap: .25rem; }
  html:not(.js) .sb-nav a { min-height: 2.5rem; padding: .4rem .75rem; font-size: 1rem; }
  html:not(.js) .sb-links { margin: 0; padding: 0; border: 0; }

  /* the bar is in the page flow: let short pages end exactly at the bottom of the screen */
  .main-col { min-height: calc(100vh - var(--topbar-h)); min-height: calc(100dvh - var(--topbar-h) - env(safe-area-inset-top)); }
  @media (max-width: 22em) { .sb-name { font-size: .875rem; } }

  /* landscape phones: don't let the bar eat the screen (relative, not static, so the menu sheet still anchors to it) */
  @media (max-height: 30em) {
    :root { --topbar-h: 3rem; scroll-padding-top: 1rem; }
    .sidebar { position: relative; }
  }
}

/* 5 · SIDEBAR MODE (laptops/desktops with a mouse or trackpad) ---------------------- */
@media (min-width: 64em) and (hover: hover) and (pointer: fine) {
  :root { --pad-x: 3rem; --pad-top: 4.5rem; scroll-padding-top: 1.5rem; }
  body { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .sidebar {
    position: sticky; top: 0; height: 100vh; height: 100dvh;
    display: flex; flex-direction: column;
    padding: 2.75rem 1.25rem 1.5rem;
    overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  }
  .sb-bar { position: relative; flex-direction: column; align-items: stretch; }
  .sb-id { flex-direction: column; align-items: center; gap: 1.125rem; text-align: center; }
  .sb-avatar {
    width: var(--avatar); height: var(--avatar);
    box-shadow: 0 0 0 3px var(--sb-ring), 0 0 0 8px rgb(255 255 255 / .12), 0 16px 32px -14px rgb(8 20 40 / .6);
  }
  .sb-text { align-items: center; gap: .125rem; }
  .sb-name { font-size: 1.25rem; text-wrap: balance; }
  .sb-role { margin-top: .5rem; }
  .theme-toggle { position: absolute; top: -2rem; right: -.5rem; width: 2.25rem; height: 2.25rem; font-size: 1.05rem; }
  .menu-toggle { display: none; }
  .sb-panel { flex: 1; display: flex; flex-direction: column; margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--sb-line); }
  .sb-nav ul { display: grid; gap: .25rem; }
  .sb-links { justify-content: center; margin-top: auto; padding-top: 1.5rem; }
  /* About: the sidebar already shows photo, role and links */
  .intro .intro__avatar, .intro .intro__role, .intro .intro__links { display: none; }

  /* 6 or more profile icons: slightly smaller chips so they still fit on one row */
  .sb-links:has(> li:nth-child(6)) { gap: .3rem; }
  .sb-links:has(> li:nth-child(6)) a { width: 2.1rem; height: 2.1rem; font-size: 1rem; }

  @media (min-width: 80em) { :root { --pad-x: 4rem; } }
  @media (max-height: 45em) {
    :root { --avatar: 5.75rem; }
    .sidebar { padding-top: 2.5rem; }
    .sb-id { gap: .75rem; }
    .sb-panel { margin-top: 1.25rem; padding-top: 1rem; }
  }
}

/* 6 · COMPONENTS ---------------------------------------------------------------- */
.page-head { margin-bottom: var(--sp-6); }
.page-title { font-size: var(--fs-xl); font-weight: 700; line-height: 1.2; letter-spacing: -.02em; overflow-wrap: break-word; }
.page-title::after,
.hero-name::after {
  content: ""; display: block; width: 2.5rem; height: 3px; margin-top: .875rem;
  border-radius: 3px; background: var(--accent-ui);
}
.page-title--hero { font-size: var(--fs-2xl); }
.page-title--hero::after { display: none; }
.hero-name { margin: 0; }
.aka { margin: .25rem 0 0; color: var(--text-muted); font-size: var(--fs-lg); font-weight: 400; white-space: nowrap; }
.section-title { margin-bottom: var(--sp-4); font-size: var(--fs-lg); font-weight: 600; letter-spacing: -.01em; }
.eyebrow { margin: 0; color: var(--text-muted); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.lead { font-size: var(--fs-md); line-height: 1.6; }
.prose { max-width: var(--measure); }
.prose > :last-child { margin-bottom: 0; }

/* figure "plates": every figure sits on white, so white-background figures look right in dark mode */
.plate {
  position: relative; display: block;
  aspect-ratio: var(--plate-ar, 4 / 3);
  background: var(--plate); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--sh-1); filter: var(--plate-filter); overflow: hidden;
}
/* the image is fitted inside the plate (never cropped), inset by --plate-pad */
.plate img {
  position: absolute; top: var(--plate-pad, .5rem); left: var(--plate-pad, .5rem);
  width: calc(100% - 2 * var(--plate-pad, .5rem)); height: calc(100% - 2 * var(--plate-pad, .5rem));
  object-fit: contain;
  transform: scale(var(--fig-scale, 1));   /* per-figure size knob: <div class="plate" style="--fig-scale: .7"> */
}
.plate--dark { --plate: #000; --plate-pad: 0px; filter: none; border-color: #000; }   /* 0px, not 0: unitless 0 breaks calc() */
/* figures are all the same size: 1 per row on phones, 2 per row on wider screens; a lone last figure is centred */
.fig-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; margin-top: var(--sp-5); }
.fig-grid > .fig { flex: 0 1 100%; min-width: 0; }
@container (min-width: 32rem) { .fig-grid > .fig { flex-basis: calc(50% - .5rem); } }

.btn {
  display: inline-flex; align-items: center; gap: .375rem;
  min-height: 2.25rem; padding: 0 .875rem;
  border: 1px solid var(--accent-line); border-radius: var(--r-pill);
  background: var(--bg); color: var(--accent);
  font: 500 var(--fs-sm)/1 var(--font-sans); white-space: nowrap; text-decoration: none; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn--toggle { background: var(--accent-soft); }
.btn--toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn .icon { font-size: 1rem; }
.chev { fill: none; }
@media (pointer: coarse) { .btn { min-height: var(--hit); } }
.badge {
  display: inline-flex; align-items: center; height: 1.375rem; padding: 0 .5rem;
  border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1; vertical-align: .08em;
}

.toc { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: var(--sp-5); }
.toc a {
  display: inline-flex; align-items: center; min-height: 2.25rem; padding: .25rem .875rem;
  border: 1px solid var(--accent-line); border-radius: var(--r-pill);
  color: var(--accent); font-size: var(--fs-sm); font-weight: 500; line-height: 1.3; text-decoration: none;
}
@media (pointer: coarse) { .toc a { min-height: var(--hit); } }

.related {
  margin-top: var(--sp-5); padding: 1rem 1.25rem;
  background: var(--surface); border-left: 3px solid var(--accent-line);
  border-radius: 0 var(--r-md) var(--r-md) 0; font-size: var(--fs-sm);
}
.related__title { margin-bottom: .5rem; color: var(--text-muted); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.related li + li { margin-top: .4rem; }
.related a { font-weight: 500; }
.related__meta { color: var(--text-muted); }
@container (min-width: 30rem) { .related__meta { white-space: nowrap; } }

/* 7 · PAGES ------------------------------------------------------------------- */
/* About */
.intro { display: grid; gap: 1.25rem; align-items: center; }
.intro__avatar {
  width: 5.5rem; height: 5.5rem; border-radius: 50%;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent-ui);
}
.intro__role { margin: .875rem 0 0; color: var(--text-muted); font-size: var(--fs-meta); }
.intro__links { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .875rem; }
.intro__links a {
  display: inline-grid; place-items: center; width: var(--hit); height: var(--hit);
  border: 1px solid var(--accent-line); border-radius: 50%; color: var(--accent);
  font-size: 1.125rem; text-decoration: none;
}
@container (min-width: 30rem) {
  .intro { grid-template-columns: auto 1fr; gap: 1.5rem; }
  .intro__avatar { width: 7rem; height: 7rem; }
}
.highlights { margin-top: var(--section-gap); padding-top: var(--sp-6); border-top: 1px solid var(--line); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.more-link { display: inline-flex; align-items: center; gap: .375rem; font-size: var(--fs-sm); font-weight: 500; text-decoration: none; }
.more-link .icon { fill: none; }
.tiles { display: grid; gap: .75rem; }
.tile {
  display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); align-items: center; gap: 1rem;
  padding: .5rem; border: 1px solid var(--line); border-radius: var(--r-lg);
  color: var(--heading); text-decoration: none;
}
.tile .plate { --plate-ar: 1; --plate-pad: .25rem; box-shadow: none; }
.tile img { transform-origin: center; }
.tile__label { font-size: var(--fs-meta); font-weight: 600; line-height: 1.35; }
@container (min-width: 36rem) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
  .tile { grid-template-columns: 1fr; gap: .75rem; padding: 0; border: 0; }
  .tile .plate { --plate-ar: 4 / 3; --plate-pad: .5rem; box-shadow: var(--sh-1); }
}

/* Research */
.topic { margin-top: var(--section-gap); padding-top: var(--section-gap); border-top: 1px solid var(--line); }

/* Publications */
.pub-tools { display: flex; justify-content: flex-end; margin: 0 0 .25rem; }
.pubs { margin: 0; padding: 0; list-style: none; }
.pub {
  display: grid; grid-template-columns: var(--num-w) minmax(0, 1fr);
  grid-template-areas: "thumb thumb" "num body";
  column-gap: .75rem; row-gap: 1rem;
  padding: 1.75rem 0; border-top: 1px solid var(--line);
}
.pub:first-child { border-top: 0; padding-top: .75rem; }
.pub__num {
  grid-area: num; padding-top: .05rem;
  color: var(--accent); font-size: var(--fs-md); font-weight: 600; line-height: 1.35;
  font-variant-numeric: tabular-nums; text-align: right;
}
.pub__thumb { grid-area: thumb; --plate-ar: 16 / 9; max-height: 13rem; }
.pub__body { grid-area: body; min-width: 0; }
@container (min-width: 34rem) {
  .pub {
    grid-template-columns: var(--num-w) var(--thumb-w) minmax(0, 1fr);
    grid-template-areas: "num thumb body"; column-gap: 1.25rem; align-items: start;
  }
  .pub__thumb { --plate-ar: 4 / 3; max-height: none; }
}
.pub__title { margin: 0 0 .375rem; font-size: var(--fs-md); font-weight: 600; line-height: 1.35; }
.pub__meta { margin: 0; color: var(--text-muted); font-size: var(--fs-meta); line-height: 1.5; }
.pub__authors, .pub__venue { display: block; }
.pub__meta .me { color: var(--text); font-weight: 600; }
.pub__meta cite { color: var(--text); font-style: italic; }
.pub__note { margin: .25rem 0 0; color: var(--text-muted); font-size: var(--fs-sm); }
.pub__links { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .875rem; }
.pub__abs { margin-top: .75rem; }
.pub__abs > summary {
  width: max-content; list-style: none; cursor: pointer;
  color: var(--accent); font-size: var(--fs-sm); font-weight: 600;
}
.pub__abs > summary::-webkit-details-marker { display: none; }
.pub__abs > summary span { display: inline-flex; align-items: center; gap: .375rem; }
.pub__abs[open] > summary .chev { transform: rotate(180deg); }
.pub__abs[data-enhanced] > summary { display: none; }
.pub__abs-body {
  max-width: var(--measure); margin-top: .75rem; padding: 1rem 1.125rem;
  background: var(--surface); border-left: 3px solid var(--accent-line);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-size: var(--fs-meta); line-height: 1.6;
}
.pub__abs-body p { margin: 0; }

/* Miscellaneous */
.section + .section { margin-top: var(--section-gap); padding-top: var(--section-gap); border-top: 1px solid var(--line); }
.subhead { margin: var(--sp-5) 0 .25rem; }
.lines li { padding: .65rem 0; border-bottom: 1px solid var(--line); }
.lines li:last-child { border-bottom: 0; }
.lines--entries li { line-height: 1.55; }
.lines--entries strong { color: var(--heading); }
.lines--entries strong a { color: var(--accent); }
/* Photos side by side, each with its own caption (stacked on phones), e.g. the team photos under Personal */
.photo-grid { display: grid; gap: 1.25rem 1rem; margin: var(--sp-4) 0 var(--sp-2); }
.photo-grid > .photo { max-width: none; margin: 0; }
@container (min-width: 32rem) { .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.course__code { color: var(--heading); font-weight: 600; font-variant-numeric: tabular-nums; }
.footnote { margin: .5rem 0 0; color: var(--text-muted); font-size: var(--fs-sm); }
.cards { display: grid; gap: .75rem; }
.card { padding: 1.125rem 1.25rem; border: 1px solid var(--line); border-radius: var(--r-md); }
.card__title { margin: 0 0 .3rem; font-size: var(--fs-base); font-weight: 600; line-height: 1.35; }
.card__title a { text-decoration-color: transparent; }
.card__title .icon { display: inline; width: .8em; height: .8em; margin-left: .3em; vertical-align: -.02em; fill: none; opacity: .8; }
.card p { margin: 0; color: var(--text-muted); font-size: var(--fs-meta); }
.media { display: grid; gap: 1.25rem; align-items: start; }
.media + .media { margin-top: var(--sp-7); }
.photo { max-width: 20rem; margin-inline: auto; }
.photo--wide { max-width: none; }
.photo img { width: 100%; border-radius: var(--r-md); box-shadow: var(--sh-1); }
.photo figcaption { margin-top: .625rem; color: var(--text-muted); font-size: var(--fs-sm); line-height: 1.5; text-align: center; text-wrap: balance; }
@container (min-width: 40rem) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .media--side { grid-template-columns: minmax(0, 1fr) 15rem; gap: 2rem; }
  .media--side .photo { margin: 0; }
}

/* 404 */
.notfound-links { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: var(--sp-5); }

/* 8 · HOVER (only on devices that really hover — avoids "stuck" hover on touch) ------ */
@media (hover: hover) {
  a:hover { color: var(--accent-strong); text-decoration-thickness: 2px; text-decoration-color: currentColor; }
  .sidebar a:hover { color: var(--sb-fg); }   /* keep sidebar links white (the rule above would make them dark blue) */
  .icon-btn:hover, .sb-nav a:hover { background: var(--sb-hover); color: var(--sb-fg); }
  .sb-nav a[aria-current="page"]:hover { background: var(--sb-active-bg); color: var(--sb-active-fg); }
  .sb-links a:hover { background: var(--sb-chip-hover); }
  .site-footer a:hover { color: var(--accent); }
  .btn:hover, .toc a:hover { border-color: var(--accent-ui); background: var(--accent-soft); color: var(--accent-strong); }
  .intro__links a:hover { border-color: var(--accent-ui); background: var(--accent-soft); color: var(--accent-strong); }
  .tile:hover { border-color: var(--accent-line); }
  .tile:hover .plate { border-color: var(--accent-line); box-shadow: var(--sh-2); }
  .tile:hover .tile__label { color: var(--accent); }
  .card__title a:hover { text-decoration-color: currentColor; }
}

/* 9 · MOTION (all animation is skipped for people who ask for reduced motion) --------- */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  a, .btn, .toc a, .icon-btn, .sb-nav a, .sb-links a, .intro__links a, .tile, .tile .plate, .tile img, .chev, .more-link .icon {
    transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease),
                border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
                text-decoration-color var(--dur) var(--ease), transform var(--dur) var(--ease);
  }
  html.js .sb-panel { transition: opacity 200ms var(--ease), transform 200ms var(--ease), visibility 0s linear 200ms; }
  html.js .sidebar[data-menu-open] .sb-panel { transition: opacity 200ms var(--ease), transform 200ms var(--ease), visibility 0s; }
  .theme-anim, .theme-anim *, .theme-anim *::before, .theme-anim *::after {
    transition: background-color 300ms var(--ease), color 300ms var(--ease), border-color 300ms var(--ease) !important;
  }
  .pub:target, .topic:target { animation: target-flash 2.4s var(--ease); border-radius: var(--r-lg); }
  @media (hover: hover) {
    .tile:hover .plate { transform: translateY(-2px); }
    .tile:hover img { transform: scale(1.03); }
    .more-link:hover .icon { transform: translateX(3px); }
  }
}
@keyframes target-flash { from { background-color: var(--accent-soft); } to { background-color: transparent; } }

/* 10 · FORCED COLOURS (Windows high contrast) ------------------------------------- */
@media (forced-colors: active) {
  .btn, .toc a, .badge, .sb-links a, .intro__links a, .card, .plate, .tile { border: 1px solid CanvasText; }
  .sb-nav a[aria-current="page"] { outline: 2px solid CanvasText; }
  .page-title::after, .hero-name::after { background: CanvasText; }
}

/* 11 · PRINT --------------------------------------------------------------------- */
@media print {
  :root, :root[data-theme="dark"] {
    color-scheme: light !important;
    --bg: #fff; --surface: #fff; --text: #000; --heading: #000; --text-muted: #333;
    --accent: #000; --accent-soft: #fff; --accent-line: #999; --line: #ccc; --plate-filter: none;
  }
  body { display: block; font-size: 10.5pt; }
  .sidebar, .skip-link, .toc, .highlights, .pub-tools, .pub__thumb, .pub__links, .site-footer a, .pub__abs > summary { display: none !important; }
  .content { max-width: none; padding: 0; }
  .pub { grid-template-columns: var(--num-w) minmax(0, 1fr); grid-template-areas: "num body"; padding: 1rem 0; }
  .pub, figure, .related, .card, .lines li { break-inside: avoid; }
  a { color: #000; text-decoration: none; }
  .pub__abs-body { border: 0; padding: .25rem 0 0; }
  @page { margin: 18mm 16mm; }
}
