/*
 * Boosters : compteur de la navbar, écran d'ouverture (app/features/boosters.js)
 * et onglet Cartes de la collection (app/pages/collection.js).
 */

/* Compteur de la navbar */

nav .booster-pill {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	border: none;
	cursor: pointer;
	font: inherit;
	font-family: var(--FontFocus);
}

nav .booster-pill.empty {
	opacity: 0.55;
}

/* Minuteur en cours (app/layout.js) : la bordure se remplit jusqu'au prochain booster.
   --progress (0 à 1) est posé chaque seconde par le JS */
nav .booster-pill.timer {
	position: relative;
	opacity: 1;
}

nav .booster-pill.timer::before {
	content: '';
	position: absolute;
	inset: 0;
	padding: 2px;
	border-radius: inherit;
	background: conic-gradient(var(--ColorPrimary) calc(var(--progress, 0) * 360deg), rgba(255, 255, 255, 0.12) 0);
	-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
	-webkit-mask-composite: xor;
	mask-composite: exclude;
	pointer-events: none;
}

/* Sans booster, seul le contenu reste estompé : la bordure du minuteur reste lisible */
nav .booster-pill.empty.timer > * {
	opacity: 0.55;
}

nav .booster-pill.has-boosters i {
	animation: booster-pill-wiggle 2.4s ease-in-out infinite;
}

@keyframes booster-pill-wiggle {
	0%, 80%, 100% {
		transform: rotate(0);
	}

	85% {
		transform: rotate(-14deg);
	}

	90% {
		transform: rotate(12deg);
	}

	95% {
		transform: rotate(-6deg);
	}
}

/* Écran d'ouverture */

.booster-layer {
	position: fixed;
	inset: 0;
	width: 100%;
	max-width: none;
	height: 100%;
	max-height: none;
	margin: 0;
	padding: 1rem;
	border: none;
	box-sizing: border-box;
	background: radial-gradient(circle at 50% 40%, rgba(40, 40, 60, 0.92), rgba(5, 5, 10, 0.97));
	color: #fff;
	overflow: hidden;
	opacity: 0;
	transition: opacity 0.3s ease;
}

.booster-layer::backdrop {
	background: transparent;
}

.booster-layer.open {
	opacity: 1;
}

.booster-close {
	position: absolute;
	top: 1rem;
	right: 1rem;
	z-index: 10;
	width: 2.75rem;
	height: 2.75rem;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	font-size: 1.2rem;
	cursor: pointer;
}

.booster-stage {
	/* Au-dessus du fond doré du god pack (.booster-aura) */
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100%;
}

.booster-hint,
.booster-count {
	margin: 0;
	text-align: center;
	opacity: 0.8;
}

.booster-count {
	font-weight: 700;
	font-size: 1.1rem;
	opacity: 1;
}

.booster-intro,
.booster-reveal {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2rem;
}

/* Rareté de la carte retournée (losanges, css/trading-card.css .rarity-gems) : place gardée avant le
   premier retournement, pas de saut */
.booster-rarity {
	display: flex;
	justify-content: center;
	min-height: 2.25rem;
	margin: -1rem 0;
}

/* Paquet : css/booster-pack.css (partagé avec l'admin) */

.booster-tag,
.collection-card .card-count {
	width: auto;
}


/* Choix du booster : carrousel des emballages (app/features/boosters.js : packTemplate).
   Le rail se décale de --index boosters, plus --drag pendant un glissement ; celui du centre
   est en avant, ses voisins en retrait sur les côtés */
.booster-carousel {
	--slide: min(56vw, 230px);
	--gap: 0.75rem;
	position: relative;
	width: 100vw;
	/* Les voisins débordent de l'écran, mais pas la secousse ni la déchirure du booster */
	overflow-x: clip;
	touch-action: pan-y;
	user-select: none;
	-webkit-user-select: none;
}

.booster-carousel .booster-pack {
	width: var(--slide);
}

.booster-carousel img {
	pointer-events: none;
	-webkit-user-drag: none;
}

