/* =============================================================================
   The Morphism Zoo - Styles
   A whimsical, children's book aesthetic for recursion schemes
   ============================================================================= */

:root {
  --zoo-cream: #FFF8E7;
  --zoo-warm-white: #FFFDF7;
  --zoo-charcoal: #2D3436;
  --zoo-orange: #FF6B35;
  --zoo-teal: #00B4A0;
  --zoo-purple: #845EC2;
  --zoo-yellow: #FFD93D;
  --zoo-pink: #FF78AE;
  --zoo-blue: #4D8BF5;
  --zoo-light-gray: #F0EDE5;
  --zoo-green: #2ECC71;
}

* { box-sizing: border-box; }

html { font-size: 18px; }

body {
  margin: 0;
  padding: 0;
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', cursive, sans-serif;
  font-weight: 400;
  background: var(--zoo-cream);
  color: var(--zoo-charcoal);
  line-height: 1.6;
}

/* =============================================================================
   Book Layout — one page, centred
   ============================================================================= */

.zoo-book {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* -- The page, centred under the top bar ----------------------------------- */

.page-frame {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

/* -- Book page (shared by cover + chapter) --------------------------------- */

.book-page {
  background: var(--zoo-warm-white);
  border: 4px solid var(--zoo-charcoal);
  border-radius: 1.5rem;
  min-height: 100%;
}

/* =============================================================================
   Cover Page
   ============================================================================= */

.cover-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  min-height: 100%;
}

.cover-content {
  text-align: center;
  max-width: 600px;
  width: 100%;
}

.cover-title {
  font-size: 3.2rem;
  margin: 0 0 0.5rem 0;
  color: var(--zoo-charcoal);
  text-shadow: 3px 3px 0 white;
}

.cover-subtitle {
  font-size: 1.3rem;
  margin: 0 0 2.5rem 0;
  font-style: italic;
  opacity: 0.85;
}

.cover-dag {
  max-width: 480px;
  margin: 0 auto;
  padding: 2rem;
  background: radial-gradient(ellipse at center, rgba(255,215,61,0.12) 0%, transparent 70%);
  border-radius: 50%;
}

.cover-hint {
  margin-top: 2.5rem;
  font-size: 0.9rem;
  font-style: italic;
  opacity: 0.5;
  letter-spacing: 0.03em;
}

.museum-link-text {
  font-family: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  font-style: italic;
  color: #888;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, color 0.2s ease;
  letter-spacing: 0.03em;
}

.museum-link-text:hover {
  color: #555;
  border-bottom-color: #999;
}

/* =============================================================================
   The Museum's invitation, folded into the cover
   ============================================================================= */

.museum-invite-question {
  font-size: 1.15rem;
  font-style: italic;
  margin: 0 0 2.5rem 0;
  opacity: 0.75;
}

.museum-invite-subtitle {
  font-family: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  font-size: 0.95rem;
  font-style: italic;
  color: #777;
  margin: 0 0 2.5rem 0;
}

/* =============================================================================
   Chapter Page
   ============================================================================= */

.chapter-page {
  padding: 1.5rem 2rem 2rem;
}

.chapter-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.chapter-title {
  font-size: 1.8rem;
  margin: 0 0 0.25rem 0;
  text-shadow: 1px 1px 0 white;
}

.chapter-tagline {
  margin: 0;
  font-size: 1rem;
  font-style: italic;
  opacity: 0.8;
}

/* =============================================================================
   Morphism DAG SVG
   ============================================================================= */

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

.dag-node {
  /* Scale about the node's own centre. An SVG element's default origin is
     the viewBox origin, so without these the node slides away from the
     pointer, loses :hover, slides back, and oscillates (worst in Safari). */
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.dag-node circle {
  transition: filter 0.15s ease;
  filter: drop-shadow(2px 3px 1px rgba(45,52,54,0.25));
}

.dag-node:hover {
  transform: scale(1.12);
}

.dag-node:hover circle {
  filter: brightness(1.08) drop-shadow(5px 8px 3px rgba(45,52,54,0.35));
}

.dag-node.active circle {
  filter: drop-shadow(0 0 10px rgba(0,0,0,0.35));
}

/* =============================================================================
   Chapter Content (panels area)
   ============================================================================= */


/* =============================================================================
   Comic Strip - All panels visible
   ============================================================================= */

.comic-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.comic-panel {
  background: white;
  border: 4px solid var(--zoo-charcoal);
  border-radius: 1rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 4px 4px 0 var(--zoo-charcoal);
  transition: transform 0.15s ease;
}

.comic-panel:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--zoo-charcoal);
}

/* =============================================================================
   Container & Header
   ============================================================================= */

.zoo-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.zoo-header {
  text-align: center;
  padding: 3rem 1rem;
  background: linear-gradient(135deg, var(--zoo-yellow) 0%, var(--zoo-orange) 100%);
  border-radius: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 8px 32px rgba(255, 107, 53, 0.3);
}

.zoo-header h1 {
  font-size: 3.5rem;
  margin: 0 0 0.5rem 0;
  color: var(--zoo-charcoal);
  text-shadow: 3px 3px 0 white;
  letter-spacing: 0.05em;
  animation: bounce 3s ease-in-out infinite;
}

.zoo-header .subtitle {
  font-size: 1.4rem;
  margin: 0;
  color: var(--zoo-charcoal);
  opacity: 0.9;
}

.zoo-intro {
  max-width: 800px;
  margin: 0 auto 3rem auto;
  text-align: center;
  font-size: 1.1rem;
  padding: 1.5rem;
  background: var(--zoo-warm-white);
  border-radius: 1rem;
  border: 3px dashed var(--zoo-teal);
}

/* =============================================================================
   Zoo Grid
   ============================================================================= */

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

