@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Serif+Text:ital@0;1&family=Lora:ital,wght@0,400;0,600;0,700;1,400&family=Playfair+Display:ital,wght@0,700;0,800;0,900;1,700&display=swap');

:root {
  /* Masculine palette — deeper, more saturated than pastel */
  --cream: #f5f0e6;
  --cream-dark: #e8dfce;
  --cream-deeper: #d4c8a8;
  --ink: #1a140e;          /* near-black for maximum contrast */
  --text-primary: #2c2018;
  --text-secondary: #4a3828;
  --text-muted: #6b5a48;
  /* Accent colors — bolder, more saturated */
  --coral: #c85a4a;
  --coral-soft: #e0a090;
  --coral-deep: #a03828;
  --teal: #2a7a82;
  --teal-soft: #5ab9d4;
  --teal-deep: #1a5a62;
  --gold: #b88a3a;
  --gold-soft: #d4a853;
  --gold-deep: #8a6020;
  --burgundy: #6a2030;
  --mint: #3a7a5a;
  --violet: #5a4a8a;
  /* Semantic colors */
  --evidence-high-bg: #d4edda;
  --evidence-high-fg: #155724;
  --evidence-mod-bg: #fff3cd;
  --evidence-mod-fg: #856404;
  --evidence-trad-bg: #d1ecf1;
  --evidence-trad-fg: #0c5460;
  /* Typography */
  --font-display: 'DM Serif Display', 'Playfair Display', Georgia, serif;
  --font-body: 'Lora', Georgia, 'Times New Roman', serif;
  --font-text: 'DM Serif Text', Georgia, serif;
  --font-heading: 'Playfair Display', Georgia, serif;
  --text-base: 1.125rem;
  --text-lg: 1.25rem;
  --text-xl: 1.5rem;
  --text-2xl: 1.875rem;
  --text-3xl: 2.25rem;
  --text-4xl: 3rem;
  --text-5xl: 3.75rem;
  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;
  /* Layout */
  --max-width: 52rem;
  --radius-sm: 4px;        /* sharper corners */
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-soft: 0 2px 8px rgba(26, 20, 14, 0.1);
  --shadow-medium: 0 4px 16px rgba(26, 20, 14, 0.15);
  --shadow-strong: 0 8px 32px rgba(26, 20, 14, 0.2);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--text-primary);
  background-color: var(--cream);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(184, 138, 58, 0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(42, 122, 130, 0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(200, 90, 74, 0.04) 0%, transparent 50%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Page container */
.page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-3xl) var(--space-xl);
  background: var(--cream);
  position: relative;
}

/* ═══════════════════════════════════════════════
   PAGE-BY-PAGE NAVIGATION
   ═══════════════════════════════════════════════ */
.page-view {
  display: none;
  animation: pageFadeIn 0.4s ease;
}
.page-view.active {
  display: block;
}
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Navigation controls */
.page-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--cream);
  border-top: 3px solid var(--gold);
  padding: var(--space-md) var(--space-xl);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 1000;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
}
.page-nav button {
  background: var(--burgundy);
  color: var(--cream);
  border: 2px solid var(--burgundy);
  padding: var(--space-sm) var(--space-lg);
  border-radius: 100px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
}
.page-nav button:hover:not(:disabled) {
  background: var(--coral);
  border-color: var(--coral);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(200, 90, 74, 0.3);
}
.page-nav button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.page-counter {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--burgundy);
  font-weight: 700;
}

/* ═══════════════════════════════════════════════
   TEXT SIZE CONTROLS
   ═══════════════════════════════════════════════ */
.text-controls {
  position: fixed;
  top: var(--space-md);
  right: var(--space-md);
  display: flex;
  gap: 8px;
  z-index: 2000;
  background: var(--cream);
  padding: 8px;
  border-radius: 100px;
  box-shadow: var(--shadow-medium);
  border: 2px solid var(--gold-soft);
}
.text-controls button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--burgundy);
  background: var(--cream);
  color: var(--burgundy);
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
}
.text-controls button:hover {
  background: var(--burgundy);
  color: var(--cream);
}
.text-controls button.active {
  background: var(--coral);
  border-color: var(--coral);
  color: white;
}

