/* =========================================================
   River Remedy — Main Stylesheet
   Design system based on UI Kit v1.0 (April 2026)
   ========================================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Bolivia identity */
  --bol-red:    #D52B1E;
  --bol-yellow: #D4A017;
  --bol-green:  #007A5E;
  --bol-orange: #E8821A;

  /* Forest scale */
  --forest-900: #0a1710;
  --forest-800: #0f2018;
  --forest-700: #132416;
  --forest-600: #1e3d2a;
  --forest-500: #2d6a4f;
  --forest-400: #4fa06a;
  --forest-300: #76bb8a;
  --forest-200: #a8d5b5;
  --forest-100: #d1ead8;
  --forest-50:  #edf7f0;

  /* Water scale */
  --water-900: #0c4a6e;
  --water-700: #075985;
  --water-500: #0ea5e9;
  --water-300: #7ec8e3;
  --water-100: #dbeafe;
  --water-50:  #eff8ff;

  /* Sage neutrals */
  --sage-50:  #f5faf6;
  --sage-100: #eaf4ec;
  --sage-200: #d1ead8;
  --sage-300: #a8d5b5;

  /* Pastel callout surfaces */
  --pastel-red:    #fff0ef;
  --pastel-yellow: #fffbeb;
  --pastel-green:  #edf7f0;
  --pastel-orange: #fff7ed;
  --pastel-blue:   #eff8ff;

  /* Text */
  --ink:      #0f2018;
  --ink-mid:  #132416;
  --ink-soft: #4a6352;

  /* Surfaces */
  --bg:      #f7fbf8;
  --surface: #ffffff;
  --border:  #d8eade;

  /* Typography */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'Inter', -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  --radius: 10px;
  --sidebar-w: 240px;
}

/* ── BASE ── */
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  display: flex;
  min-height: 100vh;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: var(--sage-300); border-radius: 3px; }

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

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--forest-800);
  position: fixed;
  left: 0; top: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sb-stripe {
  height: 4px;
  flex-shrink: 0;
  background: linear-gradient(90deg,
    var(--bol-red) 33.3%,
    var(--bol-yellow) 33.3% 66.6%,
    var(--bol-green) 66.6%);
}

.sb-brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sb-logo { width: 30px; height: 30px; flex-shrink: 0; }

.sb-wordmark {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.sb-wordmark span { color: var(--water-300); }
.sb-wordmark small {
  display: block;
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 500;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 3px;
}

.sb-section { padding: 8px 0 4px; }

.sb-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.28);
  padding: 8px 20px 5px;
}

.sb-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 20px;
  font-size: 12.5px;
  font-weight: 500;
  color: rgba(255,255,255,0.58);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.14s;
  line-height: 1.3;
}
.sb-link:hover {
  color: #fff;
  background: rgba(255,255,255,0.05);
  border-left-color: var(--water-300);
}
.sb-link.active {
  color: #fff;
  border-left-color: var(--bol-yellow);
  background: rgba(255,255,255,0.07);
  font-weight: 600;
}
.sb-icon { font-size: 13px; flex-shrink: 0; width: 16px; text-align: center; opacity: 0.7; }
.sb-link.active .sb-icon { opacity: 1; }

.sb-divider { height: 1px; background: rgba(255,255,255,0.06); margin: 8px 20px; }

.sb-bottom {
  margin-top: auto;
  padding-bottom: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* ── MAIN LAYOUT ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ── PAGE HERO ── */
.page-hero {
  background: linear-gradient(135deg, var(--forest-700) 0%, var(--forest-600) 100%);
  color: #fff;
  padding: 52px 60px 72px;
  position: relative;
  overflow: hidden;
}
.page-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    168deg,
    transparent, transparent 60px,
    rgba(126,200,227,0.04) 60px, rgba(126,200,227,0.04) 61px
  );
  pointer-events: none;
}
.page-hero.hero-red    { background: linear-gradient(135deg, #5c1010 0%, var(--forest-700) 100%); }
.page-hero.hero-orange { background: linear-gradient(135deg, #4a2008 0%, var(--forest-700) 100%); }
.page-hero.hero-water  { background: linear-gradient(135deg, var(--water-900) 0%, var(--forest-700) 100%); }
.page-hero.hero-deep   { background: linear-gradient(135deg, var(--forest-900) 0%, var(--forest-600) 100%); }

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--water-300);
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}
.hero-eyebrow::before {
  content: '';
  width: 24px; height: 2px;
  background: linear-gradient(90deg, var(--bol-red), var(--bol-yellow), var(--bol-green));
  border-radius: 1px;
  flex-shrink: 0;
}

.hero-title {
  font-family: var(--font-display);
  font-size: 46px;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
  position: relative;
  z-index: 1;
  max-width: 760px;
}
.hero-title em { color: var(--water-300); font-style: italic; }
.hero-title .accent-red    { color: #ff8a80; }
.hero-title .accent-yellow { color: var(--bol-yellow); }

.hero-sub {
  font-size: 15px;
  line-height: 1.65;
  color: rgba(255,255,255,0.68);
  max-width: 620px;
  position: relative;
  z-index: 1;
}

.hero-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 20px;
  position: relative;
  z-index: 1;
}
.hero-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.8);
  border: 1px solid rgba(255,255,255,0.15);
}

