/* ============================================================
   Two-accent system, grounded in a real classification map.
   Base near-white, yellow + blue as the only accent colors,
   structural greys sampled from the source image.
   ============================================================ */

:root {
  color-scheme: light dark;
  --base: #FCFCFC;
  --ink: #111111;
  --ink-soft: #5C5C5C;
  --yellow: #FCD83C;
  --blue: #18B4FC;
  --grey-mid: #D8D8D8;
  --grey-soft: #E4E4E4;
  --grey-line: #C9C9C9;
  /* Fixed-dark surfaces (photo overlays with a hardcoded scrim) need text
     that never flips with the theme — see .tight-tile-overlay, .person-tag. */
  --overlay-text: #FCFCFC;
  --overlay-text-soft: rgba(255, 255, 255, 0.75);

  /* Hero map edge-fade reach — how far the solid-color gradient intrudes
     from each edge before going transparent. Dark mode uses smaller values
     since the same reach reads as a heavier vignette against a dark base. */
  --hero-fade-x: 8%;
  --hero-fade-x-inner: 4%;
  --hero-fade-bottom: 3%;
  --hero-fade-top: 7%;

  /* Font variables (--font-display, --font-accent-serif, --font-body,
     --font-mono) are injected as inline <style> in base.njk, generated
     from src/_data/fonts.js — that's the one place to change a typeface.
     Don't redefine them here; main.css only ever REFERENCES var(--font-*). */

  --page-margin: 3rem;
  --max-width: 120rem;

  /* ── Type scale — fluid via clamp(min, viewport-relative, max) ──
     1rem = 10px (set by html font-size: 62.5% below).
     Min kicks in on mobile; max caps on large monitors.
     ──────────────────────────────────────────────────────────── */
  --t-label:   clamp(1.2rem, 1.0vw, 1.5rem);  /* tags, dates, mono meta  */
  --t-body:    clamp(1.5rem, 1.2vw, 1.7rem);  /* body / nav / supporting */
  --t-prose:   clamp(1.6rem, 1.4vw, 1.9rem);  /* lede, pub titles, prose */
  --t-sub:     clamp(1.9rem, 1.8vw, 2.4rem);  /* sub-headings            */
  --t-section: clamp(2.4rem, 2.6vw, 3.4rem);  /* section h2 headings     */
}

/* Dark mode — follows the OS/browser color-scheme preference by default;
   the toggle in the header can force light or dark via [data-theme] on
   <html>, overriding the system preference. Same 8 tokens, inverted;
   accents (yellow/blue) and the invariant overlay tokens above stay put. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --base: #121212;
    --ink: #F2F2F2;
    --ink-soft: #A8A8A8;
    --grey-mid: #565656;
    --grey-soft: #1D1D1D;
    --grey-line: #333333;
    --hero-fade-x: 4%;
    --hero-fade-x-inner: 2%;
    --hero-fade-bottom: 1.5%;
    --hero-fade-top: 3.5%;
  }
}

:root[data-theme="dark"] {
  --base: #121212;
  --ink: #F2F2F2;
  --ink-soft: #A8A8A8;
  --grey-mid: #565656;
  --grey-soft: #1D1D1D;
  --grey-line: #333333;
  --hero-fade-x: 4%;
  --hero-fade-x-inner: 2%;
  --hero-fade-bottom: 1.5%;
  --hero-fade-top: 3.5%;
}

* { box-sizing: border-box; }
html { font-size: 62.5%; scroll-behavior: smooth; } /* 1rem = 10px */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-kicker, .hero-name, .hero-lede, .hero-links, .hero-map img,
  .page-label, .page-title, .page-lede, .page-hero-map img { animation: none; opacity: 1; }
  .reveal { opacity: 1; transform: none; transition: none; }
}

body {
  margin: 0;
  background: var(--base);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--t-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); text-decoration: none; border-bottom: 1.5px solid var(--grey-mid); }
a:hover { border-bottom-color: var(--blue); }

p { margin: 0 0 1.1rem; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.wrap { max-width: var(--max-width); margin: 0 auto; padding: 0 var(--page-margin); }

/* ---- Fixed background: grayscale map + network (non-home pages) ---- */
.bg-network-wrap {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  transition: filter 0.1s linear;
}
.bg-network-wrap .bg-map-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.1;
  filter: grayscale(100%);
}
.bg-network-wrap .network-anim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
/* Fade all edges of the background into the page base color */
.bg-network-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to right,  var(--base) 0%, transparent 35%),
    linear-gradient(to left,   var(--base) 0%, transparent 35%),
    linear-gradient(to bottom, var(--base) 0%, transparent 15%),
    linear-gradient(to top,    var(--base) 0%, transparent 25%);
}

/* Hide map text labels from the background SVG */
.bg-network-wrap text { display: none; }

/* Remove edge gradients in dark mode */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bg-network-wrap::after { background: none; }
}
:root[data-theme="dark"] .bg-network-wrap::after { background: none; }

/* ---- Fixed footpath background (homepage only): behind content, fixed while scrolling ---- */
.bg-footpath {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  height: min(70vh, 46rem);
  width: auto;
  z-index: -1;
  pointer-events: none;
  color: var(--grey-mid);
  opacity: 1;
  transition: opacity 0.2s;
}
.bg-footpath .footpath-svg {
  display: block;
  height: 100%;
  width: auto;
}
.bg-footpath { opacity: 0.25; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bg-footpath { opacity: 0.08; }
}
:root[data-theme="dark"] .bg-footpath { opacity: 0.08; }

