/* KICKOFF · motion.css (M1) : système d'animation global.
   Règle d'or : transform/opacity uniquement (compositeur GPU), 60fps mobile.
   Entrées cubic-bezier(.16,1,.3,1) 300-500ms, staggers 40-70ms, press 120ms.
   Tout est neutralisé sous prefers-reduced-motion (bloc final). */

/* ============================================================
   KEYFRAMES GLOBALES
   ============================================================ */
/* NB : pas de keyframe "to" sur les entrées : l'animation retombe sur la
   valeur naturelle de l'élément (sinon elle écraserait les opacités du style,
   ex. .notif-row lue à .72 ou les blasons estompés à .45). */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
}
@keyframes fadeIn {
  from { opacity: 0; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(.92); }
}
@keyframes popIn {
  0%   { opacity: 0; transform: scale(.55); }
  62%  { opacity: 1; transform: scale(1.07); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes slideInR {
  from { opacity: 0; transform: translateX(28px); }
}
@keyframes slideInL {
  from { opacity: 0; transform: translateX(-28px); }
}
@keyframes viewOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-12px); }
}
@keyframes glowBreath {
  0%, 100% { opacity: .28; }
  50%      { opacity: .85; }
}
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}
@keyframes shimmer {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100%); }
}
@keyframes badgePop {
  0%   { transform: scale(.2); }
  55%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}
@keyframes dotPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.55); opacity: .5; }
}
/* allumage du wordmark (one-shot d'entrée : brightness toléré, jamais en boucle) */
@keyframes igniteUp {
  0%   { opacity: 0; transform: translateY(.4em); filter: brightness(.3); }
  55%  { opacity: 1; transform: translateY(-.03em); filter: brightness(1.9); }
  100% { opacity: 1; transform: translateY(0); filter: brightness(1); }
}
@keyframes slashHit {
  0%   { opacity: 0; transform: translateY(-.55em) scale(1.7); }
  45%  { opacity: 1; transform: translateY(0) scale(1.12); }
  70%  { transform: scale(.94); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes spotSway {
  0%, 100% { transform: rotate(13deg); }
  50%      { transform: rotate(17deg); }
}

/* ============================================================
   UTILITAIRES
   ============================================================ */

/* feedback tactile 120ms */
.press { transition: transform .12s ease; -webkit-tap-highlight-color: transparent; }
.press:active { transform: scale(.96); }
.tab svg { transition: transform .12s ease; }
.tab:active svg { transform: scale(.86); }

/* stagger d'enfants : vague 55ms, plafonnée au 12e
   (fill backwards : cache pendant le délai, puis rend la main au style) */
.anim-stagger > * { animation: fadeUp .5s cubic-bezier(.16,1,.3,1) backwards; }
.anim-stagger > *:nth-child(1)  { animation-delay: .02s; }
.anim-stagger > *:nth-child(2)  { animation-delay: .075s; }
.anim-stagger > *:nth-child(3)  { animation-delay: .13s; }
.anim-stagger > *:nth-child(4)  { animation-delay: .185s; }
.anim-stagger > *:nth-child(5)  { animation-delay: .24s; }
.anim-stagger > *:nth-child(6)  { animation-delay: .295s; }
.anim-stagger > *:nth-child(7)  { animation-delay: .35s; }
.anim-stagger > *:nth-child(8)  { animation-delay: .405s; }
.anim-stagger > *:nth-child(9)  { animation-delay: .46s; }
.anim-stagger > *:nth-child(10) { animation-delay: .515s; }
.anim-stagger > *:nth-child(11) { animation-delay: .57s; }
.anim-stagger > *:nth-child(n+12) { animation-delay: .62s; }

/* stagger piloté par --i (grilles denses : blasons, avatars) */
.stagger-i {
  animation: fadeUp .45s cubic-bezier(.16,1,.3,1) backwards;
  animation-delay: calc(var(--i, 0) * 45ms);
}

/* entrée simple avec délai custom --d */
.a-in {
  animation: fadeUp .55s cubic-bezier(.16,1,.3,1) backwards;
  animation-delay: var(--d, 0s);
}

/* ============================================================
   SKELETONS DE CHARGEMENT
   ============================================================ */
.skel {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--ink-2);
  border: 1px solid var(--line);
}
.skel::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.055), transparent);
  animation: shimmer 1.3s ease infinite;
}
.skel-row { border-radius: 12px; }

/* ============================================================
   AMBIANCE GLOBALE : le stade la nuit
   ============================================================ */
.stadium-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(560px 300px at 50% -80px, rgba(232,0,13,.07), transparent 70%),
    radial-gradient(140% 110% at 50% 55%, transparent 55%, rgba(0,0,0,.38) 100%);
}

/* ============================================================
   TRANSITIONS D'ÉCRAN (routeur)
   ============================================================ */
.view { animation: fadeUp .38s cubic-bezier(.16,1,.3,1) backwards; }
#screen.screen-out .view {
  animation: viewOut .2s cubic-bezier(.4,0,1,1) both;
  pointer-events: none;
}

/* ---------- toasts : slide + rebond léger ---------- */
.toast {
  transform: translateY(-16px) scale(.93);
  transition: opacity .3s cubic-bezier(.16,1,.3,1), transform .38s cubic-bezier(.34,1.56,.64,1);
}
.toast.in { transform: translateY(0) scale(1); }

/* ---------- pastille notification qui pop ---------- */
.notif-badge.pop { animation: badgePop .45s cubic-bezier(.34,1.56,.64,1); }