/* ── WAVE DIVIDER ── */
.wave { display: block; width: 100%; line-height: 0; overflow: hidden; }
.wave svg { display: block; width: 100%; }

/* ── SECTIONS ── */
.section {
  padding: 52px 60px 36px;
}
.section.alt { background: var(--surface); }
.section.sage { background: var(--sage-50); }
.section.dark { background: var(--forest-800); color: #fff; }
.section.compact { padding-top: 32px; padding-bottom: 24px; }

.section-eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bol-red);
  margin-bottom: 8px;
}
.section.dark .section-eyebrow { color: var(--water-300); }

.section-title {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 8px;
  line-height: 1.2;
}
.section.dark .section-title { color: #fff; }

.section-lead {
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--ink-soft);
  max-width: 720px;
  margin-bottom: 32px;
}
.section.dark .section-lead { color: rgba(255,255,255,0.65); }

/* ── GRIDS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.grid-7030 { display: grid; grid-template-columns: 7fr 3fr; gap: 28px; align-items: start; }
.grid-6040 { display: grid; grid-template-columns: 6fr 4fr; gap: 28px; align-items: start; }

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
  transition: box-shadow 0.18s, transform 0.18s;
}
.card:hover { box-shadow: 0 6px 28px rgba(45,106,79,0.09); transform: translateY(-2px); }
.card-accent { border-top: 3px solid var(--forest-400); }
.card-accent.red    { border-top-color: var(--bol-red); }
.card-accent.yellow { border-top-color: var(--bol-yellow); }
.card-accent.green  { border-top-color: var(--bol-green); }
.card-accent.orange { border-top-color: var(--bol-orange); }
.card-accent.blue   { border-top-color: var(--water-500); }

.card-label { font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 10px; }
.card-title { font-family: var(--font-display); font-size: 19px; font-weight: 600; color: var(--ink); margin-bottom: 8px; line-height: 1.25; }
.card-body  { font-size: 13.5px; line-height: 1.65; color: var(--ink-soft); }

/* ── STAT CARDS ── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-card.red::before    { background: var(--bol-red); }
.stat-card.yellow::before { background: var(--bol-yellow); }
.stat-card.green::before  { background: var(--bol-green); }
.stat-card.blue::before   { background: var(--water-500); }
.stat-card.orange::before { background: var(--bol-orange); }
.stat-card.forest::before { background: var(--forest-400); }

.stat-value { font-family: var(--font-display); font-size: 36px; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.stat-card.red .stat-value    { color: var(--bol-red); }
.stat-card.yellow .stat-value { color: var(--bol-yellow); }
.stat-card.green .stat-value  { color: var(--bol-green); }
.stat-card.blue .stat-value   { color: var(--water-700); }
.stat-card.orange .stat-value { color: var(--bol-orange); }
.stat-card.forest .stat-value { color: var(--forest-500); }

.stat-label { font-size: 11.5px; color: var(--ink-soft); line-height: 1.4; font-weight: 500; }
.stat-context { font-size: 11px; color: var(--ink-soft); margin-top: 6px; opacity: 0.75; }

/* ── CALLOUTS ── */
.callout {
  display: flex;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 10px;
  border-left: 3px solid;
  font-size: 13.5px;
  line-height: 1.6;
  align-items: flex-start;
  margin: 16px 0;
}
.callout.alert   { background: var(--pastel-red);    border-color: var(--bol-red);    color: #7f1d1d; }
.callout.finding { background: var(--pastel-yellow); border-color: var(--bol-yellow); color: #713f12; }
.callout.success { background: var(--pastel-green);  border-color: var(--bol-green);  color: #1e4d38; }
.callout.info    { background: var(--pastel-blue);   border-color: var(--water-500);  color: var(--water-900); }
.callout.method  { background: var(--sage-50);       border-color: var(--forest-300); color: var(--forest-700); }
.callout-icon { font-size: 17px; flex-shrink: 0; line-height: 1.2; }
.callout-body strong { display: block; font-weight: 700; margin-bottom: 3px; }

/* ── TAGS ── */
.tag { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.11em; text-transform: uppercase; padding: 4px 10px; border-radius: 20px; }
.tag-red    { background: var(--pastel-red);    color: var(--bol-red); }
.tag-yellow { background: var(--pastel-yellow); color: #92720e; }
.tag-green  { background: var(--pastel-green);  color: var(--bol-green); }
.tag-orange { background: var(--pastel-orange); color: #c2410c; }
.tag-blue   { background: var(--pastel-blue);   color: var(--water-700); }
.tag-sage   { background: var(--sage-100);      color: var(--forest-600); }

.metal-tag { display: inline-block; font-family: var(--font-mono); font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 5px; letter-spacing: 0.06em; }
.metal-pb { background: #fce7e7; color: #991b1b; }
.metal-as { background: #fff3e0; color: #c2410c; }
.metal-cd { background: #fffbeb; color: #92720e; }
.metal-zn { background: #edf7f0; color: var(--bol-green); }
.metal-hg { background: var(--pastel-blue); color: var(--water-700); }
.metal-fe { background: #fdf4ff; color: #7e22ce; }
.metal-mn { background: #f0fdf4; color: #166534; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.14s;
}
.btn-primary { background: var(--forest-500); color: #fff; }
.btn-primary:hover { background: var(--forest-600); transform: translateY(-1px); }
.btn-outline { background: transparent; color: var(--forest-500); border: 1.5px solid var(--forest-200); }
.btn-outline:hover { border-color: var(--forest-500); background: var(--forest-50); }
.btn-ghost { background: var(--forest-50); color: var(--forest-500); }
.btn-ghost:hover { background: var(--forest-100); }
.btn-sm { font-size: 11.5px; padding: 6px 14px; }
.btn-lg { font-size: 14px; padding: 12px 26px; }

/* ── VISUALIZATION EMBEDS ── */
.viz-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 8px 0;
}
.viz-wrap iframe { width: 100%; border: none; display: block; }
.viz-wrap.h-400 iframe { height: 400px; }
.viz-wrap.h-500 iframe { height: 500px; }
.viz-wrap.h-600 iframe { height: 600px; }
.viz-wrap.h-700 iframe { height: 700px; }
.viz-wrap.h-800 iframe { height: 800px; }
.viz-caption {
  padding: 10px 16px;
  font-size: 11.5px;
  color: var(--ink-soft);
  border-top: 1px solid var(--border);
  background: var(--sage-50);
  line-height: 1.5;
}
.viz-caption strong { color: var(--ink); font-weight: 600; }

.viz-img-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  margin: 8px 0;
}
.viz-img-wrap img { width: 100%; cursor: zoom-in; transition: opacity 0.14s; }
.viz-img-wrap img:hover { opacity: 0.92; }

/* ── DATA TABLES ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.data-table th { background: var(--forest-800); color: rgba(255,255,255,0.85); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; padding: 11px 14px; text-align: left; }
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--ink-mid); vertical-align: top; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--sage-50); }
.data-table .num { font-family: var(--font-mono); font-size: 12px; }

/* ── FINDING HIGHLIGHT BLOCKS ── */
.finding-block {
  background: linear-gradient(135deg, var(--forest-800) 0%, var(--forest-600) 100%);
  border-radius: 12px;
  padding: 28px 32px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.finding-block::before {
  content: '';
  position: absolute;
  top: -24px; right: -24px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.03);
}
.finding-block .fb-label { font-size: 10px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--bol-yellow); margin-bottom: 8px; }
.finding-block .fb-value { font-family: var(--font-display); font-size: 42px; font-weight: 700; line-height: 1; color: #fff; margin-bottom: 6px; }
.finding-block .fb-desc  { font-size: 13px; color: rgba(255,255,255,0.7); line-height: 1.5; }

/* ── TIMELINE ── */
.timeline { position: relative; padding-left: 32px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 10px; top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--bol-red) 0%, var(--bol-yellow) 50%, var(--bol-green) 100%);
  border-radius: 1px;
}
.tl-item { position: relative; margin-bottom: 36px; }
.tl-item::before {
  content: '';
  position: absolute;
  left: -26px; top: 6px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--bol-yellow);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--bol-yellow);
}
.tl-date { font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--bol-orange); letter-spacing: 0.06em; margin-bottom: 4px; }
.tl-title { font-family: var(--font-display); font-size: 19px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.tl-body { font-size: 13.5px; line-height: 1.65; color: var(--ink-soft); }

/* ── EQUATIONS / CODE ── */
.eq-box {
  background: var(--forest-900);
  border-radius: 8px;
  padding: 14px 18px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--forest-200);
  border: 1px solid var(--forest-700);
  overflow-x: auto;
  margin: 12px 0;
}
.eq-box .eq-var { color: var(--bol-yellow); }

/* ── METAL RETENTION (mech cards) ── */
.mech-card {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
}
.mech-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }
.mech-card.pb::before { background: var(--bol-red); }
.mech-card.as::before { background: var(--bol-orange); }
.mech-card.cd::before { background: var(--bol-yellow); }
.mech-card.zn::before { background: var(--bol-green); }
.mech-metal { font-family: var(--font-mono); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; margin-bottom: 6px; }
.mech-kd { font-family: var(--font-display); font-size: 28px; font-weight: 700; color: var(--ink); line-height: 1; margin-bottom: 2px; }
.mech-kd-unit { font-size: 12px; color: var(--ink-soft); }
.mech-control { font-size: 12px; color: var(--ink-soft); margin-top: 8px; line-height: 1.5; }
.mech-control strong { color: var(--ink); font-weight: 600; }

/* ── HYPOXIC EVENT CARDS ── */
.event-card { border-radius: 12px; border: 1px solid var(--border); overflow: hidden; background: var(--surface); }
.event-header { padding: 16px 20px; display: flex; justify-content: space-between; align-items: flex-start; }
.event-header.critical { background: #fef2f2; border-bottom: 2px solid var(--bol-red); }
.event-header.limited  { background: var(--pastel-yellow); border-bottom: 2px solid var(--bol-yellow); }
.event-header.recent   { background: var(--pastel-blue); border-bottom: 2px solid var(--water-500); }
.event-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; color: var(--ink); }
.event-meta { font-size: 11.5px; color: var(--ink-soft); margin-top: 3px; }
.event-body { padding: 18px 20px; }

/* ── ENRICHMENT GRID ── */
.enrich-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.enrich-cell { background: var(--sage-50); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; text-align: center; }
.enrich-metal { font-family: var(--font-mono); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); margin-bottom: 6px; }
.enrich-value { font-family: var(--font-display); font-size: 28px; font-weight: 700; color: var(--bol-red); line-height: 1; }
.enrich-value.moderate { color: var(--bol-yellow); }
.enrich-value.mild     { color: var(--bol-orange); }
.enrich-suffix { font-size: 11px; color: var(--ink-soft); margin-top: 3px; }

/* ── COST CARDS (remediation) ── */
.cost-card { border-radius: 12px; border: 1px solid var(--border); overflow: hidden; background: var(--surface); }
.cost-card-header { padding: 14px 20px; font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: #fff; }
.cost-card-header.t1 { background: var(--bol-green); }
.cost-card-header.t2 { background: var(--bol-yellow); color: var(--ink); }
.cost-card-header.t3 { background: var(--bol-orange); }
.cost-body { padding: 20px; }
.cost-amount { font-family: var(--font-display); font-size: 32px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.cost-name { font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 10px; }
.cost-desc { font-size: 13px; color: var(--ink-soft); line-height: 1.6; }
.cost-list { margin-top: 14px; list-style: none; }
.cost-list li { font-size: 12.5px; color: var(--ink-mid); padding: 4px 0; border-bottom: 1px solid var(--sage-100); display: flex; align-items: flex-start; gap: 8px; }
.cost-list li:last-child { border-bottom: none; }
.cost-list li::before { content: '✓'; color: var(--bol-green); font-weight: 700; flex-shrink: 0; }

/* ── PHASE STEPS ── */
.phase-steps { display: flex; flex-direction: column; gap: 0; }
.phase-step { display: grid; grid-template-columns: 72px 1fr; gap: 20px; padding: 20px 0; border-bottom: 1px solid var(--border); }
.phase-step:last-child { border-bottom: none; }
.phase-num { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.phase-circle { width: 36px; height: 36px; border-radius: 50%; background: var(--forest-500); color: #fff; font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.phase-duration { font-family: var(--font-mono); font-size: 10px; color: var(--ink-soft); text-align: center; letter-spacing: 0.04em; white-space: nowrap; }
.phase-title { font-weight: 700; font-size: 14px; color: var(--ink); margin-bottom: 5px; }
.phase-desc { font-size: 13px; color: var(--ink-soft); line-height: 1.6; }

/* ── TECH CARDS ── */
.tech-card { border-radius: 10px; border: 1px solid var(--border); background: var(--surface); overflow: hidden; }
.tech-header { padding: 16px 20px; background: var(--forest-50); border-bottom: 1px solid var(--border); }
.tech-name { font-family: var(--font-display); font-size: 17px; font-weight: 600; color: var(--ink); }
.tech-sub { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.tech-body { padding: 16px 20px; }
.pro-con-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pro-list, .con-list { list-style: none; }
.pro-list li, .con-list li { font-size: 12.5px; padding: 4px 0; display: flex; gap: 7px; align-items: flex-start; color: var(--ink-mid); line-height: 1.45; }
.pro-list li::before { content: '✓'; color: var(--bol-green); font-weight: 700; flex-shrink: 0; font-size: 11px; margin-top: 1px; }
.con-list li::before { content: '!'; color: var(--bol-orange); font-weight: 700; flex-shrink: 0; font-size: 11px; margin-top: 1px; }

/* ──────────────────────────────────────────
   Language toggle — sliding pill (design 02)
   ────────────────────────────────────────── */

.lang-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px 5px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  user-select: none;
}

.lang-pill__globe {
  color: var(--forest-500);
  flex-shrink: 0;
}

.lang-pill__track {
  position: relative;
  display: flex;
  background: var(--sage-100);
  border-radius: 9999px;
  padding: 3px;
}

.lang-pill__thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc(50% - 3px);
  background: var(--forest-500);
  border-radius: 9999px;
  transition: transform 0.25s cubic-bezier(.4,.1,.2,1);
  box-shadow: 0 1px 3px rgba(45,106,79,0.25);
}

.lang-pill[data-lang="es"] .lang-pill__thumb {
  transform: translateX(100%);
}

.lang-pill__opt {
  position: relative;
  z-index: 1;
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 5px 14px;
  border-radius: 9999px;
  color: var(--ink-soft);
  font: inherit;
  letter-spacing: 0.04em;
  transition: color 0.2s ease;
  line-height: 1;
}

.lang-pill__opt[aria-pressed="true"] {
  color: #fff;
}

.lang-pill__opt:focus-visible {
  outline: 2px solid var(--water-500);
  outline-offset: 2px;
}

/* ── Sidebar (dark) variant ── */
.lang-toggle-widget {
  padding: 8px 14px 4px;
}
.lang-toggle-widget .lang-pill {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.65);
  justify-content: space-between;
  padding: 5px 8px 5px 12px;
}
.lang-toggle-widget .lang-pill__globe {
  color: rgba(255, 255, 255, 0.72);
}
.lang-toggle-widget .lang-pill__track {
  flex: 1;
  background: rgba(0, 0, 0, 0.22);
}
.lang-toggle-widget .lang-pill__thumb {
  background: var(--forest-400);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.lang-toggle-widget .lang-pill__opt {
  flex: 1;
  text-align: center;
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  padding: 5px 0;
}
.lang-toggle-widget .lang-pill__opt[aria-pressed="true"] {
  color: #fff;
}

/* ── Mobile fixed variant (light) ── */
.lang-toggle-mobile {
  display: none;
}
@media (max-width: 880px) {
  .lang-toggle-mobile {
    display: block;
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 200;
  }
  .lang-toggle-mobile .lang-pill {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .lang-pill__thumb {
    transition: none;
  }
  .lang-pill__opt {
    transition: none;
  }
}

/* ── SIDEBAR REPORT CTA ── */
.sb-report-cta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 14px 4px;
  padding: 9px 14px;
  background: var(--forest-500);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  line-height: 1.35;
  transition: background 0.15s, transform 0.12s;
}
.sb-report-cta:hover {
  background: var(--forest-600);
  transform: translateY(-1px);
}
.sb-report-cta-icon { font-size: 15px; flex-shrink: 0; opacity: 0.85; }

/* ── HERO REPORT BUTTON ── */
.hero-actions { margin-top: 22px; }
.btn-hero-report {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 8px;
  background: rgba(255,255,255,0.10);
  border: 1.5px solid rgba(255,255,255,0.32);
  color: #fff;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
  backdrop-filter: blur(4px);
}
.btn-hero-report:hover {
  background: rgba(255,255,255,0.20);
  border-color: rgba(255,255,255,0.65);
  transform: translateY(-1px);
}

/* ── MAP INTERACTIVE OVERLAY ── */
.viz-wrap.map-interactive { position: relative; cursor: pointer; }
.map-activate-overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 1.25rem;
  transition: opacity 0.2s;
}
.map-activate-hint {
  background: rgba(15, 32, 24, 0.72);
  color: rgba(255,255,255,0.92);
  padding: 0.4rem 1.1rem;
  border-radius: 20px;
  font-size: 12px;
  letter-spacing: 0.02em;
  pointer-events: none;
}
.viz-wrap.map-interactive.active .map-activate-overlay { display: none; }
.viz-wrap.map-interactive:not(.active) iframe { pointer-events: none; }
.viz-wrap.map-interactive.active { cursor: default; }

/* ── LIGHTBOX ── */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(10,23,16,0.93);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.lightbox.open { opacity: 1; pointer-events: all; }
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: var(--radius); box-shadow: 0 24px 80px rgba(0,0,0,0.5); }
.lightbox-close { position: absolute; top: 20px; right: 24px; color: rgba(255,255,255,0.6); font-size: 28px; cursor: pointer; background: none; border: none; transition: color 0.14s; line-height: 1; }
.lightbox-close:hover { color: #fff; }

/* ── FOOTER ── */
.page-footer {
  padding: 24px 60px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: auto;
}
.footer-brand { font-family: var(--font-display); font-size: 14px; color: var(--ink-soft); }
.footer-links { display: flex; gap: 20px; }
.footer-links a { font-size: 12px; color: var(--ink-soft); text-decoration: none; transition: color 0.14s; }
.footer-links a:hover { color: var(--forest-500); }
.footer-note { font-size: 11px; color: var(--ink-soft); opacity: 0.65; }

/* ── UTILITY ── */
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mb-8 { margin-bottom: 32px; }
.gap-4 { gap: 16px; }
.font-mono { font-family: var(--font-mono); }
.text-muted { color: var(--ink-soft); }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11px; }
p { font-size: 14px; line-height: 1.7; color: var(--ink-mid); margin-bottom: 12px; }
p:last-child { margin-bottom: 0; }

/* ── RESPONSIVE ── */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-7030, .grid-6040 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  /* Sidebar becomes a slide-in drawer on mobile.
     Replaces: .sidebar { display: none; } */
  .sidebar {
    width: min(280px, 78vw);
    transform: translateX(-100%);
    transition: transform 280ms cubic-bezier(.4,.1,.2,1);
    z-index: 260;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
  }
  body[data-mobile-nav="open"] .sidebar {
    transform: translateX(0);
  }
  .main { margin-left: 0; }
  .page-hero { padding: 36px 28px 52px; }
  .hero-title { font-size: 34px; }
  .section { padding: 36px 28px 24px; }
  .page-footer { padding: 20px 28px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .enrich-grid { grid-template-columns: 1fr 1fr; }
  .pro-con-grid { grid-template-columns: 1fr; }
}

/* =========================================================
   PARTITIONING PAGE EXTENSIONS (added 2026-04)
   New classes used only in partitioning.html:
     .metal-story        — narrative subsection block in §5 (Four Metal Stories)
     .metal-story-header — flex row: title + Kd badge
     .metal-story-title  — h3-level headline for each metal block
     .metal-story-kd     — monospaced Kd badge beside the headline
     .spectrum-wrap      — overflow container for the inline SVG spectrum (§2)
     .cross-link-card    — forward-navigation card for §7 remediation links
   These do not override any existing class; they compose on top of the design
   system tokens already defined above.
   ========================================================= */

.metal-story {
  padding: 32px 0;
  border-bottom: 1px solid var(--border);
}
.metal-story:last-child { border-bottom: none; padding-bottom: 0; }

.metal-story-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}
.metal-story-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}
.metal-story-kd {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--sage-100);
  padding: 3px 9px;
  border-radius: 5px;
  white-space: nowrap;
}