/* ---- Fixed streetlamp background (teaching page): behind content, fixed while scrolling ---- */
.bg-light {
  position: fixed;
  right: 0;
  bottom: 0;
  height: min(75vh, 52rem);
  width: auto;
  z-index: 0;
  pointer-events: none;
  opacity: 0.9;
}
.bg-light img {
  display: block;
  height: 100%;
  width: auto;
}
/* Constrain teaching course list so lamp is always visible beside it */
.teaching-courses .wrap { max-width: 80rem; }
[data-page="teaching"] .bg-network-wrap::after { background: none; }

/* ---- Nav ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--base);
  border-bottom: 1px solid var(--grey-line);
}
.site-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1.1rem;
  padding-bottom: 1.1rem;
}
.site-nav .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.15rem;
  border-bottom: none;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.brand-logo {
  height: 56px;
  width: auto;
  display: block;
  mix-blend-mode: multiply;
  transition: filter 0.2s;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo {
    filter: invert(1);
    mix-blend-mode: screen;
  }
}
:root[data-theme="dark"] .brand-logo {
  filter: invert(1);
  mix-blend-mode: screen;
}
.site-nav ul { display: flex; gap: 2rem; list-style: none; margin: 0; padding: 0; }
.site-nav a {
  border-bottom: none;
  font-size: 1.9rem;
  color: var(--ink-soft);
  position: relative;
}
.site-nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -5px;
  height: 2px;
  background: var(--yellow);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a:hover::after, .site-nav a[aria-current="page"]::after { transform: scaleX(1); }
.site-nav a[aria-current="page"] { color: var(--ink); }

.site-nav-right { display: flex; align-items: center; gap: 2rem; }

/* ---- Theme controls: Auto switch + light/dark switch, side by side.
   [data-theme] on <html> is set by the inline script in base.njk. ---- */
.theme-controls { display: flex; align-items: center; gap: 1.6rem; flex-shrink: 0; }

.switch { display: inline-flex; align-items: center; gap: 0.7rem; cursor: pointer; }
.switch-label { font-size: 1.3rem; color: var(--ink-soft); }

.switch-track {
  position: relative;
  display: inline-block;
  width: 3.6rem;
  height: 2rem;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--grey-mid);
  transition: background 0.2s ease;
}
.switch-track input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.switch-track input:disabled { cursor: not-allowed; }
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--base);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}
.switch-track input:checked ~ .switch-thumb { transform: translateX(1.6rem); }
.switch-track input:checked + .switch-thumb { background: var(--base); }
.switch-track:has(input:checked) { background: var(--ink-soft); }
.switch-track:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 2px; }
.switch-track:has(input:disabled) { opacity: 0.45; }

.switch-mode { gap: 0.6rem; }
.switch-icon { width: 1.6rem; height: 1.6rem; flex-shrink: 0; color: var(--ink-soft); }
.switch-mode:has(input:disabled) { opacity: 0.45; cursor: default; }

/* ---- Hero: two-column layout, map on the right ---- */
.hero {
  display: grid;
  grid-template-columns: 3fr 2fr;
  border-top: 1px solid var(--grey-line);
  border-bottom: 1px solid var(--grey-line);
  /* Override .wrap padding — hero-content handles its own left inset;
     right padding here gives the map the same edge margin as other elements. */
  padding: 0 var(--page-margin) 0 0;
}

.hero-content {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 2rem 3rem 2.5rem var(--page-margin);
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes map-reveal {
  from { opacity: 0; transform: scale(1.06); }
  to   { opacity: 1; transform: scale(1); }
}

.hero-kicker {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1.7rem;
  color: var(--ink);
  margin-bottom: 2rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  line-height: 1.5;
  animation: fade-up 0.8s cubic-bezier(0.22,1,0.36,1) both;
  animation-delay: 0.15s;
}

.dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-yellow { background: var(--yellow); }
.dot-blue   { background: var(--blue); }

.hero-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 3.5vw, 4.5rem);
  line-height: 0.95;
  letter-spacing: -0.025em;
  margin: 0 0 1.8rem;
  animation: fade-up 0.8s cubic-bezier(0.22,1,0.36,1) both;
  animation-delay: 0.1s;
}

.hero-lede {
  font-size: 1.7rem;
  line-height: 1.65;
  color: var(--ink);
  margin-bottom: 0.8rem;
  animation: fade-up 0.8s cubic-bezier(0.22,1,0.36,1) both;
  animation-delay: 0.48s;
}
.hero-kicker + .hero-lede {
  border-top: 1px solid var(--grey-line);
  padding-top: 1.8rem;
  margin-top: 0.4rem;
}
.hero-lede:last-of-type { margin-bottom: 1.5rem; }

.hero-links {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
  animation: fade-up 0.8s cubic-bezier(0.22,1,0.36,1) both;
  animation-delay: 0.65s;
}

/* Map panel */
.hero-map {
  position: relative;
  overflow: hidden;
  background: var(--grey-soft);
}
.hero-map img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  opacity: 0.6;
  display: block;
  animation: map-reveal 1.4s ease both;
  animation-delay: 0.1s;
}
/* Fade: left edge softly bleeds into text column; edges fade into page base */
.hero-map::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(to right,  var(--base) 0%, transparent var(--hero-fade-x)),
    linear-gradient(to left,   var(--base) 0%, transparent var(--hero-fade-x-inner)),
    linear-gradient(to bottom, var(--base) 0%, transparent var(--hero-fade-bottom)),
    linear-gradient(to top,    var(--base) 0%, transparent var(--hero-fade-top));
}