/* ═══════════════════════════════════════════════
   TITLE PAGE
   ═══════════════════════════════════════════════ */
.title-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-4xl) var(--space-xl);
}

.title-frame {
  position: relative;
  padding: var(--space-4xl) var(--space-3xl);
  border: 4px solid var(--gold);
  background: linear-gradient(135deg, rgba(245, 240, 230, 0.97), rgba(232, 223, 206, 0.95));
  box-shadow:
    var(--shadow-strong),
    inset 0 0 0 8px var(--cream),
    inset 0 0 0 11px var(--teal);
  max-width: 38rem;
  width: 100%;
}

.title-decoration {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
}
.title-decoration span {
  width: 16px;
  height: 16px;
  display: block;
  transform: rotate(45deg);
  border: 2px solid var(--ink);
}
.title-decoration span:nth-child(1) { background: var(--coral); }
.title-decoration span:nth-child(2) { background: var(--gold); }
.title-decoration span:nth-child(3) { background: var(--teal); }
.title-decoration span:nth-child(4) { background: var(--gold); }
.title-decoration span:nth-child(5) { background: var(--coral); }

.title-main {
  font-family: var(--font-display);
  font-size: var(--text-5xl);
  font-weight: 800;
  color: var(--burgundy);
  line-height: 1.05;
  margin-bottom: var(--space-md);
  letter-spacing: -0.02em;
  text-shadow: 3px 3px 0 var(--gold-deep);
}

.title-subtitle {
  font-family: var(--font-text);
  font-size: var(--text-xl);
  color: var(--teal-deep);
  font-style: italic;
  margin-bottom: var(--space-2xl);
  letter-spacing: 0.02em;
}

.title-divider {
  width: 14rem;
  height: 4px;
  background: linear-gradient(90deg, var(--coral), var(--gold), var(--teal));
  margin: var(--space-xl) auto;
  border-radius: 2px;
}

.title-attribution {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  color: var(--text-secondary);
  line-height: 1.8;
  font-weight: 600;
}

.title-attribution strong {
  color: var(--burgundy);
  font-weight: 700;
}

.title-compiled {
  font-family: var(--font-text);
  font-size: var(--text-xl);
  color: var(--text-primary);
  margin-top: var(--space-sm);
  font-weight: 700;
}

/* ═══════════════════════════════════════════════
   TABLE OF CONTENTS
   ═══════════════════════════════════════════════ */
.toc {
  background: linear-gradient(135deg, var(--cream-dark), var(--cream-deeper));
  border: 3px solid var(--gold);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  margin-bottom: var(--space-3xl);
  box-shadow: var(--shadow-soft);
}

.toc-title {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  color: var(--burgundy);
  text-align: center;
  margin-bottom: var(--space-xl);
  font-weight: 800;
}

.toc-list {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md) var(--space-2xl);
}

.toc-list li {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
}

.toc-number {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--coral);
  min-width: 1.5rem;
  font-weight: 700;
}

.toc-list a {
  color: var(--text-primary);
  text-decoration: none;
  font-size: var(--text-base);
  border-bottom: 2px dotted transparent;
  transition: all 0.2s;
  padding: 2px 4px;
  border-radius: 4px;
  font-weight: 600;
}

.toc-list a:hover {
  color: var(--burgundy);
  border-bottom-color: var(--coral);
  background: rgba(212, 168, 83, 0.1);
}

.toc-list a .toc-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  display: block;
  margin-top: 2px;
  font-weight: 400;
}

/* ═══════════════════════════════════════════════
   RECIPE PAGES
   ═══════════════════════════════════════════════ */