.spectrum-wrap {
  overflow-x: auto;
  margin: 24px 0 8px;
  padding: 4px 0 8px;
}

.cross-link-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
}
.cross-link-card:hover {
  box-shadow: 0 6px 24px rgba(45,106,79,0.1);
  transform: translateY(-2px);
  border-color: var(--forest-300);
}
.cross-link-card-icon {
  font-size: 26px;
  flex-shrink: 0;
  color: var(--forest-400);
  line-height: 1;
}
.cross-link-card-body { min-width: 0; }
.cross-link-card-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 3px;
}
.cross-link-card-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
}
.cross-link-card-desc {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.45;
}

/* equation display component for §3 Kd formula */
.kd-formula {
  background: var(--sage-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.kd-equation {
  font-family: var(--font-body);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--ink);
  margin-bottom: 14px;
  line-height: 1.4;
}
.kd-where {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 16px;
  row-gap: 4px;
  font-size: 13px;
  line-height: 1.55;
  margin: 0;
}
.kd-where dt {
  font-weight: 600;
  color: var(--ink);
}
.kd-where dd {
  color: var(--ink-soft);
  margin: 0;
}

/* inline anchor link at bottom of stripped-down mech-cards (§4) */
.mech-story-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--forest-500);
  text-decoration: none;
}
.mech-story-link:hover { text-decoration: underline; color: var(--forest-600); }

