:root {
  --ink: #05060b;
  --cream: #f3ead9;
  --gold: #d9b77e;
  --gold-soft: rgba(217, 183, 126, 0.55);
  --serif: "Didot", "Bodoni 72", "Bodoni MT", "Playfair Display", "Hoefler Text", Georgia, "Times New Roman", serif;
  --sans: "Avenir Next", "Avenir", "Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif;

  /* When the title card starts to arrive. Without JavaScript there is no title sequence, so it arrives at once. */
  --title-at: 0s;
}

/* intro.js adds "js" before first paint, which switches on the full title sequence. */
.js {
  --title-at: calc(var(--lead, 0s) + 25.5s);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  height: 100%;
  background: var(--ink);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.stage {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  justify-items: center;
  min-height: 100vh;
  min-height: 100svh;
  padding:
    max(1.5rem, env(safe-area-inset-top))
    max(1.5rem, env(safe-area-inset-right))
    max(1.75rem, env(safe-area-inset-bottom))
    max(1.5rem, env(safe-area-inset-left));
  overflow: hidden;
  isolation: isolate;
  text-align: center;
}

/* ---------- Background layers, back to front ---------- */

.backdrop,
.sky,
.shade,
.curtain {
  position: absolute;
  inset: 0;
}

.backdrop {
  --focus-y: 62%; /* which part of the image stays in view when it is cropped */
  z-index: -4;
  background: var(--ink) url("/assets/hero.jpg") center var(--focus-y) / cover no-repeat;
  transform-origin: 50% var(--horizon-y, 78%);
  animation: drift 40s ease-in-out infinite alternate;
}

/* Warm light on the horizon that slowly brightens and dims. Needs the horizon position from intro.js. */
.glow {
  display: none;
  position: absolute;
  left: 50%;
  top: var(--horizon-y);
  width: 130%;
  height: 38vh;
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgba(255, 214, 150, 0.5), rgba(214, 160, 92, 0.18) 45%, rgba(214, 160, 92, 0));
  mix-blend-mode: screen;
  animation: breathe 9s ease-in-out infinite alternate;
}

.has-horizon .glow {
  display: block;
}

.sky {
  z-index: -3;
  width: 100%;
  height: 100%;
}

.shade {
  z-index: -2;
  background:
    radial-gradient(ellipse at 50% 45%, rgba(5, 6, 11, 0.35), rgba(5, 6, 11, 0) 65%),
    linear-gradient(to bottom, rgba(5, 6, 11, 0.55), rgba(5, 6, 11, 0) 30%, rgba(5, 6, 11, 0) 70%, rgba(5, 6, 11, 0.7));
}

/* Black curtain that lifts to reveal the scene. */
.curtain {
  z-index: -1;
  background: var(--ink);
  opacity: 0;
  pointer-events: none;
  animation: lift 2.8s ease-out both;
}

.js .curtain {
  animation: lift var(--lift-for, 9s) ease-in-out var(--lift-at, 2s) both;
}

