/*
 * Emballage d'un booster, partagé par l'app (app/features/boosters.js : packButton) et l'admin
 * (admin/sections/pack-visual.php : liste, page et aperçu du booster).
 * Réglages d'admin > Cartes > booster > Apparence (php/boosters.php : normalize_pack) :
 *   --pack-1, --pack-2 (couleurs), --pack-text (texte), --pack-logo (largeur du logo, %),
 *   --pack-art (illustration de fond), data-gradient, data-pattern, data-effect.
 * Forme d'un paquet de cartes à collectionner : soudures crantées en haut et en bas, dents larges au
 * bout arrondi (motif SVG de --crimp-w × --crimp-h répété), striées (--ridge : largeur d'une strie),
 * et feuille bombée (.booster-pack-foil).
 * L'ouverture (secousse, déchirure, god pack) est dans css/boosters.css.
 */

.booster-pack {
	--pack-fill: linear-gradient(145deg, var(--pack-1, #ffd65a), var(--pack-2, #c98a12));
	--crimp-w: 20px;
	--crimp-h: 6px;
	--crimp-top: linear-gradient(#000 0 0) bottom / 100% calc(100% - var(--crimp-h)) no-repeat,
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='6'%3E%3Cpath transform='matrix(1 0 0 -1 0 6)' d='M0 0H20V1Q19.2 1 18.4 1.4L12 4.6Q10 5.6 8 4.6L1.6 1.4Q0.8 1 0 1Z'/%3E%3C/svg%3E") top / var(--crimp-w) var(--crimp-h) repeat-x;
	--crimp-bottom: linear-gradient(#000 0 0) top / 100% calc(100% - var(--crimp-h)) no-repeat,
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='6'%3E%3Cpath d='M0 0H20V1Q19.2 1 18.4 1.4L12 4.6Q10 5.6 8 4.6L1.6 1.4Q0.8 1 0 1Z'/%3E%3C/svg%3E") bottom / var(--crimp-w) var(--crimp-h) repeat-x;
	--ridge: 3px;
	--ridges: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.22) 0 var(--ridge), rgba(0, 0, 0, 0.12) var(--ridge) calc(2 * var(--ridge)));
	position: relative;
	display: flex;
	flex-direction: column;
	width: min(60vw, 230px);
	aspect-ratio: 5 / 8;
	padding: 0;
	border: none;
	background: none;
	cursor: pointer;
	/* Ombre portée sur la découpe crantée (une box-shadow serait coupée par le masque) */
	filter: drop-shadow(0 1rem 1.25rem rgba(0, 0, 0, 0.45));
	animation: booster-float 3s ease-in-out infinite;
	-webkit-tap-highlight-color: transparent;
}

/* Dégradé */
.booster-pack[data-gradient="vertical"] {
	--pack-fill: linear-gradient(180deg, var(--pack-1, #ffd65a), var(--pack-2, #c98a12));
}

.booster-pack[data-gradient="radial"] {
	--pack-fill: radial-gradient(circle at 50% 40%, var(--pack-1, #ffd65a), var(--pack-2, #c98a12) 85%);
}

.booster-pack[data-gradient="solid"] {
	--pack-fill: linear-gradient(var(--pack-1, #ffd65a), var(--pack-1, #ffd65a));
}

.booster-pack-top,
.booster-pack-body {
	display: block;
	background: var(--pack-fill);
}

/* Soudure du haut, arrachée à l'ouverture : striée, dents en haut, bords assombris par le pli */
.booster-pack-top {
	height: 12%;
	background:
		linear-gradient(90deg, rgba(0, 0, 0, 0.3), transparent 8%, transparent 92%, rgba(0, 0, 0, 0.3)),
		linear-gradient(transparent 70%, rgba(0, 0, 0, 0.18)),
		var(--ridges),
		var(--pack-fill);
	-webkit-mask: var(--crimp-top);
	mask: var(--crimp-top);
	transition: transform 0.6s cubic-bezier(0.3, 0.7, 0.4, 1.4), opacity 0.6s ease;
	transform-origin: left bottom;
}

.booster-pack-body {
	position: relative;
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	/* Pointillés de déchirure en haut, dents de la soudure en bas */
	border-top: 2px dashed rgba(255, 255, 255, 0.5);
	-webkit-mask: var(--crimp-bottom);
	mask: var(--crimp-bottom);
	color: var(--pack-text, #fff);
	font-weight: 800;
	font-size: 1.1rem;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	overflow: hidden;
}

.booster-pack-body span {
	width: auto;
}

/* Nom, accroche ou illustration masqués (aperçu de l'admin) */
.booster-pack [hidden],
.booster-pack-body .booster-pack-title:not(:has(> :not([hidden]))) {
	display: none;
}

/* Contenu au-dessus de l'illustration et du motif */
.booster-pack-body > img,
.booster-pack-body > .booster-pack-title {
	position: relative;
}

/* Illustration de fond, motif et feuille, sous le contenu */
.booster-pack-body .booster-pack-art,
.booster-pack-body .booster-pack-pattern,
.booster-pack-body .booster-pack-foil {
	position: absolute;
	inset: 0;
	transition: opacity 0.5s ease;
	pointer-events: none;
}

.booster-pack-art {
	background: var(--pack-art) center / cover no-repeat;
}

.booster-pack[data-pattern="stripes"] .booster-pack-pattern {
	background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.16) 0 12px, transparent 12px 24px);
}

.booster-pack[data-pattern="dots"] .booster-pack-pattern {
	background: radial-gradient(rgba(255, 255, 255, 0.28) 22%, transparent 25%) 0 0 / 16px 16px;
}

.booster-pack[data-pattern="grid"] .booster-pack-pattern {
	background:
		linear-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1px) 0 0 / 18px 18px,
		linear-gradient(90deg, rgba(255, 255, 255, 0.16) 1px, transparent 1px) 0 0 / 18px 18px;
}

.booster-pack[data-pattern="diamonds"] .booster-pack-pattern {
	background: conic-gradient(from 45deg, rgba(255, 255, 255, 0.15) 0 90deg, transparent 0 180deg, rgba(255, 255, 255, 0.15) 0 270deg, transparent 0) 0 0 / 22px 22px;
}

.booster-pack[data-pattern="waves"] .booster-pack-pattern {
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='14'%3E%3Cpath d='M0 7 C5 1.5 15 1.5 20 7 S35 12.5 40 7' fill='none' stroke='white' stroke-opacity='0.24' stroke-width='2'/%3E%3C/svg%3E") 0 0 / 40px 14px;
}

/* Feuille de l'emballage, par-dessus l'illustration : soudure striée du bas, reflet vertical,
   bords et soudures assombris pour un paquet bombé */
.booster-pack-body .booster-pack-foil {
	--seal: 8%;
	background:
		linear-gradient(rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.25)) left 0 bottom var(--seal) / 100% 1px no-repeat,
		var(--ridges) bottom / 100% var(--seal) no-repeat,
		linear-gradient(90deg, transparent 12%, rgba(255, 255, 255, 0.2) 18%, transparent 26%),
		linear-gradient(90deg, rgba(0, 0, 0, 0.35), transparent 9%, transparent 91%, rgba(0, 0, 0, 0.35)),
		linear-gradient(rgba(0, 0, 0, 0.15), transparent 8%, transparent 84%, rgba(0, 0, 0, 0.25) 92%);
}

/* Logo du booster (admin > Cartes), ou logo TurboQuest */
.booster-pack-body img {
	width: var(--pack-logo, 60%);
	max-height: calc(var(--pack-logo, 60%) * 0.6);
	object-fit: contain;
	filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4));
}

.booster-pack-body .booster-pack-title {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.3rem;
	max-width: 85%;
	text-align: center;
	text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.booster-pack-body .booster-pack-name {
	font-size: 1rem;
	line-height: 1.15;
	letter-spacing: 0.04em;
	text-wrap: balance;
}

.booster-pack-body .booster-pack-subtitle {
	font-size: 0.65rem;
	font-weight: 700;
	letter-spacing: 0.14em;
	opacity: 0.9;
}

/* Effet */
.booster-pack-body::after {
	content: '';
	position: absolute;
	inset: -50%;
	background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, 0.35) 50%, transparent 60%);
	animation: booster-sheen 3s ease-in-out infinite;
	pointer-events: none;
}

.booster-pack[data-effect="none"] .booster-pack-body::after {
	content: none;
}

/* Holographique : feuille irisée qui défile, avec un reflet par-dessus. Calque deux fois plus
   grand que le paquet, penché à 115° : les dégradés restent horizontaux et se répètent sur la
   largeur, l'animation les décale d'une période exacte pour boucler sans saut */
.booster-pack[data-effect="holo"] .booster-pack-body::after {
	inset: -50%;
	background:
		linear-gradient(90deg, transparent 40%, rgba(255, 255, 255, 0.55) 50%, transparent 60%) 0 0 / 50% 100%,
		linear-gradient(90deg, #ff5ec4, #ffd65a 20%, #5effa8 40%, #5ed8ff 60%, #b45eff 80%, #ff5ec4) 0 0 / 50% 100%;
	mix-blend-mode: overlay;
	opacity: 0.45;
	transform: rotate(25deg);
	animation: booster-holo 6s linear infinite;
}

/* Paillettes : éclats de tailles et teintes variées, qui s'allument au passage de la lumière */
.booster-pack[data-effect="sparkle"] .booster-pack-body::after {
	inset: 0;
	background:
		radial-gradient(circle, #fff 0 1.2px, transparent 2.4px) 3px 7px / 29px 31px,
		radial-gradient(circle, #fff6c8 0 0.8px, transparent 1.8px) 17px 2px / 19px 23px,
		radial-gradient(circle, #d6f4ff 0 1px, transparent 2px) 9px 13px / 37px 17px,
		radial-gradient(circle, rgba(255, 255, 255, 0.9) 0 0.6px, transparent 1.4px) 0 0 / 11px 13px,
		radial-gradient(circle, #fff 0 1.8px, rgba(255, 255, 255, 0.35) 2.6px, transparent 4.5px) 21px 27px / 53px 61px;
	-webkit-mask: linear-gradient(115deg, rgba(0, 0, 0, 0.3) 35%, #000 50%, rgba(0, 0, 0, 0.3) 65%) 0 0 / 300% 100%;
	mask: linear-gradient(115deg, rgba(0, 0, 0, 0.3) 35%, #000 50%, rgba(0, 0, 0, 0.3) 65%) 0 0 / 300% 100%;
	animation: booster-glitter 2.6s ease-in-out infinite;
}

/* Miniature (tableau et en-tête de l'admin) : emballage seul, sans texte ni animation */
.booster-pack.mini {
	--crimp-w: 7px;
	--crimp-h: 2.1px;
	--ridge: 1px;
	width: 2.5rem;
	cursor: inherit;
	filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
	animation: none;
}

.booster-pack.mini .booster-pack-body {
	border-top-width: 1px;
}

.booster-pack.mini .booster-pack-title {
	display: none;
}

.booster-pack.mini .booster-pack-body img {
	filter: none;
}

@keyframes booster-float {
	0%, 100% {
		transform: translateY(0) rotate(-2deg);
	}

	50% {
		transform: translateY(-10px) rotate(2deg);
	}
}

@keyframes booster-sheen {
	from {
		transform: translateX(-60%);
	}

	to {
		transform: translateX(60%);
	}
}

@keyframes booster-holo {
	/* Décalage = (calque - tuile) × position : tuiles de 50 %, 100 % les avance d'une tuile */
	from {
		background-position: 0 0, 0 0;
	}

	to {
		background-position: 100% 0, 100% 0;
	}
}

@keyframes booster-glitter {
	from {
		-webkit-mask-position: 100% 0;
		mask-position: 100% 0;
	}

	to {
		-webkit-mask-position: 0 0;
		mask-position: 0 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.booster-pack,
	.booster-pack-body::after {
		animation: none !important;
	}
}
