.stage { position: relative; aspect-ratio: 747 / 1000; overflow: hidden; border-radius: 10px; background: #eee; }
.stage > img, .stage > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.stage > svg.fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* Flicker uses linear segments so the beam is already changing on the first frame. */
.flicker { animation: flicker 2.6s linear infinite; }
@keyframes flicker {
  0%, 100% { opacity: .25; } 12% { opacity: .62; } 23% { opacity: .28; } 37% { opacity: .72; }
  48% { opacity: .38; } 61% { opacity: .66; } 74% { opacity: .3; } 86% { opacity: .56; }
}
.pulse { animation: pulse 2.6s linear infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse {
  0%, 100% { opacity: .18; transform: scale(1); } 12% { opacity: .55; }
  23% { opacity: .2; transform: scale(.97); } 37% { opacity: .65; }
  48% { opacity: .3; transform: scale(1.02); } 61% { opacity: .58; }
  74% { opacity: .2; transform: scale(.98); } 86% { opacity: .48; }
}
.bloom { animation: bloom 6.5s linear infinite; transform-box: fill-box; transform-origin: center; opacity: 0; }
@keyframes bloom {
  0% { opacity: 0; transform: scale(.55) translate(0, 0); }
  35% { opacity: .85; transform: scale(1) translate(calc(var(--dx) * .5), calc(var(--dy) * .5)); }
  70% { opacity: .6; transform: scale(1.18) translate(var(--dx), var(--dy)); }
  100% { opacity: 0; transform: scale(1.3) translate(calc(var(--dx) * 1.3), calc(var(--dy) * 1.3)); }
}
.dust { animation: dust 6s linear infinite; opacity: 0; }
@keyframes dust {
  0% { opacity: 0; transform: translate(0, -1.5px); }
  15% { opacity: .85; }
  80% { opacity: .6; }
  100% { opacity: 0; transform: translate(3px, 6px) translateX(var(--drift)); }
}
/* Leonardo line-draw: the mask rectangle slides from the torch toward the paper (transform only). */
/* Starts slightly advanced (negative delay) so the pen is already moving on the first frame. */
.sweep { animation: sweep 4.2s linear -0.12s infinite; }
@keyframes sweep {
  0% { transform: translateX(0); opacity: 1; }
  36% { transform: translateX(var(--sweep)); opacity: 1; }
  88% { transform: translateX(var(--sweep)); opacity: 1; }
  94% { transform: translateX(var(--sweep)); opacity: 0; }
  94.5% { transform: translateX(0); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}
.deepen { animation: deepen 6s ease-in-out infinite; }
@keyframes deepen { 0%, 100% { opacity: .1; } 50% { opacity: .55; } 80% { opacity: .45; } }
.breathe { animation: breathe 6s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: .0; } 50% { opacity: .45; } }

@media (prefers-reduced-motion: reduce) {
  .flicker, .pulse, .bloom, .dust, .sweep, .deepen, .breathe { animation: none !important; }
  .flicker, .pulse { opacity: .4; }
  .sweep { transform: translateX(var(--sweep)); }
}