/* =========================================================
   HYPOXIC PAGE EXTENSIONS (added 2026-04)
   New classes used only in hypoxic.html:
     .enrich-value.stable  — replaces numeric EF with "Stable" for
                             metals that showed no significant change
                             (As, Fe in Event 2 enrich-grid)
     .theory-card          — four-metal prediction-vs-observation card
     .theory-section-label — "Predicted" / "Observed" micro-label
     .theory-text          — body text within a theory card
     .theory-verdict       — colored verdict badge (confirmed /
                             confirmed-nuanced)
     .hypoxic-timeline-wrap — overflow container for the inline SVG
                             event timeline (§4)
   These do not override any existing class; they compose on top of the
   design system tokens already defined above.
   ========================================================= */

.enrich-value.stable {
  color: var(--forest-500);
  font-size: 22px;
}

.hypoxic-timeline-wrap {
  overflow-x: auto;
  margin: 24px 0 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px 12px;
}

.theory-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.theory-section-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 4px;
  margin-top: 12px;
}

.theory-text {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.theory-verdict {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 11px;
  border-radius: 20px;
  margin-top: 14px;
}

.theory-verdict.confirmed         { background: var(--pastel-green);  color: var(--bol-green); }
.theory-verdict.confirmed-nuanced { background: var(--pastel-yellow); color: #713f12; }

/* ============================================================
   Click-to-Expand Iframe Modal (added for 3D model viewer UX)
   Used on: 3d-models.html
   ============================================================ */

/* visually-hidden utility (used for SR-only bilingual labels) */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* expand affordance on iframe wrappers */
.viz-expandable { position: relative; }
.viz-expand-btn {
  position: absolute; top: 10px; right: 10px;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--forest-800);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  font-size: 16px; line-height: 1;
  cursor: pointer; opacity: 0.55;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 5;
}
.viz-expandable:hover .viz-expand-btn,
.viz-expand-btn:focus-visible { opacity: 1; }
.viz-expand-btn:hover { transform: scale(1.05); }
.viz-expand-btn:focus-visible {
  outline: 2px solid var(--sage-100);
  outline-offset: 2px;
}

/* iframe modal overlay */
.iframe-modal {
  position: fixed; inset: 0;
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease;
}
.iframe-modal[data-open="true"] {
  opacity: 1; pointer-events: auto;
}
.iframe-modal[hidden] { display: none; }

.iframe-modal-backdrop {
  position: absolute; inset: 0;
  background: var(--forest-800);
  opacity: 0.85;
}

.iframe-modal-content {
  position: relative;
  width: 95vw; height: 92vh;
  max-width: 1600px;
  background: var(--bg);
  border-radius: 8px;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.iframe-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--sage-100);
  flex-shrink: 0;
}
.iframe-modal-title {
  margin: 0;
  font-family: 'Inter', sans-serif;
  font-size: 14px; font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.iframe-modal-close {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  font-size: 18px; cursor: pointer;
  color: var(--ink-soft);
  border-radius: 4px;
  transition: background 0.12s ease, color 0.12s ease;
}
.iframe-modal-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--ink);
}
.iframe-modal-close:focus-visible {
  outline: 2px solid var(--sage-100);
  outline-offset: 2px;
}

