/* =====================================================================
   Mouvements de l'interface : chargement entre les pages, entrées,
   boutons, fenêtres, notifications, cartes, classement, boutique.
   Une seule « signature » de mouvement : départ vif, arrivée douce
   (var(--ease-out)), petit dépassement pour ce qui « se pose » (ressort).
   Tout est coupé si l'appareil demande moins d'animations, et allégé
   en qualité « Économie » (html[data-fx="eco"]).
   ===================================================================== */

:root {
  --ease-snap: cubic-bezier(0.2, 0.9, 0.2, 1);
  --spring: linear(0, 0.009, 0.035 2.1%, 0.141, 0.281 6.7%, 0.723 12.9%, 0.938 16.7%, 1.017, 1.077, 1.121, 1.149 24.3%, 1.159, 1.163, 1.161, 1.154 29.9%, 1.129 32.8%, 1.051 39.6%, 1.017 43.1%, 0.991, 0.977 51%, 0.974 53.8%, 0.975 57.1%, 0.997 69.8%, 1.003 76.9%, 1.004 83.8%, 1);
}

/* ---------- Chargement d'une page : un filet rouge file sous l'en-tête ---------- */
.header::before {
  content: '';
  position: absolute;
  left: 0;
  bottom: -2px;
  z-index: 3;
  width: 38%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--red) 30%, #fff 70%, transparent);
  box-shadow: 0 0 12px var(--red);
  opacity: 0;
  transform: translateX(-110%);
  pointer-events: none;
}
body.routing .header::before {
  opacity: 1;
  animation: routeBar 0.9s var(--ease-snap) infinite;
}
@keyframes routeBar {
  to {
    transform: translateX(280%);
  }
}

/* ---------- Entrée d'une page ---------- */
.page-enter {
  animation: pageIn2 0.55s var(--ease-out) backwards;
}
@keyframes pageIn2 {
  from {
    opacity: 0;
    transform: translateY(18px);
    clip-path: inset(0 0 12% 0);
  }
}
.page-head h1 {
  animation: headIn 0.7s var(--ease-out) 0.05s backwards;
}
.page-head .eyebrow {
  animation: headIn 0.6s var(--ease-out) backwards;
}
@keyframes headIn {
  from {
    opacity: 0;
    transform: translateX(-26px) skewX(-8deg);
    filter: blur(4px);
  }
}
.page-head::after {
  animation: ruleIn 0.8s var(--ease-out) 0.15s backwards;
}
@keyframes ruleIn {
  from {
    transform: skewX(-30deg) scaleX(0);
  }
}

/* ---------- Boutons : reflet au survol, enfoncement, onde au clic ---------- */
.btn {
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.15s var(--ease-out), background 0.15s, color 0.15s, scale 0.12s var(--ease-out), box-shadow 0.2s;
}
.btn:not(.glow)::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.22) 50%, transparent 65%);
  transform: translateX(-130%);
  pointer-events: none;
}
.btn:not(.glow):hover::after {
  transform: translateX(130%);
  transition: transform 0.6s var(--ease-out);
}
.btn:not([disabled]):active {
  scale: 0.96;
}
/* le contenu passe devant le reflet ; l'onde du clic, elle, reste hors du flux (sinon le bouton grandit) */
.btn > :not(.fx-ripple) {
  position: relative;
  z-index: 1;
}
.btn-hot:not([disabled]):hover {
  box-shadow: 0 8px 26px -6px rgba(225, 6, 0, 0.7);
}
.btn-gold:not([disabled]):hover {
  box-shadow: 0 8px 26px -6px rgba(255, 184, 0, 0.6);
}

/* ---------- Menus, onglets, liens de navigation ---------- */
.dropdown {
  transform-origin: top right;
  transition: opacity 0.18s, transform 0.28s var(--spring);
}
.dropdown:not(.open) {
  transform: translateY(-8px) scale(0.96);
}
.nav a.active::after,
.tabs a.active::after {
  animation: tabIn 0.4s var(--ease-out);
}
@keyframes tabIn {
  from {
    transform: skewX(-30deg) scaleX(0);
  }
}
.nav a::before {
  content: '';
  position: absolute;
  left: 11px;
  right: 11px;
  bottom: -12px;
  height: 3px;
  background: rgba(255, 255, 255, 0.35);
  transform: skewX(-30deg) scaleX(0);
  transform-origin: left;
  transition: transform 0.3s var(--ease-out);
}
.nav a:not(.active):hover::before {
  transform: skewX(-30deg) scaleX(1);
}

