/* Space Voyage. Type personality: "observatory brass and starlight", continued from Our Sun's Family (the same kind of
   book): the words are museum labels in cream engraved serif on a smoked night-glass plaque with a fine brass edge and two
   brass pins, a gold small-caps head naming the stop, and the guide's fact on its own gold strip. A gold thread pins the
   label to the body it describes. New here: the light-speed clock, a brass stopwatch that counts the trip. */
:root {
  --ink: #f7eedb; --cream: #f7eedb; --engrave: #f0c978; --fact: #ffd27a; --glass: 14, 16, 40; --brass: 214, 172, 92;
  --red: #ff9a7a; --night: #0d1430; --gold-glow: #ffcf66; --ink-soft: #d9c7a0;
  --display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --body: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --voice: Georgia, "Book Antiqua", serif;
  --round: "Arial Rounded MT Bold", "Segoe UI Rounded", "Trebuchet MS", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--ink); }
body { font-family: var(--body); touch-action: none; -webkit-user-select: none; user-select: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#book { position: fixed; inset: 0; }
.stage { position: absolute; inset: 0; overflow: hidden; background: #0d1430; }
.still, .gl { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.gl { opacity: 0; transition: opacity .35s; }
.gl.ready { opacity: 1; }
.taps { position: absolute; inset: 0; pointer-events: none; }
.taps > * { pointer-events: auto; }

/* ---------- the museum label (the words) ---------- */
.story { position: absolute; z-index: 5; overflow: hidden; font-size: 28px; line-height: 1.38; color: var(--cream);
  padding: .8em 1.1em .85em; border-radius: 7px; border: 1.5px solid rgba(var(--brass), .62);
  background: radial-gradient(ellipse at 18% 0%, rgba(255, 236, 190, .1), transparent 55%), linear-gradient(165deg, rgba(var(--glass), .8), rgba(8, 9, 26, .9));
  -webkit-backdrop-filter: blur(5px) saturate(1.1); backdrop-filter: blur(5px) saturate(1.1);
  box-shadow: inset 0 0 0 5px rgba(6, 7, 20, .35), inset 0 0 0 6px rgba(var(--brass), .2), 0 0 22px rgba(255, 200, 110, .08), 0 10px 26px rgba(0, 0, 0, .45);
  transition: border-color .5s, box-shadow .6s; -webkit-user-select: text; user-select: text; }
.story::before, .story::after { content: ""; position: absolute; top: 9px; width: 10px; height: 10px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #fff2c8, #d6ac5c 45%, #7a5a22 100%); box-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
.story::before { left: 9px; } .story::after { right: 9px; }
.story.lit { border-color: rgba(255, 222, 150, .95); box-shadow: inset 0 0 0 5px rgba(6, 7, 20, .3), inset 0 0 0 6px rgba(255, 214, 130, .4), 0 0 34px rgba(255, 200, 110, .42), 0 10px 26px rgba(0, 0, 0, .45); }
.story.scrolly { overflow-y: auto; touch-action: pan-y; }
.story p { margin: .1em 0; }
.story .plaque-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1em .7em; margin: 0 0 .35em; padding-bottom: .3em; border-bottom: 1px solid rgba(var(--brass), .38);
  font-variant: small-caps; letter-spacing: .09em; line-height: 1.15; }
.plaque-head .name { font-size: .86em; font-weight: 700; color: var(--engrave); text-shadow: 0 1px 0 rgba(0, 0, 0, .6); }
.plaque-head .no { font-size: .6em; color: #d9c7a0; letter-spacing: .12em; }
.story.lit .plaque-head .name { color: #ffe3a0; text-shadow: 0 0 .6em rgba(255, 205, 110, .9); }
.story .refrain { font-style: italic; color: #f3dca6; padding-left: .6em; border-left: 2px solid rgba(var(--brass), .5); }
.story .refrain em { font-style: italic; }
.story em { font-style: italic; }
.story .boom { font: 900 1.3em/1.05 var(--round); letter-spacing: .02em; margin: .05em 0 .2em; }
.story .boom span { display: inline-block; color: #ffd27a; -webkit-text-stroke: 2px #4a2612; paint-order: stroke fill; text-shadow: 0 3px 0 rgba(0, 0, 0, .35); animation: boom 1.6s ease-in-out infinite; animation-delay: calc(var(--k) * .18s); }
.story .boom span:nth-child(2) { color: #ff9a5a; } .story .boom span:nth-child(3) { color: #fff1c8; }
@keyframes boom { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-3px) rotate(2deg); } }
/* the guide's fact: its own gold strip */
.story .ship { margin-top: .45em; padding-top: .4em; border-top: 1px dashed rgba(var(--brass), .45); font: italic 700 .8em/1.32 var(--voice); color: var(--fact); }
.story .say { cursor: pointer; border-radius: 6px; padding: .02em .12em; text-shadow: 0 0 .45em rgba(255, 190, 80, .35); transition: background .25s, text-shadow .25s; }
.story .say .spk { width: 1em; height: 1em; vertical-align: -.15em; margin-right: .3em; fill: none; stroke: #f0c978; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.story .say .spk path:first-child { fill: rgba(240, 201, 120, .5); }
.story .say:hover, .story .say.speaking { color: #ffe7b0; background: rgba(255, 196, 92, .16); text-shadow: 0 0 .7em rgba(255, 200, 100, .85); }
.story .say:focus-visible { outline: 3px solid #ffd36a; }
/* tappable words: starlight gold with a glowing underline */
.story .nw { white-space: nowrap; }
.story .word { font: inherit; font-weight: 700; color: #ffe6a6; background: none; border: 0; padding: 0 .08em; margin: 0; cursor: pointer; border-radius: 6px;
  text-decoration: underline; text-decoration-thickness: .08em; text-underline-offset: .18em; text-decoration-color: rgba(255, 214, 120, .85); text-shadow: 0 0 .5em rgba(255, 210, 110, .55); }
.story .word:focus-visible { outline: 3px solid #ffd36a; }
.story .word[aria-expanded="true"], .story .word:hover { background: rgba(255, 205, 110, .22); }

/* ---------- the light-speed clock: a brass stopwatch that counts the trip ---------- */
.clock { position: fixed; z-index: 6; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 300px);
  padding: 6px 16px 6px 8px; border-radius: 999px; border: 1.5px solid rgba(var(--brass), .7); cursor: pointer; color: var(--cream); font: 700 22px/1.05 var(--display); text-align: left;
  background: linear-gradient(165deg, rgba(var(--glass), .82), rgba(8, 9, 26, .92)); box-shadow: inset 0 0 0 3px rgba(6, 7, 20, .4), 0 6px 18px rgba(0, 0, 0, .45); }
.clock[hidden] { display: none; }
.clock .face { position: relative; width: 44px; height: 44px; border-radius: 50%; flex: none; margin-top: 4px;
  background: radial-gradient(circle at 40% 35%, #fff8e2, #f2dfae 60%, #c99a4a); box-shadow: 0 0 0 3px #b8893e, 0 0 0 4px #6a4a1a, 0 0 14px rgba(255, 200, 110, .55); }
.clock .face::before { content: ""; position: absolute; left: 50%; top: -8px; width: 10px; height: 7px; margin-left: -5px; border-radius: 3px 3px 1px 1px; background: #c99a4a; box-shadow: 0 0 0 1px #6a4a1a; }
.clock .hand { position: absolute; left: 50%; top: 50%; width: 2.5px; height: 17px; margin-left: -1.25px; background: #5a2e12; border-radius: 2px; transform-origin: 50% 100%; transform: translateY(-100%) rotate(var(--a, 0deg)); }
.clock .hub { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: #5a2e12; }
.clock .read { display: flex; flex-direction: column; min-width: 0; }
.clock .t { font-variant-numeric: tabular-nums; color: #ffe3a0; text-shadow: 0 0 .5em rgba(255, 205, 110, .5); white-space: nowrap; }
.clock .lbl { font: italic 500 13px/1.2 var(--voice); color: #d9c7a0; }
.clock .grown { display: none; font: 500 14px/1.3 var(--voice); color: var(--cream); }
.clock.flipped .grown { display: block; } .clock.flipped .lbl { display: none; }
.clock:focus-visible { outline: 3px solid #ffd36a; outline-offset: 3px; }
#pin-thread { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; overflow: visible; opacity: 0; transition: opacity .6s; }
#pin-thread.on { opacity: 1; }
#pin-thread .thread { fill: none; stroke: rgba(var(--brass), .8); stroke-width: 1.9; filter: drop-shadow(0 0 2px rgba(255, 200, 110, .35)); }
#pin-thread .pin { fill: #e6bf72; stroke: #7a5a22; stroke-width: 1; }
#pin-thread .ring { fill: none; stroke: rgba(var(--brass), .3); stroke-width: 1.2; stroke-dasharray: 3 5; }
#pin-thread.lit .thread { stroke: rgba(255, 226, 150, .95); stroke-width: 2; filter: drop-shadow(0 0 4px rgba(255, 205, 110, .8)); }
#book[data-words="hidden"] #pin-thread { opacity: 0; }
/* in the label: a small brass stopwatch line under the stop's name */
.story .clock-slot { margin: 0 0 .45em; }
.story .clock { position: static; transform: none; display: inline-flex; max-width: 100%; gap: .45em; padding: .22em .7em .22em .3em; font-size: .62em; box-shadow: inset 0 0 0 2px rgba(6, 7, 20, .4); background: rgba(0, 0, 0, .22); }
.story .clock .face { width: 1.7em; height: 1.7em; margin-top: .2em; }
.story .clock .face::before { top: -.32em; width: .4em; height: .3em; margin-left: -.2em; }
.story .clock .hand { height: .66em; width: 2px; margin-left: -1px; }
.story .clock .t { font-size: 1.05em; }
.story .clock .lbl { font-size: .72em; white-space: normal; }
.story .clock .grown { font-size: .72em; }
.story .say-name { font: inherit; background: none; border: 0; padding: 0; cursor: pointer; color: var(--engrave); font-variant: small-caps; letter-spacing: inherit; text-decoration: underline dotted rgba(240, 201, 120, .6); text-underline-offset: .2em; }
.story .say-name:hover, .story .say-name:focus-visible { color: #ffe3a0; text-shadow: 0 0 .6em rgba(255, 205, 110, .9); outline: none; }
/* reveal: lines arrive one by one; a tap shows them all; reduced motion shows them at once */
.story.reveal > * { animation: rise .7s ease-out both; animation-delay: calc(var(--i) * .5s + .2s); }
.story.reveal.all > * { animation: none; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* cover title: big storybook lettering on the morning sky (no panel) */
#book[data-layout="portrait"] .title { text-align: center; }
#book[data-page="end"] .still { animation: drift 40s ease-in-out infinite alternate; }
@keyframes drift { from { transform: scale(1.02); } to { transform: scale(1.1) translate(-1.5%, 1%); } }
#book[data-page="cover"] .story, #book[data-page="end"] .story { background: none; border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; text-align: center; }
#book[data-page="cover"] .story::before, #book[data-page="cover"] .story::after, #book[data-page="end"] .story::before, #book[data-page="end"] .story::after { display: none; }
.title { margin: 0; text-align: left; font: 900 2.6em/1 var(--round); color: #fff6e2; -webkit-text-stroke: 3px #5a2e12; paint-order: stroke fill; text-shadow: 0 6px 18px rgba(60, 30, 10, .35); }
.title .t2 { color: #ffcf6a; }
.title .sub { display: block; margin-top: .45em; font: 800 .3em/1.2 var(--body); letter-spacing: .08em; color: #3a2610; -webkit-text-stroke: 0; text-shadow: 0 0 10px rgba(255, 250, 235, .95), 0 0 3px rgba(255, 250, 235, 1); }
.the-end { margin: 0; font: 900 2.4em/1 var(--round); color: #fff3d0; -webkit-text-stroke: 3px #2a2350; paint-order: stroke fill; text-shadow: 0 0 24px rgba(255, 220, 140, .6); }
.end-note { font: italic 500 .62em/1.3 var(--voice); color: #fff6e2; text-shadow: 0 1px 6px rgba(10, 15, 40, .9); }
.end-buttons { display: flex; gap: .6em; justify-content: center; flex-wrap: wrap; margin-top: .6em; }
.end-buttons button { font: 800 .62em/1 var(--round); padding: .7em 1.2em; border-radius: 999px; border: 0; cursor: pointer; color: #fff; background: #3a6fb8; box-shadow: 0 5px 0 #234a80; }
.end-buttons .nightlight { background: #6a4aa8; box-shadow: 0 5px 0 #43307a; }

/* ---------- big lettering across the picture (Blast off!) ---------- */
.boom-big { position: fixed; left: 0; right: 0; top: 16vh; z-index: 4; text-align: center; pointer-events: none; opacity: 0;
  font: 900 clamp(54px, 11vw, 150px)/1 var(--round); color: #ffd77a; -webkit-text-stroke: 3px #5a3a22; paint-order: stroke fill; text-shadow: 0 6px 18px rgba(60, 30, 10, .35); }
.boom-big.show { animation: pop 1.8s ease-out forwards; }
@keyframes pop { 0% { opacity: 0; transform: scale(.4) rotate(-6deg); } 15% { opacity: 1; transform: scale(1.12) rotate(2deg); } 25% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(1.05) translateY(-20px); } }

/* ---------- glowing tappable things (over the real 3D objects) ---------- */
.tap { position: absolute; transform: translate(-50%, -50%); border: 0; padding: 0; background: none; border-radius: 50%; cursor: pointer; min-width: 56px; min-height: 56px; }
.tap::before { content: ""; position: absolute; inset: 14%; border-radius: 50%; background: radial-gradient(circle, rgba(255, 238, 170, .55), rgba(255, 220, 120, .18) 55%, transparent 72%); animation: breathe 2.4s ease-in-out infinite; }
.tap:focus-visible { outline: 4px solid #ffd36a; outline-offset: 2px; }
.tap.helper::before { animation-duration: 4s; opacity: .35; }
.tap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
@keyframes breathe { 0%, 100% { transform: scale(.85); opacity: .55; } 50% { transform: scale(1.08); opacity: 1; } }
.speak-ring { position: absolute; width: 140px; height: 140px; margin: -70px 0 0 -70px; border-radius: 50%; pointer-events: none; opacity: 0; transition: opacity .3s;
  box-shadow: 0 0 0 3px rgba(255, 210, 110, .8), 0 0 40px 12px rgba(255, 200, 90, .45), inset 0 0 30px rgba(255, 210, 120, .35); }
.speak-ring.on { opacity: 1; animation: breathe 1.4s ease-in-out infinite; }

/* the count-down button and the roar button: cockpit buttons, clear of the page arrows */
.count { position: fixed; z-index: 6; width: clamp(110px, 16vmin, 170px); height: clamp(110px, 16vmin, 170px); border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 40% 35%, #fff7e0, #ffd36a 55%, #e08a2a); box-shadow: 0 0 0 6px rgba(255, 255, 255, .55), 0 0 40px rgba(255, 200, 90, .8), 0 8px 0 #a85a18; font: 900 clamp(48px, 9vmin, 92px)/1 var(--round); color: #5a2e12; }
.count .n { display: block; animation: tick .35s ease-out; }
.count.go { background: radial-gradient(circle at 40% 35%, #fff, #ff8a5a 55%, #c8321f); color: #fff; font-size: clamp(26px, 4.6vmin, 44px); }
.count:active { transform: translateY(4px); box-shadow: 0 0 0 6px rgba(255, 255, 255, .55), 0 0 40px rgba(255, 200, 90, .8), 0 4px 0 #a85a18; }
.count:focus-visible, .hold:focus-visible { outline: 4px solid #fff; outline-offset: 4px; }
@keyframes tick { from { transform: scale(1.5); opacity: 0; } to { transform: none; opacity: 1; } }
.hold { position: fixed; z-index: 6; width: clamp(104px, 15vmin, 150px); height: clamp(104px, 15vmin, 150px); border-radius: 50%; border: 0; cursor: pointer; touch-action: none;
  background: radial-gradient(circle at 40% 35%, #ff9a7a, #d8341f 60%, #8e1a10); box-shadow: 0 0 0 7px #d9dde6, 0 0 0 10px #8a93a8, 0 8px 18px rgba(0, 0, 0, .4); color: #fff; font: 900 clamp(17px, 2.6vmin, 24px)/1.05 var(--round); }
.hold .ring { position: absolute; inset: -10px; border-radius: 50%; border: 4px solid rgba(255, 200, 120, 0); transition: border-color .2s; }
.hold.on { transform: scale(.94); background: radial-gradient(circle at 40% 35%, #ffd0a0, #ff5a2a 60%, #b01e10); }
.hold.on .ring { border-color: rgba(255, 200, 120, .9); animation: breathe .5s ease-in-out infinite; }

/* ---------- page arrows (bottom corners) and quiet controls (top right) ---------- */
.page-controls .corner { position: fixed; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 8; width: 76px; height: 76px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 250, 238, .9); box-shadow: 0 4px 14px rgba(0, 0, 0, .3), inset 0 0 0 2px rgba(120, 190, 255, .7); display: grid; place-items: center; }
.page-controls .previous { left: max(14px, env(safe-area-inset-left)); } .page-controls .next { right: max(14px, env(safe-area-inset-right)); }
.corner svg { width: 46px; height: 46px; fill: none; stroke: #23315e; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.corner:disabled { display: none; }
.corner:focus-visible { outline: 4px solid #ffd36a; outline-offset: 3px; }
.quiet-controls { position: fixed; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); z-index: 8; display: flex; gap: 6px; }
.utility { width: 44px; height: 44px; border-radius: 12px; border: 0; cursor: pointer; background: rgba(255, 250, 238, .78); box-shadow: 0 2px 8px rgba(0, 0, 0, .2); display: grid; place-items: center; }
.utility svg { width: 24px; height: 24px; fill: none; stroke: #23315e; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.utility:focus-visible { outline: 3px solid #ffd36a; }
#sound .off { display: none; } #sound[aria-pressed="true"] .off { display: inline; } #sound[aria-pressed="true"] .waves { display: none; }
#music[aria-pressed="true"], #words[aria-pressed="true"] { background: #ffe6a8; }
#motion .play-icon { display: none; } #motion[aria-pressed="true"] .play-icon { display: inline; } #motion[aria-pressed="true"] .pause-icon { display: none; }
#book[data-words="hidden"] .story { opacity: 0; pointer-events: none; }
#book[data-page="end"][data-words="hidden"] .story { opacity: 1; pointer-events: auto; }

/* word card: a small paper tag in the panel's style */
.word-card { position: fixed; z-index: 12; width: min(340px, calc(100vw - 24px)); padding: 16px 18px 14px; border-radius: 16px; background: #fbf3e0; color: #2a1c0e;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3), inset 0 0 0 1.5px rgba(var(--brass), .9), inset 0 0 0 5px #fbf3e0, inset 0 0 0 6px rgba(var(--brass), .4); }
.word-card h2 { margin: 0 34px 2px 0; font: 700 28px/1.1 var(--display); color: #7a4a10; font-variant: small-caps; letter-spacing: .05em; }
.word-card #word-say { margin: 0 0 6px; font: 600 15px/1.2 var(--body); color: #6a5434; }
.word-card #word-say:empty { display: none; }
.word-card #word-definition { margin: 0 0 10px; font: 500 20px/1.35 var(--body); }
.word-card .replay { font: 700 15px/1 var(--body); padding: 9px 14px; border-radius: 999px; border: 0; background: #f2dfae; color: #5a3a10; cursor: pointer; }
.word-card .close { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border: 0; background: none; font-size: 28px; cursor: pointer; color: #6a5434; }

/* page turn: the old page sweeps away like a leaf (reversed for Back); reduced motion crossfades */
.turn-sheet { position: fixed; inset: 0; z-index: 7; pointer-events: none; }
.turn-sheet img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.turn-sheet .edge { position: absolute; top: 0; bottom: 0; width: 60px; background: linear-gradient(90deg, rgba(0, 0, 0, .25), rgba(255, 250, 235, .9) 40%, rgba(0, 0, 0, 0)); }
.turn-sheet.fwd { animation: leaf-fwd .7s cubic-bezier(.5, 0, .3, 1) forwards; }
.turn-sheet.back { animation: leaf-back .7s cubic-bezier(.5, 0, .3, 1) forwards; }
.turn-sheet.fwd .edge { right: 0; transform: translateX(100%) scaleX(-1); } .turn-sheet.back .edge { left: 0; transform: translateX(-100%); }
.turn-sheet.fade { animation: fade .25s ease-out forwards; }
@keyframes leaf-fwd { from { clip-path: inset(0 0 0 0); transform: none; } to { clip-path: inset(0 100% 0 0); transform: translateX(-4%); } }
@keyframes leaf-back { from { clip-path: inset(0 0 0 0); transform: none; } to { clip-path: inset(0 0 0 100%); transform: translateX(4%); } }
@keyframes fade { to { opacity: 0; } }

.night { position: fixed; inset: 0; z-index: 20; background: #120d08; transition: opacity 6s; }
.night.out { opacity: 0; }
.night canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.night-exit { position: absolute; inset: 0; width: 100%; border: 0; background: none; color: rgba(255, 210, 150, .35); font: 600 16px var(--body); cursor: pointer; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 30px; }
.oops { position: fixed; left: 12px; right: 12px; bottom: 100px; z-index: 30; font: 13px/1.4 var(--body); color: #5a1a10; background: #fff3e8; border: 1px solid #d0452c; border-radius: 10px; padding: 10px 12px; }
.no-script { color: #fff; padding: 2em; }

@media (prefers-reduced-motion: reduce) {
  #book[data-page="end"] .still { animation: none; }
  .story.reveal > *, .story .boom span, .tap::before, .speak-ring.on, .count .n { animation: none !important; }
}