.booster-track {
	display: flex;
	gap: var(--gap);
	padding-left: calc(50% - var(--slide) / 2);
	transform: translateX(calc(var(--drag, 0px) - var(--index, 0) * (var(--slide) + var(--gap))));
	transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.booster-track.dragging {
	transition: none;
}

.booster-slide {
	flex: 0 0 var(--slide);
	transition: transform 0.4s ease, opacity 0.4s ease, filter 0.4s ease;
}

/* Assombris plutôt que transparents : on ne voit pas la page à travers */
.booster-carousel.several .booster-slide:not(.active) {
	transform: scale(0.78);
	filter: brightness(0.4) saturate(0.6);
}

/* Le booster au centre est le seul à flotter */
.booster-slide:not(.active) .booster-pack {
	animation: none;
}

/* Pendant l'ouverture, seul le booster choisi reste */
.booster-carousel.opening .booster-slide:not(.active),
.booster-carousel.opening .booster-arrow {
	opacity: 0;
	pointer-events: none;
}

.booster-arrow {
	position: absolute;
	top: 50%;
	z-index: 1;
	display: none;
	align-items: center;
	justify-content: center;
	width: 2.75rem;
	height: 2.75rem;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	font-size: 1rem;
	cursor: pointer;
	transform: translateY(-50%);
	transition: opacity 0.2s ease;
}

.booster-arrow.prev {
	left: calc(50% - var(--slide) / 2 - 4rem);
}

.booster-arrow.next {
	right: calc(50% - var(--slide) / 2 - 4rem);
}

.booster-arrow:disabled {
	opacity: 0;
	pointer-events: none;
}

/* Flèches à la souris seulement : au doigt, on glisse */
@media (hover: hover) and (pointer: fine) {
	.booster-arrow {
		display: flex;
	}
}

.booster-set {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.15rem;
	max-width: min(92vw, 420px);
	margin-top: -1rem;
	text-align: center;
}

.booster-set span {
	width: auto;
	max-width: 100%;
}

.booster-set-name {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	font-weight: 700;
	font-size: 1.1rem;
}

.booster-set-count {
	font-size: 0.85rem;
	opacity: 0.7;
}

.booster-dots {
	display: flex;
	gap: 0.5rem;
	margin-top: -1.25rem;
}

.booster-dot {
	width: 0.5rem;
	height: 0.5rem;
	padding: 0;
	border: none;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.3);
	cursor: pointer;
	transition: width 0.3s ease, background 0.3s ease;
}

.booster-dot[aria-current="true"] {
	width: 1.5rem;
	background: #fff;
}

/* Pendant l'ouverture : plus de choix */
.booster-intro:has(.booster-carousel.opening) .booster-set,
.booster-intro:has(.booster-carousel.opening) .booster-dots {
	opacity: 0;
	transition: opacity 0.2s ease;
}

.booster-summary-set {
	margin: -0.5rem 0 0;
	text-align: center;
	opacity: 0.75;
}

.booster-pack.opening {
	animation: booster-shake 0.35s linear infinite;
}

.booster-pack.torn {
	animation: none;
}

.booster-pack.torn .booster-pack-top {
	transform: translate(40%, -180%) rotate(-35deg);
	opacity: 0;
}

.booster-pack.torn .booster-pack-body {
	animation: booster-burst 0.65s ease-in forwards;
}

/* God pack : le booster se couvre d'or et s'emballe (tremblement, grossissement, éclat)
   jusqu'au flash, puis se déchire en gardant cette pose */
.booster-pack-top,
.booster-pack-body {
	isolation: isolate;
}

.booster-pack-top {
	position: relative;
}

