/* =====================================================================
   Effets visuels : toile WebGL, bandes cinéma, grands titres, fissures,
   ondes au clic. Les animations elles-mêmes sont pilotées en JavaScript
   (public/js/gfx/) ; ce fichier ne donne que l'apparence.
   Ordre des plans : page < bandes cinéma (355) < toile d'effets (360)
   < fissures (365) < grands titres (370) < notifications (400).
   ===================================================================== */

canvas#fx-gl {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 360;
  pointer-events: none;
  display: none;
}

.fx-flash {
  position: fixed;
  inset: 0;
  z-index: 365;
  pointer-events: none;
  mix-blend-mode: screen;
}

/* ---------- Bandes de cinéma ---------- */
.fx-letterbox {
  position: fixed;
  inset: 0;
  z-index: 355;
  pointer-events: none;
}
.fx-letterbox i {
  position: absolute;
  left: 0;
  right: 0;
  height: min(11vh, 90px);
  background: #000;
  will-change: transform;
}
.fx-letterbox i:first-child {
  top: 0;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
}
.fx-letterbox i:last-child {
  bottom: 0;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.6);
}

/* ---------- Grands titres « cinéma » ---------- */
.fx-title {
  --tc: var(--gold);
  position: fixed;
  left: 50%;
  top: 42%;
  z-index: 370;
  pointer-events: none;
  transform: translate(-50%, -50%);
  width: max-content;
  max-width: calc(100vw - 24px);
  text-align: center;
  perspective: 900px;
  will-change: transform, opacity;
}
/* bandeau incliné derrière le mot, façon habillage de course télévisé */
.fx-title-word::before {
  content: '';
  position: absolute;
  inset: 8% -6%;
  z-index: -1;
  background: linear-gradient(100deg, rgba(10, 10, 12, 0.97), rgba(24, 24, 28, 0.95));
  clip-path: polygon(4% 0, 100% 0, 96% 100%, 0 100%);
  box-shadow: inset 0 -3px 0 var(--tc);
  transform-origin: left center;
  animation: fxPlate 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.fx-title-word::after {
  /* filet de couleur qui file sous le bandeau */
  content: '';
  position: absolute;
  left: -6%;
  right: -6%;
  bottom: 2%;
  height: 4px;
  background: linear-gradient(90deg, transparent, var(--tc) 20%, #fff 50%, var(--tc) 80%, transparent);
  filter: drop-shadow(0 0 8px var(--tc));
  transform-origin: left;
  animation: fxRule 0.9s 0.15s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes fxPlate {
  from {
    transform: scaleX(0) skewX(-18deg);
    opacity: 0;
  }
  to {
    transform: scaleX(1) skewX(0);
    opacity: 1;
  }
}
@keyframes fxRule {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}
.fx-title-word {
  position: relative;
  isolation: isolate;
  display: flex;
  justify-content: center;
  padding: 0.06em 0.4em 0.1em;
  font: 900 italic clamp(2.4rem, 9vw, 6.4rem) / 1 var(--font-display);
  text-transform: uppercase;
  letter-spacing: -0.01em;
  white-space: nowrap;
  transform-style: preserve-3d;
  filter: drop-shadow(0 0 22px color-mix(in srgb, var(--tc) 55%, transparent)) drop-shadow(0 6px 0 rgba(0, 0, 0, 0.55));
}
.fx-title-word span {
  display: inline-block;
  will-change: transform, opacity, filter;
  /* deux couches découpées dans les lettres : un reflet qui balaie (lettre après lettre),
     sur un dégradé de métal (clair en haut, sombre en bas) */
  background:
    linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, 0.95) 50%, transparent 62%) no-repeat,
    linear-gradient(180deg, #ffffff 0%, color-mix(in srgb, var(--tc) 35%, #fff) 30%, var(--tc) 58%, color-mix(in srgb, var(--tc) 55%, #000) 100%);
  background-size: 300% 100%, 100% 100%;
  background-position: 160% 0, 0 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  /* les lettres italiques débordent de leur boîte : on élargit la zone peinte sans changer l'espacement */
  padding: 0.04em 0.14em 0.08em;
  margin: 0 -0.14em;
  animation: fxSweep 1.4s calc(0.45s + var(--i) * 0.045s) cubic-bezier(0.65, 0, 0.35, 1) both;
}
@keyframes fxSweep {
  from {
    background-position: 160% 0, 0 0;
  }
  to {
    background-position: -60% 0, 0 0;
  }
}
.fx-title-sub {
  margin-top: 0.7em;
  font: 800 italic clamp(0.8rem, 2.4vw, 1.15rem) / 1.25 var(--font-display);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
}
.fx-title-victory .fx-title-word {
  font-size: clamp(2.8rem, 11vw, 7.6rem);
}
.fx-title-victory .fx-title-word::before {
  box-shadow: inset 0 -4px 0 var(--red), inset 0 4px 0 rgba(255, 255, 255, 0.06);
}
.fx-title-defeat {
  --tc: #aab3c5;
}
.fx-title-defeat .fx-title-word span {
  background:
    linear-gradient(115deg, transparent 40%, rgba(220, 230, 255, 0.55) 50%, transparent 60%) no-repeat,
    linear-gradient(180deg, #e8ecf4 0%, #9aa3b5 45%, #4b5160 100%);
  background-size: 300% 100%, 100% 100%;
  -webkit-background-clip: text;
  background-clip: text;
}
.fx-title-defeat .fx-title-word::before {
  background: linear-gradient(100deg, rgba(8, 9, 12, 0.94), rgba(20, 22, 28, 0.9));
  box-shadow: inset 0 -3px 0 #4b5160;
}
.fx-title-defeat .fx-title-word::after {
  background: linear-gradient(90deg, transparent, #5b606b 25%, #aab3c5 50%, #5b606b 75%, transparent);
  filter: none;
}
/* couleurs très claires (or) : lettres sombres sur bandeau doré, comme l'ancienne annonce */
.fx-title.dark .fx-title-word::before {
  background: linear-gradient(100deg, var(--tc), color-mix(in srgb, var(--tc) 75%, #fff));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.35);
}
.fx-title.dark .fx-title-word {
  filter: drop-shadow(0 0 26px color-mix(in srgb, var(--tc) 70%, transparent));
}
.fx-title.dark .fx-title-word span {
  background:
    linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, 0.85) 50%, transparent 60%) no-repeat,
    linear-gradient(180deg, #2a1d00 0%, #000 100%);
  background-size: 300% 100%, 100% 100%;
  -webkit-background-clip: text;
  background-clip: text;
}
.fx-title.dark .fx-title-sub {
  color: #fff;
}

/* ---------- Verre fissuré ---------- */
.fx-crack {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 365;
  pointer-events: none;
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.6)) drop-shadow(0 0 1px rgba(0, 0, 0, 0.9));
}
.fx-crack path {
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Onde au clic ---------- */
.fx-ripple,
.btn > .fx-ripple {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0.18) 40%, transparent 70%);
  mix-blend-mode: plus-lighter;
  z-index: 0;
}

/* Préférence « réduire les animations » : aucun mouvement dans les titres */
@media (prefers-reduced-motion: reduce) {
  .fx-title-word::before,
  .fx-title-word::after,
  .fx-title-word span {
    animation: none;
  }
}
