/* ==========================================================================
   Ahmed Abdelmotteleb — site styles
   One stylesheet, no framework. Tokens first, then base, layout, components,
   and page-specific blocks. Dark mode follows the OS setting.
   ========================================================================== */

@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("/assets/fonts/source-serif-4-latin.woff2") format("woff2");
  font-weight: 500 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --surface-2: #f3f2ec;
  --ink: #0f1b2d;
  --ink-2: #344155;
  --muted: #5a6577;
  --line: #e2e0d8;
  --line-strong: #cfccc1;
  --accent: #b3122e;
  --accent-ink: #ffffff;
  --accent-soft: #fbe8ea;
  --curve: #b3122e;
  --grid: #e7e5de;
  --focus: #1d4ed8;

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;

  --step--1: clamp(0.84rem, 0.82rem + 0.1vw, 0.9rem);
  --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  --step-1: clamp(1.15rem, 1.08rem + 0.35vw, 1.3rem);
  --step-2: clamp(1.4rem, 1.25rem + 0.7vw, 1.75rem);
  --step-3: clamp(1.75rem, 1.45rem + 1.4vw, 2.5rem);
  --step-4: clamp(2.35rem, 1.7rem + 3.2vw, 4.1rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: clamp(2.5rem, 2rem + 2.5vw, 4rem);
  --space-8: clamp(3.5rem, 2.5rem + 5vw, 6.5rem);

  --radius: 10px;
  --radius-lg: 16px;
  --gutter: clamp(1rem, 0.5rem + 2.5vw, 2rem);
  --maxw: 72rem;
  --prose: 42rem;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b121c;
    --surface: #111a26;
    --surface-2: #162130;
    --ink: #e9edf2;
    --ink-2: #c3ccd8;
    --muted: #94a0b1;
    --line: #223043;
    --line-strong: #31425a;
    --accent: #ff6b6b;
    --accent-ink: #1a0a0c;
    --accent-soft: #2b1418;
    --curve: #ff6b6b;
    --grid: #1b2738;
    --focus: #8ab4ff;
    color-scheme: dark;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 5rem;
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.65;
  font-feature-settings: "cv11", "ss01";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
img { height: auto; }

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.012em;
  margin: 0 0 var(--space-3);
  text-wrap: balance;
}
h1 { font-size: var(--step-4); letter-spacing: -0.02em; }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); line-height: 1.3; }
h4 { font-size: var(--step-0); font-family: var(--font-sans); font-weight: 600; letter-spacing: 0; }

p { margin: 0 0 var(--space-4); text-wrap: pretty; }
ul, ol { margin: 0 0 var(--space-4); padding-left: 1.2em; }
li + li { margin-top: var(--space-2); }

a {
  color: var(--ink);
  text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.18em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
a:hover { color: var(--accent); text-decoration-color: currentColor; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

sub, sup { font-size: 0.72em; line-height: 0; }

.mono { font-family: var(--font-mono); font-size: 0.9em; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.icon { width: 1.15em; height: 1.15em; flex: none; }

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -3rem;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: var(--space-3); color: var(--bg); }

/* ---------- Layout ---------- */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.prose { max-width: var(--prose); }

.section { padding-block: var(--space-7); }
.section + .section,
.hero + .section { border-top: 1px solid var(--line); }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2) var(--space-5);
  margin-bottom: var(--space-6);
}
.section-head h2 { margin: 0; }
.section-head .more { display: inline-flex; align-items: center; min-height: 44px; font-weight: 500; font-size: var(--step--1); white-space: nowrap; }

.eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.02em;
  color: var(--accent);
  margin-bottom: var(--space-2);
}

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 3.75rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
}
.brand:hover { color: var(--ink); }
.brand-mark { width: 34px; height: 34px; color: var(--accent); }
.brand-name { display: none; }
@media (min-width: 40rem) { .brand-name { display: inline; } }

.nav ul {
  display: flex;
  gap: clamp(0.15rem, 1.5vw, 1.25rem);
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav li + li { margin: 0; }
.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 0.6rem;
  border-radius: 8px;
  color: var(--ink-2);
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
}
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current="page"] {
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--accent);
  border-radius: 0;
}

/* ---------- Buttons ---------- */
.actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 48px;
  padding: 0.7rem 1.15rem;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: 0.97rem;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 88%, var(--ink));
  border-color: color-mix(in srgb, var(--accent) 88%, var(--ink));
  color: var(--accent-ink);
}
@media (prefers-reduced-motion: no-preference) {
  .btn:active { transform: translateY(1px); }
}