/* =============================================================================
   Exhibit Cards
   ============================================================================= */

.zoo-exhibit {
  background: var(--zoo-warm-white);
  border-radius: 1.5rem;
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  border: 4px solid transparent;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.zoo-exhibit.clickable:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.exhibit-cata { border-color: var(--zoo-orange); }
.exhibit-ana { border-color: var(--zoo-blue); }
.exhibit-hylo { border-color: var(--zoo-purple); }
.exhibit-para { border-color: var(--zoo-teal); }
.exhibit-apo { border-color: var(--zoo-pink); }
.exhibit-histo { border-color: var(--zoo-yellow); }
.exhibit-futu { border-color: var(--zoo-orange); }
.exhibit-zygo { border-color: var(--zoo-green); }

.exhibit-header h2 {
  font-size: 1.3rem;
  margin: 0 0 0.25rem 0;
}

.exhibit-header .tagline {
  font-size: 0.9rem;
  margin: 0;
  opacity: 0.7;
  font-style: italic;
}

.zoo-exhibit .description {
  font-size: 0.9rem;
  margin: 1rem 0;
  line-height: 1.5;
}

.click-hint {
  text-align: center;
  padding: 0.75rem;
  background: linear-gradient(135deg, var(--zoo-yellow) 0%, var(--zoo-orange) 100%);
  border-radius: 0.75rem;
  font-weight: bold;
  font-size: 0.95rem;
}

/* =============================================================================
   Footer
   ============================================================================= */

.zoo-footer {
  text-align: center;
  padding: 3rem 1rem;
  margin-top: 3rem;
  opacity: 0.8;
  font-size: 0.95rem;
}

/* =============================================================================
   Storybook Overlay
   ============================================================================= */

.storybook-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.storybook {
  background: var(--zoo-cream);
  border-radius: 1.5rem;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  border: 6px solid var(--zoo-charcoal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.storybook-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  border: 3px solid var(--zoo-charcoal);
  background: var(--zoo-yellow);
  color: var(--zoo-charcoal);
  font-size: 1.8rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease;
  z-index: 10;
  line-height: 1;
}

.storybook-close:hover {
  transform: scale(1.1) rotate(90deg);
  background: var(--zoo-orange);
}

.storybook-header {
  padding: 1.25rem 4rem 1rem 1.5rem;
  background: linear-gradient(135deg, var(--zoo-yellow) 0%, var(--zoo-orange) 100%);
  border-bottom: 4px solid var(--zoo-charcoal);
}

.storybook-header h2 {
  margin: 0;
  font-size: 1.4rem;
  color: var(--zoo-charcoal);
  text-shadow: 1px 1px 0 white;
}

.storybook-page {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* =============================================================================
   Story Page Content
   ============================================================================= */

.story-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.speech-bubble {
  background: var(--zoo-yellow);
  border: 3px solid var(--zoo-charcoal);
  border-radius: 1.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  position: relative;
  font-size: 0.95rem;
  max-width: 100%;
  text-align: center;
  box-shadow: 3px 3px 0 var(--zoo-charcoal);
}

.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border: 10px solid transparent;
  border-top-color: var(--zoo-charcoal);
  border-bottom: 0;
}

.speech-bubble::before {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border: 7px solid transparent;
  border-top-color: var(--zoo-yellow);
  border-bottom: 0;
}

.story-diagram {
  width: 100%;
  max-width: 400px;
  height: auto;
  margin: 0.5rem 0;
}

.page-caption {
  font-size: 1rem;
  font-style: italic;
  color: var(--zoo-charcoal);
  opacity: 0.7;
  margin: 0.5rem 0 0 0;
  text-align: center;
}

/* =============================================================================
   Code Section with Egg Reveal
   ============================================================================= */

.code-section {
  background: var(--zoo-light-gray);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-top: 1rem;
}

.code-section h3 {
  margin: 0 0 1rem 0;
  color: var(--zoo-purple);
  font-size: 1.3rem;
  text-align: center;
}

.code-example {
  margin-bottom: 1.5rem;
}

.code-example h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  color: var(--zoo-charcoal);
}

.code-block {
  background: var(--zoo-charcoal);
  color: #F8F8F2;
  padding: 1rem;
  border-radius: 0.75rem;
  overflow-x: auto;
  font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  margin: 0;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3);
}

.code-block.usage {
  border-left: 4px solid var(--zoo-teal);
}

.code-block.signature {
  border-left: 4px solid var(--zoo-purple);
}

/* Egg reveal container */
.signature-container {
  text-align: center;
}

.signature-egg {
  display: flex;
  justify-content: center;
}

.egg-button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, #F5F0E6 0%, #E8E0D0 100%);
  border: 4px solid var(--zoo-charcoal);
  border-radius: 3rem;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 4px 4px 0 var(--zoo-charcoal);
}

.egg-button:hover {
  transform: translate(-2px, -2px) scale(1.02);
  box-shadow: 6px 6px 0 var(--zoo-charcoal);
}

.egg-button:active {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 var(--zoo-charcoal);
}

.egg-icon {
  font-size: 2rem;
  animation: wiggle 2s ease-in-out infinite;
}

.egg-text {
  color: var(--zoo-charcoal);
  font-weight: bold;
}

@keyframes wiggle {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
}

/* Revealed signature */
.signature-revealed {
  animation: hatch 0.5s ease-out;
}

.signature-revealed h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  color: var(--zoo-purple);
}

.signature-explained {
  margin: 1rem 0 0 0;
  font-size: 0.95rem;
  line-height: 1.5;
  padding: 1rem;
  background: white;
  border-radius: 0.5rem;
  border-left: 4px solid var(--zoo-purple);
}

