/* Layout: single reading column (~68ch) with a wide mountain ridge band under the hero.
   Research chain shown as a four-station route. */
:root {
  --paper: #f5f7f8;
  --surface: #ffffff;
  --ink: #15212b;
  --muted: #56636e;
  --rule: #d6dde2;
  --accent: #23617f;
  --accent-soft: #e2edf2;
  --ridge-1: #c9d6de;
  --ridge-2: #9fb3c0;
  --ridge-3: #5f7a8b;
  --overlay: rgba(10, 18, 24, 0.82);
  --overlay-ink: #f3f6f8;
  --backdrop: rgba(8, 14, 19, 0.88);
  --font-display: "Spectral", Georgia, "Times New Roman", serif;
  --font-body: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.3rem;
  --step-2: 1.75rem;
  --step-3: clamp(2.3rem, 5vw, 3.4rem);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f161c; --surface: #16212a; --ink: #e5ebef; --muted: #98a6b1;
    --rule: #26333d; --accent: #82b8d4; --accent-soft: #1b2e3a;
    --ridge-1: #1c2a34; --ridge-2: #273946; --ridge-3: #3a5262;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f161c; --surface: #16212a; --ink: #e5ebef; --muted: #98a6b1;
  --rule: #26333d; --accent: #82b8d4; --accent-soft: #1b2e3a;
  --ridge-1: #1c2a34; --ridge-2: #273946; --ridge-3: #3a5262;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.65;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.wrap {
  max-width: 50rem;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Header */
.site-header { border-bottom: 1px solid var(--rule); }
.site-header .wrap {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.5rem 1.5rem; padding-block: 1rem;
}
.brand { font-family: var(--font-display); font-size: var(--step-1); font-weight: 600; color: var(--ink); text-decoration: none; }
.nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; font-size: var(--step--1); }
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); }

/* Hero */
.hero .wrap {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2rem;
  align-items: end; padding-block: 3.5rem 1.5rem;
}
.eyebrow {
  font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); margin: 0 0 0.75rem;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; text-wrap: balance; margin: 0; }
h1 { font-size: var(--step-3); letter-spacing: -0.01em; }
.lead { font-size: var(--step-1); line-height: 1.5; color: var(--muted); margin: 1rem 0 0; max-width: 34em; }
.portrait {
  width: 11rem; aspect-ratio: 4 / 5; max-width: 100%;
  background: var(--accent-soft); border: 1px solid var(--rule);
  display: grid; place-items: center; position: relative; overflow: hidden;
}
.portrait span { font-family: var(--font-display); font-size: 2.6rem; color: var(--accent); }
.portrait img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }

.ridge { display: block; width: 100%; height: 110px; }
.ridge .r1 { fill: var(--ridge-1); }
.ridge .r2 { fill: var(--ridge-2); }
.ridge .r3 { fill: var(--ridge-3); }

/* Sections */
main section { padding-block: 2.5rem; border-top: 1px solid var(--rule); }
main section:first-child { border-top: 0; }
h2 { font-size: var(--step-2); margin-bottom: 1rem; }
p { margin: 0 0 1rem; max-width: 65ch; }

.notice {
  display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; align-items: baseline;
  background: var(--accent-soft); padding: 0.9rem 1.1rem; margin-top: 1.5rem;
  border-left: 3px solid var(--accent);
}
.notice strong { font-weight: 600; }

/* Research route */
.route { list-style: none; padding: 0; margin: 1.75rem 0 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.25rem; counter-reset: stop; }
.route li { position: relative; padding-top: 1.6rem; border-top: 2px solid var(--ridge-2); counter-increment: stop; }
.route li::before {
  content: counter(stop); position: absolute; top: -0.85rem; left: 0;
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--accent); color: var(--accent);
  font-family: var(--font-mono); font-size: 0.8rem; display: grid; place-items: center;
}
.route h3 { font-size: var(--step-0); font-family: var(--font-body); font-weight: 600; margin-bottom: 0.3rem; }
.route p { font-size: var(--step--1); color: var(--muted); margin: 0; }

.keywords { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0; margin: 1.5rem 0 0; list-style: none; }
.keywords li { font-family: var(--font-mono); font-size: 0.78rem; border: 1px solid var(--rule); padding: 0.2rem 0.6rem; color: var(--muted); }

/* Publications */
.pubs { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.4rem; }
.pub-title { font-family: var(--font-display); font-size: var(--step-1); line-height: 1.3; margin: 0 0 0.25rem; }
.pub-title a { color: var(--ink); text-decoration: none; }
.pub-title a:hover { color: var(--accent); }
.pub-meta { font-size: var(--step--1); color: var(--muted); margin: 0; }
.pub-meta em { color: var(--ink); }
.pub-meta .me { font-weight: 600; color: var(--ink); }
.tag { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.more { margin-top: 1.5rem; font-size: var(--step--1); }

/* Timeline */
.path { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; }
.path li { display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: 1rem; }
.path .when { font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); padding-top: 0.2rem; }
.path strong { font-weight: 600; }
.path span { display: block; color: var(--muted); font-size: var(--step--1); }