.iframe-modal-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: var(--bg);
}

/* header text wrapper (title + hint) */
.iframe-modal-header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* mouse-control hint subtitle */
.iframe-modal-hint {
  margin: 0;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.iframe-modal-hint-sep {
  opacity: 0.5;
  user-select: none;
}

/* mobile: hide desktop hint (touch users get Plotly's native gestures) */
@media (max-width: 640px) {
  .iframe-modal-hint { display: none; }
}

/* mobile: full-screen modal */
@media (max-width: 768px) {
  .iframe-modal-content {
    width: 100vw; height: 100vh;
    max-width: none;
    border-radius: 0;
  }
}

/* Contact page — author/team credits
   Used on: contact.html
   ============================================================ */

/* Site author block */
.author-block { align-items: center; gap: 32px; }
.author-photo img {
  width: 100%; max-width: 220px;
  border-radius: 50%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  margin: 0 auto; display: block;
  box-shadow: 0 6px 18px rgba(15, 32, 24, 0.12);
}
.author-name {
  font-family: 'Playfair Display', serif;
  font-size: 22px; font-weight: 600;
  margin: 0 0 6px;
  color: var(--ink);
}
.author-role {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 14px;
}
.author-links { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.author-links li { margin-bottom: 6px; }
.author-links a { color: var(--water-300); }

/* Mentor / team cards */
.mentor-card, .team-card { display: flex; flex-direction: column; align-items: center; text-align: center; }
.mentor-photo img,
.team-card .mentor-photo img {
  width: 110px; height: 110px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 12px;
  box-shadow: 0 3px 10px rgba(15, 32, 24, 0.10);
}
.mentor-photo.mentor-logo {
  width: 110px; height: 110px;
  display: flex; align-items: center; justify-content: center;
  background: #fff;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
  box-shadow: 0 3px 10px rgba(15, 32, 24, 0.10);
}
.mentor-photo.mentor-logo img {
  width: 100%; height: 100%;
  object-fit: contain;
  border-radius: 0;
  box-shadow: none;
}

/* Institution cards */
.institution-card { display: flex; flex-direction: column; align-items: center; text-align: center; }
.institution-logo {
  width: 100%; height: 90px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.institution-logo img {
  max-width: 70%; max-height: 80px;
  object-fit: contain;
  opacity: 0.92;
}

/* Group photo */
.group-photo {
  max-width: 560px;
  margin: 0 auto;
}
.group-photo img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
}

/* Mentor grid — 5 cards centered (3+2) */
.mentor-grid-5 {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
}
.mentor-grid-5 > .card {
  flex: 0 1 calc(33.333% - 14px);
  min-width: 200px;
  max-width: 320px;
}

/* Team card contribution metadata */
.team-contribution {
  font-size: 12px;
  color: var(--ink-soft);
  font-style: italic;
  margin: 4px 0 8px;
  line-height: 1.4;
}
.team-link {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  color: var(--water-300);
  text-decoration: none;
  margin-bottom: 8px;
}
.team-link:hover { text-decoration: underline; }
.contact-line {
  font-size: 12px;
  margin: 0;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .author-block { grid-template-columns: 1fr; }
  .author-photo img { max-width: 160px; }
}

/* ── PLAIN-LANGUAGE HEADLINE CALLOUT ── */
.plain-headline {
  background: var(--pastel-blue);
  border-left: 3px solid var(--water-700);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 0 0 1.5rem;
  max-width: 760px;
}
.plain-headline-eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--water-700);
  margin-bottom: 0.5rem;
}
.plain-headline p {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink-mid);
  margin: 0;
}
@media (max-width: 720px) {
  .plain-headline { padding: 0.85rem 1rem; }
  .plain-headline p { font-size: 0.95rem; }
}