/* Network SVG — sits above the gradient overlay in hero panels.
   Street lines use currentColor so they follow the theme; set color here. */
.network-anim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  color: var(--ink);
}
/* Gradient overlays are z-index 2; lift dots above them in both hero contexts */
.hero-map .network-anim,
.page-hero-map .network-anim { z-index: 3; }

/* Icon links — uniform circle, same size for CV/GitHub/LinkedIn/Scholar */
.icon-link {
  width: 5rem; height: 5rem;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--grey-mid);
  border-radius: 50%;
  color: var(--ink-soft);
  border-bottom: none !important;
  transition: border-color 0.18s ease, color 0.18s ease;
}
.icon-link:hover { border-color: var(--ink); color: var(--ink); }
.icon-link svg { width: 2.2rem; height: 2.2rem; fill: currentColor; }

/* ---- Inner page hero: compact header with optional image panel ---- */
.page-hero--full { grid-template-columns: 1fr; }
.page-hero {
  display: grid;
  grid-template-columns: 3fr 2fr;
  border-top: 1px solid var(--grey-line);
  border-bottom: 1px solid var(--grey-line);
  max-width: var(--max-width);
  margin: 0 auto;
}
.page-hero-content {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 2rem 3rem 2.5rem var(--page-margin);
}
.page-label {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin-bottom: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: fade-up 0.8s cubic-bezier(0.22,1,0.36,1) both;
  animation-delay: 0.1s;
}
.page-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 4vw, 4rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin-bottom: 1.1rem;
  animation: fade-up 0.8s cubic-bezier(0.22,1,0.36,1) both;
  animation-delay: 0.25s;
}
.page-lede {
  font-size: var(--t-prose);
  line-height: 1.65;
  color: var(--ink-soft);
  animation: fade-up 0.8s cubic-bezier(0.22,1,0.36,1) both;
  animation-delay: 0.4s;
}
.page-hero-map {
  position: relative;
  overflow: hidden;
  background: transparent;
}
.page-hero-map img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  animation: map-reveal 1.4s ease both;
  animation-delay: 0.1s;
}
.page-hero-map::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(to right, var(--base) 0%, transparent 35%);
}

/* ---- Section ---- */
.section { padding: 2.5rem 0; }
.section.alt { background: var(--grey-soft); }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.section-label {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.section-head h2 {
  font-family: var(--font-accent-serif);
  font-weight: 600;
  font-size: var(--t-section);
  margin: 0.2rem 0 0;
  letter-spacing: -0.005em;
}

.view-all {
  font-family: var(--font-mono);
  font-size: 1.9rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.25em;
  border-bottom: none;
}

/* ---- Project grid: flat tiles, two-accent system, no card shadows ---- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.4rem;
  background: transparent;
  border: none;
}

.tile {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: 1.6rem;
  padding: 0;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: inherit;
  border: none;
  box-shadow:
    0 1px 2px rgba(0,0,0,0.05),
    0 4px 14px rgba(0,0,0,0.09),
    0 16px 40px rgba(0,0,0,0.10);
  transition: box-shadow 0.28s ease, transform 0.28s ease;
}
.tile:hover {
  box-shadow:
    0 2px 4px rgba(0,0,0,0.07),
    0 8px 24px rgba(0,0,0,0.13),
    0 24px 56px rgba(0,0,0,0.13);
  transform: translateY(-3px);
}
/* gloss sheen lives on the text block only, never over the image */
.tile-text {
  position: relative;
}
.tile-text::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(255,255,255,0.55) 0%,
    rgba(255,255,255,0) 55%);
  pointer-events: none;
  z-index: 1;
}
/* inner top-edge highlight = glass rim */
.tile::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    inset 0 1.5px 0 rgba(255,255,255,1),
    inset 0 -1px 0 rgba(0,0,0,0.04),
    inset 1px 0 0 rgba(255,255,255,0.5),
    inset -1px 0 0 rgba(255,255,255,0.5);
  pointer-events: none;
  z-index: 6;
}

.tile-art {
  width: 100%;
  aspect-ratio: 16/10;
  overflow: hidden;
  margin-bottom: 0;
  background: #e0e0e0;
}
.tile-art img { width: 100%; height: 100%; object-fit: cover; display: block; transition: filter 0.55s ease, transform 0.55s ease; }
.tile:hover .tile-art img { filter: grayscale(1); transform: scale(1.04); }

/* text area below image */
.tile-text {
  padding: 1.4rem 1.4rem 1.6rem;
}