/* ---------- Fenêtres : arrivée sur ressort, fond qui s'assombrit ---------- */
.modal-back {
  animation: backIn 0.25s ease-out backwards;
}
@keyframes backIn {
  from {
    background: rgba(0, 0, 0, 0);
  }
}
html[data-fx='ultra'] .modal-back {
  backdrop-filter: blur(5px) saturate(0.8);
}
.modal {
  animation: modalIn2 0.5s var(--spring) backwards;
}
@keyframes modalIn2 {
  from {
    opacity: 0;
    transform: translateY(26px) scale(0.94);
  }
  40% {
    opacity: 1;
  }
}
.modal::before {
  /* filet de lumière qui parcourt la bordure rouge à l'ouverture */
  content: '';
  position: absolute;
  top: -3px;
  left: 0;
  width: 40%;
  height: 3px;
  background: linear-gradient(90deg, transparent, #fff, transparent);
  animation: modalRule 0.9s 0.15s var(--ease-out) both;
  pointer-events: none;
}
@keyframes modalRule {
  from {
    transform: translateX(-100%);
    opacity: 1;
  }
  to {
    transform: translateX(260%);
    opacity: 0;
  }
}

/* ---------- Notifications : glissent, minuteur qui s'écoule ---------- */
.toast {
  position: relative;
  overflow: hidden;
  animation: toastIn2 0.55s var(--spring) backwards;
}
@keyframes toastIn2 {
  from {
    opacity: 0;
    transform: translateX(110%) skewX(-8deg);
  }
}
.toast::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: currentColor;
  opacity: 0.35;
  transform-origin: left;
  animation: toastTimer var(--ms, 3800ms) linear forwards;
}
.toast.ok::after {
  background: var(--ok);
  opacity: 0.8;
}
.toast.err::after {
  background: var(--bad);
  opacity: 0.8;
}
.toast.gold::after {
  background: var(--gold);
  opacity: 0.9;
}
@keyframes toastTimer {
  to {
    transform: scaleX(0);
  }
}
.toast.out {
  animation: toastOut2 0.32s var(--ease-in, ease-in) forwards;
}
@keyframes toastOut2 {
  to {
    opacity: 0;
    transform: translateX(60%) scale(0.92);
  }
}

/* ---------- Cartes : arrivée en cascade, soulèvement au survol, sélection ---------- */
.card-slot {
  animation: cardIn2 0.6s var(--ease-out) backwards;
}
@keyframes cardIn2 {
  from {
    opacity: 0;
    transform: translateY(26px) rotateX(-14deg) scale(0.95);
  }
}
.card-grid > .card-slot:nth-child(2) { animation-delay: 30ms; }
.card-grid > .card-slot:nth-child(3) { animation-delay: 60ms; }
.card-grid > .card-slot:nth-child(4) { animation-delay: 90ms; }
.card-grid > .card-slot:nth-child(5) { animation-delay: 120ms; }
.card-grid > .card-slot:nth-child(6) { animation-delay: 150ms; }
.card-grid > .card-slot:nth-child(7) { animation-delay: 180ms; }
.card-grid > .card-slot:nth-child(8) { animation-delay: 210ms; }
.card-grid > .card-slot:nth-child(9) { animation-delay: 240ms; }
.card-grid > .card-slot:nth-child(10) { animation-delay: 270ms; }
.card-grid > .card-slot:nth-child(11) { animation-delay: 300ms; }
.card-grid > .card-slot:nth-child(12) { animation-delay: 330ms; }
.card-grid > .card-slot:nth-child(n + 13) { animation-delay: 360ms; }