.recipe-header {
  text-align: center;
  margin-bottom: var(--space-3xl);
  padding-bottom: var(--space-xl);
  border-bottom: 3px solid var(--gold);
}

.recipe-number {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: var(--coral);
  margin-bottom: var(--space-xs);
  font-weight: 700;
}

.recipe-title {
  font-family: var(--font-heading);
  font-size: var(--text-4xl);
  font-weight: 800;
  color: var(--burgundy);
  margin-bottom: var(--space-sm);
  line-height: 1.15;
}

.recipe-subtitle {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: var(--space-md);
}

.recipe-meta {
  display: flex;
  gap: var(--space-lg);
  flex-wrap: wrap;
  justify-content: center;
  margin-top: var(--space-md);
  font-size: 0.95rem;
  color: var(--text-muted);
}

.recipe-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--cream-dark);
  padding: var(--space-xs) var(--space-md);
  border-radius: 100px;
  border: 2px solid var(--cream-deeper);
  font-weight: 600;
}

.recipe-tag {
  display: inline-block;
  background: var(--cream-dark);
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: var(--space-xs) var(--space-md);
  border-radius: 100px;
  margin: var(--space-xs);
  border: 2px solid var(--cream-deeper);
  font-weight: 600;
}

/* ═══════════════════════════════════════════════
   WHY THIS HEALS + EVIDENCE
   ═══════════════════════════════════════════════ */
.heals-callout {
  background: linear-gradient(135deg, rgba(42, 122, 130, 0.07), rgba(58, 122, 90, 0.05));
  border-left: 6px solid var(--teal);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-lg) var(--space-xl);
  margin-bottom: var(--space-2xl);
  box-shadow: var(--shadow-soft);
  position: relative;
}

.heals-callout-title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  color: var(--teal-deep);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 700;
}

.heals-callout p {
  color: var(--text-secondary);
  font-size: var(--text-base);
  line-height: 1.7;
}

/* Evidence badge */
.evidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-left: auto;
}
.evidence-high { background: var(--evidence-high-bg); color: var(--evidence-high-fg); border: 2px solid var(--evidence-high-fg); }
.evidence-moderate { background: var(--evidence-mod-bg); color: var(--evidence-mod-fg); border: 2px solid var(--evidence-mod-fg); }
.evidence-traditional { background: var(--evidence-trad-bg); color: var(--evidence-trad-fg); border: 2px solid var(--evidence-trad-fg); }

/* ═══════════════════════════════════════════════
   INGREDIENTS
   ═══════════════════════════════════════════════ */
.ingredients-box {
  background: linear-gradient(135deg, var(--cream-dark), var(--cream-deeper));
  border: 3px solid var(--gold);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-2xl);
  box-shadow: var(--shadow-soft);
}

.ingredients-title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  color: var(--burgundy);
  margin-bottom: var(--space-md);
  font-weight: 700;
}

.ingredients-list {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm) var(--space-xl);
}

.ingredients-list li {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  font-size: var(--text-base);
  line-height: 1.5;
  font-weight: 600;
}

.ingredient-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
  margin-top: 6px;
  border: 2px solid var(--ink);
}
.ingredient-dot.coral { background: var(--coral); }
.ingredient-dot.teal { background: var(--teal); }
.ingredient-dot.gold { background: var(--gold); }

.pantry-icon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 700;
  border: 2px solid transparent;
}

.pantry-green { background: var(--evidence-high-bg); color: var(--evidence-high-fg); border-color: var(--evidence-high-fg); }
.pantry-yellow { background: var(--evidence-mod-bg); color: var(--evidence-mod-fg); border-color: var(--evidence-mod-fg); }
.pantry-red { background: rgba(232, 120, 106, 0.15); color: var(--coral-deep); border-color: var(--coral-deep); }

/* ═══════════════════════════════════════════════
   STEPS
   ═══════════════════════════════════════════════ */
.steps-section { margin-bottom: var(--space-3xl); }