.tile-status {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  text-transform: capitalize;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.tile-status .dot { width: 0.4rem; height: 0.4rem; border-radius: 50%; display: inline-block; }
.tile-status.is-active .dot { background: var(--blue); }
.tile-status.is-early .dot { background: var(--yellow); }
.tile-status.is-completed .dot { background: var(--grey-mid); }
.tile-status.is-foundational .dot { background: var(--ink); }

.tile h3 { font-family: var(--font-display); font-weight: 700; font-size: 1.9rem; color: #111; margin: 0 0 0.5rem; letter-spacing: -0.01em; line-height: 1.2; }
.tile p { font-size: 1.5rem; color: #555; margin: 0; line-height: 1.55; }

/* dark mode card */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tile {
    background: var(--grey-soft);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4), 0 4px 20px rgba(0,0,0,0.4);
  }
  :root:not([data-theme="light"]) .tile:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.5), 0 12px 36px rgba(0,0,0,0.5);
  }
  :root:not([data-theme="light"]) .tile::after { box-shadow: none; }
  :root:not([data-theme="light"]) .tile-text::before { display: none; }
  :root:not([data-theme="light"]) .tile h3 { color: var(--ink); }
  :root:not([data-theme="light"]) .tile p { color: var(--ink-soft); }
}
:root[data-theme="dark"] .tile {
  background: var(--grey-soft);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4), 0 4px 20px rgba(0,0,0,0.4);
}
:root[data-theme="dark"] .tile:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.5), 0 12px 36px rgba(0,0,0,0.5);
}
:root[data-theme="dark"] .tile::after { box-shadow: none; }
:root[data-theme="dark"] .tile-text::before { display: none; }
:root[data-theme="dark"] .tile h3 { color: var(--ink); }
:root[data-theme="dark"] .tile p { color: var(--ink-soft); }

/* full-width quote tile */
.tile.quote-tile {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 2rem;
  align-items: center;
}
.tile.quote-tile blockquote {
  font-family: var(--font-display);
  font-weight: 600;
  font-style: normal;
  font-size: 1.3rem;
  line-height: 1.35;
  margin: 0;
  border-left: 4px solid var(--yellow);
  padding-left: 1.2rem;
}

/* ---- Portfolio-style page intro ---- */
.portfolio-intro {
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  padding: 3rem 0 2.4rem;
  border-bottom: 1px solid var(--grey-line);
}
.portfolio-intro h1 {
  font-family: var(--font-accent-serif);
  font-weight: 600;
  font-size: clamp(3rem, 5vw, 5rem);
  line-height: 1.0;
  letter-spacing: -0.01em;
  margin: 0;
}
.portfolio-intro .lede-block { font-size: var(--t-prose); line-height: 1.7; color: var(--ink-soft); max-width: 68ch; }

/* ---- Filter bar ---- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 1.6rem;
  padding: 1.2rem 0 1.4rem;
  border-bottom: 1px solid var(--grey-mid);
  flex-wrap: wrap;
}
.filter-bar .filter-by-label {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  white-space: nowrap;
  flex-shrink: 0;
}
.filter-controls {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
  flex: 1;
}
.filter-divider {
  width: 1px;
  height: 1.4rem;
  background: var(--grey-mid);
  flex-shrink: 0;
}
.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

/* status legend removed — status is communicated via inline label in each card */

/* ---- Tight logo/photo reveal grid (Tres Mares portfolio + team pattern) ---- */
.tight-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--grey-line);
  border-top: 1px solid var(--grey-line);
}
.tight-tile {
  position: relative;
  background: var(--base);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  opacity: 0;
  transition: opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease, box-shadow 0.2s ease;
  border: none;
  border-top: 3px solid var(--grey-line);
  padding: 0;
  margin: 0;
  width: 100%;
  font: inherit;
  text-align: inherit;
  cursor: pointer;
  color: inherit;
}
.tight-tile:hover { background: var(--base); }
.tight-tile[data-status="active"]      { border-top-color: var(--blue); }
.tight-tile[data-status="early stage"] { border-top-color: var(--yellow); }
.tight-tile[data-status="completed"]   { border-top-color: var(--grey-mid); }
.tight-tile[data-status="foundational"]{ border-top-color: var(--ink); }
.tight-tile.is-visible { opacity: 1; }
.tight-tile.is-hidden-by-filter { display: none; }

/* Image sits on top, fixed height, always visible */
.tight-tile-photo {
  position: relative;
  width: 100%;
  height: 16rem;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--grey-soft);
}
.tight-tile-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: grayscale(1);
  transition: filter 0.55s ease, transform 0.55s ease;
  transform: scale(1.04);
}
.tight-tile:hover .tight-tile-photo img {
  filter: grayscale(0);
  transform: scale(1);
}

/* Text block always below the image */
.tight-tile-rest {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 1.6rem 1.6rem 2rem;
}
.tight-tile-rest .rest-status {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  text-transform: capitalize;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.tight-tile-rest .rest-status .dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.tight-tile-rest .rest-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.8rem;
  color: var(--ink);
  text-align: left;
  letter-spacing: -0.01em;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tight-tile-rest .rest-blurb {
  font-size: 1.45rem;
  color: var(--ink-soft);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-align: left;
}

/* Overlay: only used on tiles without images */
.tight-tile-overlay { display: none; }
@media (max-width: 900px) { .tight-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px) { .tight-grid { grid-template-columns: 1fr; } }

/* ---- Briefs (early-stage small list) ---- */
.briefs-list { list-style: none; margin: 0; padding: 0; }
.brief-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1rem 0;
  border-bottom: 1px solid var(--grey-mid);
}
.brief-item h4 { font-family: var(--font-display); font-weight: 700; font-size: var(--t-prose); margin: 0; }
.brief-item h4 a { border-bottom: none; color: var(--ink); }
.brief-item h4 a:hover { color: var(--blue); }
.brief-item .brief-tag { font-family: var(--font-mono); font-size: var(--t-label); color: var(--ink-soft); text-transform: uppercase; }