/* la carte se soulève (propriété « translate » : se cumule avec l'inclinaison 3D) */
.card .body {
  transition: transform 0.5s var(--ease-out), box-shadow 0.3s, translate 0.35s var(--ease-out), scale 0.35s var(--ease-out);
}
.card-slot:hover .card .body,
.card.tilting .body {
  translate: 0 -2.4cqw;
}
/* au survol, les cartes Épiques et plus « respirent » une lumière de leur couleur */
.card.r-4 .body::after,
.card.r-5 .body::after,
.card.r-6 .body::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 5;
  border-radius: inherit;
  box-shadow: inset 0 0 0 0.7cqw color-mix(in srgb, var(--rc) 80%, #fff), 0 0 7cqw color-mix(in srgb, var(--rc) 60%, transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.card-slot:hover .card.r-4 .body::after,
.card-slot:hover .card.r-5 .body::after,
.card-slot:hover .card.r-6 .body::after,
.card.tilting.r-4 .body::after,
.card.tilting.r-5 .body::after,
.card.tilting.r-6 .body::after {
  opacity: 1;
  animation: rarityBreath 1.6s ease-in-out infinite;
}
@keyframes rarityBreath {
  50% {
    opacity: 0.45;
  }
}
/* sélection (échanges, atelier, bataille) : la carte « clique » en place */
.card.selected .body {
  animation: selectPop 0.45s var(--spring);
}
@keyframes selectPop {
  from {
    scale: 0.92;
  }
}

/* ---------- Classement : lignes en cascade, podium qui brille ---------- */
.table tbody tr {
  animation: rowIn 0.45s var(--ease-out) backwards;
}
.table tbody tr:nth-child(2) { animation-delay: 25ms; }
.table tbody tr:nth-child(3) { animation-delay: 50ms; }
.table tbody tr:nth-child(4) { animation-delay: 75ms; }
.table tbody tr:nth-child(5) { animation-delay: 100ms; }
.table tbody tr:nth-child(6) { animation-delay: 125ms; }
.table tbody tr:nth-child(7) { animation-delay: 150ms; }
.table tbody tr:nth-child(8) { animation-delay: 175ms; }
.table tbody tr:nth-child(9) { animation-delay: 200ms; }
.table tbody tr:nth-child(10) { animation-delay: 225ms; }
.table tbody tr:nth-child(n + 11) { animation-delay: 250ms; }
@keyframes rowIn {
  from {
    opacity: 0;
    transform: translateX(-18px);
  }
}
.podium .step {
  position: relative;
  overflow: hidden;
}
.podium .step.p1::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 220, 120, 0.35) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: sweep 3.6s 0.8s ease-in-out infinite;
  pointer-events: none;
}

/* ---------- Boutique : produits éclairés par le pointeur, paquet qui suit la souris ---------- */
.shop-pack {
  --mx: 50%;
  --my: 0%;
  --tx: 0deg;
  --ty: 0deg;
  /* pas d'« overflow: hidden » : le bandeau « Le plus choisi » dépasse volontairement en haut */
  animation: shopIn 0.65s var(--spring) backwards;
}
@keyframes shopIn {
  from {
    opacity: 0;
    transform: translateY(34px) scale(0.94);
  }
}
.shop-pack::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(260px circle at var(--mx) var(--my), rgba(255, 255, 255, 0.09), transparent 60%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.shop-pack:hover::before {
  opacity: 1;
}
.shop-pack.hot::after {
  /* bordure qui pulse doucement sur l'offre mise en avant */
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(225, 6, 0, 0.9), 0 0 22px rgba(225, 6, 0, 0.35);
  animation: hotPulse 2.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes hotPulse {
  50% {
    opacity: 0.35;
  }
}
.shop-art {
  perspective: 700px;
}
.shop-pack:hover .shop-art .pack {
  transform: rotate(-2deg) translateY(-8px) rotateX(var(--tx)) rotateY(var(--ty));
  transition: transform 0.12s linear;
}
.shop-credits {
  transition: transform 0.3s var(--spring);
}
.shop-pack:hover .shop-credits {
  transform: scale(1.08);
}

/* ---------- Décorations (réglages, profil) ---------- */
.deco-card,
.cos-card {
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s;
}
.deco-card:hover,
.cos-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px -12px rgba(0, 0, 0, 0.8);
}

/* ---------- Qualité « Économie » : pas d'effets coûteux en continu ---------- */
html[data-fx='eco'] .card-slot:hover .card .body::after,
html[data-fx='eco'] .shop-pack.hot::after,
html[data-fx='eco'] .podium .step.p1::after {
  animation: none;
}
html[data-fx='off'] .card-slot,
html[data-fx='off'] .table tbody tr,
html[data-fx='off'] .shop-pack {
  animation: none;
}

/* ---------- Réglage de la qualité des effets ---------- */
.fx-quality {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.fx-quality label {
  position: relative;
  padding: 8px 14px;
  font: 800 italic 0.85rem var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.25s var(--spring);
}
.fx-quality label.on {
  background: var(--red);
  border-color: var(--red);
  transform: scale(1.04);
}
.fx-quality input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* ---------- Moins d'animations demandé par l'appareil ---------- */
@media (prefers-reduced-motion: reduce) {
  .page-enter,
  .page-head h1,
  .page-head .eyebrow,
  .card-slot,
  .table tbody tr,
  .shop-pack,
  .modal,
  .toast,
  .card.selected .body {
    animation-duration: 0.01ms !important;
  }
  .btn:not(.glow)::after,
  .card-slot:hover .card .body::after,
  .shop-pack.hot::after,
  .podium .step.p1::after,
  body.routing .header::before {
    animation: none !important;
    transition: none !important;
  }
}