/* Small link chips (paper/slides/recording) */
.links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-3) 0 0;
  padding: 0;
  list-style: none;
}
.links li + li { margin: 0; }
.links a {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  min-height: 36px;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: var(--step--1);
  font-weight: 500;
  text-decoration: none;
  color: var(--ink-2);
  background: var(--surface);
}
.links a:hover { color: var(--accent); border-color: var(--accent); }
.links .icon { width: 0.95em; height: 0.95em; }

.chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.4;
  padding: 0.12rem 0.5rem;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.chip-neutral { background: var(--surface-2); color: var(--ink-2); }

/* Social icon row */
.social {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.social li + li { margin: 0; }
.social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  color: var(--ink-2);
  border: 1px solid var(--line);
  background: var(--surface);
}
.social a:hover { color: var(--accent); border-color: var(--accent); }
.social .icon { width: 20px; height: 20px; }
@media (max-width: 30rem) {
  .social { gap: 3px; }
  .social a { width: 38px; height: 38px; }
  .social .icon { width: 18px; height: 18px; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding-block: var(--space-6) var(--space-7);
}
.hero-grid {
  display: grid;
  gap: var(--space-5);
  align-items: center;
}
.hero-id {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.hero-photo {
  flex: none;
  width: 76px;
  aspect-ratio: 1;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 4px var(--line-strong);
}
.hero-photo img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; }
.hero-id .eyebrow { margin: 0; line-height: 1.5; }
.hero-id .eyebrow span { display: block; }
.hero h1 { margin-bottom: var(--space-4); }
.hero .tagline {
  font-family: var(--font-serif);
  font-size: var(--step-2);
  line-height: 1.3;
  font-weight: 500;
  color: var(--ink);
  max-width: 34ch;
  margin-bottom: var(--space-4);
}
.hero .tagline em { font-style: normal; color: var(--accent); }
.hero .summary { color: var(--ink-2); max-width: 58ch; margin-bottom: var(--space-5); }
.hero .actions { margin-bottom: var(--space-5); }

.hero-figure { display: none; }

@media (min-width: 56rem) {
  .hero { padding-block: var(--space-8) var(--space-7); }
  .hero-grid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: var(--space-7); }
  .hero-id .hero-photo { display: none; }
  .hero-figure {
    display: flex;
    justify-content: flex-end;
    margin: 0;
  }
  .hero-figure .portrait {
    width: min(100%, 360px);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--surface-2);
    aspect-ratio: 4 / 5;
  }
  .hero-figure .portrait img { width: 100%; height: 100%; object-fit: cover; }
}

/* The Jacobian-peak plot (research page) */
.plot { color: var(--curve); }
.plot .axis { stroke: var(--line-strong); stroke-width: 1.25; fill: none; }
.plot .gridline { stroke: var(--grid); stroke-width: 1; }
.plot .model { stroke: currentColor; stroke-width: 2.5; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.plot .fill { fill: currentColor; opacity: 0.08; }
.plot .hist { stroke: var(--ink-2); stroke-width: 1.25; fill: none; opacity: 0.45; }
.plot .pt { fill: var(--ink); }
.plot .err { stroke: var(--ink); stroke-width: 1.5; }
.plot .peak { stroke: var(--ink-2); stroke-width: 1.25; stroke-dasharray: 4 4; }
.plot text { font-family: var(--font-mono); font-size: 24px; fill: var(--muted); }
.plot .label-peak { fill: var(--ink); font-size: 26px; }

/* ---------- Cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
  gap: var(--space-4);
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:hover { border-color: var(--line-strong); }
.card h3 { margin-bottom: var(--space-2); }
.card h3 a { text-decoration: none; }
.card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.card h3 a:focus-visible { outline: none; }
.card:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }
.card p { color: var(--ink-2); font-size: 0.97rem; margin-bottom: var(--space-3); }
.card .meta { margin-top: auto; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.card .num {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--muted);
  margin-bottom: var(--space-3);
}
@media (prefers-reduced-motion: no-preference) {
  .card:hover { transform: translateY(-2px); }
}
@media (min-width: 60rem) {
  .cards-feature { grid-template-columns: repeat(3, 1fr); }
  .cards-feature .card:first-child { grid-column: span 2; }
}

/* ---------- Publications / talks lists ---------- */
.entries { list-style: none; margin: 0; padding: 0; }
.entries > li { margin: 0; padding-block: var(--space-5); border-top: 1px solid var(--line); }
.entries > li:first-child { border-top: 0; padding-top: 0; }
.entry-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-2);
}
.entry-title {
  font-family: var(--font-serif);
  font-size: var(--step-1);
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 var(--space-1);
}
.entry-title a { text-decoration: none; }
.entry-title a:hover { text-decoration: underline; }
.entry-sub { color: var(--muted); font-size: 0.95rem; margin: 0; }
.entry-note { color: var(--ink-2); font-size: 0.97rem; margin: var(--space-2) 0 0; max-width: 64ch; }

