/* CSS styles for PolaRiS - Light Mode Premium Theme */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@300;400;500;600;700&family=Fira+Code:wght@400;500;600&display=swap');

:root {
  /* Cornell-anchored palette: carnelian primary, vibrant rainbow accents
     (matches the poster's Cornell-red-plus-rainbow theme). */
  --carnelian: #b31b1b;
  --gold: #d4940a;
  --vivid-orange: #e8590c;
  --hyper-magenta: #c2255c;
  --neon-violet: #7c3aed;
  --cool-horizon: #3b82f6;
  --blue-energy: #2563eb;
  /* 4th accent for the OOD section — the three terms own red/blue/violet,
     and every remaining palette hue collides with one of them. */
  --detect-green: #2f9e44;

  /* Light mode backgrounds */
  --bg-deep: #fafafa;
  --bg-surface: #ffffff;
  --bg-elevated: #f5f5f5;
  --bg-card: rgba(255, 255, 255, 0.95);

  /* Text hierarchy */
  --text-primary: #1a1a1a;
  --text-secondary: #4a4a4a;
  --text-muted: #7a7a7a;

  /* Refined borders */
  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-light: rgba(0, 0, 0, 0.1);

  /* Elegant gradients */
  --gradient-warm: linear-gradient(135deg, var(--carnelian) 0%, var(--vivid-orange) 100%);
  --gradient-cool: linear-gradient(135deg, var(--cool-horizon) 0%, var(--neon-violet) 100%);
  --gradient-full: linear-gradient(135deg, var(--carnelian) 0%, var(--gold) 30%, var(--neon-violet) 65%, var(--blue-energy) 100%);

  /* Light mode shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 8px 40px rgba(179, 27, 27, 0.12);

  /* Type scale — every text element maps to one of these roles. */
  --fs-hero: clamp(32px, 7vw, 76px);             /* page title */
  --fs-section-title: clamp(27px, 4.2vw, 38px);  /* .tagline section headers */
  --fs-heading: clamp(23px, 3.4vw, 32px);        /* card headings, def index */
  --fs-title: clamp(19px, 2.6vw, 24px);          /* card/item titles, sub-hero */
  --fs-body-lg: clamp(17px, 2vw, 19px);          /* leads, abstract, card prose */
  --fs-body: clamp(16px, 1.7vw, 18px);           /* base body text */
  --fs-caption: 15.5px;                          /* figure captions */
  --fs-ui: 15px;                                 /* buttons, links, small headings */
  --fs-meta: 14px;                               /* notes, eyebrows, mono badges */
  --fs-mono-sm: 12.5px;                          /* pills, counters, tiny labels */
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg-deep);
  background-image:
    radial-gradient(ellipse 120% 60% at 50% -20%, rgba(179, 27, 27, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse 80% 50% at 100% 50%, rgba(124, 58, 237, 0.03) 0%, transparent 50%);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-primary);
  padding: clamp(24px, 4vw, 48px) clamp(18px, 3vw, 28px);
  position: relative;
  min-height: 100vh;
  line-height: 1.65;
  font-size: var(--fs-body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

/* Clean modern headings */
h1, h2, h3, h4, h5, h6, .section-heading {
  font-family: 'Space Grotesk', -apple-system, sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.hero-text {
  font-family: 'Space Grotesk', -apple-system, sans-serif;
  font-weight: 700;
  letter-spacing: -0.03em;
}

/* Main Content */
.main-content {
  max-width: 1060px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* Hero Section - Elegant */
.hero-flow {
  position: relative;
  overflow: hidden;
  padding: clamp(40px, 6vw, 64px) clamp(24px, 4.5vw, 48px) clamp(32px, 4.5vw, 48px);
  border-radius: 28px;
  margin-bottom: 40px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
}

/* Soft flowing gradient orbs */
.hero-flow::before {
  content: "";
  position: absolute;
  width: 600px;
  height: 600px;
  top: -250px;
  left: -150px;
  background: radial-gradient(circle, rgba(179, 27, 27, 0.12) 0%, rgba(179, 27, 27, 0) 70%);
  animation: orbFlow1 25s ease-in-out infinite;
  z-index: 0;
  pointer-events: none;
}

.hero-flow::after {
  content: "";
  position: absolute;
  width: 500px;
  height: 500px;
  bottom: -200px;
  right: -100px;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.08) 0%, rgba(124, 58, 237, 0) 70%);
  animation: orbFlow2 30s ease-in-out infinite;
  z-index: 0;
  pointer-events: none;
}

.hero-flow > * {
  position: relative;
  z-index: 1;
}

/* Third orb */
.hero-flow .hero-orb {
  position: absolute;
  width: 450px;
  height: 450px;
  top: 40%;
  right: 10%;
  transform: translateY(-50%);
  background: radial-gradient(circle, rgba(37, 99, 235, 0.06) 0%, rgba(37, 99, 235, 0) 70%);
  animation: orbFlow3 28s ease-in-out infinite;
  z-index: 0;
  pointer-events: none;
}

@keyframes orbFlow1 {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(80px, 40px); }
  50% { transform: translate(120px, -20px); }
  75% { transform: translate(40px, 60px); }
}