/* Links grid */
.links { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem 2rem; }
.links li { display: flex; flex-direction: column; border-bottom: 1px solid var(--rule); padding-bottom: 0.6rem; }
.links .label { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.links a, .links .value { overflow-wrap: anywhere; }

/* Talk page */
.materials { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.75rem; }
.materials li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 1rem; padding: 0.9rem 1.1rem; background: var(--surface); border: 1px solid var(--rule); }
.materials .status { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); }
.button {
  display: inline-block; background: var(--accent); color: var(--paper); text-decoration: none;
  padding: 0.65rem 1.2rem; font-weight: 600; font-size: var(--step--1);
}
.button:hover { opacity: 0.9; }

.site-footer { border-top: 1px solid var(--rule); color: var(--muted); font-size: var(--step--1); }
.site-footer .wrap { padding-block: 1.5rem 2.5rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem; }

/* Shared additions */
.page-head .wrap { padding-block: 2.75rem 1.25rem; }
.page-head h1 { font-size: clamp(2rem, 4.5vw, 2.8rem); }
section h3 { font-family: var(--font-display); font-size: var(--step-1); margin: 1.75rem 0 0.75rem; }
section h3:first-of-type { margin-top: 0; }
.badge { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); border: 1px solid currentColor; padding: 0.05rem 0.4rem; margin-right: 0.4rem; white-space: nowrap; }
.pub-note { font-size: var(--step--1); color: var(--muted); margin: 0.4rem 0 0; }
.pub-actions { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-family: var(--font-mono); font-size: 0.8rem; margin: 0.4rem 0 0; }
.path p { font-size: var(--step--1); color: var(--muted); margin: 0.3rem 0 0; }
.path .when strong { display: block; color: var(--accent); font-weight: 500; }
.path a { font-weight: 600; }
.bullets { padding-left: 1.1rem; margin: 0; display: grid; gap: 0.5rem; }
.bullets li { max-width: 65ch; }
.bullets li span { color: var(--muted); font-size: var(--step--1); }

/* 3D designs */
.designs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.5rem 2rem; }
.design { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.design-img { display: block; aspect-ratio: 4 / 3; max-width: 100%; background: var(--surface); border: 1px solid var(--rule); overflow: hidden; }
.design-img img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.design-img:hover img { transform: scale(1.03); }
.design-body { display: flex; flex-direction: column; align-items: flex-start; flex: 1; }
.design-body h2 { font-size: var(--step-1); margin-bottom: 0.4rem; }
.design-body p { font-size: var(--step--1); color: var(--muted); margin: 0 0 0.5rem; }
.design-body .design-meta { font-family: var(--font-mono); font-size: 0.78rem; margin-bottom: 1rem; }
.design-body .button { margin-top: auto; }
.empty { color: var(--muted); }

/* Lab gallery: two columns, newest first; .wide spans both */
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem 1.25rem; align-items: start; }
.shot { margin: 0; position: relative; min-width: 0; }
.shot.wide { grid-column: 1 / -1; }
.shot a { display: block; }
.shot img { width: 100%; height: auto; border: 1px solid var(--rule); }
.shot figcaption { font-size: var(--step--1); color: var(--muted); padding-top: 0.45rem; }
.shot .year { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.06em; color: var(--accent); margin-right: 0.6rem; }
@media (hover: hover) and (pointer: fine) {
  .shot figcaption {
    position: absolute; left: 1px; right: 1px; bottom: 1px; padding: 3rem 1rem 0.9rem;
    background: linear-gradient(transparent, var(--overlay)); color: var(--overlay-ink);
    opacity: 0; transition: opacity 0.25s ease; pointer-events: none;
  }
  .shot figcaption .year { color: var(--overlay-ink); opacity: 0.8; }
  .shot:hover figcaption, .shot:focus-within figcaption { opacity: 1; }
}

/* Enlarged view */
.lightbox { border: 0; padding: 0; background: transparent; max-width: min(92vw, 1400px); max-height: 92vh; overflow: visible; }
.lightbox::backdrop { background: var(--backdrop); }
.lightbox img { max-width: min(92vw, 1400px); max-height: 82vh; width: auto; margin: 0 auto; }
.lightbox p { color: var(--overlay-ink); text-align: center; margin: 0.75rem auto 0; font-size: var(--step--1); }
.lightbox-close {
  position: absolute; top: -2.6rem; right: 0; background: none; border: 0; color: var(--overlay-ink);
  font-size: 2rem; line-height: 1; cursor: pointer; padding: 0.2rem 0.5rem;
}
.lightbox-close:focus-visible { outline: 2px solid var(--overlay-ink); }

@media (max-width: 640px) {
  .hero .wrap { grid-template-columns: 1fr; padding-block: 2rem 1rem; }
  .portrait { width: 8rem; grid-row: 1; }
  .route { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 2rem; }
  .path li { grid-template-columns: 1fr; gap: 0.1rem; }
  .links { grid-template-columns: 1fr; }
  .designs { grid-template-columns: 1fr; }
  .gallery { grid-template-columns: 1fr; }
  .ridge { height: 70px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