/* ---- Footer ---- */
.site-footer {
  padding: 1.6rem var(--page-margin);
  font-family: var(--font-mono);
  font-size: 1.4rem;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  border-top: 1px solid var(--grey-mid);
}
.site-footer a { color: var(--ink-soft); border-bottom: none; }
.site-footer a:hover { color: var(--blue); }

/* ---- Page header (non-home) ---- */
.page-header { padding-top: 3rem; padding-bottom: 2rem; }
.page-header .eyebrow {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}
.page-header h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 5vw, 3.2rem);
  margin: 0.3rem 0 0;
  letter-spacing: -0.015em;
}
.page-header .lede { max-width: 38rem; color: var(--ink-soft); margin-top: 0.8rem; }

.accent-serif {
  font-family: var(--font-accent-serif) !important;
  font-weight: 600 !important;
}

/* ---- Project detail ---- */
.project-hero .page-hero-map { background: var(--grey-soft); }

/* Metadata fields (Deployed by, Method, Status, …) */
.project-fields {
  margin: 1.4rem 0 1.6rem;
  display: flex;
  flex-direction: column;
  animation: fade-up 0.8s cubic-bezier(0.22,1,0.36,1) both;
  animation-delay: 0.55s;
}
.project-field-row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--grey-line);
}
.project-field-row:first-child { border-top: 1px solid var(--grey-line); }
.project-field-row dt {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  width: 9rem;
  flex-shrink: 0;
}
.project-field-row dd { margin: 0; font-size: var(--t-body); color: var(--ink); }

/* Lede text on project hero — override shared .page-lede */
.project-hero .page-lede { font-size: var(--t-body); line-height: 1.65; }

/* Code / paper links inside the hero */
.project-hero-links {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  animation: fade-up 0.8s cubic-bezier(0.22,1,0.36,1) both;
  animation-delay: 0.7s;
}
.proj-link {
  font-family: var(--font-display);
  font-size: var(--t-body);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink-soft);
  border: 2px solid var(--grey-mid);
  border-radius: 0.5rem;
  padding: 0.6rem 1.4rem;
  transition: border-color 0.15s, color 0.15s;
}
.proj-link:hover { border-color: var(--blue); color: var(--blue); }
.proj-link svg { width: 1.6rem; height: 1.6rem; }

/* Project body text */
.project-prose { font-size: var(--t-body); line-height: 1.85; }
.project-prose h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--t-sub);
  margin: 2.5rem 0 0.7rem;
}
.project-prose p { margin: 0 0 1.3rem; }

/* Spin-off projects section */
.project-spinoffs { margin-top: 4rem; padding-top: 3rem; border-top: 1px solid var(--grey-line); }
.project-spinoffs-label {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin: 0 0 2rem;
}
.spinoff-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0; }
.spinoff-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2rem;
  padding: 1.6rem 0;
  border-bottom: 1px solid var(--grey-line);
}
.spinoff-item:first-child { border-top: 1px solid var(--grey-line); }
.spinoff-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--t-sub);
  margin: 0 0 0.4rem;
}
.spinoff-blurb { font-size: var(--t-body); color: var(--ink-soft); margin: 0; }
.spinoff-link {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  color: var(--ink-soft);
  white-space: nowrap;
  border-bottom: none;
}
.spinoff-link:hover { color: var(--blue); }

/* Team strip — compact grid for project pages */
.team-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
  gap: 1.5rem 1rem;
}
.team-strip-member { text-align: left; }
.team-strip-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--grey-soft);
  overflow: hidden;
  margin-bottom: 0.6rem;
}
.team-strip-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.team-strip-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.88rem;
  margin: 0 0 0.1rem;
}
.team-strip-role {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin: 0;
}
.team-strip-member.reveal { transition-delay: calc(var(--i, 0) * 0.07s); }

.press-strip { background: var(--grey-soft); padding: 3rem 0; }
.press-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: 2rem; }
.press-item { border-bottom: none; display: flex; flex-direction: column; gap: 0.4rem; }
.press-outlet { font-family: var(--font-display); font-weight: 700; font-size: var(--t-body); display: block; color: var(--ink); }
.press-headline { font-size: var(--t-label); color: var(--ink-soft); line-height: 1.5; }
.press-item:hover .press-outlet { color: var(--blue); }

/* ---- Generic prose pages ---- */
.page-body { padding-top: 2rem; padding-bottom: 4rem; }
.page-body h3 { font-family: var(--font-display); font-weight: 700; font-size: var(--t-prose); margin-top: 2rem; }

/* ---- Teaching course list ---- */
.course-list { list-style: none; margin: 0; padding: 0; }
.course-row {
  display: grid;
  grid-template-columns: 16rem 1fr;
  gap: 3rem;
  padding: 3rem 0;
  border-bottom: 1px solid var(--grey-line);
  align-items: start;
}
.course-row:first-child { border-top: 1px solid var(--grey-line); }
.course-row-meta {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.4rem;
}
.course-code {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.05em;
}
.course-term,
.course-level {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  color: var(--ink-soft);
  letter-spacing: 0.03em;
}
.course-row-body { display: flex; flex-direction: column; gap: 1rem; }
.course-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--t-sub);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink);
}
.course-desc {
  font-size: var(--t-body);
  line-height: 1.65;
  color: var(--ink-soft);
  margin: 0;
}
.course-link {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  font-weight: 600;
  color: var(--ink);
  border-bottom: none;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.25em;
}
.course-link:hover { color: var(--blue); }
@media (max-width: 700px) {
  .course-row { grid-template-columns: 1fr; gap: 1rem; }
}

