html, body {
  background: var(--noite);
}

#loader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--noite);
  display: grid;
  place-items: center;
  transition: opacity 0.6s var(--ease-out-cinema), visibility 0.6s;
}

#loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.loader-mark {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: 0.32em;
  color: var(--osso);
}

.loader-progress {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  color: var(--texto-fraco);
}

#timeline-track {
  position: relative;
  width: 100%;
  height: 1000vh;
  background: var(--noite);
}

#stage {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: var(--noite);
}

#stage-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#overlay-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.film-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 7;
  opacity: 0.08;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.92' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.65 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 240px 240px;
  animation: grainShift 0.8s steps(3) infinite;
  will-change: background-position;
}

@keyframes grainShift {
  0%   { background-position: 0 0; }
  33%  { background-position: -80px 60px; }
  66%  { background-position: 100px -40px; }
  100% { background-position: -40px -80px; }
}

@media (prefers-reduced-motion: reduce) {
  .film-grain { animation: none; }
}

#film-fade-out {
  position: absolute;
  inset: 0;
  background: var(--noite);
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  transition: opacity 1s var(--ease-in-out-cinema);
}

#film-fade-out.is-active {
  opacity: 1;
}
