/* The palette is named for what it lights, not for what it is. */
:root {
  --night-between-stars: #0d0b17;
  --deep-dusk-violet: #1b1530;
  --porch-light-gold: #f2c46d;
  --porch-light-gold-soft: rgba(242, 196, 109, 0.55);
  --lantern-cream: #f7ecd4;
  --caption-glass: rgba(13, 11, 23, 0.80);
  --door-oak: #4a2e1a;
  --door-oak-dark: #2a190d;
  --library-shelf-wood: #3b2615;
  --focus-ring-gold: #ffd98a;
  --story-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --plain-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Helvetica, Arial, sans-serif;
}

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
  background: #000;
  color: var(--lantern-cream);
  font-family: var(--plain-sans);
  overflow: hidden;
}

/* The viewport letterboxes a fixed 1920 x 1080 stage into any window. */
#viewport { position: fixed; inset: 0; background: #000; }
#stage {
  position: absolute;
  left: 0; top: 0;
  width: 1920px; height: 1080px;
  transform-origin: 0 0;
  overflow: hidden;
  background: var(--night-between-stars);
}

.scene { position: absolute; inset: 0; visibility: hidden; overflow: hidden; }
.scene.is-on { visibility: visible; }

/* A "cam" is the camera: one image, moved by translate and scale only. */
.cam { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; transform-origin: 0 0; will-change: transform; }
.cam img { display: block; width: 1920px; height: 1080px; object-fit: cover; }

/* ---------- Scene 2: the crew, in their usual order ---------- */
#s-crew {
  background:
    radial-gradient(ellipse at 50% 30%, #2a2144 0%, var(--night-between-stars) 70%);
}
.crew-row {
  position: absolute; left: 100px; top: 110px;
  width: 1720px;
  display: flex; gap: 40px;
}
.crew-card {
  width: 400px;
  text-align: center;
  opacity: 0;
  transition: none;
}
.crew-card img {
  width: 380px; height: 380px; display: block; margin: 0 auto;
  border-radius: 18px;
  border: 3px solid rgba(242, 196, 109, 0.35);
  box-shadow: 0 18px 40px rgba(0,0,0,0.55);
}
.crew-card.is-speaking img {
  border-color: var(--porch-light-gold);
  box-shadow: 0 0 0 6px rgba(242, 196, 109, 0.25), 0 0 60px rgba(242, 196, 109, 0.45);
}
.crew-card h2 {
  margin: 26px 0 10px;
  font-family: var(--story-serif);
  font-size: 54px; font-weight: 600;
  color: var(--porch-light-gold);
  letter-spacing: 0.02em;
}
.crew-card p {
  margin: 0 10px;
  font-family: var(--story-serif);
  font-size: 31px; line-height: 1.3;
  color: var(--lantern-cream);
}

