/* ================= OPENING SEQUENCE =================
   A letterboxed, single-shot film over the particle field.
   html.is-intro is set before first paint by the script in <head>. */

/* While the film plays, the page can't scroll anyway. Turning off touch panning means every
   touch, a swipe included, counts as the interaction browsers need before they allow sound. */
html.is-intro,
html.is-intro * {
  touch-action: none !important;
}
html.is-intro {
  overscroll-behavior: none;
}

.intro {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  pointer-events: none;
  color: var(--ink);
}
html.is-intro .intro,
.intro.is-playing {
  display: block;
}
.intro[hidden] {
  display: none !important;
}

.intro__veil {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 75% 70% at 50% 50%, transparent 40%, rgba(0, 0, 0, 0.72) 100%);
  transition: opacity 1.4s var(--ease);
}
.intro__grain {
  position: absolute;
  inset: -40%;
  background-image: var(--grain);
  opacity: 0.075;
  mix-blend-mode: screen;
  animation: grain 0.8s steps(5) infinite;
  transition: opacity 1.2s;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-7%, 4%); }
  40% { transform: translate(5%, -6%); }
  60% { transform: translate(-3%, 8%); }
  80% { transform: translate(6%, 2%); }
  100% { transform: translate(0, 0); }
}
.intro__flash {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255, 252, 240, 0.95) 0, rgba(254, 159, 109, 0.4) 18%, rgba(140, 41, 129, 0.12) 38%, transparent 62%);
  mix-blend-mode: screen;
}
.intro__flash.is-on {
  animation: flash 1.25s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}
@keyframes flash {
  0% { opacity: 0; transform: scale(0.4); }
  7% { opacity: 1; transform: scale(0.9); }
  100% { opacity: 0; transform: scale(1.9); }
}

.intro__cap {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(90vw, 18ch);
  translate: -50% -50%;
  margin: 0;
  font-size: clamp(30px, 4.2vw, 62px);
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: -0.035em;
  text-align: center;
  text-wrap: balance;
  text-shadow: 0 2px 36px rgba(0, 0, 0, 0.85);
}
.intro__cap span {
  display: inline-block;
  opacity: 0;
  filter: blur(16px);
  transform: translateY(0.28em) scale(1.06);
  transition: opacity 0.9s var(--ease), filter 1.1s var(--ease), transform 1.2s var(--ease);
  transition-delay: calc(var(--i) * 85ms);
}
.intro__cap.is-in span {
  opacity: 1;
  filter: blur(0);
  transform: none;
}
.intro__cap.is-out span {
  opacity: 0;
  filter: blur(12px);
  transform: translateY(-0.18em) scale(0.98);
  transition-duration: 0.55s, 0.6s, 0.7s;
  transition-delay: calc(var(--i) * 35ms);
}

.intro__bar {
  position: absolute;
  left: 0;
  right: 0;
  height: max(46px, 10.5vh);
  background: #000;
  transition: transform 1.3s cubic-bezier(0.7, 0, 0.2, 1);
}
.intro__bar--top {
  top: 0;
}
.intro__bar--bot {
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--gutter);
}
.intro__track {
  flex: 1;
  max-width: 420px;
  height: 1px;
  background: rgba(255, 255, 255, 0.14);
  opacity: 0;
  transition: opacity 0.8s;
}
.intro.is-running .intro__track {
  opacity: 1;
}

/* Sound cue, in the top bar. Browsers only allow sound after a click, tap or key press, so
   when the music can't start by itself this asks for one. It is not a button and the film
   doesn't wait for it; it goes away the moment the music starts. */
.intro__bar--top {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--gutter);
}
.intro__sound {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  letter-spacing: 0.01em;
  color: var(--ink-2);
  opacity: 0;
  translate: 0 -6px;
  transition: opacity 0.7s, translate 0.7s var(--ease), color 0.3s;
}
.intro.wants-sound .intro__sound {
  opacity: 1;
  translate: 0 0;
}
.intro.is-nudge .intro__sound {
  color: var(--ink);
}
.intro__eq {
  display: inline-flex;
  align-items: center;
  gap: 2.5px;
  height: 14px;
}
.intro__eq i {
  width: 2px;
  height: 3px;
  border-radius: 1px;
  background: currentColor;
}
.intro.wants-sound .intro__eq i {
  animation: eq-wait 1.8s ease-in-out infinite;
  animation-delay: calc(var(--k) * 0.16s);
}
.intro.is-nudge .intro__eq i {
  animation-duration: 0.7s;
}
@keyframes eq-wait {
  0%, 100% { height: 3px; }
  50% { height: 9px; }
}
/* the music has started: the bars come alive for a moment, then the cue leaves */
.intro.has-sound .intro__sound {
  opacity: 0;
  transition: opacity 0.6s 1.1s, translate 0.7s var(--ease);
}
.intro.has-sound .intro__ask {
  opacity: 0;
  transition: opacity 0.3s;
}
.intro.has-sound .intro__eq i {
  animation: eq-live 0.42s ease-in-out infinite alternate;
  animation-delay: calc(var(--k) * -0.13s);
}
@keyframes eq-live {
  from { height: 3px; }
  to { height: 14px; }
}
.for-touch {
  display: none;
}
@media (hover: none) and (pointer: coarse) {
  .for-touch {
    display: inline;
  }
  .for-pointer {
    display: none;
  }
}

/* the ending: bars part like a curtain, texture lifts */
.intro.is-ending .intro__bar--top {
  transform: translateY(-100%);
}
.intro.is-ending .intro__bar--bot {
  transform: translateY(100%);
}
.intro.is-ending .intro__veil,
.intro.is-ending .intro__grain {
  opacity: 0;
}

/* hero UI waits backstage during the film, then arrives in a stagger */
html.is-intro .nav,
html.is-intro .hero__title,
html.is-intro .hero__sub,
html.is-intro .hero__controls,
html.is-intro .readout {
  opacity: 0;
  transform: translateY(20px);
  filter: blur(8px);
  pointer-events: none;
}
html.is-revealing .nav,
html.is-revealing .hero__title,
html.is-revealing .hero__sub,
html.is-revealing .hero__controls,
html.is-revealing .readout {
  transition: opacity 1s var(--ease), transform 1.3s var(--ease), filter 1.1s var(--ease);
  transition-delay: var(--rd, 0s);
}
.hero__title { --rd: 0.15s; }
.hero__sub { --rd: 0.32s; }
.hero__controls { --rd: 0.48s; }
.readout { --rd: 0.62s; }
.nav { --rd: 0.75s; }

.replay {
  border: 0;
  background: none;
  padding: 0;
  font-size: 13px;
  color: var(--ink-2);
  text-decoration: underline;
  text-decoration-color: var(--hair-2);
  text-underline-offset: 0.2em;
}
.replay:hover {
  color: var(--ink);
}

@media (max-width: 600px) {
  .intro__bar {
    height: max(56px, 9vh);
  }
  .intro__track {
    display: none;
  }
}