@keyframes orbFlow2 {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-60px, -50px); }
  50% { transform: translate(-100px, 30px); }
  75% { transform: translate(-30px, -40px); }
}

@keyframes orbFlow3 {
  0%, 100% { transform: translateY(-50%) translate(0, 0); }
  33% { transform: translateY(-50%) translate(-50px, 70px); }
  66% { transform: translateY(-50%) translate(40px, -50px); }
}

.hero-text {
  font-size: var(--fs-hero);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 20px;
  text-align: center;
  color: var(--text-primary);
}

.sub-hero-text {
  font-family: 'Space Grotesk', -apple-system, sans-serif;
  font-size: var(--fs-title);
  font-weight: 400;
  font-style: normal;
  margin-bottom: 36px;
  line-height: 1.5;
  text-align: center;
  color: var(--text-secondary);
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

.hero-pill-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 36px;
}

.hero-pill {
  font-family: 'Fira Code', monospace;
  font-size: var(--fs-mono-sm);
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 100px;
  background: rgba(179, 27, 27, 0.1);
  border: 1px solid rgba(179, 27, 27, 0.25);
  color: var(--carnelian);
  transition: all 0.25s ease;
  animation: pillPopIn 0.5s ease both;
}

.hero-pill:nth-child(1) { animation-delay: 0.1s; }
.hero-pill:nth-child(2) { animation-delay: 0.2s; }
.hero-pill:nth-child(3) { animation-delay: 0.3s; }

@keyframes pillPopIn {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(10px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.hero-pill:hover {
  background: rgba(179, 27, 27, 0.18);
  border-color: rgba(179, 27, 27, 0.4);
  transform: translateY(-2px);
}

.hero-flow .authors {
  text-align: center;
}

/* Authors */
.authors {
  font-size: var(--fs-body);
  color: var(--text-secondary);
  line-height: 2;
  margin-top: 0;
  margin-bottom: 32px;
  text-align: center;
}

.authors span {
  display: block;
  font-size: var(--fs-meta);
  color: var(--text-muted);
  margin-top: 8px;
}

.authors .affiliation {
  font-family: 'Inter', -apple-system, sans-serif;
  font-style: normal;
  font-size: var(--fs-meta);
  color: var(--text-muted);
  margin-top: 12px;
}

.affiliation-logo {
  height: 52px;
  width: auto;
  vertical-align: middle;
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin: 16px auto 0;
  display: block;
}

.authors a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

.authors a:hover {
  color: var(--carnelian);
}

.authors sup {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 1px;
}

.authors .author-note {
  display: block;
  font-size: var(--fs-meta);
  color: var(--text-muted);
  margin-top: 6px;
  margin-bottom: 4px;
}

.authors .affiliation sup {
  font-size: 9px;
  margin-right: 2px;
}

/* Hero Actions */
.hero-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 28px;
}

.cta {
  font-weight: 600;
  font-size: var(--fs-ui);
  text-decoration: none;
  padding: 14px 28px;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  background: transparent;
  transition: all 0.25s ease;
}

.cta.primary {
  background: var(--carnelian);
  border-color: var(--carnelian);
  color: #fff;
  font-weight: 600;
}

.cta.ghost {
  border-color: rgba(217, 45, 32, 0.3);
  color: var(--carnelian);
}

.cta.dark {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: #fff;
}

.cta.dark:hover {
  background: #000;
  border-color: #000;
}

.cta:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.cta.primary:hover {
  box-shadow: 0 12px 32px rgba(217, 45, 32, 0.35);
}

/* Hero Waves */
.hero-waves {
  position: relative;
  width: 100%;
  height: 70px;
  margin-top: 24px;
  overflow: hidden;
  opacity: 0.7;
}

.waves-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.wave-parallax use {
  animation: waveShift 16s cubic-bezier(0.55, 0.5, 0.45, 0.5) infinite;
}

.wave-parallax use:nth-child(1) { animation-delay: -2s; animation-duration: 16s; }
.wave-parallax use:nth-child(2) { animation-delay: -4s; animation-duration: 14s; }
.wave-parallax use:nth-child(3) { animation-delay: -6s; animation-duration: 20s; }
.wave-parallax use:nth-child(4) { animation-delay: -8s; animation-duration: 18s; }

@keyframes waveShift {
  0% { transform: translate3d(-90px, 0, 0); }
  50% { transform: translate3d(20px, 0, 0); }
  100% { transform: translate3d(-90px, 0, 0); }
}

/* Tagline - Section Headers */
.tagline {
  font-family: 'Space Grotesk', -apple-system, sans-serif;
  font-size: var(--fs-section-title);
  font-weight: 500;
  letter-spacing: -0.02em;
  background: transparent;
  color: var(--text-primary);
  display: block;
  padding: 48px 0 0 0;
  margin: 24px 0 20px 0;
  border: none;
  position: relative;
}

.tagline::before {
  display: none;
}

/* The underline takes the section's accent (via the same accent-* classes
   the cards use), falling back to brand carnelian. */
.tagline::after {
  content: '';
  display: block;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg,
      var(--accent, var(--carnelian)) 0%,
      color-mix(in srgb, var(--accent, var(--carnelian)) 15%, transparent) 40%,
      transparent 100%);
  border-radius: 2px;
  margin-bottom: 12px;
  margin-top: 24px;
}