/* ---------- Scene 4: the doorway ---------- */
#s-doorway {
  background: radial-gradient(ellipse at 50% 45%, var(--deep-dusk-violet) 0%, var(--night-between-stars) 75%);
}
#stars { position: absolute; inset: 0; }
.door-glow {
  position: absolute; left: 460px; top: -100px; width: 1000px; height: 1100px;
  background: radial-gradient(ellipse at 50% 50%, rgba(242,196,109,0.55) 0%, rgba(242,196,109,0.12) 40%, rgba(242,196,109,0) 68%);
  opacity: 0.35;
}
.door {
  position: absolute; left: 680px; top: 50px; width: 560px; height: 800px;
  perspective: 1800px;
  border-radius: 280px 280px 0 0;
}
.door-view {
  position: absolute; inset: 0; overflow: hidden;
  border-radius: 280px 280px 0 0;
  background: #20183a;
}
.door-view img {
  position: absolute; left: -1376px; top: -99px;
  width: 4071px; height: 2291px; max-width: none;
}
.door-view::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 70%, rgba(255,214,140,0.25), rgba(255,214,140,0) 60%);
}
.leaf {
  position: absolute; top: 0; width: 280px; height: 800px;
  background:
    linear-gradient(90deg, var(--door-oak-dark) 0%, var(--door-oak) 30%, #5d3a22 55%, var(--door-oak) 80%, var(--door-oak-dark) 100%);
  box-shadow: inset 0 0 0 8px var(--door-oak-dark), inset 0 0 0 11px rgba(242,196,109,0.6);
  will-change: transform;
}
.leaf.left  { left: 0;  border-radius: 280px 0 0 0; transform-origin: 0 50%; }
.leaf.right { right: 0; border-radius: 0 280px 0 0; transform-origin: 100% 50%; }
.leaf .panel {
  position: absolute; left: 50px; right: 50px;
  border: 3px solid rgba(242,196,109,0.55);
  border-radius: 6px;
  background: rgba(0,0,0,0.12);
}
.leaf .panel.upper { top: 300px; height: 190px; }
.leaf .panel.lower { top: 540px; height: 200px; }
.leaf .knob {
  position: absolute; top: 500px; width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3cf, var(--porch-light-gold) 45%, #8a6424 100%);
}
.leaf.left .knob  { right: 18px; }
.leaf.right .knob { left: 18px; }
.door-group { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; transform-origin: 960px 0; transform: scale(0.84); }
.door-frame { position: absolute; left: 650px; top: 20px; width: 620px; height: 860px; overflow: visible; }
.threshold-words {
  position: absolute; left: 0; right: 0; top: 890px;
  text-align: center;
  font-family: var(--story-serif);
  font-size: 30px; letter-spacing: 0.5em;
  color: var(--porch-light-gold);
}

/* ---------- Scene 5: the Neighborhood, the Library, the porch light ---------- */
#s-neighborhood { background: var(--night-between-stars); }
.layer { position: absolute; inset: 0; }
#library-layer { opacity: 0; background: linear-gradient(180deg, #1a120c 0%, #24170d 60%, #140d08 100%); }
#library-layer svg { position: absolute; inset: 0; }
.library-lamp-sweep {
  position: absolute; top: 0; left: 360px; width: 1200px; height: 1080px;
  background: radial-gradient(ellipse at 50% 45%, rgba(255,214,140,0.20), rgba(255,214,140,0) 60%);
  pointer-events: none;
}
#porch-layer {
  opacity: 0;
  background: radial-gradient(ellipse at 50% 38%, #2b1f14 0%, var(--night-between-stars) 65%);
}
.porch-glow {
  position: absolute; left: 660px; top: 80px; width: 600px; height: 600px; border-radius: 50%;
  background: radial-gradient(circle, rgba(242,196,109,0.65) 0%, rgba(242,196,109,0.18) 38%, rgba(242,196,109,0) 70%);
}
.porch-lantern { position: absolute; left: 860px; top: 150px; width: 200px; height: 420px; }
.porch-line {
  position: absolute; left: 0; right: 0; top: 610px;
  margin: 0; text-align: center;
  font-family: var(--story-serif);
  font-size: 104px; font-weight: 500;
  color: var(--porch-light-gold);
  text-shadow: 0 0 40px rgba(242,196,109,0.35);
}
.artwork-credit {
  position: absolute; left: 0; right: 0; top: 770px;
  margin: 0; text-align: center;
  font-family: var(--story-serif);
  font-size: 30px; color: var(--lantern-cream); opacity: 0.9;
}

/* ---------- Captions: real text, warm cream on dark glass ---------- */
#caption {
  position: absolute; left: 50%; bottom: 100px;
  transform: translateX(-50%);
  width: max-content; max-width: 1560px;
  padding: 22px 48px;
  background: var(--caption-glass);
  border: 1px solid rgba(242,196,109,0.45);
  border-radius: 16px;
  text-align: center;
  opacity: 0;
}
#caption p {
  margin: 0;
  font-family: var(--story-serif);
  font-size: 48px; line-height: 1.3;
  color: var(--lantern-cream);
}
#caption p + p { margin-top: 14px; }