.steps-title {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  color: var(--burgundy);
  margin-bottom: var(--space-xl);
  text-align: center;
  font-weight: 800;
}

.step {
  display: flex;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
  align-items: flex-start;
}

.step-number {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  color: var(--cream);
  background: var(--coral);
  width: 3.5rem;
  height: 3.5rem;
  min-width: 3.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(200, 90, 74, 0.3);
}

.step-content { flex: 1; }

.step-content p {
  color: var(--text-primary);
  font-size: var(--text-base);
  line-height: 1.7;
  margin-bottom: var(--space-sm);
}

.step-time {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--cream-dark);
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 6px 14px;
  border-radius: 100px;
  margin-top: var(--space-sm);
  border: 2px solid var(--cream-deeper);
  font-weight: 600;
}

/* ═══════════════════════════════════════════════
   CONTEXT BLOCKS — with icons + waiting-step distinction
   ═══════════════════════════════════════════════ */
.context-block {
  margin: var(--space-lg) 0 var(--space-xl) 3rem;
  padding: var(--space-lg) var(--space-xl) var(--space-lg) 3.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  position: relative;
}

.context-icon {
  position: absolute;
  left: -1.5rem;
  top: var(--space-lg);
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  background: var(--cream);
  border: 3px solid;
  box-shadow: var(--shadow-soft);
}

/* Context types with masculine palette */
.context-health { background: linear-gradient(135deg, rgba(42, 122, 130, 0.07), rgba(58, 122, 90, 0.04)); border-left: 6px solid var(--teal); }
.context-health .context-icon { border-color: var(--teal); color: var(--teal-deep); }
.context-health .context-label { color: var(--teal-deep); }

.context-history { background: linear-gradient(135deg, rgba(184, 138, 58, 0.08), rgba(212, 168, 83, 0.05)); border-left: 6px solid var(--gold); }
.context-history .context-icon { border-color: var(--gold); color: var(--gold-deep); }
.context-history .context-label { color: var(--gold-deep); }

.context-islamic { background: linear-gradient(135deg, rgba(106, 32, 48, 0.06), rgba(138, 58, 74, 0.04)); border-left: 6px solid var(--burgundy); }
.context-islamic .context-icon { border-color: var(--burgundy); color: var(--burgundy); }
.context-islamic .context-label { color: var(--burgundy); }

.context-funfact { background: linear-gradient(135deg, rgba(200, 90, 74, 0.06), rgba(224, 160, 144, 0.04)); border-left: 6px solid var(--coral); }
.context-funfact .context-icon { border-color: var(--coral); color: var(--coral-deep); }
.context-funfact .context-label { color: var(--coral-deep); }

.context-cultural { background: linear-gradient(135deg, rgba(90, 74, 138, 0.06), rgba(149, 128, 201, 0.04)); border-left: 6px solid var(--violet); }
.context-cultural .context-icon { border-color: var(--violet); color: var(--violet); }
.context-cultural .context-label { color: var(--violet); }

.context-science { background: linear-gradient(135deg, rgba(58, 122, 90, 0.07), rgba(94, 184, 148, 0.05)); border-left: 6px solid var(--mint); }
.context-science .context-icon { border-color: var(--mint); color: var(--mint); }
.context-science .context-label { color: var(--mint); }

/* Waiting step styling */
.context-block.waiting-step {
  background: repeating-linear-gradient(
    135deg,
    rgba(212, 168, 83, 0.06),
    rgba(212, 168, 83, 0.06) 10px,
    rgba(212, 168, 83, 0.02) 10px,
    rgba(212, 168, 83, 0.02) 20px
  );
  border-left-style: dashed;
}

.context-label {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-xs);
  font-weight: 800;
}