/* The definitions section holds all three term accents, so its underline
   walks gold → blue → violet in the order the terms appear. */
#definitions.tagline::after {
  background: linear-gradient(90deg,
      var(--gold) 0%,
      var(--blue-energy) 38%,
      var(--neon-violet) 72%,
      transparent 100%);
}

/* Images */
img {
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  margin: 0;
  box-sizing: border-box;
  box-shadow: var(--shadow-md);
}

.main-content > img {
  margin-left: 0;
  margin-right: 0;
}

.teaser-image {
  border: 3px solid var(--border-light) !important;
}

/* Method section: the overview figure and the numbered pipeline share one
   card, so the figure sits flush inside the card's padding. */
.method-card .teaser-image {
  margin-bottom: 4px;
}

.method-steps {
  list-style: none;
  counter-reset: method-step;
  display: grid;
  gap: 20px;
  /* Last element in the card — the card's own padding closes it out. */
  margin: 28px 0 4px 0;
  padding: 0;
}

.method-steps li {
  counter-increment: method-step;
  position: relative;
  padding-left: 58px;
  font-size: var(--fs-body-lg);
  line-height: 1.65;
  color: var(--text-secondary);
}

.method-steps li::before {
  content: counter(method-step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 28px;
  font-family: 'Fira Code', monospace;
  font-size: var(--fs-meta);
  font-weight: 600;
  color: var(--carnelian);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.method-steps b {
  color: var(--text-primary);
}

@media (max-width: 768px) {
  .method-steps li {
    padding-left: 44px;
  }

  .method-steps li::before {
    width: 30px;
  }
}

/* Figure Caption */
.figure-caption {
  font-size: var(--fs-caption);
  color: var(--text-muted);
  text-align: center;
  margin-top: 20px;
  margin-bottom: 48px;
  padding: 0 clamp(8px, 3vw, 32px);
  line-height: 1.7;
}

/* Card Surface - Refined */
.card-surface {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  padding: clamp(20px, 3vw, 32px);
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
}

.card-surface:hover {
  box-shadow: var(--shadow-lg);
}

.section-heading {
  font-size: var(--fs-heading);
  margin: 0 0 12px 0;
  color: var(--text-primary);
}

.section-lead {
  color: var(--text-muted);
  margin: 0 0 24px 0;
  font-size: var(--fs-body-lg);
  line-height: 1.65;
  max-width: 820px;
}

/* Verdict line closing each results section, tinted with its accent. */
.section-takeaway {
  margin: 28px auto 4px;
  max-width: 860px;
  padding: 16px 24px;
  border-left: 4px solid var(--accent, var(--carnelian));
  border-radius: 0 14px 14px 0;
  background: color-mix(in srgb, var(--accent, var(--carnelian)) 6%, var(--bg-surface));
  font-size: var(--fs-body-lg);
  line-height: 1.65;
  color: var(--text-secondary);
}

.section-takeaway b {
  color: var(--text-primary);
}

/* Resources Section */
.resources-card {
  margin-top: 24px;
}

.resources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.resource-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.resource-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.resource-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: rgba(179, 27, 27, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  color: var(--carnelian);
}

.resource-item h3 {
  font-family: 'Space Grotesk', -apple-system, sans-serif;
  font-size: var(--fs-title);
  font-weight: 600;
  margin: 0 0 10px 0;
  color: var(--text-primary);
}

.resource-item p {
  font-size: var(--fs-body);
  color: var(--text-secondary);
  margin: 0 0 18px 0;
  line-height: 1.6;
}

.resource-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-ui);
  font-weight: 600;
  color: var(--carnelian);
  text-decoration: none;
  transition: all 0.2s ease;
}

