/* Kybernetic landing. Palette from the brand guide; one design system, three atmospheres.
   Only transform and opacity ever animate. */

@font-face { font-family: "Cormorant"; font-style: italic; font-weight: 500; font-display: swap;
  src: url(/fonts/cormorant-garamond-latin-500-italic.4fb55a7a6d.woff2) format("woff2"); }
@font-face { font-family: "Josefin"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(/fonts/josefin-sans-latin-400-normal.242e987823.woff2) format("woff2"); }
@font-face { font-family: "Josefin"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(/fonts/josefin-sans-latin-600-normal.56c4c27838.woff2) format("woff2"); }

:root {
  --navy: #042a37;
  --navy-deep: #021b24;
  --emerald: #42e695;
  --teal: #3bb2b8;
  --mint: #c7f0ed;
  --ink: #e8fbf8;
  --gradient: linear-gradient(180deg, #42e695 0%, #3bb2b8 100%);
  --gradient-h: linear-gradient(90deg, #42e695 0%, #3bb2b8 100%);

  --serif: "Cormorant", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Josefin", "Josefin Sans", "Avenir Next", "Segoe UI", system-ui, sans-serif;

  /* Per-universe accent; swapped by html[data-universe]. */
  --accent: #42e695;
  --accent-soft: rgba(66, 230, 149, 0.14);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --fade-out: 520ms;
  --crossfade: 1800ms;
}
html[data-universe="middle-earth"] { --accent: #e9c46a; --accent-soft: rgba(233, 196, 106, 0.16); }
html[data-universe="star-trek"]    { --accent: #6fb7ff; --accent-soft: rgba(111, 183, 255, 0.16); }
html[data-universe="harry-potter"] { --accent: #b4a7ff; --accent-soft: rgba(180, 167, 255, 0.16); }

*, *::before, *::after { box-sizing: border-box; }
html {
  /* Scales the whole composition: 17px on a laptop, ~25px on 4K. */
  font-size: clamp(16px, 0.35vw + 12px, 26px);
  background: var(--navy-deep);
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  background: radial-gradient(120% 90% at 50% 36%, #07394b 0%, var(--navy) 52%, var(--navy-deep) 100%);
  color: var(--ink);
  font-family: var(--sans);
  overflow-x: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Atmosphere ---------- */
.atmos { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.layer { position: absolute; inset: 0; opacity: 0; transition: opacity var(--crossfade) var(--ease); }
html[data-universe="middle-earth"] .layer-middle-earth,
html[data-universe="star-trek"] .layer-star-trek,
html[data-universe="harry-potter"] .layer-harry-potter { opacity: 1; }

/* A low horizon, echoing the brand background: a faint line of light and its reflection. */
.floor { position: absolute; left: 0; right: 0; bottom: 0; height: 30vh;
  background:
    linear-gradient(90deg, transparent 0%, rgba(66, 230, 149, 0.55) 22%, rgba(59, 178, 184, 0.55) 78%, transparent 100%) top / 100% 1px no-repeat,
    linear-gradient(180deg, rgba(59, 178, 184, 0.07) 0%, rgba(4, 42, 55, 0) 70%); }

/* Middle-earth: warm light through slow mist. */
.layer-middle-earth { background:
    radial-gradient(60% 50% at 50% 100%, rgba(240, 190, 90, 0.34), transparent 72%),
    radial-gradient(45% 40% at 12% 8%, rgba(214, 160, 70, 0.16), transparent 70%); }
.mist { position: absolute; width: 90vmax; height: 90vmax; border-radius: 50%; will-change: transform; }
.mist.m1 { left: -30vmax; top: 5vh;
  background: radial-gradient(closest-side, rgba(244, 205, 120, 0.2), rgba(190, 170, 110, 0.08) 55%, transparent 75%);
  animation: drift-a 70s ease-in-out infinite alternate; }
.mist.m2 { right: -35vmax; top: 25vh;
  background: radial-gradient(closest-side, rgba(230, 240, 225, 0.14), rgba(150, 170, 140, 0.06) 55%, transparent 75%);
  animation: drift-b 90s ease-in-out infinite alternate; }

/* Star Trek: depth, two star fields at different speeds, a cold nebula. */
.layer-star-trek { background: radial-gradient(80% 60% at 78% 18%, rgba(60, 120, 255, 0.34), transparent 70%),
    radial-gradient(60% 50% at 10% 90%, rgba(30, 70, 190, 0.22), transparent 70%); }
.stars { position: absolute; top: 0; left: 0; height: 100%; width: calc(100% + 520px); will-change: transform;
  background-repeat: repeat; }
.stars.s1 { background-size: 520px 520px; opacity: 0.8; animation: pan 260s linear infinite;
  background-image:
    radial-gradient(1px 1px at 40px 60px, #fff, transparent), radial-gradient(1px 1px at 210px 130px, #cfe6ff, transparent),
    radial-gradient(1.5px 1.5px at 380px 40px, #fff, transparent), radial-gradient(1px 1px at 120px 300px, #fff, transparent),
    radial-gradient(1px 1px at 470px 260px, #bfe3ff, transparent), radial-gradient(1.5px 1.5px at 300px 440px, #fff, transparent),
    radial-gradient(1px 1px at 60px 470px, #e6f3ff, transparent), radial-gradient(1px 1px at 430px 480px, #fff, transparent); }
.stars.s2 { background-size: 330px 330px; opacity: 0.5; animation: pan 140s linear infinite;
  background-image:
    radial-gradient(1px 1px at 20px 90px, #fff, transparent), radial-gradient(1px 1px at 160px 30px, #dcecff, transparent),
    radial-gradient(1px 1px at 280px 210px, #fff, transparent), radial-gradient(1px 1px at 90px 260px, #fff, transparent),
    radial-gradient(1px 1px at 240px 310px, #cfe6ff, transparent); }
.nebula { position: absolute; left: 50%; top: 30%; width: 110vmax; height: 70vmax; margin: -35vmax 0 0 -55vmax;
  background:
    radial-gradient(closest-side at 35% 45%, rgba(70, 120, 255, 0.3), transparent 70%),
    radial-gradient(closest-side at 65% 55%, rgba(59, 178, 184, 0.24), transparent 70%);
  will-change: transform, opacity; animation: breathe 40s ease-in-out infinite alternate; }

/* Harry Potter: a violet glow from above and a few rising motes. */
.layer-harry-potter { background: radial-gradient(75% 60% at 50% 0%, rgba(130, 100, 240, 0.42), transparent 70%),
    radial-gradient(50% 40% at 90% 100%, rgba(90, 60, 190, 0.22), transparent 70%); }
.glow { position: absolute; left: 50%; top: 42%; width: 70vmax; height: 70vmax; margin: -35vmax 0 0 -35vmax;
  background: radial-gradient(closest-side, rgba(160, 130, 255, 0.2), transparent 70%);
  will-change: transform, opacity; animation: breathe 18s ease-in-out infinite alternate; }
.motes i { position: absolute; bottom: -6vh; left: var(--x); width: var(--s); height: var(--s); border-radius: 50%;
  background: #d9d2ff; box-shadow: 0 0 8px 2px rgba(180, 167, 255, 0.55); opacity: 0; will-change: transform, opacity;
  animation: rise var(--t) linear var(--d) infinite; }
.motes i:nth-child(1)  { --x: 8%;  --s: 3px; --t: 26s; --d: -2s; }
.motes i:nth-child(2)  { --x: 17%; --s: 2px; --t: 32s; --d: -11s; }
.motes i:nth-child(3)  { --x: 26%; --s: 4px; --t: 29s; --d: -19s; }
.motes i:nth-child(4)  { --x: 35%; --s: 2px; --t: 36s; --d: -7s; }
.motes i:nth-child(5)  { --x: 44%; --s: 3px; --t: 27s; --d: -15s; }
.motes i:nth-child(6)  { --x: 53%; --s: 2px; --t: 34s; --d: -24s; }
.motes i:nth-child(7)  { --x: 61%; --s: 4px; --t: 30s; --d: -5s; }
.motes i:nth-child(8)  { --x: 70%; --s: 2px; --t: 38s; --d: -17s; }
.motes i:nth-child(9)  { --x: 78%; --s: 3px; --t: 28s; --d: -9s; }
.motes i:nth-child(10) { --x: 86%; --s: 2px; --t: 33s; --d: -21s; }
.motes i:nth-child(11) { --x: 92%; --s: 3px; --t: 31s; --d: -13s; }
.motes i:nth-child(12) { --x: 48%; --s: 2px; --t: 40s; --d: -28s; }

@keyframes drift-a { to { transform: translate3d(22vw, -4vh, 0); } }
@keyframes drift-b { to { transform: translate3d(-24vw, 5vh, 0); } }
@keyframes pan { to { transform: translate3d(-520px, 0, 0); } }
@keyframes breathe { from { transform: scale(0.94); opacity: 0.7; } to { transform: scale(1.06); opacity: 1; } }
@keyframes rise {
  0% { transform: translate3d(0, 0, 0); opacity: 0; }
  12% { opacity: 0.85; }
  85% { opacity: 0.5; }
  100% { transform: translate3d(2.5vw, -108vh, 0); opacity: 0; }
}

/* ---------- Composition ---------- */
.brand, main, .controls, footer, .progress { position: relative; z-index: 1; }

.brand { display: flex; align-items: center; justify-content: center; gap: 0.7rem;
  padding: clamp(1.1rem, 3.2vh, 2.2rem) 1rem 0; }
.mark { height: 1.9rem; width: auto; display: block; }
.wordmark { font-weight: 600; font-size: 0.82rem; letter-spacing: 0.5em; margin-right: -0.5em;
  background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* The stage fills the middle row and is absolutely centred, so a longer quotation never moves
   anything else on the page. */
main { position: relative; min-height: 15rem; }
.stage { position: absolute; inset: 0; margin: 0; display: grid; place-content: center; justify-items: center;
  padding: 1.5rem clamp(1.25rem, 6vw, 6rem); text-align: center; }
.stage::before { content: "\201C" / ""; display: block; height: 0.5em; font-family: var(--serif); font-style: italic;
  font-size: clamp(4.5rem, 3rem + 5vw, 9rem); line-height: 1; margin-bottom: 0.1em; opacity: 0.55;
  background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }

.stage[data-open="1"]::before { visibility: hidden; }
.quote { margin: 0; max-width: 21em; font-family: var(--serif); font-style: italic; font-weight: 500;
  color: var(--ink); text-wrap: balance; hyphens: manual; overflow-wrap: break-word;
  text-shadow: 0 0 40px var(--accent-soft); }
.quote p { margin: 0; }
.stage[data-size="short"] .quote { font-size: clamp(2.1rem, 1.3rem + 3.6vw, 5.4rem); line-height: 1.16; }
.stage[data-size="long"]  .quote { font-size: clamp(1.7rem, 1.1rem + 2.5vw, 3.7rem); line-height: 1.24; max-width: 24em; }
.stage[data-size="xl"]    .quote { font-size: clamp(1.45rem, 1rem + 1.9vw, 2.9rem); line-height: 1.3; max-width: 27em; }

.credit { margin-top: clamp(1.4rem, 3.4vh, 2.6rem); display: grid; gap: 0.55rem; justify-items: center; }
.speaker { font-weight: 600; font-size: 0.8rem; letter-spacing: 0.32em; margin-right: -0.32em; text-transform: uppercase;
  color: var(--accent); transition: color var(--crossfade) var(--ease); }
.work { font-weight: 400; font-size: 0.86rem; letter-spacing: 0.1em; color: rgba(199, 240, 237, 0.74); }
.work cite { font-style: normal; }
.sep { opacity: 0.6; }

/* ---------- Reveal ---------- */
.js .stage { opacity: 0; transition: opacity var(--fade-out) var(--ease); }
.js .stage.ready { opacity: 1; }
.js .stage.out { opacity: 0; }
.w { display: inline-block; white-space: pre; opacity: 0; transform: translate3d(0, 0.35em, 0);
  transition: opacity 900ms var(--ease) var(--d, 0ms), transform 1100ms var(--ease) var(--d, 0ms); }
.stage.in .w { opacity: 1; transform: none; }
.js .credit { opacity: 0; transform: translate3d(0, 0.5rem, 0);
  transition: opacity 900ms var(--ease) var(--cd, 600ms), transform 1000ms var(--ease) var(--cd, 600ms); }
.js .stage.in .credit { opacity: 1; transform: none; }
.js .stage.out .credit { transition-delay: 0ms; }

/* ---------- Controls ---------- */
.controls { display: flex; justify-content: center; gap: 0.5rem; padding: 0.5rem 1rem 0.9rem; }
.controls button { width: 2.9rem; height: 2.9rem; display: grid; place-items: center; padding: 0; cursor: pointer;
  background: transparent; border: 1px solid transparent; border-radius: 50%; color: rgba(199, 240, 237, 0.62);
  transition: color 250ms var(--ease), border-color 250ms var(--ease), background-color 250ms var(--ease); }
.controls button:hover { color: var(--accent); border-color: rgba(199, 240, 237, 0.2); }
.controls button:focus-visible { outline: 2px solid var(--emerald); outline-offset: 3px; color: var(--ink); }
.controls button:active { background: var(--accent-soft); }
.controls svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round; }
.i-play { display: none; fill: currentColor !important; }
#toggle[aria-pressed="true"] .i-pause { display: none; }
#toggle[aria-pressed="true"] .i-play { display: block; }

.progress { height: 2px; width: min(22rem, 56vw); margin: 0 auto 1.1rem; background: rgba(199, 240, 237, 0.1);
  border-radius: 2px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--gradient-h); transform: scaleX(0); transform-origin: left; }
.progress span.run { animation: fill var(--interval, 18s) linear forwards; }
.progress span.hold { animation-play-state: paused; }
@keyframes fill { to { transform: scaleX(1); } }

footer { padding: 0 1.25rem clamp(0.9rem, 2.4vh, 1.5rem); text-align: center; }
footer p { margin: 0 auto; max-width: 60rem; font-size: 0.72rem; letter-spacing: 0.06em; line-height: 1.6;
  color: rgba(199, 240, 237, 0.62); text-wrap: balance; }

/* ---------- Small and unusual screens ---------- */
@media (max-width: 520px) {
  .wordmark { letter-spacing: 0.4em; margin-right: -0.4em; }
  .quote { max-width: 100%; }
  .speaker { letter-spacing: 0.26em; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .brand { display: none; }
  main { min-height: 10.5rem; }
  .stage::before { display: none; }
  .stage[data-size="short"] .quote { font-size: clamp(1.5rem, 4.4vh, 2.6rem); }
  .stage[data-size="long"] .quote, .stage[data-size="xl"] .quote { font-size: clamp(1.2rem, 3.8vh, 2rem); }
  .credit { margin-top: 0.9rem; }
  .controls { padding-bottom: 0.2rem; }
  .progress { margin-bottom: 0.4rem; }
}
@media (min-aspect-ratio: 21/9) { .quote { max-width: 26em; } }

@media (forced-colors: active) {
  .wordmark, .stage::before { background: none; color: CanvasText; }
  .speaker { color: LinkText; }
}

/* ---------- Reduced motion: still, with a plain short fade; rotation starts paused (app.js) ---------- */
@media (prefers-reduced-motion: reduce) {
  .atmos *, .atmos *::before { animation: none !important; }
  .motes { display: none; }
  .layer, .speaker { transition-duration: 0.01ms; }
  .js .stage { transition-duration: 200ms; }
  .w, .js .credit { transform: none; transition: opacity 200ms linear; transition-delay: 0ms; }
  .progress span.run { animation: none; }
}

/* Used by app.js to swap content while hidden without animating the reset. */
.snap, .snap .w, .snap .credit { transition: none !important; }