.context-block p {
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.context-block p:last-child { margin-bottom: 0; }

/* ═══════════════════════════════════════════════
   SAFETY WARNING
   ═══════════════════════════════════════════════ */
.safety-warning {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: linear-gradient(135deg, rgba(200, 90, 74, 0.1), rgba(200, 90, 74, 0.05));
  border: 3px solid var(--coral);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  margin: var(--space-lg) 0 var(--space-xl) 3rem;
  color: var(--coral-deep);
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(200, 90, 74, 0.15);
}

.safety-warning i {
  font-size: 1.4rem;
  flex-shrink: 0;
  color: var(--coral);
}

.safety-warning p {
  font-size: 0.95rem;
  margin: 0;
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════
   VISUALS
   ═══════════════════════════════════════════════ */
.visual-container {
  margin: var(--space-lg) 0 var(--space-xl) 3rem;
  text-align: center;
}

.visual-frame {
  display: inline-block;
  background: var(--cream);
  border: 3px solid var(--cream-deeper);
  border-radius: var(--radius-md);
  padding: var(--space-xs);
  box-shadow: var(--shadow-soft);
  max-width: 100%;
  overflow: hidden;
}

.visual-frame img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
}

.visual-caption {
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: var(--space-xs);
}

/* SVG diagrams */
.svg-diagram {
  margin: var(--space-lg) 0 var(--space-xl) 3rem;
  text-align: center;
  background: var(--cream);
  border: 3px solid var(--cream-deeper);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-soft);
  position: relative;
}

.svg-diagram svg { max-width: 100%; height: auto; }

.diagram-placeholder {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.5;
  margin: 0;
  padding: var(--space-md);
  background: linear-gradient(135deg, rgba(74, 159, 168, 0.04), rgba(122, 184, 154, 0.03));
  border: 2px dashed var(--teal-soft);
  border-radius: var(--radius-sm);
  text-align: left;
}

.diagram-placeholder::before {
  content: '📊';
  display: block;
  font-size: 1.5rem;
  margin-bottom: var(--space-sm);
  text-align: center;
}

.diagram-caption {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: var(--space-sm);
}

/* ═══════════════════════════════════════════════
   CLICKABLE TERMS
   ═══════════════════════════════════════════════ */
.clickable-term {
  color: var(--burgundy);
  border-bottom: 2px dotted var(--coral);
  cursor: pointer;
  font-weight: 700;
  transition: all 0.2s;
  position: relative;
}

.clickable-term:hover {
  background: rgba(212, 168, 83, 0.15);
  border-bottom-color: var(--burgundy);
  color: var(--coral-deep);
}

.term-tooltip {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--burgundy);
  color: var(--cream);
  padding: 12px 16px;
  border-radius: 8px;
  width: 280px;
  font-size: 0.85rem;
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
  transition: all 0.3s;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.term-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--burgundy);
}

.clickable-term:hover .term-tooltip {
  visibility: visible;
  opacity: 1;
}

/* Term popup modal */
#term-popup {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10000;
  background: rgba(26, 20, 14, 0.6);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

#term-popup.active {
  display: flex;
  animation: popupFadeIn 0.3s ease;
}

@keyframes popupFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

#term-popup-content {
  background: var(--cream);
  border: 3px solid var(--burgundy);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-strong);
  position: relative;
  animation: popupSlideIn 0.3s ease;
}

@keyframes popupSlideIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.term-popup-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 2rem;
  height: 2rem;
  background: var(--cream-dark);
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.term-popup-close:hover {
  background: var(--burgundy);
  color: white;
  border-color: var(--burgundy);
}

#term-popup-content h3 {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  color: var(--burgundy);
  margin-bottom: var(--space-md);
  padding-right: var(--space-xl);
  font-weight: 700;
}

.term-popup-description {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: var(--space-md);
  font-weight: 600;
}

.term-popup-extract {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: var(--space-lg);
}

/* ═══════════════════════════════════════════════
   FOOTER + WHERE TO FIND
   ═══════════════════════════════════════════════ */