.resource-link:hover {
  gap: 10px;
}

.resource-link svg {
  transition: transform 0.2s ease;
}

.resource-link:hover svg {
  transform: translate(2px, -2px);
}

/* BibTeX */
.bibtex-code {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: clamp(20px, 3vw, 32px);
  border-radius: 20px;
  margin: 88px auto -44px;
  max-width: 1000px;
  box-sizing: border-box;
  font-size: var(--fs-meta);
  box-shadow: var(--shadow-sm);
}

.bibtex-title {
  font-family: 'Space Grotesk', -apple-system, sans-serif;
  font-size: var(--fs-title);
  font-weight: 600;
  margin-bottom: 18px;
  color: var(--text-primary);
}

.bibtex-code pre {
  white-space: pre;
  overflow-x: auto;
  margin: 0;
}

.bibtex-code code {
  font-family: 'Fira Code', monospace;
  font-size: 13.5px;
  line-height: 1.7;
}

/* Footer */
.footer {
  font-size: var(--fs-meta);
  color: var(--text-muted);
  margin-top: 120px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 40px;
  text-align: center;
}

.footer a {
  color: var(--carnelian);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.footer a:hover {
  opacity: 0.8;
}

/* Definitions Stack */
/* The three definitions are cards stacked vertically inside the section's
   .card-surface, each carrying its accent as a top stripe plus an index
   badge in the card head. The card's lead paragraph supplies the top gap. */
/* The three definitions read as one continuous section rather than three
   nested cards: no shells or badges, just headed blocks separated by a rule. */
.def-stack {
  display: grid;
  gap: clamp(28px, 4vw, 44px);
  margin: 0 0 4px 0;
}

.def-block + .def-block {
  border-top: 1px solid var(--border-subtle);
  padding-top: clamp(28px, 4vw, 44px);
}

/* Accent colors: set --accent on any ancestor (a figure stack or the
   definitions shell) and it cascades down to the title/stripe below,
   regardless of which markup shape is using it. */
/* Term 1 = gold, term 2 = blue, term 3 = violet — kept consistent between
   the definitions stack and each term's section card. Green is the
   non-term 4th (OOD); carnelian stays the site-wide brand/fallback. */
.accent-gold   { --accent: var(--gold); }
.accent-blue   { --accent: var(--blue-energy); }
.accent-violet { --accent: var(--neon-violet); }
.accent-green  { --accent: var(--detect-green); }

/* The accent survives the loss of the card stripe as a rule under the title. */
.def-title {
  font-family: 'Space Grotesk', -apple-system, sans-serif;
  font-size: var(--fs-title);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 18px 0;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--accent, var(--carnelian));
}

.def-image {
  display: block;
  width: 100%;
  height: auto;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 14px;
  box-sizing: border-box;
  margin: 0;
}

/* Figure and the red-mug story run side by side; the formal definition sits
   below at full width, where the display equations have room. The panels are
   wide and short (4:1 to 7:1), so the image takes the larger share. */
.def-split {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: clamp(20px, 3vw, 34px);
  align-items: center;
  margin-bottom: 22px;
}

/* Story on the left, figure on the right — the column weights follow the
   markup order so the figure keeps the larger share either way. */