.booster-pack-top::before,
.booster-pack-body::before {
	content: '';
	position: absolute;
	inset: 0;
	z-index: -1;
	background: linear-gradient(145deg, #fff3b0, #ffd65a 30%, #c98a12 70%, #7a4a00);
	opacity: 0;
	transition: opacity 0.5s ease;
	pointer-events: none;
}

.booster-pack-top::before {
	background: var(--ridges), linear-gradient(145deg, #fff3b0, #ffd65a 40%, #c98a12);
}

.booster-pack.god .booster-pack-top::before,
.booster-pack.god .booster-pack-body::before {
	opacity: 1;
}

/* L'or recouvre aussi l'illustration et le motif choisis dans l'admin */
.booster-pack.god .booster-pack-art,
.booster-pack.god .booster-pack-pattern {
	opacity: 0;
}

.booster-pack.god {
	animation: booster-god-charge 1.6s ease-in forwards;
}

.booster-pack.god.torn {
	animation: none;
	transform: scale(1.15);
	filter: brightness(1.8) drop-shadow(0 0 40px rgba(255, 200, 40, 0.9));
}

@keyframes booster-god-charge {
	0% {
		transform: none;
		filter: brightness(1) drop-shadow(0 0 0 rgba(255, 200, 40, 0));
	}

	10% { transform: translateX(-2px) rotate(-1deg) scale(1.01); }
	18% { transform: translateX(2px) rotate(1deg) scale(1.02); }
	26% { transform: translateX(-3px) rotate(-2deg) scale(1.03); }
	33% { transform: translateX(3px) rotate(2deg) scale(1.04); }
	40% { transform: translateX(-4px) rotate(-3deg) scale(1.05); }
	46% { transform: translateX(5px) rotate(3deg) scale(1.06); }
	52% { transform: translateX(-6px) rotate(-4deg) scale(1.07); }
	57% { transform: translateX(6px) rotate(4deg) scale(1.08); }
	62% { transform: translateX(-7px) rotate(-5deg) scale(1.09); }
	67% { transform: translateX(8px) rotate(5deg) scale(1.1); }
	71% { transform: translateX(-8px) rotate(-6deg) scale(1.11); }
	75% { transform: translateX(9px) rotate(6deg) scale(1.12); }
	79% { transform: translateX(-9px) rotate(-6deg) scale(1.12); }
	83% { transform: translateX(10px) rotate(7deg) scale(1.13); }
	87% { transform: translateX(-10px) rotate(-7deg) scale(1.13); }
	90% { transform: translateX(10px) rotate(7deg) scale(1.14); }
	93% { transform: translateX(-10px) rotate(-7deg) scale(1.14); }
	96% { transform: translateX(8px) rotate(5deg) scale(1.15); }

	100% {
		transform: scale(1.15);
		filter: brightness(1.8) drop-shadow(0 0 40px rgba(255, 200, 40, 0.9));
	}
}

/* Flash blanc plein écran au moment où le god pack se déchire */
.booster-flash {
	position: absolute;
	inset: 0;
	z-index: 5;
	background: radial-gradient(circle at 50% 45%, #fff 30%, #fff6d0 65%, #ffd65a);
	pointer-events: none;
	animation: booster-flash 0.7s ease-out forwards;
}

@keyframes booster-flash {
	0% {
		opacity: 0;
	}

	12% {
		opacity: 1;
	}

	100% {
		opacity: 0;
	}
}

/* Fond doré du god pack : lueur, rayons lents et particules qui montent */
.booster-aura {
	position: absolute;
	inset: 0;
	overflow: hidden;
	background: radial-gradient(circle at 50% 45%, rgba(255, 200, 60, 0.45), rgba(150, 90, 0, 0.25) 45%, transparent 75%);
	opacity: 0;
	transition: opacity 0.6s ease;
	pointer-events: none;
}

.booster-aura.on {
	opacity: 1;
}

.booster-aura::before {
	content: '';
	position: absolute;
	top: 45%;
	left: 50%;
	width: 200vmax;
	aspect-ratio: 1;
	translate: -50% -50%;
	background: repeating-conic-gradient(from 0deg, rgba(255, 215, 0, 0.12) 0deg 8deg, transparent 8deg 24deg);
	-webkit-mask: radial-gradient(circle, #000 5%, transparent 45%);
	mask: radial-gradient(circle, #000 5%, transparent 45%);
	animation: booster-rays 40s linear infinite;
}

.booster-mote {
	position: absolute;
	bottom: -1rem;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #ffe58a;
	box-shadow: 0 0 8px 2px rgba(255, 200, 60, 0.8);
	opacity: 0;
	animation: booster-mote-rise 5s linear infinite;
}

/* Variété par cycles de longueurs différentes (12, 5, 7, 3), comme les confettis */
.booster-mote:nth-child(12n+1) { left: 8%; }
.booster-mote:nth-child(12n+2) { left: 63%; }
.booster-mote:nth-child(12n+3) { left: 29%; }
.booster-mote:nth-child(12n+4) { left: 88%; }
.booster-mote:nth-child(12n+5) { left: 45%; }
.booster-mote:nth-child(12n+6) { left: 17%; }
.booster-mote:nth-child(12n+7) { left: 74%; }
.booster-mote:nth-child(12n+8) { left: 37%; }
.booster-mote:nth-child(12n+9) { left: 95%; }
.booster-mote:nth-child(12n+10) { left: 3%; }
.booster-mote:nth-child(12n+11) { left: 55%; }
.booster-mote:nth-child(12n+12) { left: 81%; }

.booster-mote:nth-child(5n+1) { animation-duration: 4.2s; --drift: 30px; }
.booster-mote:nth-child(5n+2) { animation-duration: 6s; --drift: -20px; }
.booster-mote:nth-child(5n+3) { animation-duration: 5.1s; --drift: 45px; }
.booster-mote:nth-child(5n+4) { animation-duration: 6.8s; --drift: -40px; }
.booster-mote:nth-child(5n+5) { animation-duration: 4.7s; --drift: 10px; }

.booster-mote:nth-child(7n+1) { animation-delay: 0s; }
.booster-mote:nth-child(7n+2) { animation-delay: -1.3s; }
.booster-mote:nth-child(7n+3) { animation-delay: -2.9s; }
.booster-mote:nth-child(7n+4) { animation-delay: -0.6s; }
.booster-mote:nth-child(7n+5) { animation-delay: -3.7s; }
.booster-mote:nth-child(7n+6) { animation-delay: -2.1s; }
.booster-mote:nth-child(7n+7) { animation-delay: -4.4s; }

.booster-mote:nth-child(3n+2) { width: 4px; height: 4px; }
.booster-mote:nth-child(3n+3) { width: 8px; height: 8px; }

@keyframes booster-mote-rise {
	0% {
		transform: translate(0, 0);
		opacity: 0;
	}

	15% {
		opacity: 1;
	}

	80% {
		opacity: 0.8;
	}

	100% {
		transform: translate(var(--drift, 0), -105vh);
		opacity: 0;
	}
}

/* Les cartes encore face cachée brillent : toutes sont rares */
.booster-reveal.god-pack .booster-card:not(.flipped) .booster-face.back {
	animation: booster-god-pulse 1.2s ease-in-out infinite;
}

@keyframes booster-god-pulse {
	0%, 100% {
		filter: drop-shadow(0 0 4px rgba(255, 214, 90, 0.6));
	}

	50% {
		filter: drop-shadow(0 0 16px rgba(255, 200, 40, 1));
	}
}

@keyframes booster-shake {
	0%, 100% {
		transform: translateX(0) rotate(0);
	}

	25% {
		transform: translateX(-6px) rotate(-3deg);
	}

	75% {
		transform: translateX(6px) rotate(3deg);
	}
}

@keyframes booster-burst {
	40% {
		transform: scale(1.08);
		filter: brightness(1.6);
	}

	100% {
		transform: scale(0.6) translateY(30%);
		opacity: 0;
		filter: brightness(3);
	}
}

/* Pile de cartes */

.booster-stack {
	position: relative;
	width: min(72vw, 300px);
	aspect-ratio: 63 / 88;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.booster-card {
	position: absolute;
	inset: 0;
	perspective: 1200px;
	/* Éventail plafonné à 6 rangs : au-delà, les cartes s'empilent sans s'écarter davantage */
	transform: translateY(calc(min(var(--i), 5) * -4px)) rotate(calc(min(var(--i), 5) * 1.5deg - 3deg));
	/* Durée et décalage : STACK_IN_MS et STACK_STAGGER_MS (app/features/boosters.js) */
	animation: booster-card-in 0.5s cubic-bezier(0.2, 0.8, 0.3, 1.2) backwards;
	animation-delay: calc(var(--i) * 80ms);
	transition: transform 0.45s cubic-bezier(0.5, 0, 0.75, 0), opacity 0.45s ease;
}

.booster-card.flipped {
	transform: none;
}

/* Rang dans la pile (--i : décalage, inclinaison, délai d'arrivée ; z-index : la première carte
   au-dessus) posé en ligne par le JS, quel que soit le nombre de cartes */

/* Carte bonus (la dernière de la pile) : une fois les autres posées (--bonus-delay, posé sur la
   pile), elle tombe par-dessus dans une onde de lumière, reste un instant, puis glisse sous la pile
   pour être retournée en dernier. Brille tant qu'elle est face cachée.
   Durée : BONUS_ARRIVE_MS dans app/features/boosters.js */
.booster-card.bonus {
	animation: booster-bonus-arrive 1.7s backwards;
	animation-delay: var(--bonus-delay);
}

.booster-card.bonus::before {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: -1;
	width: 200%;
	aspect-ratio: 1;
	translate: -50% -50%;
	border-radius: 50%;
	background: radial-gradient(circle, rgba(124, 240, 255, 0.9) 0%, rgba(138, 92, 255, 0.6) 30%, transparent 62%);
	opacity: 0;
	pointer-events: none;
	animation: booster-bonus-burst 1.1s ease-out forwards;
	animation-delay: calc(var(--bonus-delay) + 0.35s);
}

.booster-reveal .booster-card.bonus:not(.flipped) .booster-face.back {
	animation: booster-bonus-pulse 1.2s ease-in-out infinite;
}

.booster-bonus-badge {
	position: absolute;
	bottom: calc(100% + 0.75rem);
	left: 50%;
	z-index: 20;
	padding: 0.35rem 0.9rem;
	border-radius: 99px;
	background: linear-gradient(135deg, #7cf0ff, #8a5cff);
	color: #fff;
	font-size: 0.85rem;
	font-weight: 800;
	width: auto;
	white-space: nowrap;
	box-shadow: 0 0 18px rgba(124, 240, 255, 0.6);
	translate: -50% 0;
	animation: booster-bonus-badge 0.5s cubic-bezier(0.2, 0.8, 0.3, 1.5) backwards;
	animation-delay: calc(var(--bonus-delay) + 0.35s);
	transition: opacity 0.3s ease;
	pointer-events: none;
}

/* Le badge s'efface dès la première carte retournée */
.booster-stack.started .booster-bonus-badge {
	opacity: 0;
}

/* Chute (0 à 35 %) et pause sur le dessus de la pile, à la pose de la première carte ; glissement
   sur le côté, passage dessous (z-index), puis retour à son rang dans l'éventail */
@keyframes booster-bonus-arrive {
	0% {
		z-index: 50;
		transform: translateY(-60vh) rotate(20deg) scale(1.2);
		opacity: 0;
		animation-timing-function: cubic-bezier(0.2, 0.8, 0.3, 1.25);
	}

	35% {
		z-index: 50;
		transform: rotate(-3deg);
		opacity: 1;
	}

	62% {
		z-index: 50;
		transform: rotate(-3deg);
		animation-timing-function: ease-in-out;
	}

	80% {
		z-index: 50;
		transform: translateX(70%) rotate(12deg);
		animation-timing-function: ease-in-out;
	}

	81% {
		z-index: 0;
		transform: translateX(70%) rotate(12deg);
		animation-timing-function: ease-in-out;
	}

	100% {
		z-index: 0;
	}
}

@keyframes booster-bonus-burst {
	0% {
		opacity: 0;
		transform: scale(0.3);
	}

	20% {
		opacity: 1;
	}

	100% {
		opacity: 0;
		transform: scale(1.4);
	}
}

/* Carte bonus retournée, puis dans le récapitulatif : elle garde son halo (pas d'étiquette) */
.booster-card.bonus.flipped .booster-face.front .tcard,
.booster-summary-card.bonus .tcard {
	filter: drop-shadow(0 0 6px rgba(124, 240, 255, 0.8)) drop-shadow(0 0 14px rgba(138, 92, 255, 0.9));
}

@keyframes booster-bonus-pulse {
	0%, 100% {
		filter: drop-shadow(0 0 4px rgba(124, 240, 255, 0.6));
	}

	50% {
		filter: drop-shadow(0 0 16px rgba(138, 92, 255, 1));
	}
}

@keyframes booster-bonus-badge {
	from {
		opacity: 0;
		transform: scale(0.4) translateY(1rem);
	}
}

.booster-card.gone {
	transform: translateX(-130vw) rotate(-25deg);
	opacity: 0;
	pointer-events: none;
}

/*
 * Retournement : on ne compte pas sur backface-visibility, que Safari iOS rate dès
 * que la face contient un mix-blend-mode (reflet des cartes) ou un halo en
 * z-index négatif (les deux faces clignotent). Chaque face est masquée au moment
 * où la carte est de profil (90°, à 40 % de l'animation).
 */
.booster-flip {
	position: relative;
	width: 100%;
	height: 100%;
	transform-style: preserve-3d;
}

.booster-card.flipped .booster-flip {
	animation: booster-flip 0.7s forwards;
}

.booster-face {
	position: absolute;
	inset: 0;
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
}

.booster-face.front {
	transform: rotateY(180deg);
	visibility: hidden;
}

.booster-card.flipped .booster-face.back {
	animation: booster-face-out 0.7s forwards;
}

.booster-card.flipped .booster-face.front {
	animation: booster-face-in 0.7s forwards;
}

@keyframes booster-flip {
	0% {
		transform: rotateY(0deg);
		animation-timing-function: cubic-bezier(0.5, 0, 1, 0.6);
	}

	40% {
		transform: rotateY(90deg);
		animation-timing-function: cubic-bezier(0, 0.5, 0.3, 1.15);
	}

	100% {
		transform: rotateY(180deg);
	}
}

@keyframes booster-face-out {
	0%, 39.9% {
		visibility: visible;
	}

	40%, 100% {
		visibility: hidden;
	}
}

@keyframes booster-face-in {
	0%, 39.9% {
		visibility: hidden;
	}

	40%, 100% {
		visibility: visible;
	}
}

/* Halo derrière une carte rare : cercle centré (pas calé sur le format de la carte) */
.booster-card.rare .booster-face.front::before {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: -1;
	width: 180%;
	aspect-ratio: 1;
	translate: -50% -50%;
	border-radius: 50%;
	background: radial-gradient(circle, #fff 0%, transparent 60%);
	opacity: 0;
	pointer-events: none;
	animation: booster-glow 1.6s ease-out 0.35s forwards;
}

/* Couleur du halo selon l'effet de la carte (reflet : blanc) */
.booster-card.rare-holo .booster-face.front::before {
	background: radial-gradient(circle, rgba(190, 140, 255, 0.95) 0%, rgba(120, 200, 255, 0.5) 30%, transparent 60%);
}

.booster-card.rare-rainbow .booster-face.front::before {
	background: conic-gradient(from 0deg, #ff004c, #ff9a00, #ffe600, #34e05a, #00b7ff, #8a3dff, #ff004c);
	-webkit-mask: radial-gradient(circle, #000 15%, transparent 60%);
	mask: radial-gradient(circle, #000 15%, transparent 60%);
	animation: booster-glow 1.6s ease-out 0.35s forwards, booster-rays 6s linear infinite;
}

/* Légendaire : rayons fins qui tournent, fondus vers l'extérieur */
.booster-card.rare-gold .booster-face.front::before {
	background: repeating-conic-gradient(from 0deg, rgba(255, 215, 0, 0.75) 0deg 6deg, transparent 6deg 22deg);
	-webkit-mask: radial-gradient(circle, #000 20%, transparent 68%);
	mask: radial-gradient(circle, #000 20%, transparent 68%);
	animation: booster-glow 1.6s ease-out 0.35s forwards, booster-rays 12s linear infinite;
}

@keyframes booster-card-in {
	from {
		transform: translateY(40vh) scale(0.6);
		opacity: 0;
	}
}

@keyframes booster-glow {
	30% {
		opacity: 1;
	}

	100% {
		opacity: 0.55;
	}
}

@keyframes booster-rays {
	to {
		rotate: 360deg;
	}
}

.booster-tag {
	position: absolute;
	top: -0.6rem;
	right: -0.4rem;
	z-index: 2;
	padding: 0.25rem 0.6rem;
	border-radius: 99px;
	background: rgba(30, 30, 30, 0.85);
	color: #fff;
	font-size: 0.75rem;
	font-weight: 700;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.booster-tag.new {
	background: linear-gradient(135deg, #ffc500, #ff7992);
	color: #1b1b1b;
}

.booster-hint.god-pack {
	color: #ffd65a;
	font-weight: 700;
}

/* Récapitulatif */

.booster-summary {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 1.5rem;
	width: 100%;
	/* Défilement vertical : le navigateur coupe aussi sur les côtés. Marge intérieure pour que
	   l'étiquette Nouvelle ! et les halos des cartes ne soient pas rognés */
	max-width: calc(480px + 3rem);
	max-height: 100%;
	overflow-y: auto;
	padding: 3rem 1.5rem 1.75rem;
	box-sizing: border-box;
}

.booster-summary .titre {
	color: #fff;
}

/* 3 cartes par ligne, sur mobile comme sur desktop. Flex plutôt que grid : la dernière ligne
   incomplète reste centrée */
.booster-summary-grid {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 1rem;
	width: 100%;
}

.booster-summary-card {
	position: relative;
	flex: 0 0 calc((100% - 2rem) / 3);
	min-width: 0;
	padding: 0;
	border: none;
	background: none;
	color: inherit;
	font: inherit;
	text-align: inherit;
	cursor: pointer;
	animation: booster-card-in 0.45s cubic-bezier(0.2, 0.8, 0.3, 1.2) backwards;
}

/* Arrivée en cascade du récapitulatif */
.booster-summary-card:nth-child(1) { animation-delay: 0ms; }
.booster-summary-card:nth-child(2) { animation-delay: 60ms; }
.booster-summary-card:nth-child(3) { animation-delay: 120ms; }
.booster-summary-card:nth-child(4) { animation-delay: 180ms; }
.booster-summary-card:nth-child(5) { animation-delay: 240ms; }
.booster-summary-card:nth-child(6) { animation-delay: 300ms; }
.booster-summary-card:nth-child(7) { animation-delay: 360ms; }
.booster-summary-card:nth-child(8) { animation-delay: 420ms; }
.booster-summary-card:nth-child(9) { animation-delay: 480ms; }
.booster-summary-card:nth-child(10) { animation-delay: 540ms; }
.booster-summary-card:nth-child(11) { animation-delay: 600ms; }

.booster-actions {
	flex: none;
	align-items: stretch;
	align-self: center;
	width: 100%;
	max-width: 320px;
	margin: 0 auto;
}

.booster-actions .btn {
	justify-content: center;
	width: 100%;
	margin: 0;
}

/* Onglet Cartes de la collection */

.cards-set {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	width: 100%;
}

.cards-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
	gap: 0.9rem;
}

.collection-card {
	position: relative;
	padding: 0;
	border: none;
	background: none;
	cursor: pointer;
	animation: collection-badge-in 0.4s ease backwards;
	animation-delay: 360ms;
}

/* Arrivée en cascade, plafonnée à la 12e carte */
.collection-card:nth-child(1) { animation-delay: 30ms; }
.collection-card:nth-child(2) { animation-delay: 60ms; }
.collection-card:nth-child(3) { animation-delay: 90ms; }
.collection-card:nth-child(4) { animation-delay: 120ms; }
.collection-card:nth-child(5) { animation-delay: 150ms; }
.collection-card:nth-child(6) { animation-delay: 180ms; }
.collection-card:nth-child(7) { animation-delay: 210ms; }
.collection-card:nth-child(8) { animation-delay: 240ms; }
.collection-card:nth-child(9) { animation-delay: 270ms; }
.collection-card:nth-child(10) { animation-delay: 300ms; }
.collection-card:nth-child(11) { animation-delay: 330ms; }

/* Actualisation (après un booster, un échange) : les cartes sont déjà là */
.cards-set.still .collection-card {
	animation: none;
}

.collection-card .card-count {
	position: absolute;
	right: -0.35rem;
	bottom: -0.35rem;
	z-index: 2;
	padding: 0.15rem 0.5rem;
	border-radius: 99px;
	background: var(--ColorPrimary);
	color: var(--ColorPrimaryText);
	font-size: 0.75rem;
	font-weight: 700;
}

/* Exemplaires engagés dans un échange en attente (app/features/trades.js) */
.collection-card .card-reserved {
	position: absolute;
	left: -0.35rem;
	bottom: -0.35rem;
	z-index: 2;
	display: inline-flex;
	width: auto;
	align-items: center;
	gap: 0.25rem;
	padding: 0.15rem 0.45rem;
	border-radius: 99px;
	background: #111;
	color: #fff;
	font-size: 0.7rem;
	font-weight: 700;
}

/* Carte à trouver : un bouton (vue en grand de son dos), sans la couleur ni la police des boutons */
.collection-card.locked {
	color: inherit;
	font: inherit;
}

.card-slot {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	aspect-ratio: 63 / 88;
	border-radius: 0.6rem;
	border: 2px dashed var(--ColorText);
	opacity: 0.35;
	font-weight: 700;
}

.card-slot .tcard-rarity {
	display: inline-flex;
	justify-content: center;
	width: auto;
	gap: 2px;
	font-size: 0.6rem;
	color: var(--rarity);
}

/* Panneau du bandeau vide (visiteur non connecté, édition passée) : pas d'espace en trop */
.collection-container > .column[data-panel="cards"]:empty {
	display: none;
}

/* Bandeau « boosters à ouvrir » de l'onglet Cartes */
.boosters-cta {
	position: relative;
	display: flex;
	align-items: center;
	gap: 1rem;
	/* Le retrait au bord de l'écran vient du panneau (css/main.css) */
	width: 100%;
	padding: 1rem 1.25rem;
	border: none;
	border-radius: var(--BorderRadius, 1rem);
	background: linear-gradient(120deg, var(--ColorPrimary, #ff7992), var(--ColorPrimary2, #ce5f73));
	color: var(--ColorPrimaryText, #1b1b1b);
	font: inherit;
	text-align: left;
	cursor: pointer;
	overflow: hidden;
	box-shadow: var(--Shadow);
}

.boosters-cta::after {
	content: '';
	position: absolute;
	inset: -50%;
	background: linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, 0.3) 50%, transparent 58%);
	animation: booster-sheen 4s ease-in-out infinite;
	pointer-events: none;
}

/* Vide : bandeau neutre, sans reflet ni bouton, il ne sert qu'au compte à rebours */
.boosters-cta.empty {
	background: var(--ColorContainer);
	color: var(--ColorText);
	cursor: default;
}

.boosters-cta.empty::after {
	display: none;
}

.boosters-cta.empty .boosters-cta-pack {
	animation: none;
	opacity: 0.5;
}

/* Avancement du minuteur, en bas du bandeau */
.boosters-cta-progress {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	height: 4px;
	background: rgba(0, 0, 0, 0.15);
}

.boosters-cta-progress span {
	display: block;
	width: 100%;
	height: 100%;
	background: currentColor;
	opacity: 0.6;
	transform: scaleX(0);
	transform-origin: left;
	transition: transform 1s linear;
}

.boosters-cta.empty .boosters-cta-progress {
	background: rgba(255, 255, 255, 0.08);
}

.boosters-cta.empty .boosters-cta-progress span {
	background: var(--ColorPrimary);
	opacity: 1;
}

.boosters-cta-pack {
	position: relative;
	flex-shrink: 0;
	width: 2.75rem;
	height: 3.75rem;
	animation: booster-float 3s ease-in-out infinite;
}

.boosters-cta-pack-front,
.boosters-cta-pack-back {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: auto;
	border-radius: 0.4rem;
	background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.25) 0 3px, transparent 3px 6px) top / 100% 18% no-repeat, #1b1b1b;
	box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35), inset 0 0 0 2px rgba(255, 255, 255, 0.35);
	color: #fff;
	font-size: 1.1rem;
}

.boosters-cta-pack-back {
	transform: translate(6px, -4px) rotate(8deg);
	opacity: 0.6;
}

.boosters-cta-text {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-width: 0;
	gap: 0.15rem;
	width: auto;
}

.boosters-cta-text strong {
	font-size: 1.1rem;
	font-weight: 800;
}

.boosters-cta-text small {
	width: auto;
	font-size: 0.8rem;
	opacity: 0.8;
}

.boosters-cta .btn.btn-primary.boosters-cta-button {
	flex-shrink: 0;
	width: auto;
	padding: 0.6rem 1.2rem;
	background-color: #1b1b1b;
	color: #fff;
}

.cards-set-header {
	flex-wrap: nowrap;
}

.cards-set-header .titre {
	min-width: 0;
}

.cards-set-header .badges {
	flex-shrink: 0;
	width: auto;
}

/* Petit écran : paquet et texte sur une ligne, bouton « Ouvrir » en pleine largeur dessous */
@media (max-width: 600px) {
	.boosters-cta {
		display: grid;
		grid-template-columns: auto 1fr;
		grid-template-areas:
			"pack text"
			"button button";
		column-gap: 0.85rem;
		row-gap: 0.85rem;
		padding: 1rem;
	}

	.boosters-cta-pack {
		grid-area: pack;
	}

	.boosters-cta-text {
		grid-area: text;
	}

	.boosters-cta-text strong {
		font-size: 1rem;
	}

	.boosters-cta .btn.btn-primary.boosters-cta-button {
		grid-area: button;
		width: 100%;
		justify-content: center;
	}
}

@media (prefers-reduced-motion: reduce) {
	.booster-pack,
	.booster-pack-body::after,
	.booster-card,
	.booster-summary-card,
	.collection-card,
	.boosters-cta::after,
	.boosters-cta-pack,
	.booster-aura::before,
	.booster-mote,
	.booster-reveal.god-pack .booster-face.back,
	.booster-card.bonus::before,
	.booster-reveal .booster-card.bonus .booster-face.back,
	.booster-bonus-badge,
	nav .booster-pill.has-boosters i {
		animation: none !important;
	}

	.booster-track,
	.booster-slide {
		transition: none;
	}

	.booster-flash,
	.booster-mote {
		display: none;
	}

	.booster-card {
		transition-duration: 0.01s;
	}

	.booster-card.flipped .booster-flip,
	.booster-card.flipped .booster-face {
		animation-duration: 0.01s;
	}
}