.two-col { display: grid; gap: var(--space-7); }
@media (min-width: 60rem) {
  .two-col { grid-template-columns: 1fr 1fr; gap: var(--space-7); }
}

/* ---------- Gallery (scroll-snap strip) ---------- */
.gallery-wrap { position: relative; }
.gallery {
  display: flex;
  gap: var(--space-4);
  margin: 0;
  padding: 0 var(--gutter) var(--space-4);
  list-style: none;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--gutter);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.gallery li + li { margin: 0; }
.gallery li { flex: none; scroll-snap-align: start; }
.gallery figure { margin: 0; width: min-content; }
.gallery img {
  height: clamp(240px, 42vw, 320px);
  width: auto;
  max-width: none;
  border-radius: var(--radius);
  background: var(--surface-2);
  object-fit: cover;
}
.gallery figcaption {
  margin-top: var(--space-2);
  font-size: var(--step--1);
  line-height: 1.45;
  color: var(--muted);
  min-width: 14rem;
}
.gallery figcaption a { color: var(--ink-2); }
@media (min-width: 72rem) {
  /* Align the strip's first item with the content column */
  .gallery { padding-inline: max(var(--gutter), calc((100vw - var(--maxw)) / 2 + var(--gutter))); scroll-padding-inline: max(var(--gutter), calc((100vw - var(--maxw)) / 2 + var(--gutter))); }
}
.gallery-controls { display: none; gap: var(--space-2); }
.js .gallery-controls { display: flex; }
.gallery-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.gallery-controls button:hover { border-color: var(--ink); }
.gallery-controls button:disabled { opacity: 0.4; cursor: default; }

/* ---------- News ---------- */
.news { list-style: none; margin: 0; padding: 0; }
.news li { margin: 0; border-top: 1px solid var(--line); }
.news li:last-child { border-bottom: 1px solid var(--line); }
.news a {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: var(--space-4);
  padding-block: var(--space-3);
  min-height: 44px;
  text-decoration: none;
}
.news time { font-family: var(--font-mono); font-size: var(--step--1); color: var(--muted); padding-top: 0.15em; }
.news a:hover span { text-decoration: underline; }
@media (max-width: 30rem) {
  .news a { grid-template-columns: 1fr; gap: 0; }
}

/* ---------- Page header (inner pages) ---------- */
.page-head { padding-block: var(--space-7) var(--space-6); border-bottom: 1px solid var(--line); }
.page-head h1 { font-size: var(--step-4); margin-bottom: var(--space-4); }
.lede { font-size: var(--step-1); color: var(--ink-2); max-width: 60ch; }
.page-head .lede { margin-bottom: 0; }
.page-head .actions { margin-top: var(--space-5); }

/* Jump links on inner pages */
.toc {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-5) 0 0;
  padding: 0;
  list-style: none;
}
.toc li + li { margin: 0; }
.toc a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--step--1);
  font-weight: 500;
  text-decoration: none;
}
.toc a:hover { color: var(--accent); }

/* ---------- Research themes ---------- */
.theme { display: grid; gap: var(--space-5) var(--space-7); }
@media (min-width: 60rem) {
  .theme { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
  .theme > .theme-aside { position: sticky; top: 5.5rem; }
}
.theme h2 { margin-bottom: var(--space-4); }
.in-short {
  font-size: var(--step-1);
  line-height: 1.55;
  color: var(--ink);
  margin-bottom: var(--space-5);
}
.label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--space-2);
}
.role-list { padding-left: 1.1em; color: var(--ink-2); }
.links-label { margin: var(--space-5) 0 0; }
.links-label + .links { margin-top: var(--space-2); }
.role-list li::marker { color: var(--accent); }