.def-split--text-first {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
}

/* The story is prose in the page's own voice, so it takes the primary text
   color; the definition below is set apart as a tinted panel in the block's
   accent, so it reads as the formal statement rather than more narration. */
.def-split .def-body {
  font-size: var(--fs-body);
  color: var(--text-primary);
  margin: 0;
}

.def-formal {
  font-size: var(--fs-body);
  color: var(--text-secondary);
  line-height: 1.65;
  /* Overlong inline math can't wrap; the panel scrolls it instead of letting
     it paint past the rounded edge. */
  overflow-x: auto;
  background: var(--bg-elevated);
  border-left: 3px solid var(--accent, var(--carnelian));
  border-radius: 0 12px 12px 0;
  padding: clamp(16px, 2vw, 22px) clamp(18px, 2.2vw, 26px);
}

.def-formal p {
  margin: 0 0 12px 0;
}

.def-formal p:last-child {
  margin-bottom: 0;
}

.def-formal em {
  color: var(--text-primary);
  font-style: italic;
}

/* Wide display equations scroll on their own instead of widening the page.
   MathJax writes an inline min-width on display math, and min-width beats
   max-width — without the override the equation forces its column past the
   viewport on phones. */
mjx-container[display='true'] {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  min-width: 0 !important;
}

.def-body {
  font-size: var(--fs-body-lg);
  color: var(--text-secondary);
  line-height: 1.65;
  margin: 0 0 16px 0;
}

.def-body em {
  color: var(--text-primary);
  font-style: italic;
}

/* Responsive */
/* Font sizes and padding scale fluidly via clamp() in the base rules;
   only the corner radii step down at phone widths. */
@media (max-width: 768px) {
  /* The nested padding stack (body + card + figure card) eats ~110px of a
     375px screen; thin each layer so figures keep the width instead. */
  body {
    padding-left: 12px;
    padding-right: 12px;
  }
  .hero-flow {
    border-radius: 24px;
  }
  .card-surface {
    border-radius: 20px;
    padding-left: 14px;
    padding-right: 14px;
  }
  .figure-card {
    padding: 12px 12px 16px;
  }
  .rollout-figure {
    padding: 10px;
  }
  .def-image {
    padding: 10px;
  }
  /* The running caption under the OOD overview goes flush left on phones. */
  .figure-caption {
    text-align: left;
  }
  /* Figure above story once the columns get too narrow to read — including
     the text-first block, which keeps the same order as the others here. */
  .def-split,
  .def-split--text-first {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }
  .def-split--text-first .def-image {
    order: -1;
  }
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Backstop: nothing may pan the page sideways on phones. */
html, body {
  overflow-x: clip;
}

/* Scroll progress bar: stands in for the nav as a sense of place. The bar
   spans the full width with a gradient whose stops scroll-progress.js
   rebuilds from the real section positions (each stop in that section's
   accent), and progress is revealed by clip-path — so the leading edge is
   always the color of the section currently on screen. The static gradient
   here is only the no-JS/pre-JS fallback. Sits below the lightbox overlay
   (z 1000) so it doesn't float over an opened figure. */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--carnelian) 0%, var(--gold) 30%, var(--neon-violet) 65%, var(--blue-energy) 100%);
  clip-path: inset(0 100% 0 0);
  z-index: 900;
  pointer-events: none;
}

/* Selection */
::selection {
  background: rgba(217, 45, 32, 0.25);
  color: var(--text-primary);
}

/* Focus */
:focus-visible {
  outline: 2px solid var(--carnelian);
  outline-offset: 3px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-elevated);
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.rollout-figure {
  display: block;
  width: 100%;
  height: auto;
  margin: 24px 0 4px 0;
  padding: 20px;
  box-sizing: border-box;
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  background: #ffffff;
}

/* Figure Stack */
/* Result figures are cards stacked vertically, sharing the definitions'
   visual language: accent top stripe, surface background, soft shadow. */
.figure-stack {
  display: grid;
  gap: 24px;
  margin: 24px 0 4px 0;
}

.figure-card {
  position: relative;
  margin: 0;
  padding: clamp(18px, 3.5vw, 36px);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.figure-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent, var(--carnelian));
  z-index: 1;
}

/* Override the global img card treatment (border/radius/shadow) — inside a
   figure card the card itself is the frame, so the image renders flat. */