.pub-list { margin: 0; padding: 0; }
.pub-year {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin: 3rem 0 0.4rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--grey-line);
}
.pub-year:first-child { margin-top: 0; }
.pub-item { padding: 1.6rem 0; border-bottom: 1px solid var(--grey-line); }
.pub-item:last-child { border-bottom: none; }
.pub-citation {
  font-size: var(--t-prose);
  line-height: 1.7;
  color: var(--ink);
  margin: 0;
}
.pub-title-link {
  color: var(--ink);
  border-bottom: 1.5px solid var(--grey-mid);
}
.pub-title-link:hover { border-bottom-color: var(--blue); color: var(--blue); }
.pub-citation em { font-style: italic; }
.pub-status {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  color: var(--ink-soft);
  text-transform: capitalize;
}
.pub-link {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  color: var(--blue);
  border-bottom: none;
  font-weight: 600;
}
.pub-link:hover { color: var(--ink); }

/* ---- Contact ---- */
.contact-body { max-width: 72rem; display: flex; flex-direction: column; gap: 4rem; }
.contact-email-block { display: flex; align-items: center; }
.contact-email-link { font-size: var(--t-label); font-family: var(--font-mono); color: var(--ink); display: inline-flex; align-items: center; gap: 0.5rem; }
.contact-email-link:hover { color: var(--blue); }
.contact-email-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.contact-phd { border-top: 1.5px solid var(--grey-mid); padding-top: 2.4rem; }
.contact-phd h3 { margin-top: 0; }
.contact-phd p { color: var(--ink-soft); line-height: 1.75; margin-bottom: 1.2rem; max-width: 66rem; }
.contact-phd-cta {
  display: inline-block; margin-top: 1.2rem;
  font-family: var(--font-mono); font-size: var(--t-label); text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--ink); color: var(--base); border: none; border-bottom: none;
  border-radius: 0.5rem; padding: 1rem 1.8rem; cursor: pointer;
}
.contact-phd-cta:hover { background: var(--yellow); color: var(--ink); }

/* ---- Team ---- */
/* ---- Grounding image + caption (Tres Mares "Cima Tresmares" pattern) ---- */
.grounding-image {
  width: 100%;
  aspect-ratio: 16/7;
  overflow: hidden;
  margin-bottom: 0.8rem;
  background: var(--grey-soft);
}
.grounding-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grounding-caption {
  font-family: var(--font-accent-serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink-soft);
  max-width: 42rem;
}
.grounding-caption strong { color: var(--ink); font-style: normal; font-weight: 600; }

/* ---- Pull statement (oversized restated line as section divider) ---- */
.pull-statement {
  font-family: var(--font-accent-serif);
  font-weight: 600;
  font-size: clamp(1.6rem, 3.4vw, 2.6rem);
  line-height: 1.25;
  max-width: 46rem;
  margin: 0;
}
.pull-statement .hl-yellow { background: var(--yellow); padding: 0 0.15em; }
.pull-statement .hl-blue { color: var(--blue); }

/* ---- Stat strip (count-up numbers, Tres Mares "in figures" pattern) ---- */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  background: var(--grey-line);
  border: 1px solid var(--grey-line);
  margin-bottom: 3rem;
}
.stat-cell {
  background: var(--base);
  padding: 2.2rem 1.2rem;
  text-align: center;
}
.stat-number {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.8rem, 6vw, 4.2rem);
  letter-spacing: -0.02em;
  line-height: 1;
}
.stat-number .accent-yellow { color: var(--yellow); -webkit-text-stroke: 1.5px var(--ink); }
.stat-number .accent-blue { color: var(--blue); }
.stat-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin-top: 0.5rem;
}