@keyframes hatch {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* =============================================================================
   Navigation
   ============================================================================= */

.storybook-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--zoo-light-gray);
  border-top: 4px solid var(--zoo-charcoal);
}

.nav-btn {
  background: var(--zoo-purple);
  color: white;
  border: 3px solid var(--zoo-charcoal);
  border-radius: 2rem;
  padding: 0.6rem 1.5rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  box-shadow: 3px 3px 0 var(--zoo-charcoal);
}

.nav-btn:hover:not(.disabled) {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--zoo-charcoal);
  background: var(--zoo-pink);
}

.nav-btn:active:not(.disabled) {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 var(--zoo-charcoal);
}

.nav-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-dots {
  display: flex;
  gap: 0.6rem;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--zoo-charcoal);
  background: white;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease, background 0.15s ease;
}

.dot:hover {
  transform: scale(1.2);
}

.dot.active {
  background: var(--zoo-purple);
  transform: scale(1.3);
}

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 768px) {
  .cover-title { font-size: 2rem; }
  .chapter-title { font-size: 1.4rem; }
  .chapter-page { padding: 1rem; }

  .comic-strip { grid-template-columns: 1fr; gap: 1rem; }
  .comic-panel { padding: 0.75rem; }
  .speech-bubble { font-size: 0.9rem; padding: 0.5rem 0.75rem; }

  .egg-button { padding: 0.75rem 1rem; }
  .egg-icon { font-size: 1.5rem; }
}

/* =============================================================================
   Animations
   ============================================================================= */

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes pageFlip {
  0% { opacity: 0; transform: translateX(30px); }
  100% { opacity: 1; transform: translateX(0); }
}

.story-page, .code-page {
  animation: pageFlip 0.3s ease-out;
}

/* =============================================================================
   Math Book View — Tufte-inspired type substitution pages
   Modelled on the Anscombe's Quartet demo from hylograph-music:
   small-caps titles, Palatino serif, #fffff8 background, thin rules
   ============================================================================= */

.math-chapter {
  font-family: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  background: #fffff8 !important;
  border: none !important;
  border-radius: 0 !important;
  line-height: 1.5;
  padding: 2.5rem 2rem;
}

.museum-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.museum-label {
  font-variant: small-caps;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: #999;
}

/* Paper badge on Hylo museum page */
.museum-paper-badge {
  text-align: center;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e8e4dc;
}

.paper-badge-btn {
  display: inline-block;
  background: none;
  border: 1px solid #ccc;
  font-family: 'STIX Two Text', 'Computer Modern', Georgia, serif;
  font-size: 0.7rem;
  font-variant: small-caps;
  letter-spacing: 0.1em;
  color: #999;
  cursor: pointer;
  padding: 0.25rem 0.8rem;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.paper-badge-btn:hover {
  color: #555;
  border-color: #888;
}

/* "See the algebra" button on the story view */
.algebra-link {
  text-align: center;
  margin-top: 1.5rem;
}

.math-button {
  font-family: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  padding: 0.4rem 1.2rem;
  border: 1px solid var(--zoo-charcoal);
  background: transparent;
  color: var(--zoo-charcoal);
  cursor: pointer;
  transition: all 0.15s ease;
}

.math-button:hover {
  background: var(--zoo-charcoal);
  color: #fffff8;
}

/* =============================================================================
   Math page layout
   ============================================================================= */

.math-page {
  max-width: 700px;
  margin: 0 auto;
}

.math-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #ddd;
}

.math-title {
  font-size: 2rem;
  font-weight: 400;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  margin: 0 0 0.5rem 0;
  color: #111;
}

.math-tagline {
  font-size: 1rem;
  font-style: italic;
  color: #555;
  margin: 0 0 0.75rem 0;
}

.math-general {
  margin: 0;
  font-size: 0.85rem;
  color: #555;
}

.math-general code {
  font-family: 'Fira Code', Monaco, Consolas, monospace;
  font-size: 0.8rem;
}

/* =============================================================================
   Usage code section
   ============================================================================= */

.math-section {
  margin-bottom: 2rem;
}

.math-code {
  background: transparent;
  color: #111;
  padding: 1rem 1.25rem;
  font-family: 'Fira Code', Monaco, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  margin: 0;
  overflow-x: auto;
}

/* =============================================================================
   Thin rule between code and substitution steps
   ============================================================================= */

.math-rule {
  border: none;
  border-top: 1px solid #ddd;
  margin: 0 0 2rem 0;
}

/* =============================================================================
   Substitution banner (like Anscombe stats bar)
   ============================================================================= */

.math-substitution-banner {
  text-align: center;
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 2.5rem;
}

.banner-sep {
  color: #ccc;
}

.banner-subs {
  font-family: 'Fira Code', Monaco, Consolas, monospace;
  font-size: 0.8rem;
  color: #111;
  background: none;
  padding: 0;
}

/* =============================================================================
   Steps
   ============================================================================= */

.math-step {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #e8e4dc;
}

.math-step:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.step-number {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid #aaa;
  color: #555;
  font-size: 0.7rem;
  font-family: 'Fira Code', monospace;
  margin-top: 0.35rem;
}

.step-content {
  flex: 1;
  min-width: 0;
}

.step-signature {
  background: transparent;
  color: #111;
  padding: 0.6rem 0.9rem;
  font-family: 'Fira Code', Monaco, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.5;
  margin: 0 0 0.6rem 0;
  overflow-x: auto;
  border-left: 2px solid #ccc;
}

.step-annotation {
  margin: 0;
  font-size: 0.9rem;
  color: #555;
  line-height: 1.6;
}

/* =============================================================================
   Punchline
   ============================================================================= */

.math-punchline {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #ddd;
}