.figure-card img {
  display: block;
  width: 100%;
  height: auto;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.figure-card figcaption {
  margin-top: 14px;
  font-size: var(--fs-caption);
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
}

/* Centered multi-line captions read poorly on a narrow column (ragged on
   both edges); justify them with hyphenation so the edges stay uniform.
   This must sit after the base rule above — equal specificity, so source
   order decides. */
@media (max-width: 768px) {
  .figure-card figcaption {
    text-align: justify;
    -webkit-hyphens: auto;
    hyphens: auto;
  }
}

/* Frame-sequence Scrubber */
.scrubber {
  margin: 24px 0 4px 0;
}

.scrubber-frame {
  position: relative;
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  background: #000;
  overflow: hidden;
  line-height: 0;
}

.scrubber-canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: pointer;
}

.scrubber-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  transition: opacity 0.3s ease;
}

.scrubber-loading.is-hidden {
  opacity: 0;
  pointer-events: none;
}

/* Deferred state on touch devices: the first frame shows through as a poster
   and the multi-MB frame download waits for an explicit tap. */
.scrubber-loading.is-deferred {
  background: rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.scrubber-loading-bar {
  width: 55%;
  max-width: 220px;
  height: 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

.scrubber-loading-fill {
  width: 0%;
  height: 100%;
  background: var(--carnelian);
  transition: width 0.15s ease;
}

.scrubber-loading-label {
  font-family: 'Fira Code', monospace;
  font-size: var(--fs-mono-sm);
  color: #fff;
  letter-spacing: 0.02em;
}

.scrubber-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  opacity: 0.4;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.scrubber.is-ready .scrubber-controls {
  opacity: 1;
  pointer-events: auto;
}

.scrubber-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.scrubber-btn:hover {
  border-color: var(--carnelian);
  color: var(--carnelian);
}

.scrubber-btn.is-active {
  background: var(--carnelian);
  border-color: var(--carnelian);
  color: #fff;
}

.scrubber-range {
  flex: 1 1 auto;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 3px;
  background: var(--border-light);
  outline: none;
  cursor: pointer;
}

.scrubber-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--carnelian);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.scrubber-range::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--carnelian);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

/* Touch: the slider is the primary control, so give it real finger targets. */
@media (pointer: coarse) {
  .scrubber-btn {
    width: 44px;
    height: 44px;
    font-size: 15px;
  }
  .scrubber-range {
    height: 6px;
  }
  .scrubber-range::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
  }
  .scrubber-range::-moz-range-thumb {
    width: 24px;
    height: 24px;
  }
}

.scrubber-counter {
  flex: 0 0 auto;
  font-family: 'Fira Code', monospace;
  font-size: var(--fs-mono-sm);
  color: var(--text-muted);
  min-width: 64px;
  text-align: right;
}

/* Figure lightbox: tap a figure to inspect it at readable size and pan.
   The image renders at >=1000px wide, so phone users get real zoom on the
   paper-width panels instead of a 100px-tall thumbnail. */
.lightbox-zoomable {
  cursor: zoom-in;
}

.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(12, 12, 14, 0.93);
  display: none;
}

.lightbox-overlay.is-open {
  display: block;
}

.lightbox-scroll {
  position: absolute;
  inset: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  padding: 20px;
}

.lightbox-img {
  display: block;
  /* margin:auto (not place-items) keeps the left edge reachable when the
     image overflows the scroll container. */
  margin: auto;
  width: max(100%, 1000px);
  max-width: none;
  height: auto;
  padding: 12px;
  border-radius: 10px;
  background: #ffffff;
}

.lightbox-close {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 1001;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

body.lightbox-lock {
  overflow: hidden;
}

/* Abstract */
.abstract-block {
  max-width: 820px;
  margin: 8px auto 40px auto;
  padding: 0 24px;
}

.abstract-heading {
  font-family: 'Space Grotesk', -apple-system, sans-serif;
  font-size: var(--fs-ui);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--carnelian);
  text-align: center;
  margin: 0 0 16px 0;
}

.abstract-block p {
  font-size: var(--fs-body-lg);
  line-height: 1.75;
  color: var(--text-secondary);
  text-align: justify;
  margin: 0;
}

.abstract-block b {
  color: var(--text-primary);
  font-weight: 600;
}

@media (max-width: 700px) {
  .abstract-block p {
    text-align: left;
  }
}