/* ============================================================
   AUTH : entrée cinématographique
   ============================================================ */
.auth { position: relative; }
.auth > *:not(.auth-fx) { position: relative; z-index: 1; }

/* décor : cônes de projecteurs + braises */
.auth-fx {
  position: absolute;
  inset: -18px -16px auto -16px;
  height: min(72vh, 580px);
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.spot {
  position: absolute;
  top: -32%;
  width: 120px;
  height: 95%;
  border-radius: 40%;
  background: linear-gradient(to bottom, rgba(232,0,13,.13), rgba(232,0,13,.03) 55%, transparent 78%);
  transform-origin: top center;
  filter: blur(10px);
  animation: spotSway 9s ease-in-out infinite;
}
.spot.s1 { left: 6%; }
.spot.s2 { left: 42%; width: 160px; animation-delay: -3s; }
.spot.s3 { right: 4%; animation-delay: -6s; animation-direction: reverse; }
.embers { position: absolute; inset: 0; width: 100%; height: 100%; }

/* wordmark qui s'allume lettre par lettre, slash qui claque */
.auth-wm .wl {
  display: inline-block;
  animation: igniteUp .55s cubic-bezier(.16,1,.3,1) both;
  animation-delay: calc(.1s + var(--i, 0) * .07s);
}
.auth-wm .wl-slash {
  display: inline-block;
  animation: slashHit .5s cubic-bezier(.34,1.56,.64,1) both;
  animation-delay: .66s;
}

/* ============================================================
   ONBOARDING
   ============================================================ */
.onb-prog {
  height: 4px;
  border-radius: 999px;
  background: var(--ink-3);
  border: 1px solid var(--line);
  overflow: hidden;
}
.onb-prog-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--red-deep), var(--red-glow));
  box-shadow: 0 0 12px rgba(232,0,13,.6);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .55s cubic-bezier(.16,1,.3,1);
}

/* transitions entre étapes */
.onb.slide-fwd  { animation: slideInR .34s cubic-bezier(.16,1,.3,1) backwards; }
.onb.slide-back { animation: slideInL .34s cubic-bezier(.16,1,.3,1) backwards; }

/* sélection club : pop + le reste s'efface */
.club-pick {
  transition: border-color .15s ease, transform .12s ease,
              background .15s ease, opacity .3s ease;
}
.club-pick.sel { animation: popIn .32s cubic-bezier(.34,1.56,.64,1); }
#onb-groups.has-sel .club-pick:not(.sel) { opacity: .45; }

/* FIX : noms de clubs longs sur une seule ligne (minmax(0,1fr) :
   sans lui, le nowrap gonfle la min-content des colonnes et la grille déborde) */
.club-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.club-pick { min-width: 0; max-width: 100%; }
.club-pick-name {
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar-pick.sel { animation: popIn .3s cubic-bezier(.34,1.56,.64,1); }

/* ============================================================
   DASHBOARD
   ============================================================ */
/* le glow du prochain match respire (opacity d'un calque, pas de repaint) */
.match-card { position: relative; }
.match-card.breathe::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  box-shadow: 0 0 38px rgba(232,0,13,.30), 0 0 90px rgba(232,0,13,.14);
  opacity: .3;
  animation: glowBreath 3.2s ease-in-out infinite;
  pointer-events: none;
}
/* blasons qui flottent, en léger décalage */
.match-card .match-side .crest { animation: floaty 4.6s ease-in-out infinite; }
.match-card .match-side:last-child .crest { animation-delay: -2.3s; }

/* ============================================================
   LEADERBOARD
   ============================================================ */
/* ma ligne : pulse doux */
.lb-row.mine { position: relative; }
.lb-row.mine::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 12px;
  box-shadow: 0 0 22px rgba(232,0,13,.35);
  opacity: .3;
  animation: glowBreath 2.6s ease-in-out infinite;
  pointer-events: none;
}

/* onglets : indicateur qui glisse (le fond rouge devient un rail) */
.seg.has-ind { position: relative; }
.seg-ind {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 6px);
  border-radius: 9px;
  background: linear-gradient(135deg, var(--red), var(--red-deep));
  box-shadow: var(--glow-red);
  transition: transform .32s cubic-bezier(.16,1,.3,1);
  pointer-events: none;
}
.seg.has-ind .seg-btn { position: relative; z-index: 1; }
.seg.has-ind .seg-btn.active { background: transparent; box-shadow: none; color: #fff; }

/* ============================================================
   PROFIL & NOTIFICATIONS
   ============================================================ */
.badge-chip {
  animation: popIn .4s cubic-bezier(.34,1.56,.64,1) both;
  transition: transform .15s ease;
}
.badge-chip:nth-child(2) { animation-delay: .06s; }
.badge-chip:nth-child(3) { animation-delay: .12s; }
.badge-chip:nth-child(n+4) { animation-delay: .18s; }
.badge-chip:hover { transform: translateY(-2px) scale(1.04); }
.badge-chip:active { transform: scale(1.08); }

.notif-row.unread .notif-dot { animation: dotPulse 1.8s ease-in-out infinite; }

/* ============================================================
   PREFERS-REDUCED-MOTION : tout couper proprement
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  html { scroll-behavior: auto !important; }
  .anim-stagger > *, .stagger-i, .a-in,
  .auth-wm .wl, .auth-wm .wl-slash, .badge-chip {
    animation-delay: 0s !important;
  }
  .spot, .embers { display: none; }
  .stadium-glow { display: none; }
}