/* ---- Scroll-reveal (sections fade/slide in as Tres Mares does) ---- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.is-visible { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ---- Team photo grid with hover-reveal bio overlay ---- */
.people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 260px));
  gap: 1px;
  background: var(--grey-line);
  border: 1px solid var(--grey-line);
}
.person-card {
  position: relative;
  background: var(--base);
  aspect-ratio: 3/4;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.person-card.is-visible { opacity: 1; transform: translateY(0); }
.person-photo {
  position: absolute;
  inset: 0;
  background: var(--grey-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.35s ease, transform 0.35s ease;
}
.person-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.person-card:hover .person-photo { filter: grayscale(1); transform: scale(1.04); }

.person-tag {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 1rem 1.1rem;
  background: linear-gradient(to top, rgba(17,17,17,0.78) 0%, rgba(17,17,17,0) 100%);
  color: var(--overlay-text);
  transition: opacity 0.3s ease;
}
.person-card:hover .person-tag { opacity: 0; }
.person-tag h4 { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; margin: 0; }
.person-tag .role { font-family: var(--font-mono); font-size: 0.72rem; text-transform: uppercase; color: var(--overlay-text-soft); }

.person-bio {
  position: absolute;
  inset: 0;
  background: var(--ink);
  color: var(--base);
  padding: 1.3rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.6rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.person-card:hover .person-bio { opacity: 1; transform: translateY(0); }
.person-bio h4 { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; margin: 0; color: var(--base); }
.person-bio .role { font-family: var(--font-mono); font-size: 0.7rem; text-transform: uppercase; color: var(--yellow); }
.person-bio p, .person-bio-text p { font-size: 0.85rem; line-height: 1.5; color: var(--grey-mid); margin: 0; }
.person-bio a { color: var(--blue); border-bottom: none; }

@media (hover: none) {
  /* touch devices: tap toggles via .is-active class set by JS */
  .person-card.is-active .person-tag { opacity: 0; }
  .person-card.is-active .person-bio { opacity: 1; transform: translateY(0); }
  .person-card.is-active .person-photo { filter: grayscale(1); }
}
.team-list { display: flex; flex-direction: column; gap: 0; }
.team-entry {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
  padding: 1.8rem 0;
  border-bottom: 1px solid var(--grey-mid);
}
.team-entry:first-child { padding-top: 0; }
.team-entry h4 { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; margin: 0 0 0.2rem; }
.team-entry .role { font-family: var(--font-mono); font-size: 0.78rem; text-transform: uppercase; color: var(--ink-soft); letter-spacing: 0.02em; }
.team-fields { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.92rem; }
.team-fields .field-row { display: flex; gap: 0.5rem; }
.team-fields .field-label { font-family: var(--font-mono); font-size: 0.75rem; text-transform: uppercase; color: var(--ink-soft); min-width: 7rem; }
.team-fields .field-value a { color: var(--ink); }
.team-fields .field-value a:hover { color: var(--blue); }
@media (max-width: 700px) {
  .team-entry { grid-template-columns: 1fr; gap: 0.6rem; }
}

/* Tile stagger for scroll-reveal */
.tile.reveal { opacity: 1; transform: none; transition-delay: calc(var(--i, 0) * 0.08s); }

@media (max-width: 960px) {
  .tile-grid { grid-template-columns: repeat(2, 1fr); }
  .tile.quote-tile { grid-template-columns: 1fr; grid-column: 1 / -1; }
}
/* Nav scales down before it wraps */
@media (max-width: 1100px) {
  .site-nav .brand { font-size: 1.85rem; }
  .site-nav a { font-size: 1.6rem; }
}
@media (max-width: 860px) {
  .site-nav .brand { font-size: 1.7rem; }
  .site-nav a { font-size: 1.45rem; }
  .site-nav ul { gap: 1.2rem; flex-wrap: wrap; }
}
@media (max-width: 700px) {
  .site-nav { flex-wrap: wrap; gap: 0.8rem; }
  .site-nav .brand { font-size: 1.6rem; }
  .site-nav a { font-size: 1.35rem; }
  /* Scale down type for tablet/mobile */
  :root {
    --t-label:   1.25rem;
    --t-body:    1.65rem;
    --t-prose:   1.8rem;
    --t-sub:     2.1rem;
    --t-section: 2.6rem;
  }
  body { font-size: 1.65rem; }
  /* Home hero stacks on mobile: map on top, text below — full-bleed again
     since the desktop right inset doesn't apply to a stacked single column. */
  .hero { grid-template-columns: 1fr; padding: 0; }
  .hero-map { min-height: 55vw; order: -1; }
  .hero-map::before {
    background:
      linear-gradient(to right,  var(--base) 0%, transparent 20%),
      linear-gradient(to left,   var(--base) 0%, transparent 20%),
      linear-gradient(to bottom, var(--base) 0%, transparent 30%),
      linear-gradient(to top,    var(--base) 0%, transparent 40%);
  }
  .hero-content { padding: 2.5rem var(--page-margin); }
  .hero-kicker { font-size: 1.65rem; }
  .hero-lede { font-size: 1.65rem; }
  /* Inner page hero stacks the same way */
  .page-hero { grid-template-columns: 1fr; }
  .page-hero-map { min-height: 55vw; order: -1; }
  .page-hero-map::before { background: linear-gradient(to bottom, transparent 40%, var(--base) 85%); }
  .page-hero-content { padding: 2.5rem var(--page-margin); }
  .tile-grid { grid-template-columns: 1fr; }
  .tight-grid { grid-template-columns: 1fr; }
  .portfolio-intro { grid-template-columns: 1fr; gap: 1.5rem; }
}
@media (max-width: 480px) {
  :root {
    --page-margin: 1.2rem;
    --t-label:   1.1rem;
    --t-body:    1.5rem;
    --t-prose:   1.65rem;
    --t-sub:     1.9rem;
    --t-section: 2.2rem;
  }
  body { font-size: 1.5rem; }
  .hero-name { font-size: 2.6rem; }
  .page-title { font-size: 2rem; }
  .site-nav a { font-size: 1.25rem; }
  .hero-kicker { font-size: 1.5rem; }
  .hero-lede { font-size: 1.5rem; }
}

/* ---- Wide detail panel (matches real Tres Mares portfolio overlay) ---- */
.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17,17,17,0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 110;
}
.panel-backdrop.is-open { opacity: 1; pointer-events: auto; }

.side-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(88vw, 58rem);
  background: var(--grey-soft);
  z-index: 111;
  transform: translateX(100%);
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: hidden;
  box-shadow: -8px 0 40px rgba(0,0,0,0.14);
  display: grid;
  grid-template-columns: 2fr 3fr;
}
.side-panel.is-open { transform: translateX(0); }

.side-panel-close {
  position: absolute;
  top: 1.4rem; right: 1.4rem;
  width: 2.4rem; height: 2.4rem;
  border: 1.5px solid var(--grey-mid);
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 2;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--ink);
}
.side-panel-close:hover { border-color: var(--ink); }