.book-footer {
  margin-top: var(--space-4xl);
  padding-top: var(--space-2xl);
  border-top: 4px double var(--gold);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.book-footer p { margin-bottom: var(--space-sm); }

/* Squiggle divider */
.squiggle-divider {
  height: 18px;
  width: 180px;
  margin: var(--space-2xl) auto;
  background: repeating-linear-gradient(
    90deg,
    var(--coral) 0px, var(--coral) 12px,
    transparent 12px, transparent 18px,
    var(--gold) 18px, var(--gold) 30px,
    transparent 30px, transparent 36px,
    var(--teal) 36px, var(--teal) 48px,
    transparent 48px, transparent 54px
  );
  border-radius: 9px;
  opacity: 0.6;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */
@media (max-width: 640px) {
  :root {
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    --text-5xl: 2.75rem;
  }

  .page { padding: var(--space-xl) var(--space-md); }
  .title-frame { padding: var(--space-2xl) var(--space-lg); }
  .ingredients-list, .toc-list { grid-template-columns: 1fr; }
  .step { gap: var(--space-md); }
  .step-number { font-size: var(--text-2xl); min-width: 2.5rem; width: 2.5rem; height: 2.5rem; }
  .context-block { margin-left: 2.5rem; }
  .text-controls { top: auto; bottom: 80px; right: var(--space-sm); }
}

/* ═══════════════════════════════════════════════
   PRINT STYLES
   ═══════════════════════════════════════════════ */
@media print {
  body { background: white; font-size: 14pt; }
  .page { max-width: 100%; padding: 1in; }
  .context-block { break-inside: avoid; }
  .step { break-inside: avoid; }
  .page-nav, .text-controls, .page-view:not(.active) { display: none !important; }
  .page-view.active { display: block !important; }
}

/* ---------- Ingredient Quantities ---------- */
.ingredient-qty {
  display: inline-block;
  background: var(--cream);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 100px;
  margin-left: auto;
  font-weight: 600;
  border: 1px solid var(--cream-deeper);
  white-space: nowrap;
}

/* ---------- Term Modal ---------- */
.term-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(42, 32, 24, 0.8);
  z-index: 3000;
  backdrop-filter: blur(4px);
}

.term-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.term-modal-content {
  background: var(--cream);
  padding: var(--space-2xl);
  border-radius: var(--radius-lg);
  max-width: 32rem;
  width: 90%;
  box-shadow: var(--shadow-strong);
  border: 3px solid var(--gold);
  position: relative;
}

.term-modal-close {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-md);
  font-size: 2rem;
  cursor: pointer;
  color: var(--text-muted);
}

.term-modal-close:hover {
  color: var(--coral-deep);
}

.term-modal-content h3 {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  color: var(--burgundy);
  margin-bottom: var(--space-md);
}

.term-modal-content p {
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ---------- Where to Find Ingredients ---------- */
.ingredients-section {
  margin: var(--space-3xl) 0;
}

/* Preparation notes reuse the recipe and physical audit, with no efficacy claims. */
.recipe-note { margin: var(--space-xl) 0; padding: var(--space-lg); border-left: 4px solid var(--teal); background: var(--cream-dark); border-radius: var(--radius-md); }
.recipe-note-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; color: var(--teal); }
.recipe-note h3 { margin: .5rem 0 1rem; }
.recipe-note ul { padding-left: 1.4rem; line-height: 1.8; }
.term-popup-panel { position: relative; max-width: 32rem; width: 100%; }
#term-popup-content { padding-top: 3.5rem; }
.term-popup-close { width: 2.5rem; height: 2.5rem; }

/* A visible keyboard destination without permanent browser-default link styling. */
.skip-link { position: fixed; top: 1rem; left: 1rem; z-index: 10001; padding: .7rem 1rem; background: var(--cream); color: var(--burgundy); border: 2px solid var(--burgundy); border-radius: var(--radius-md); font-weight: 700; transform: translateY(-200%); }
.skip-link:focus { transform: translateY(0); outline: 3px solid var(--teal); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