.math-punchline blockquote {
  margin: 0;
  padding: 0;
  font-size: 1.05rem;
  font-style: italic;
  color: #111;
  line-height: 1.7;
}

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 768px) {
  .math-page { padding: 0 0.5rem; }
  .math-title { font-size: 1.5rem; }
  .step-signature { font-size: 0.68rem; }
  .math-step { gap: 0.75rem; }
  .math-code { font-size: 0.7rem; padding: 0.75rem; }
}

/* =============================================================================
   Plates — HATS-drawn frames of a trace (Zoo.Plate). Positions come from
   hylograph-layout; only colour and type live here. --creature is set on
   each plate from the creature's record.
   ============================================================================= */

.plate-figure { margin: 0; width: 100%; display: flex; flex-direction: column; align-items: center; }
.plate-container { width: 100%; display: flex; justify-content: center; }
.plate { max-width: 100%; height: auto; overflow: visible; }

.plate-edge { stroke: var(--zoo-charcoal); stroke-width: 4; stroke-linecap: round; }
.plate--running .plate-edge--pending { stroke: #c8c4bc; }

.plate-node { stroke: var(--zoo-charcoal); stroke-width: 3; transition: fill 0.3s ease, opacity 0.3s ease; }
.plate-node--branch { fill: var(--creature); }
.plate-node--leaf { fill: var(--zoo-teal); }
.plate--running .plate-node--pending { opacity: 0.3; }
.plate-node--done.plate-node--branch { fill: var(--zoo-pink); }
.plate-node--active.plate-node--branch { fill: var(--zoo-pink); }
.plate--downward .plate-node--active.plate-node--root.plate-node--branch,
.plate--downward .plate-node--done.plate-node--root.plate-node--branch { fill: var(--zoo-purple); }

.plate-halo { fill: var(--zoo-yellow); opacity: 0.55; stroke: none; }

.plate-label {
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', cursive;
  font-weight: 700;
  font-size: 24px;
  text-anchor: middle;
  dominant-baseline: central;
  fill: white;
  stroke: var(--zoo-charcoal);
  stroke-width: 2;
  paint-order: stroke fill;
  pointer-events: none;
}
.plate--running .plate-label--pending { opacity: 0.35; }

/* The scrubber: back, play/pause, forward, and where we are. */
.scrubber {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', cursive;
}
.scrubber-button {
  font: inherit;
  font-size: 0.9rem;
  min-width: 2.2rem;
  padding: 0.2rem 0.5rem;
  background: var(--zoo-warm-white);
  border: 3px solid var(--zoo-charcoal);
  border-radius: 0.6rem;
  box-shadow: 2px 2px 0 var(--zoo-charcoal);
  cursor: pointer;
}
.scrubber-button:disabled { opacity: 0.35; cursor: default; }
.scrubber-play { background: var(--zoo-yellow); }
.scrubber-index { font-size: 0.85rem; margin-left: 0.5rem; color: #555; }


/* =============================================================================
   The picture-book skin for Specimen: CSS over Specimen's own class names,
   and nothing more (brief §5.4). Bigger, rounder, the Zoo's colours.
   ============================================================================= */

.specimen-doc.picture-book {
  --gutter: 0rem;
  --rhs-gutter: 0rem;
  --ink: var(--zoo-charcoal);
  --soft-ink: var(--zoo-charcoal);
  --margin: #8a877e;
  --hairline: transparent;
  --accent: var(--zoo-orange);
  width: 100%;
  margin-top: 0.75rem;
  background: var(--zoo-warm-white);
  border: 3px dashed var(--zoo-charcoal);
  border-radius: 1rem;
  padding: 0.75rem 1rem;
}
.picture-book .specimen-stack { column-gap: 0.5rem; }
.picture-book .row > .label { display: none; }
.picture-book .row .name,
.picture-book .row .sep,
.picture-book .row .type,
.picture-book .row > .defn-body {
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', cursive;
  font-size: 0.95rem;
}
.picture-book .row > .name { color: var(--zoo-orange); font-weight: 700; }
.picture-book .row > .defn-body { border-left: 3px solid var(--zoo-yellow); color: var(--zoo-charcoal); }
.picture-book .marginalia, .picture-book .doc { font-family: 'Comic Sans MS', 'Comic Neue', cursive; font-style: normal; }

/* =============================================================================
   Museum: Specimen code and Sigil signatures in the Tufte page
   ============================================================================= */

.specimen-doc.museum-code {
  --gutter: 4.5rem;
  --rhs-gutter: 0rem;
  --paper: transparent;
  margin-bottom: 1.25rem;
}
.museum-code .row .name,
.museum-code .row .sep,
.museum-code .row .type,
.museum-code .row > .defn-body { font-size: 0.78rem; }

.math-general .sigil-signature,
.step-signature .sigil-signature { --font-mono: 'JetBrains Mono', 'Fira Code', Monaco, monospace; text-align: left; }
.math-general .sigil-signature { display: inline-block; }
.sigil-type .sig-full, .sigil-type .sig-body { display: inline; }
.sigil-type .sig-body { border: none; padding: 0; margin: 0; }
.step-change { display: flex; align-items: baseline; gap: 0.35rem; flex-wrap: wrap; }
.sigil-unparsed { color: #b03a2e; }

.step-changes {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  font-size: 0.85rem;
  color: #555;
}
.step-change var { font-family: 'JetBrains Mono', monospace; font-style: italic; color: #0369a1; }
.step-change code { font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; }

.math-chapter .plate-figure { margin: 0 0 2rem; }
.plate-caption {
  font-family: 'STIX Two Text', Georgia, serif;
  font-style: italic;
  font-size: 0.85rem;
  color: #555;
  margin-top: 0.5rem;
  text-align: center;
}
.math-chapter .scrubber { font-family: 'STIX Two Text', Georgia, serif; }
.math-chapter .scrubber-button {
  border: 1px solid #aaa;
  border-radius: 0.25rem;
  box-shadow: none;
  background: transparent;
}

.museum-colophon {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid #ddd;
  font-size: 0.8rem;
  color: #777;
}
.museum-colophon a { color: inherit; }

.cover-placeholder {
  border: 3px dashed #c8c4bc;
  border-radius: 1rem;
  padding: 1.5rem;
  color: #777;
  font-size: 0.9rem;
}

/* =============================================================================
   Plates, phase 3: seeds, captions, notes, and per-creature accents
   ============================================================================= */

.plate-node--seed { fill: var(--zoo-warm-white); stroke-dasharray: 6 5; }
.plate-label--seed { fill: var(--zoo-charcoal); stroke: none; font-size: 20px; }
.plate--running .plate-node--seed.plate-node--pending { opacity: 1; }
.plate--running .plate-label--seed.plate-label--pending { opacity: 1; }

.plate-node--leaf.plate-node--active,
.plate-node--leaf.plate-node--done { fill: var(--zoo-teal); }
.plate-node--discarded { opacity: 0.25; }
.plate-node--reused { fill: var(--zoo-yellow); }
.plate-label--reused { fill: var(--zoo-charcoal); stroke: none; }
.plate-node--recalled { stroke: var(--zoo-orange); stroke-width: 6; }
.plate-node--main { fill: var(--creature); }
.plate-node--helper { fill: #7a9e5c; }
.plate-node--first { fill: var(--creature); }
.plate-node--second { fill: var(--zoo-blue); }
.plate-edge--discarded { opacity: 0.25; }

.plate-caption-text {
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', cursive;
  font-weight: 700;
  font-size: 18px;
  dominant-baseline: central;
  fill: var(--zoo-charcoal);
}
.plate-caption-text--seed { font-weight: 400; fill: #777; }
.plate--running .plate-caption-text--pending { opacity: 0.4; }
.plate-note {
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', cursive;
  font-size: 16px;
  dominant-baseline: central;
  fill: var(--zoo-purple);
  font-weight: 700;
}

.algebra-panel { margin-bottom: 1.5rem; align-items: stretch; }
.algebra-panel .specimen-doc.picture-book { margin-top: 0; border: none; }

.museum-notes { margin: 1.5rem 0 0; }
.museum-note, .museum-relatives p, .museum-duality p {
  font-size: 0.9rem;
  color: #444;
  line-height: 1.6;
}
.museum-note code, .museum-duality code { font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; }
.museum-relatives, .museum-duality { margin-top: 1.5rem; }

/* Apo's input row is not waiting to be computed: it stays in full view
   until a cell of it is copied (discarded) or handed over (reused). */
.plate--running .plate-node--pending.plate-node--input,
.plate--running .plate-label--pending.plate-label--input { opacity: 1; }
.plate--running .plate-node--pending:not(.plate-node--input):not(.plate-node--seed) { opacity: 0.3; }

/* Specimen's marginalia is an editorial pull-quote (cream block, accent
   circle, drop cap). In the Zoo's skin and on the Museum's page it is set
   as plain prose: CSS over Specimen's own class names, nothing more. */
.picture-book .row > .marginalia,
.museum-code .row > .marginalia {
  margin-top: 0.9rem;
  padding: 0;
  background: transparent;
  border: none;
  max-width: none;
  font-size: 0.95rem;
}
.picture-book .row > .marginalia { font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', cursive; font-style: normal; }
.museum-code .row > .marginalia { font-family: 'STIX Two Text', Georgia, serif; color: #444; }
.picture-book .row > .marginalia::before,
.museum-code .row > .marginalia::before { display: none; }
.picture-book .row > .marginalia p.can-dropcap:first-of-type::first-letter,
.museum-code .row > .marginalia p.can-dropcap:first-of-type::first-letter {
  font: inherit;
  font-size: 1em;
  line-height: inherit;
  float: none;
  font-weight: 700;
  margin: 0;
  color: var(--accent);
}
.museum-code { --accent: #555; }

/* The unfolds' family: grown cells settle into blue-greys, never the folds'
   computed pink. The creature's own colour marks the cell being grown. */
.plate--unfolding .plate-node--branch,
.plate--unfolding .plate-node--leaf { fill: #c9d3e6; }
.plate--unfolding .plate-node--active.plate-node--branch,
.plate--unfolding .plate-node--active.plate-node--leaf { fill: var(--creature); }
.plate--unfolding .plate-node--done.plate-node--branch { fill: #8ea3c8; }
.plate--unfolding .plate-node--done.plate-node--leaf { fill: #5f7398; }
.plate--unfolding .plate-node--seed { fill: var(--zoo-warm-white); }
.plate--unfolding .plate-node--reused { fill: var(--zoo-yellow); }
.plate--unfolding .plate-node--input.plate-node--pending { fill: #c9d3e6; }
.plate--unfolding .plate-node--done.plate-node--main { fill: #8ea3c8; }
.plate--unfolding .plate-node--done.plate-node--helper { fill: #7d9a86; }
.plate--unfolding .plate-node--active.plate-node--helper { fill: #7a9e5c; }

/* =============================================================================
   The cover: the mirror (Zoo.Cover). Positions come from the layout; only
   colour and type live here.
   ============================================================================= */

.cover-plate { width: 100%; max-width: 760px; height: auto; overflow: visible; }
.cover-edge { fill: none; stroke: var(--zoo-charcoal); stroke-width: 2.5; stroke-linecap: round; }
.cover-edge--duality { stroke: var(--zoo-purple); stroke-dasharray: 7 6; stroke-width: 2.5; }
.cover-arrow { fill: var(--zoo-charcoal); }
.cover-node { cursor: pointer; }
.cover-disc { stroke: var(--zoo-charcoal); stroke-width: 3; transition: r 0.15s ease; }
.cover-node:hover .cover-disc { stroke-width: 4.5; }
.cover-name {
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', cursive;
  font-weight: 700;
  font-size: 15px;
  text-anchor: middle;
  dominant-baseline: central;
  fill: white;
  stroke: var(--zoo-charcoal);
  stroke-width: 0.8;
  paint-order: stroke fill;
  pointer-events: none;
}
.cover-sides {
  display: flex;
  justify-content: space-between;
  max-width: 760px;
  margin: 1rem auto 0;
  padding: 0 1rem;
  font-size: 0.9rem;
  color: #777;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cover-legend {
  max-width: 640px;
  margin: 1rem auto 0;
  font-size: 0.85rem;
  color: #555;
  text-align: center;
}
.cover-legend code { font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; }
.reptile-house {
  max-width: 420px;
  margin: 1.5rem auto 0;
  padding: 0.75rem 1rem;
  border: 3px dashed #c8c4bc;
  border-radius: 1rem;
  color: #777;
  font-size: 0.85rem;
  text-align: left;
}
.reptile-house h3 { margin: 0 0 0.25rem; font-size: 1rem; color: #999; }
.reptile-house p { margin: 0; }

/* =============================================================================
   Museum: transformations, sidebars, and the anatomy room
   ============================================================================= */

.museum-transformation { margin: 0 0 2rem; }
.museum-sidebar {
  margin: 2rem 0 0;
  padding: 1rem 1.25rem;
  border-left: 3px solid #d8d4cc;
  background: #fbf9f3;
}
.museum-sidebar-title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  color: #333;
}
.anatomy-machines { display: flex; flex-direction: column; gap: 1.25rem; margin-bottom: 2rem; }
.anatomy-equation { margin: 0 0 1.5rem; }
.anatomy-verdict { font-size: 0.85rem; color: #555; margin: -0.5rem 0 0 4.5rem; font-style: italic; }
.anatomy-verdict--defined::before { content: "Definition. "; font-style: normal; font-weight: 700; color: #333; }
.anatomy-verdict--proved::before { content: "Theorem. "; font-style: normal; font-weight: 700; color: #333; }

/* The transformations' tones: the two creatures each law joins. */
.plate-node--para.plate-node--branch { fill: #00B4A0; }
.plate-node--zygo.plate-node--branch { fill: #2ECC71; }
.plate-node--seed.plate-node--helper { stroke: #7a9e5c; }
.cover-dag { max-width: 760px; padding: 1rem; }

/* The way back out of the Museum, set like its label: small caps, quiet. */
.museum-back {
  font-variant: small-caps;
  letter-spacing: 0.06em;
  font-size: 0.95rem;
  color: #555;
  text-decoration: none;
  border-bottom: 1px solid #ccc;
  margin-right: 12rem;
}
.museum-back:hover { color: #111; border-bottom-color: #111; }
.museum-back-arrow { font-variant: normal; }
@media (max-width: 768px) { .museum-back { margin-right: 0; } }

/* Para's ghosts: the original subtree, kept in view because para may still
   inspect it, its values used up. Faint and dotted: not a live value, and
   not a seed (dashed). */
.plate-node--ghost { fill: var(--zoo-warm-white) !important; opacity: 0.55; stroke-dasharray: 2 5; stroke-width: 2; }
.plate-label--ghost { fill: #9a9690; stroke: none; opacity: 0.8; }

/* =============================================================================
   Playback: a trace stepped through in a modal (Zoo.Playback). Controls at
   the top, a line for the frame, and a fixed stage the drawing fills.
   ============================================================================= */

.watch-link {
  display: inline-block;
  margin: 0.75rem auto 0;
  padding: 0.35rem 1rem;
  font: inherit;
  font-weight: 700;
  color: var(--zoo-charcoal);
  background: var(--zoo-yellow);
  border: 3px solid var(--zoo-charcoal);
  border-radius: 0.8rem;
  box-shadow: 3px 3px 0 var(--zoo-charcoal);
  text-decoration: none;
}
.watch-link:hover, .watch-link:focus { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--zoo-charcoal); }
.math-chapter .watch-link {
  font-family: 'STIX Two Text', Georgia, serif;
  font-weight: 400;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  background: transparent;
  border: none;
  border-bottom: 1px solid #aaa;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  color: #333;
}
.math-chapter .watch-link:hover, .math-chapter .watch-link:focus { transform: none; box-shadow: none; border-bottom-color: #111; }
.museum-plate, .museum-transformation { display: flex; flex-direction: column; align-items: center; }

@media (prefers-reduced-motion: reduce) {
  .plate-node, .watch-link { transition: none; }
}

/* A node that has consumed its children stands alone but is a computed
   value: it keeps the folds' colours, not an input leaf's. */
.plate--folding .plate-node--folded { fill: var(--zoo-pink); }
.plate--downward .plate-node--folded.plate-node--root { fill: var(--zoo-purple); }
.plate-label--folded { fill: white; }

/* =============================================================================
   The top bar (Zoo.Navigation): the title, the eleven creatures as dots,
   the Story · Watch · Anatomy switch. One structure in every view, at one
   height, so nothing moves between views; only its lettering changes.
   ============================================================================= */

.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  height: 3.6rem;
  padding: 0 1.25rem;
  border-bottom: 1px solid #d8d4cc;
  background: var(--zoo-cream);
}
.top-bar a { color: inherit; text-decoration: none; }
.top-bar-title { justify-self: start; font-weight: 700; white-space: nowrap; }
.top-bar-title:hover, .top-bar-title:focus { text-decoration: underline; }

.top-bar-creatures { display: flex; align-items: flex-start; gap: 0; margin: 0; padding: 0; list-style: none; }
.top-bar-creature { width: 2.4rem; display: flex; justify-content: center; }
.creature-dot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 2.6rem;
  padding-top: 0.45rem;
  outline: none;
}
.creature-dot-disc {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: var(--creature-colour);
  border: 1.5px solid var(--zoo-charcoal);
  transition: transform 0.12s ease;
}
.creature-dot--current .creature-dot-disc { transform: scale(1.6); }
.creature-dot:hover .creature-dot-disc, .creature-dot:focus-visible .creature-dot-disc { transform: scale(1.35); }
.creature-dot:focus-visible .creature-dot-disc { box-shadow: 0 0 0 3px rgba(77, 139, 245, 0.45); }
.creature-dot-name {
  position: absolute;
  top: 1.55rem;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.75rem;
  line-height: 1;
  visibility: hidden;
}
.creature-dot--current .creature-dot-name { visibility: visible; font-weight: 700; }
.creature-dot:hover .creature-dot-name, .creature-dot:focus-visible .creature-dot-name { visibility: visible; }

.top-bar-views { justify-self: end; display: flex; gap: 0.2rem; margin: 0; padding: 0; list-style: none; white-space: nowrap; }
.top-bar-views li + li::before { content: "·"; padding-right: 0.2rem; opacity: 0.5; }
.view-switch { padding: 0.1rem 0.25rem; border-bottom: 2px solid transparent; opacity: 0.65; }
.view-switch:hover, .view-switch:focus { opacity: 1; }
.view-switch--current { opacity: 1; font-weight: 700; border-bottom-color: currentColor; }
.top-bar-room { font-style: italic; opacity: 0.75; }

/* Story: the Zoo's hand. */
.top-bar--hand { font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', cursive; font-size: 0.95rem; }
/* Watch and Anatomy (and the anatomy room): the Museum's small caps. */
.top-bar--museum {
  font-family: 'STIX Two Text', Georgia, serif;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  font-size: 0.95rem;
  background: #fffff8;
  color: #333;
}
.top-bar--museum .top-bar-title { font-weight: 400; }
.top-bar--museum .creature-dot-name { font-variant: normal; letter-spacing: 0; font-style: italic; }
.top-bar--museum .view-switch--current { font-weight: 400; }

@media (max-width: 900px) {
  .top-bar { grid-template-columns: auto 1fr auto; padding: 0 0.6rem; gap: 0.5rem; }
  .top-bar-creature { width: 1.55rem; }
  .top-bar-title { font-size: 0.8rem; }
}

/* Previous / next at the foot of Story and Anatomy. */
.page-foot {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin: 2rem 0 0.5rem;
  font-size: 1.05rem;
}
.page-foot a { color: inherit; text-decoration: none; border-bottom: 1px solid transparent; }
.page-foot a:hover, .page-foot a:focus { border-bottom-color: currentColor; }
.page-foot-separator { opacity: 0.5; }
.math-chapter .page-foot { font-family: 'STIX Two Text', Georgia, serif; font-variant: small-caps; letter-spacing: 0.05em; }

/* =============================================================================
   The creature's portrait, beside its title on the Story view. Until the
   plates arrive, a neutral frame in the creature's colour.
   ============================================================================= */

/* -- The Story view: a split. The portrait column on the left, large and
   sticky; the explanation on the right, the picture book shrunk a little
   so more of it is in view at once. ------------------------------------- */

.view--story .page-frame { max-width: 1320px; }
.story-split {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 2rem;
  align-items: start;
}
.story-portrait-column {
  position: sticky;
  top: calc(3.6rem + 1rem);
  margin: 0;
  text-align: center;
}
/* The picture book, shrunk rather than restyled: same outlines, shadows,
   bubbles and lettering, at a smaller scale. */
.story-explanation { zoom: 0.8; min-width: 0; }
.story-explanation .page-foot { margin-top: 1.5rem; }

.creature-portrait { margin: 0; }
.creature-portrait .chapter-heading { margin: 1rem 0 0.25rem; }
.creature-portrait .chapter-title { font-size: 2rem; }
.portrait-frame {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  border: 3px solid var(--zoo-charcoal);
  border-radius: 1rem;
  box-shadow: 4px 4px 0 var(--zoo-charcoal);
  overflow: hidden;
}
/* As wide as the column, unless that would push the title out of view. */
.portrait-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 19rem);
}

/* Tenniel: black line art multiplied over a wash of the creature's colour.
   The paper is whitened first, so cream and white scans take the same wash. */
.creature-portrait--washed .portrait-frame {
  padding: 0.75rem;
  background: color-mix(in srgb, var(--creature-colour) 30%, white);
  isolation: isolate;
}
.creature-portrait--washed .portrait-image {
  mix-blend-mode: multiply;
  filter: grayscale(1) contrast(1.35) brightness(1.12);
}

/* No plate yet: the same large frame, dashed, waiting. */
.creature-portrait--to-come .portrait-frame {
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: calc(100vh - 19rem);
  display: flex;
  align-items: center;
  justify-content: center;
  border-style: dashed;
  border-color: color-mix(in srgb, var(--creature-colour) 70%, var(--zoo-charcoal));
  background: color-mix(in srgb, var(--creature-colour) 14%, white);
  box-shadow: none;
}
.portrait-initial {
  font-size: 2.4rem;
  font-weight: 700;
  color: color-mix(in srgb, var(--creature-colour) 75%, var(--zoo-charcoal));
}
.portrait-caption { margin-top: 0.4rem; font-size: 0.8rem; font-style: italic; opacity: 0.75; line-height: 1.35; }
.portrait-credit { display: block; font-style: normal; opacity: 0.85; }
.portrait-credit i { font-style: italic; }

/* Narrow screens: the portrait and title above the explanation. */
@media (max-width: 900px) {
  .story-split { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
  .story-portrait-column { position: static; }
  .portrait-image { max-height: 55vh; }
  .creature-portrait--to-come .portrait-frame { width: 70%; max-height: 50vh; }
  .story-explanation { zoom: 1; }
}


/* =============================================================================
   Watch: the room between the two wings. Picture-book plates on a quiet
   ground; controls in the Museum's type.
   ============================================================================= */

.view--watch { background: #f6f4ee; }
.watch-page { max-width: 1100px; margin: 0 auto; padding: 1rem 1.25rem 2rem; font-family: 'STIX Two Text', Georgia, serif; color: #222; }
.playback { display: flex; flex-direction: column; background: var(--zoo-warm-white); border: 1px solid #d8d4cc; border-radius: 0.5rem; }
.playback-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #e2ded5;
  font-variant: small-caps;
  letter-spacing: 0.04em;
}
.playback-button {
  cursor: pointer;
  font: inherit;
  min-width: 2.4rem;
  padding: 0.2rem 0.6rem;
  background: transparent;
  border: 1px solid #aaa;
  border-radius: 0.2rem;
  color: inherit;
}
.playback-button:disabled { opacity: 0.35; cursor: default; }
.playback-play { background: var(--zoo-yellow); border-color: #8a7a2a; }
.playback-index { margin-left: 0.5rem; min-width: 7.5em; }
.playback-title { flex: 1; text-align: right; opacity: 0.75; }
.playback-line { min-height: 1.6em; margin: 0; padding: 0.6rem 1.25rem 0; text-align: center; font-style: italic; color: #555; }
.playback-stage { height: min(60vh, 560px); display: flex; padding: 0.5rem 1rem 1rem; }
.playback-stage svg.plate { width: 100%; height: 100%; max-width: none; }

.watch-reels { margin-top: 1.25rem; }
.watch-reels-title { margin: 0 0 0.4rem; font-size: 0.85rem; font-weight: 400; font-variant: small-caps; letter-spacing: 0.08em; color: #888; }
.watch-reels ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 0.25rem; }
.watch-reel { color: #333; text-decoration: none; border-bottom: 1px solid transparent; }
.watch-reel:hover, .watch-reel:focus { border-bottom-color: #333; }
.watch-reel--current { font-weight: 700; }
.watch-reel--current::before { content: "▸ "; }
.watch-reel-caption { font-weight: 400; font-style: italic; color: #666; }
.watch-unknown { font-style: italic; color: #777; }

/* "watch this →" on Story and Anatomy. */
/* The foot of a Story: one line that says what the run does, and the way
   to Watch it. No drawing: Watch has the plate. */
.watch-again { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.75rem 1rem; margin: 0 0 1.5rem; }
.watch-again-line { margin: 0; }
.watch-again-line::before, .watch-again-line::after { display: none; }
.watch-again .watch-link { margin: 0; white-space: nowrap; }

/* =============================================================================
   The cover: the way into the Museum, folded in from its old page.
   ============================================================================= */

.cover-museum { margin-top: 2.5rem; padding-top: 2rem; border-top: 2px dashed #d8d4cc; }
.cover-museum .museum-invite-question { margin-bottom: 1rem; }
.cover-museum-title {
  font-family: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  font-size: 1.9rem;
  font-weight: 400;
  font-variant: small-caps;
  letter-spacing: 0.06em;
  margin: 0 0 0.3rem;
  color: #111;
}
.cover-museum .museum-invite-subtitle { margin-bottom: 1.25rem; }
.cover-anatomy-room {
  display: inline-block;
  padding: 0.5rem 1.4rem;
  font-family: 'STIX Two Text', Georgia, serif;
  font-size: 1.15rem;
  font-variant: small-caps;
  letter-spacing: 0.06em;
  color: #111;
  text-decoration: none;
  background: #fffff8;
  border: 1px solid #333;
}
.cover-anatomy-room:hover, .cover-anatomy-room:focus { background: #111; color: #fffff8; }
.cover-museum-note { margin: 0.75rem 0 0; font-family: 'STIX Two Text', Georgia, serif; font-size: 0.9rem; font-style: italic; color: #666; }
.cover-museum-note .museum-link-text { color: #444; border-bottom-color: #bbb; text-decoration: none; }

/* The anatomy room's two machines, set large enough to read, the
   constraints close by rather than at the end of a long leader. */
.anatomy-machine .sig-full { font-size: 18px; width: fit-content; }
.anatomy-machine .sig-quant, .anatomy-machine .sig-ctx-item { font-size: 16px; }
.anatomy-machine .sig-leader { min-width: 2rem; }

.reptile-house-plate {
  float: right;
  width: 7rem;
  margin: 0 0 0.5rem 1rem;
}
.reptile-house-plate {
  mix-blend-mode: multiply;
  filter: grayscale(1) contrast(1.3) brightness(1.1);
  opacity: 0.75;
}

/* Phone width: the bar takes two rows, the title and the switch above the
   eleven dots, so nothing runs off the screen. */
@media (max-width: 640px) {
  .top-bar {
    height: auto;
    grid-template-columns: auto 1fr;
    grid-template-areas: "title views" "creatures creatures";
    row-gap: 0;
    padding: 0.35rem 0.6rem 0;
  }
  .top-bar-title { grid-area: title; }
  .top-bar-views { grid-area: views; }
  .top-bar-creatures { grid-area: creatures; justify-content: space-between; }
  .top-bar-creature { width: auto; flex: 1 1 0; }
}