/* ── GLOSSARY TOOLTIPS ── */
dfn.term {
  font-style: normal;
  border-bottom: 1px dotted var(--water-700);
  cursor: help;
  position: relative;
  outline: none;
}
dfn.term:focus-visible {
  outline: 2px solid var(--water-500);
  outline-offset: 2px;
  border-radius: 2px;
}
dfn.term .term-tip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: max-content;
  max-width: 320px;
  background: var(--ink);
  color: #fff;
  padding: 0.7rem 0.85rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-style: normal;
  font-weight: 400;
  line-height: 1.45;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 140ms ease, transform 140ms ease, visibility 140ms;
  z-index: 50;
  pointer-events: none;
  white-space: normal;
}
dfn.term:hover .term-tip,
dfn.term:focus .term-tip,
dfn.term:focus-within .term-tip,
dfn.term[data-open="true"] .term-tip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}
@media (max-width: 720px) {
  dfn.term .term-tip {
    max-width: min(280px, calc(100vw - 2rem));
    left: 0;
  }
}

/* ──────────────────────────────────────────
   Mobile nav drawer
   ────────────────────────────────────────── */

/* Default (desktop): drawer chrome is invisible. */
.mobile-nav-toggle,
.mobile-nav-backdrop,
.mobile-nav-close {
  display: none;
}