/* The first thing on screen: a line of light drawn along the horizon. */
.first-light {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: var(--horizon-y);
  height: 2px;
  margin-top: -1px;
  background: linear-gradient(to right, rgba(217, 183, 126, 0), var(--gold) 25%, #fff4dc 50%, var(--gold) 75%, rgba(217, 183, 126, 0));
  box-shadow: 0 0 18px 2px rgba(240, 196, 130, 0.55);
  opacity: 0;
  pointer-events: none;
  animation: first-light var(--light-for, 8s) ease-in-out 0.4s both;
}

.has-horizon .first-light {
  display: block;
}

/* ---------- Opening cards ---------- */

.cards {
  display: none;
  position: absolute;
  inset: 0;
  place-items: center;
  padding: 2rem max(1.75rem, env(safe-area-inset-right)) 2rem max(1.75rem, env(safe-area-inset-left));
  pointer-events: none;
}

.js .cards {
  display: grid;
}

.card {
  grid-area: 1 / 1;
  max-width: 24ch;
  margin: 0;
  font-size: clamp(1.4rem, 1rem + 2.4vw, 2.6rem);
  font-style: italic;
  line-height: 1.35;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 24px rgba(5, 6, 11, 0.7);
  opacity: 0;
  animation: card 5.5s ease-in-out both;
}

/* Timed to the music: the third card is fully on screen 20.5s after the lead, when its line is sung.
   --lead is how much instrumental opening plays first; intro.js sets it. */
.card:nth-child(1) { animation-delay: calc(var(--lead, 0s) + 4s); }
.card:nth-child(2) { animation-delay: calc(var(--lead, 0s) + 11s); }
.card:nth-child(3) { animation-delay: calc(var(--lead, 0s) + 19s); animation-duration: 5.6s; }

.card-credit {
  font-style: normal;
  letter-spacing: 0.14em;
  text-indent: 0.14em;
  text-transform: uppercase;
}

.card-credit span {
  display: block;
  margin-bottom: 0.9rem;
}

/* ---------- Title card ---------- */

.title-card {
  grid-row: 2;
  max-width: 100%;
}

.eyebrow,
.coming,
.card-credit span,
.countdown small,
.skip {
  font-family: var(--sans);
  font-size: clamp(0.75rem, 0.68rem + 0.3vw, 0.85rem);
  font-weight: 500;
  font-style: normal;
  letter-spacing: 0.36em;
  text-indent: 0.36em; /* balances the trailing letter-space so the text stays centred */
  text-transform: uppercase;
  color: var(--gold);
}

.eyebrow,
.coming {
  margin: 0;
}

.eyebrow {
  animation: rise 1.6s ease-out calc(var(--title-at) + 0.6s) both;
}

h1 {
  margin: 1.4rem 0 0;
  font-size: clamp(2.1rem, 9.5vw, 6rem);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  text-transform: uppercase;
  text-shadow: 0 2px 30px rgba(5, 6, 11, 0.6);
  animation: rise 2s ease-out calc(var(--title-at) + 1s) both;
}

h1 span {
  display: block;
}

.rule {
  width: min(9rem, 40%);
  height: 1px;
  margin: 1.9rem auto 1.6rem;
  background: linear-gradient(to right, transparent, var(--gold), transparent);
  animation: widen 1.8s ease-out calc(var(--title-at) + 1.8s) both;
}

.tagline {
  margin: 0;
  font-size: clamp(1.05rem, 0.9rem + 0.9vw, 1.5rem);
  font-style: italic;
  letter-spacing: 0.03em;
  color: rgba(243, 234, 217, 0.88);
  animation: rise 1.8s ease-out calc(var(--title-at) + 2.2s) both;
}

/* ---------- Countdown and release line ---------- */

.marquee {
  grid-row: 3;
  align-self: end;
  display: grid;
  justify-items: center;
  gap: 1rem;
  animation: rise 1.8s ease-out calc(var(--title-at) + 3s) both;
}

.countdown {
  display: flex;
  gap: clamp(1rem, 5vw, 2.4rem);
}

.countdown div {
  display: grid;
  gap: 0.4rem;
  min-width: 3.2rem;
}

.countdown span {
  font-size: clamp(1.5rem, 1.2rem + 1.6vw, 2.3rem);
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 1;
  letter-spacing: 0.04em;
}

.countdown small {
  font-size: 0.66rem;
  letter-spacing: 0.26em;
  text-indent: 0.26em;
}

.coming {
  padding: 0.9rem 0 0.2rem;
  border-top: 1px solid var(--gold-soft);
  color: rgba(243, 234, 217, 0.8);
}

/* ---------- Begin screen ---------- */

/* Browsers only allow sound after a tap, so the sequence waits behind a Begin button. */
.waiting .seq,
.waiting .backdrop {
  animation-play-state: paused;
}

.gate {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.6rem;
  transition: opacity 0.9s ease;
  animation: rise 1.6s ease-out 0.3s both;
}

.gate.leaving {
  opacity: 0;
  pointer-events: none;
}

.begin {
  display: grid;
  justify-items: center;
  gap: 1.5rem;
  padding: 1rem 2rem;
  border: 0;
  background: none;
  color: var(--cream);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.begin svg {
  width: clamp(4.5rem, 20vw, 6rem);
  height: auto;
  overflow: visible;
  animation: pulse 3.2s ease-in-out infinite alternate;
}

.begin circle {
  fill: rgba(217, 183, 126, 0.06);
  stroke: var(--gold);
  stroke-width: 1;
}

.begin path {
  fill: var(--cream);
}

.begin span {
  font-family: var(--serif);
  font-size: clamp(1.1rem, 0.9rem + 1vw, 1.5rem);
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  text-transform: uppercase;
}

.begin:hover circle {
  fill: rgba(217, 183, 126, 0.16);
}

.hint {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  text-transform: uppercase;
  color: rgba(243, 234, 217, 0.5);
}

/* ---------- Corner controls: music, skip and replay ---------- */

.sound {
  position: absolute;
  top: max(0.5rem, env(safe-area-inset-top));
  left: max(0.5rem, env(safe-area-inset-left));
  min-height: 2.75rem;
  padding: 0.6rem 1rem;
  border: 0;
  background: none;
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(243, 234, 217, 0.55);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sound:hover {
  color: var(--cream);
}

.skip {
  position: absolute;
  top: max(0.5rem, env(safe-area-inset-top));
  right: max(0.5rem, env(safe-area-inset-right));
  min-height: 2.75rem;
  padding: 0.6rem 1rem;
  border: 0;
  background: none;
  font-size: 0.68rem;
  letter-spacing: 0.28em;
  text-indent: 0;
  color: rgba(243, 234, 217, 0.55);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  animation: rise 1.2s ease-out 1.5s both;
}

.skip:hover {
  color: var(--cream);
}

a {
  color: var(--gold);
  text-underline-offset: 0.25em;
}

a:focus-visible,
.skip:focus-visible,
.sound:focus-visible,
.begin:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 0.3em;
}

/* Skipping jumps every part of the sequence to its final state. */
.intro-skip .seq {
  animation-duration: 1ms !important;
  animation-delay: 0s !important;
}

/* ---------- Layout variations ---------- */

/* Wide screens: title on one line */
@media (min-width: 60rem) {
  h1 span {
    display: inline;
  }
}

/* Phones held sideways: little height to work with */
@media (orientation: landscape) and (max-height: 30rem) {
  h1 {
    margin-top: 0.6rem;
    font-size: clamp(1.8rem, 10vh, 3rem);
  }

  h1 span {
    display: inline;
  }

  .rule {
    margin: 0.7rem auto 0.6rem;
  }

  .marquee {
    gap: 0.45rem;
  }

  .countdown {
    gap: 1.5rem;
  }

  .countdown div {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    min-width: 0;
  }

  .countdown span {
    font-size: 1.15rem;
  }

  .coming {
    padding-top: 0.45rem;
  }

  .gate {
    gap: 0.8rem;
  }

  .begin {
    gap: 0.8rem;
  }

  .begin svg {
    width: 4rem;
  }
}

/* ---------- Motion ---------- */

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

@keyframes first-light {
  0% { opacity: 0; transform: scaleX(0); }
  8% { opacity: 1; }
  45% { opacity: 1; transform: scaleX(1); }
  100% { opacity: 0; transform: scaleX(1); }
}

@keyframes card {
  0% { opacity: 0; transform: translateY(0.5rem); }
  30% { opacity: 1; transform: none; }
  72% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: none; }
}

@keyframes drift {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

@keyframes pulse {
  from { transform: scale(1); opacity: 0.85; }
  to { transform: scale(1.06); opacity: 1; }
}

@keyframes breathe {
  from { opacity: 0.2; }
  to { opacity: 0.9; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(0.6rem); }
  to { opacity: 1; transform: none; }
}

@keyframes widen {
  from { opacity: 0; transform: scaleX(0); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
  }
}
