/* ==========================================================================
   FX — atmosphere layer. Everything here is decorative and pointer-transparent.
   Layers are injected by js/fx.js. Disabled under prefers-reduced-motion.
   ========================================================================== */

/* ---------- Curtain: page fades up out of black ---------- */

html::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  pointer-events: none;
  animation: fx-curtain 1s cubic-bezier(.6, 0, .2, 1) .05s forwards;
}
@keyframes fx-curtain { to { opacity: 0; visibility: hidden; } }

/* ---------- Atmosphere: darkness + flashlight ----------
   One tiny canvas (1/16 resolution) drawn by js/fx.js and stretched to the
   viewport: a single small texture instead of a full-screen gradient. */

.fx-atmo {
  position: fixed;
  inset: 0;
  z-index: 15;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- Film grain (offset stepped by the fx.js ticker) ---------- */

.fx-grain {
  position: fixed;
  inset: -128px 0 0 -128px;
  z-index: 60;
  pointer-events: none;
  opacity: .034;
  background: url("../assets/img/grain.webp") 0 0 / 128px 128px repeat;
  will-change: transform;
}

/* ---------- Failing-bulb flicker on display type ----------
   Glow is static; fx.js adds .is-flickering to one visible title every few
   seconds, so nothing animates in between. */

.intro-title,
.about h2 img { filter: drop-shadow(0 0 10px rgba(255, 255, 255, .18)); }
.section-title,
.contact-title,
.about h2,
.event-info h2 {
  text-shadow: 0 0 14px rgba(255, 255, 255, .18);
}
.is-flickering { animation: fx-flicker .7s linear 1; }

@keyframes fx-flicker {
  0%, 18%, 34%, 52%, 80%, 100% { opacity: 1; }
  10%, 26% { opacity: .44; }
  66% { opacity: .55; }
}

.nav a:hover { animation: fx-flicker-fast .5s linear 1; }
@keyframes fx-flicker-fast {
  0%, 100% { opacity: 1; }
  20% { opacity: .48; }
  35% { opacity: 1; }
  55% { opacity: .63; }
}

/* ---------- Rise: elements surface from the dark ---------- */

/* Blur only runs during the reveal; filter: none afterwards drops the layer */
.fx-rise {
  opacity: 0;
  translate: 0 18px;
  filter: blur(8px);
  transition:
    opacity 1s cubic-bezier(.2, .7, .2, 1),
    translate .9s cubic-bezier(.2, .7, .2, 1),
    filter 1s cubic-bezier(.2, .7, .2, 1);
  transition-delay: var(--fx-delay, 0s);
}
.fx-rise.is-risen {
  opacity: 1;
  translate: 0 0;
  filter: none;
}

/* ---------- Posters: haunted on hover ---------- */

/* Fade in once decoded (main.js adds .is-loaded); the poster's dark box shows until then */
img.fade-img { opacity: 0; transition: opacity .5s; }
img.fade-img.is-loaded { opacity: 1; }
.event-card.is-past a:hover > .poster { filter: none; }
.event-card .poster { transition: filter .8s; }

/* ---------- Buttons: tremble ---------- */

.btn--light:hover,
.btn--recap:hover,
.btn--past:hover { animation: fx-tremble .35s linear infinite; }
/* Carousel arrows keep translate for centring, so they tremble with transform */
.carousel-btn:hover { animation: fx-tremble-t .35s linear infinite; }
@keyframes fx-tremble-t {
  0%, 100% { transform: translate(0, -1px); }
  25% { transform: translate(-.45px, -1.3px); }
  50% { transform: translate(.45px, -.7px); }
  75% { transform: translate(-.3px, -1px); }
}
@keyframes fx-tremble {
  0%, 100% { translate: 0 -1px; }
  25% { translate: -.45px -1.3px; }
  50% { translate: .45px -.7px; }
  75% { translate: -.3px -1px; }
}

/* ---------- Carousel change: signal glitch ---------- */

.feature.is-glitch .feature-slide.is-active {
  animation: fx-glitch .45s steps(1) 1;
}
@keyframes fx-glitch {
  0%   { clip-path: inset(10% 0 60% 0); translate: -9px 0; filter: brightness(1.75) grayscale(1); }
  15%  { clip-path: inset(55% 0 15% 0); translate: 7.5px 0; }
  30%  { clip-path: inset(30% 0 40% 0); translate: -4.5px 0; filter: invert(.75) grayscale(1); }
  45%  { clip-path: inset(0 0 0 0); translate: 3px 0; filter: none; opacity: .55; }
  60%  { opacity: 1; translate: 0 0; }
  100% { clip-path: none; }
}

/* ---------- About CTA: slow pulse, like something breathing behind it ---------- */

.about .cta { position: relative; isolation: isolate; }
.about .cta::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  z-index: -1;
  white-space: pre;
  color: transparent;
  text-shadow: 0 0 22px rgba(255, 255, 255, .26);
  opacity: var(--pulse, .5); /* stepped by the fx.js ticker */
  will-change: opacity;
}

/* ---------- Keep content above the background ---------- */

main { position: relative; z-index: 1; }

/* ---------- Reduced motion: keep the mood, drop the movement ---------- */

@media (prefers-reduced-motion: reduce) {
  html::after { display: none; }
  .fx-grain { display: none; }
  *, *::before, *::after { animation: none !important; }
  .fx-rise { opacity: 1; translate: none; filter: none; transition: none; }
}