.side-panel-image {
  position: relative;
  overflow: hidden;
  background: var(--grey-mid);
}
.side-panel-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.side-panel-body {
  padding: 4rem 3.5rem 4rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.side-panel-body h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 2rem;
  color: var(--ink);
}

/* Field table: LABEL (bold uppercase left) / VALUE (right) */
.side-panel-fields { border-top: 1px solid var(--grey-line); margin-bottom: 3rem; }
.side-panel-fields .field-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1rem 0;
  border-bottom: 1px solid var(--grey-line);
}
.side-panel-fields .field-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--t-label);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink);
}
.side-panel-fields .field-value {
  font-family: var(--font-body);
  font-size: var(--t-body);
  color: var(--ink);
  text-align: right;
}

.side-panel-body p.side-panel-desc {
  font-size: var(--t-prose);
  line-height: 1.65;
  color: var(--ink);
  margin: 0 0 auto;
  padding-bottom: 3rem;
}

/* Code / Paper links */
.side-panel-links {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}
.side-panel-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-display);
  font-size: var(--t-label);
  font-weight: 600;
  color: var(--ink-soft);
  border: 2px solid var(--grey-mid);
  border-radius: 0.5rem;
  padding: 0.7rem 1.3rem;
  text-decoration: none;
  transition: border-color 0.18s, color 0.18s;
}
.side-panel-links a svg { width: 1.4rem; height: 1.4rem; flex-shrink: 0; }
.side-panel-links a:hover { border-color: var(--ink); color: var(--ink); }

/* "View full page" — primary CTA */
.side-panel-full-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-display);
  font-size: var(--t-body);
  font-weight: 700;
  color: var(--ink);
  border: none;
  border-top: 1px solid var(--grey-line);
  padding-top: 1.4rem;
  text-decoration: none;
}
.side-panel-full-link::after { content: '→'; font-weight: 400; }
.side-panel-full-link:hover { color: var(--blue); }

body.panel-locked { overflow: hidden; }

@media (max-width: 700px) {
  .side-panel { width: 100vw; grid-template-columns: 1fr; grid-template-rows: 14rem 1fr; }
  .side-panel-body { padding: 3rem 1.8rem 3rem; }
  .side-panel-body h2 { font-size: clamp(1.4rem, 6vw, 2rem); margin-bottom: 1.5rem; }
}

/* ---- Tag filter buttons ---- */
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 1.2rem 0 1.6rem;
}
.tag-btn {
  font-family: var(--font-body);
  font-size: var(--t-label);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  background: var(--base);
  border: 2px solid var(--grey-mid);
  border-radius: 0.5rem;
  color: var(--ink);
  padding: 0.55rem 1.2rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.tag-btn:hover { border-color: var(--ink); color: var(--ink); }
.tag-btn.is-selected { background: rgba(122,140,53,0.15); border-color: rgba(122,140,53,0.6); color: #4a5520; }
.tag-btn.is-selected:hover { background: rgba(122,140,53,0.22); border-color: rgba(122,140,53,0.8); color: #4a5520; }

/* Status pill selected states use accent fills but keep identical border-width to topic pills */
.status-btn-active { border-color: var(--blue); }
.status-btn-active:hover { border-color: var(--blue); color: var(--blue); }
.status-btn-active.is-selected { background: var(--blue); border-color: var(--blue); color: var(--base); }
.status-btn-active.is-selected:hover { background: var(--blue); border-color: var(--blue); color: var(--base); }

.status-btn-early { border-color: var(--yellow); }
.status-btn-early:hover { border-color: var(--yellow); color: var(--ink); }
.status-btn-early.is-selected { background: var(--yellow); border-color: var(--yellow); color: var(--ink); }
.status-btn-early.is-selected:hover { background: var(--yellow); border-color: var(--yellow); color: var(--ink); }

.status-btn-completed { border-color: var(--grey-mid); }
.status-btn-completed:hover { border-color: var(--grey-mid); color: var(--ink-soft); }
.status-btn-completed.is-selected { background: var(--grey-mid); border-color: var(--grey-mid); color: var(--ink); }
.status-btn-completed.is-selected:hover { background: var(--grey-mid); border-color: var(--grey-mid); color: var(--ink); }

/* Small inline dot inside status filter pills */
.filter-dot {
  width: 0.5rem; height: 0.5rem; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
  background: var(--grey-mid);
  vertical-align: middle; margin-right: 0.3rem;
}

/* Pagination count */
.pagination-wrap { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; padding: 0 0 0.5rem; }
.pagination-count { font-family: var(--font-mono); font-size: var(--t-label); color: var(--ink-soft); }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  padding: 2.5rem 0;
}
.pagination button {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.4rem;
  background: var(--base);
  border: 2px solid var(--grey-mid);
  border-radius: 0.5rem;
  width: 3.4rem; height: 3.4rem;
  cursor: pointer;
  color: var(--ink-soft);
}
.pagination button.is-current { color: var(--ink); border-color: var(--ink); }
.pagination button:hover:not(.is-current) { border-color: var(--blue); color: var(--blue); }
.pagination button[disabled] { opacity: 0.35; cursor: default; }
.pagination button[disabled]:hover { border-color: var(--grey-mid); color: var(--ink-soft); }