#scene-title {
  position: absolute; left: 48px; top: 36px;
  padding: 10px 22px;
  background: var(--caption-glass);
  border-radius: 12px;
  font-family: var(--story-serif);
  font-size: 36px; color: var(--porch-light-gold);
  display: none;
}

#fade { position: absolute; inset: 0; background: #000; opacity: 1; pointer-events: none; }

#intro {
  position: absolute; inset: 0;
  display: none; align-items: center; justify-content: center; flex-direction: column;
  background: var(--night-between-stars);
  text-align: center;
}
#intro h1 {
  margin: 0 0 24px;
  font-family: var(--story-serif); font-weight: 500;
  font-size: 110px; color: var(--porch-light-gold);
}
#intro p { margin: 0; font-family: var(--story-serif); font-size: 40px; color: var(--lantern-cream); }

/* ---------- Controls: outside the stage, keyboard reachable, 44px+ ---------- */
#controls {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%);
  width: max-content; max-width: calc(100vw - 24px);
  display: flex; gap: 12px; align-items: center;
  padding: 10px 14px;
  background: rgba(13, 11, 23, 0.86);
  border: 1px solid rgba(242,196,109,0.4);
  border-radius: 14px;
  z-index: 10;
}
#controls button {
  white-space: nowrap;
  min-width: 52px; min-height: 52px;
  padding: 0 18px;
  font: 600 20px/1 var(--plain-sans);
  color: var(--night-between-stars);
  background: var(--porch-light-gold);
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer;
}
#controls button:hover { background: var(--lantern-cream); }
#controls button:focus { outline: none; }
#controls button:focus-visible {
  outline: 4px solid var(--focus-ring-gold);
  outline-offset: 3px;
  box-shadow: 0 0 0 7px var(--night-between-stars);
}
#controls button[hidden] { display: none; }
#status {
  min-width: 200px; padding: 0 8px;
  font: 500 20px/1.2 var(--plain-sans);
  color: var(--lantern-cream);
}

body.record #controls { display: none; }
body.record { cursor: none; }
body.reduced #scene-title { display: block; }
body.reduced #fade { display: none; }
body.reduced #caption p { font-size: 42px; }

/* ---------- Site additions: a way home, readable captions on narrow screens, a text version ---------- */
#home-link {
  position: fixed; left: 12px; top: 10px; z-index: 11;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  color: var(--lantern-cream); text-decoration: none;
  font: 600 16px/1 var(--plain-sans);
  background: rgba(13, 11, 23, 0.86);
  border: 1px solid rgba(242,196,109,0.4); border-radius: 12px;
}
#home-link:hover { color: var(--porch-light-gold); }
#home-link:focus-visible { outline: 4px solid var(--focus-ring-gold); outline-offset: 3px; }
#caption-out {
  position: fixed; left: 16px; right: 16px; z-index: 9;
  display: none; margin: 0; padding: 14px 16px;
  background: var(--caption-glass);
  border: 1px solid rgba(242,196,109,0.45); border-radius: 12px;
  text-align: center;
}
#caption-out p { margin: 0; font: 400 19px/1.45 var(--story-serif); color: var(--lantern-cream); }
#caption-out p + p { margin-top: 10px; }
#caption-out .title { color: var(--porch-light-gold); font-size: 15px; margin-bottom: 6px; }
body.narrow #caption-out { display: block; }
body.narrow #caption { display: none; }
body.narrow #scene-title { display: none !important; }
@media (max-width: 640px) {
  #controls { flex-wrap: wrap; justify-content: center; width: calc(100vw - 24px); gap: 8px; }
  #controls button { min-width: 64px; padding: 0 12px; font-size: 17px; }
  #status { flex-basis: 100%; min-width: 0; text-align: center; font-size: 16px; }
}
.transcript {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