@media (max-width: 900px) {
  /* Hamburger button — fixed top-left, visible when drawer is closed. */
  .mobile-nav-toggle {
    display: flex;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
    color: var(--ink);
    padding: 0;
    transition: opacity 180ms ease, visibility 180ms ease;
  }
  .mobile-nav-toggle:focus-visible {
    outline: 2px solid var(--water-500);
    outline-offset: 2px;
  }
  body[data-mobile-nav="open"] .mobile-nav-toggle {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  /* Backdrop — covers everything behind the drawer when it's open. */
  .mobile-nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 32, 24, 0);
    z-index: 250;
    pointer-events: none;
    transition: background 280ms ease;
  }
  body[data-mobile-nav="open"] .mobile-nav-backdrop {
    background: rgba(15, 32, 24, 0.55);
    pointer-events: auto;
  }

  /* Close button inside the drawer (top-right of the sidebar on mobile). */
  .mobile-nav-close {
    display: flex;
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.85);
    padding: 0;
    z-index: 5;
  }
  .mobile-nav-close:hover {
    background: rgba(255, 255, 255, 0.1);
  }
  .mobile-nav-close:focus-visible {
    outline: 2px solid var(--water-300);
    outline-offset: 2px;
  }

  /* Lock body scroll while drawer is open. */
  body[data-mobile-nav="open"] {
    overflow: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .mobile-nav-backdrop,
  .mobile-nav-toggle {
    transition: none;
  }
}