details.expert {
  margin-top: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
details.expert > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 48px;
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
details.expert > summary::-webkit-details-marker { display: none; }
details.expert > summary::after {
  content: "";
  flex: none;
  width: 0.6rem;
  height: 0.6rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.2s ease;
}
details.expert[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
details.expert > summary:hover { color: var(--accent); }
details.expert > div { padding: 0 var(--space-4) var(--space-4); color: var(--ink-2); }
details.expert > div > :last-child { margin-bottom: 0; }

.theme-aside { display: grid; gap: var(--space-5); align-content: start; }
.decay { color: var(--ink); }
.toolkit { padding: var(--space-5); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.toolkit h3 { font-family: var(--font-sans); font-size: 0.97rem; font-weight: 600; margin-bottom: var(--space-3); }
code { font-family: var(--font-mono); font-size: 0.88em; padding: 0.1em 0.35em; border-radius: 5px; background: var(--surface-2); }

.faq dt { font-weight: 600; color: var(--ink); margin-top: var(--space-4); }
.faq dd { margin: var(--space-1) 0 0; }

.figure { margin: 0; }
.figure img, .figure svg { border-radius: var(--radius); }
.figure .frame {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: var(--space-4);
}
.figure figcaption { margin-top: var(--space-3); font-size: var(--step--1); color: var(--muted); line-height: 1.5; }

/* ---------- CV page ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline > li {
  position: relative;
  margin: 0;
  padding: 0 0 var(--space-6) var(--space-6);
  border-left: 2px solid var(--line);
}
.timeline > li:last-child { padding-bottom: 0; border-left-color: transparent; }
.timeline > li::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 0.45rem;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--bg);
  border: 2px solid var(--accent);
}
.timeline > li.current::before { background: var(--accent); }
.timeline .when { font-family: var(--font-mono); font-size: var(--step--1); color: var(--muted); display: block; margin-bottom: var(--space-1); }
.timeline h3 { margin-bottom: var(--space-1); }
.timeline .where { color: var(--ink-2); margin-bottom: var(--space-3); }
.timeline ul { color: var(--ink-2); padding-left: 1.1em; margin-bottom: 0; }
.timeline ul li::marker { color: var(--accent); }

.roles { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); list-style: none; margin: 0; padding: 0; }
.roles > li { margin: 0; padding: var(--space-5); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.roles-single { grid-template-columns: 1fr; }
.section-head-spaced { margin-top: var(--space-7); }
.roles h3 { margin-bottom: var(--space-1); }
.roles .when { font-family: var(--font-mono); font-size: var(--step--1); color: var(--muted); display: block; margin-bottom: var(--space-3); }
.roles p { margin: 0; color: var(--ink-2); font-size: 0.97rem; }
.roles p + p { margin-top: var(--space-2); }

.skill-groups { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); }
.skill-groups h3 { font-family: var(--font-sans); font-size: 0.97rem; font-weight: 600; margin-bottom: var(--space-3); }
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; margin: 0; padding: 0; }
.tags li { margin: 0; }
.tags li {
  font-size: 0.88rem;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
}

.compact { list-style: none; margin: 0; padding: 0; }
.compact li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-4);
  margin: 0;
  padding-block: var(--space-3);
  border-top: 1px solid var(--line);
}
.compact li:last-child { border-bottom: 1px solid var(--line); }
.compact a { display: inline-block; padding-block: 0.7rem; margin-block: -0.7rem; }
.compact .desc { display: block; margin-top: 0.15rem; color: var(--ink-2); font-size: 0.93rem; }
.compact strong { font-weight: 600; }
.subhead { font-family: var(--font-sans); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: var(--space-6) 0 var(--space-3); }
.section-head + .subhead { margin-top: 0; }
.compact .when { font-family: var(--font-mono); font-size: var(--step--1); color: var(--muted); white-space: nowrap; padding-top: 0.15em; }

.interests-title { font-family: var(--font-sans); font-size: 0.97rem; font-weight: 600; margin: var(--space-5) 0 var(--space-3); }
.interests { margin-bottom: var(--space-4); }
.photo-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin: 0 0 var(--space-4); }
.photo-pair img { width: 100%; height: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--radius); }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: var(--space-7);
  padding-block: var(--space-7) var(--space-6);
  background: var(--surface-2);
  border-top: 1px solid var(--line);
}
.site-footer h2 { font-size: var(--step-3); margin-bottom: var(--space-3); }
.site-footer .contact-grid { display: grid; gap: var(--space-6); }
@media (min-width: 52rem) {
  .site-footer .contact-grid { grid-template-columns: 1.3fr 1fr; align-items: end; }
}
.site-footer .email {
  font-family: var(--font-serif);
  font-size: var(--step-2);
  font-weight: 500;
  word-break: break-word;
}
.site-footer .fine {
  margin-top: var(--space-7);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2) var(--space-5);
  font-size: var(--step--1);
  color: var(--muted);
}
.site-footer .fine p { margin: 0; }
.site-footer .fine a { color: var(--muted); }

/* ---------- 404 ---------- */
.notfound { padding-block: var(--space-8); }
.notfound .plot { max-width: 30rem; margin-bottom: var(--space-5); }

/* ---------- Print ---------- */
@media print {
  .site-header, .site-footer, .gallery-wrap, .actions, .toc { display: none !important; }
  body { background: #fff; color: #000; }
  details.expert > div { display: block; }
  a { color: inherit; text-decoration: none; }
}
