/* =====================================================================
   Parcours joueur : landing + roue + révélation du gain (mobile-first)
   Mise en page des créas Meta : photo sombre plein cadre, voile rouge à gauche, texte blanc empilé.
   ===================================================================== */
/* Rien ne doit déborder horizontalement (cartouches inclinés) : on coupe sur html (viewport) ET body.
   clip (et non hidden) sur body : pas de conteneur de défilement, le position: sticky reste actif. */
html { overflow-x: hidden; }
body.game { position: relative; overflow-x: clip; color: var(--c-white); background: var(--c-red-dark); --c-focus: var(--c-yellow); }

/* ---------- Fond : photo de la salle + voile rouge latéral (seul dégradé autorisé) ---------- */
/* Couvre toute la hauteur de la page (et non la seule fenêtre) : le rouge descend jusqu'au pied de page,
   y compris sous la fin du formulaire et dans les captures pleine page. */
.backdrop {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-color: var(--c-red-dark);
  background-image: var(--veil), url('/assets/photos/machines.webp');
  /* Mobile : photo limitée au haut de page (hero + roue) pour ne pas l'agrandir à l'excès ; dessous, le rouge sombre */
  background-size: 100% 100%, auto min(100%, 1100px);
  background-position: 0 0, 62% 0;
  background-repeat: no-repeat;
}
@media (min-width: 960px) {
  .backdrop {
    background-size: 100% 100%, cover;
    --veil: linear-gradient(90deg, #EB0303 0%, #EB0303 30%, rgba(144, 5, 8, .88) 48%, rgba(144, 5, 8, .25) 72%, rgba(144, 5, 8, 0) 100%);
    background-image: var(--veil), url('/assets/photos/machine-large.webp');
    background-position: 0 0, 100% 50%;
  }
}
body[data-state="result"] .backdrop { background-image: var(--veil), url('/assets/photos/clientes.webp'); background-position: 0 0, 70% 20%; }
body[data-state="result"]:has(#result-lose:not([hidden])) .backdrop { background-image: var(--veil), url('/assets/photos/bar.webp'); }
.topbar, .stage, .site-footer, .demo-banner { position: relative; z-index: 1; }

/* ---------- En-tête : logo accroché en haut à gauche ---------- */
.topbar {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  max-width: 1200px; margin: 0 auto; padding: 0 16px;
}
.topbar .brand { font-size: clamp(11px, 3.3vw, 15px); }
.icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; margin-top: 12px; padding: 0;
  border: 2px solid var(--c-white); border-radius: var(--radius-sm); background: transparent;
  color: var(--c-white); cursor: pointer;
}
.icon-btn:hover { background: var(--c-white); color: var(--c-red); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn[aria-pressed="true"] .icon-off, .icon-btn[aria-pressed="false"] .icon-on { display: none; }

/* ---------- Mise en page ---------- */
.stage {
  display: grid; gap: 18px; align-content: start; /* main étiré (flex: 1) : pas d'espace réparti entre les lignes */
  grid-template-areas: "hero" "wheel" "form" "lots" "result";
  max-width: 1200px; margin: 0 auto; padding: 18px 16px 40px;
}
.hero { grid-area: hero; }
.wheel-zone { grid-area: wheel; }
.play-card { grid-area: form; }
.lots { grid-area: lots; }
.result { grid-area: result; }

.showcase { display: contents; }

/* Desktop : comme la créa ads1, texte + formulaire sur le rouge à gauche, roue sur la photo à droite */
@media (min-width: 960px) {
  .stage {
    grid-template-columns: minmax(0, 480px) minmax(0, 1fr);
    grid-template-areas: "hero side" "form side";
    column-gap: 64px; align-items: start; padding-top: 26px;
  }
  /* Roue en haut de la colonne droite, liste des lots dessous (pas de sticky : rien n'est rogné) */
  .showcase {
    grid-area: side;
    display: flex; flex-direction: column; justify-content: flex-start; align-items: center; gap: 34px;
    padding: 8px 0 24px;
  }
  .showcase .wheel { width: min(480px, 58vh); margin-top: 22px; }
  body[data-state="spinning"] .stage { grid-template-areas: "hero side"; }
  body[data-state="spinning"] .showcase { justify-content: center; min-height: min(100vh, 880px); }
  body[data-state="spinning"] .showcase .wheel { width: min(560px, 70vh); }
  body[data-state="result"] .stage { grid-template-columns: minmax(0, 520px) minmax(0, 1fr); grid-template-areas: "result ."; }
  body[data-state="result"] .showcase { display: none; }
}

body[data-state="spinning"] .play-card,
body[data-state="spinning"] .lots { display: none; }
/* Mobile, roue qui tourne : accroche réduite et grille limitée à hero + roue (pas de rangées vides ni de grand aplat
   rouge sous « La roue tourne… ») */
@media (max-width: 959px) {
  body[data-state="spinning"] .stage { grid-template-areas: "hero" "wheel"; gap: 6px; padding-bottom: 20px; align-content: center; }
  body[data-state="spinning"] .kicker,
  body[data-state="spinning"] .subtitle,
  body[data-state="spinning"] .title > .t-md { display: none; }
  body[data-state="spinning"] .title { margin-bottom: 0; }
  body[data-state="spinning"] .spin-status { margin-top: 14px; }
}
body[data-state="result"] .hero,
body[data-state="result"] .wheel-zone,
body[data-state="result"] .play-card,
body[data-state="result"] .lots { display: none; }

/* ---------- Accroche : titres empilés, tailles contrastées ---------- */
.kicker { margin: 0 0 14px; font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.title { margin: 0 0 14px; font-weight: 800; line-height: 1; letter-spacing: -.01em; }
.title:focus { outline: none; }
.title > span { display: block; }
.t-sm { font-size: clamp(1.6rem, 7.4vw, 2.4rem); }
.t-xl { font-size: clamp(3.8rem, 21vw, 6.8rem); font-weight: 900; line-height: .92; letter-spacing: -.02em; }
.t-q { font-size: .5em; letter-spacing: 0; }
.title > .t-tag { display: inline-block; margin: .3em 0 .32em -.05em; font-size: clamp(1.7rem, 8vw, 2.7rem); }
.t-md { font-size: clamp(1.2rem, 5.4vw, 1.65rem); line-height: 1.15; }
.subtitle { margin: 0; max-width: 26em; font-size: clamp(.95rem, 3.9vw, 1.08rem); font-weight: 600; }
.subtitle strong { font-weight: 900; }

/* ---------- Roue ---------- */
.wheel-zone { display: flex; flex-direction: column; align-items: center; }
.wheel {
  position: relative; width: min(88vw, 460px); aspect-ratio: 1; margin: 18px auto 6px;
  -webkit-user-select: none; user-select: none;
}
body[data-state="spinning"] .wheel { width: min(100vw - 40px, 520px); }
.wheel > .wheel-base, .wheel > .wheel-rotor, .wheel > .wheel-cap { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.wheel-rotor { transform-origin: 50% 50%; will-change: transform; backface-visibility: hidden; }
.wheel-cap { pointer-events: none; }
.wheel-pointer {
  position: absolute; z-index: 3; top: -5%; left: 50%; width: 12%; height: auto;
  transform: translateX(-50%); transform-origin: 50% 30%;
}
.wheel-label { font-family: var(--font); font-weight: 900; letter-spacing: .01em; }
/* Retournement à 180° autour du centre du libellé (moitié gauche de la roue) */
.wheel-label { transform-box: fill-box; transform-origin: 50% 50%; transition: transform .5s cubic-bezier(.3, .7, .3, 1), opacity .4s ease; }
.wheel-label.is-flipped { transform: rotate(180deg); }
.wheel-pin { fill: var(--c-white); stroke: var(--c-red-dark); stroke-width: 2; }
.wheel-segment { transition: opacity .4s ease; }
/* Arrêt : la case gagnante reste pleine, les autres s'effacent */
.wheel.is-won .wheel-segment:not(.is-winner), .wheel.is-won .wheel-label:not(.is-winner),
.wheel.is-lost .wheel-segment:not(.is-winner), .wheel.is-lost .wheel-label:not(.is-winner) { opacity: .4; }
.wheel-hub-text { fill: var(--c-white); font-family: var(--font); font-size: 22px; font-weight: 800; letter-spacing: -.02em; }

/* Ampoules simples (blanc sur la bande rouge) : chenillard en opacité → 60 fps */
.bulb { animation: bulb 1.6s linear infinite; }
.wheel.is-spinning .bulb { animation-duration: .5s; }
.wheel.is-won .bulb { animation: bulb-flash .36s steps(2, jump-none) infinite; animation-delay: 0s !important; }
.wheel.is-lost .bulb { animation-duration: 3.2s; }
@keyframes bulb { 0%, 35%, 100% { opacity: .4; } 8% { opacity: 1; } }
@keyframes bulb-flash { from { opacity: 1; } to { opacity: .3; } }

.spin-status { min-height: 1.6em; margin: 8px 0 0; text-align: center; font-size: 1.1rem; font-weight: 800; }

/* ---------- Formulaire : champs blancs sur le rouge ---------- */
.play-card { position: relative; padding: 22px 16px 20px; margin: 0 -16px; background: var(--c-red); }
@media (min-width: 600px) { .play-card { margin: 0; padding: 24px 22px 22px; } }
@media (min-width: 960px) { .play-card { padding: 4px 0 0; background: transparent; } }
@media (max-width: 380px) {
  .stage { padding-left: 12px; padding-right: 12px; }
  .play-card { margin: 0 -12px; padding: 20px 12px 18px; }
}
.loading { padding: 30px 0; font-weight: 700; }
.closed { padding: 10px 0; }
.closed h2 { margin: 0 0 .6rem; font-size: 1.6rem; }
.closed p { margin: 0; font-weight: 600; }
.form-title { margin: 0 0 .15rem; font-size: 1.6rem; }
.form-intro { margin: .7rem 0 1.1rem; font-size: .9rem; font-weight: 600; }
.field { margin-bottom: 14px; }
.field > label:not(.check) { display: block; margin-bottom: 5px; font-size: .88rem; font-weight: 700; }
.field input[type="text"], .field input[type="email"], .field input[type="tel"], .field select {
  display: block; width: 100%; min-width: 0; min-height: 52px; padding: 12px 14px;
  border: 3px solid var(--c-white); border-radius: var(--radius-sm);
  background-color: var(--c-white); color: var(--c-black); font-weight: 600;
  font-size: 16px; /* évite le zoom iOS */
  -webkit-appearance: none; appearance: none;
}
.field input::placeholder { color: #8A8A8A; font-weight: 500; }
.field input:focus, .field select:focus { outline: none; border-color: var(--c-black); }
.field input[aria-invalid="true"], .field select[aria-invalid="true"] { border-color: var(--c-yellow); }

/* Date de naissance : jj / mm / aaaa */
fieldset.field { min-width: 0; padding: 0; border: 0; }
.field-date legend { display: block; margin-bottom: 5px; padding: 0; font-size: .88rem; font-weight: 700; }
.date-selects { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.6fr) minmax(0, 1.05fr); gap: 8px; }
.field select {
  padding: 12px 28px 12px 12px; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23EB0303' stroke-width='2.4' stroke-linecap='square'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 12px 8px;
}
.field select:invalid { color: #8A8A8A; } /* option « jj / mm / aaaa » non choisie */
.field select option { color: var(--c-black); background: var(--c-white); }
/* Erreur : étiquette noire, texte jaune (lisible sur le rouge) */
.field-error {
  display: inline-block; margin: 6px 0 0; padding: 2px 8px;
  font-size: .8rem; font-weight: 700; color: var(--c-yellow); background: var(--c-black);
}
.field-error:empty { display: none; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: .88rem; font-weight: 600; line-height: 1.4; cursor: pointer; }
.check input {
  flex: none; display: grid; place-items: center; width: 24px; height: 24px; margin: 0;
  border: 0; border-radius: var(--radius-sm); background: var(--c-white); cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.check input:checked {
  background: var(--c-white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3.2L13 4.8' fill='none' stroke='%23EB0303' stroke-width='3' stroke-linecap='square'/%3E%3C/svg%3E") center / 16px no-repeat;
}
.check input[aria-invalid="true"] { outline: 3px solid var(--c-yellow); outline-offset: 0; }
.check input:focus-visible { outline: 3px solid var(--c-black); outline-offset: 2px; }
.check a { color: var(--c-white); font-weight: 800; }
.check-soft { font-size: .8rem; font-weight: 500; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.turnstile { margin: 6px 0 12px; display: flex; justify-content: center; }
.alert {
  margin: 4px 0 14px; padding: 10px 12px; border-left: 6px solid var(--c-yellow);
  background: var(--c-black); color: var(--c-white); font-size: .88rem; font-weight: 700;
}
/* Bouton signature : cartouche blanc incliné, texte rouge sombre très gras */
.btn-spin {
  min-height: 64px; margin: 8px 0 6px; border: 0;
  font-size: clamp(1.2rem, 5.6vw, 1.45rem); font-weight: 900; letter-spacing: .01em; text-transform: uppercase;
  transform: rotate(-2deg);
}
.btn-spin:hover:not(:disabled) { color: var(--c-white); background: var(--c-black); }
.btn-spin:active { transform: rotate(-2deg) scale(.98); }
.btn-spin:disabled { transform: rotate(-2deg); }
.form-legal { margin: 14px 0 0; font-size: .74rem; font-weight: 500; }
.form-legal a { color: var(--c-white); font-weight: 700; }

/* ---------- Lots : cartouches inclinés (comme la créa ads4) ---------- */
.lots-title { margin: 6px 0 14px; font-size: 1.35rem; font-weight: 900; }
.lot-chips { display: flex; flex-wrap: wrap; gap: 12px 10px; margin: 0; padding: 0; list-style: none; }
.chip { font-size: 1rem; --tilt: -3deg; }
.chip:nth-child(even) { --tilt: 2.5deg; }
.chip-jackpot { color: var(--c-white); background: var(--c-red-dark); }
.lots-note { margin: 16px 0 0; max-width: 30em; font-size: .8rem; font-weight: 600; }
@media (min-width: 960px) {
  .lots { width: 100%; max-width: 560px; padding: 0 12px; text-align: center; }
  .lots-title { margin: 0 0 18px; font-size: 1.6rem; }
  .lot-chips { justify-content: center; gap: 16px 14px; }
  .lots-note { margin: 22px auto 0; }
}

/* ---------- Résultat ---------- */
.result { display: flex; flex-direction: column; align-items: flex-start; padding: 4px 0 20px; perspective: 1400px; }
.card3d {
  position: relative; width: min(100%, 520px);
  transform-style: preserve-3d; transition: transform .9s cubic-bezier(.2, .85, .25, 1);
}
.card3d.is-flipped { transform: rotateY(180deg); }
.card-face { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.card-front { position: relative; transform: rotateY(180deg); }
/* Dos de la carte : le bloc logo, en grand */
.card-back { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 18px; padding-top: 40px; }
.card-back .brand { font-size: 22px; }
.card-back p { margin: 0; font-size: 1.3rem; font-weight: 800; animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }

.result-kicker { margin: 0; font-size: clamp(1.7rem, 7.6vw, 2.4rem); font-weight: 900; line-height: 1.05; }
.result-sub { margin: 4px 0 0; font-size: clamp(1.1rem, 4.8vw, 1.35rem); font-weight: 800; }
/* Le lot dans un cartouche blanc incliné, en très gros */
.result-lot {
  display: inline-block; max-width: 100%; margin: 14px 0 22px -2px; padding: .08em .3em .12em;
  background: var(--c-white); color: var(--c-red-dark);
  font-size: clamp(2.1rem, 10.5vw, 3.3rem); font-weight: 900; line-height: 1.02; letter-spacing: -.015em;
  overflow-wrap: anywhere; transform: rotate(var(--tilt));
}
.result-lot:focus { outline: none; }
/* Bloc QR + code : blanc, droit, net (scan facile) */
.ticket-box { padding: 18px 16px 16px; background: var(--c-white); color: var(--c-black); text-align: center; border-radius: var(--radius-sm); }
.qr-box { width: max-content; margin: 0 auto 10px; }
.qr-box canvas { image-rendering: pixelated; }
.code-label { margin: 0; font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--c-muted-dark); }
.code { margin: 0 0 6px; font-size: clamp(1.6rem, 7.4vw, 2rem); font-weight: 900; letter-spacing: .06em; color: var(--c-black); font-variant-numeric: tabular-nums; }
.expiry { margin: 0 0 10px; font-weight: 800; color: var(--c-red); }
.expiry.is-expired { color: var(--c-black); background: var(--c-yellow); display: inline-block; padding: 0 .4em; }
.result-how { margin: 0 auto 14px; max-width: 26em; font-size: .86rem; font-weight: 500; color: #333; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.result-actions .btn { padding-left: .6em; padding-right: .6em; }
.result-tip { margin: 12px 0 0; font-size: .76rem; color: var(--c-muted-dark); }
.result-outro { margin: 18px 0 0; font-size: 1.15rem; font-weight: 800; }
#result-lose .result-kicker { font-size: clamp(1.4rem, 6vw, 1.8rem); }
.result-lose-title {
  display: inline-block; margin: 14px 0 20px; padding: .08em .3em .12em;
  background: var(--c-white); color: var(--c-red-dark);
  font-size: clamp(2.2rem, 11vw, 3.4rem); font-weight: 900; line-height: 1.02; transform: rotate(var(--tilt));
}
.result-lose-title:focus { outline: none; }
.result-lose-text { margin: 0 0 10px; max-width: 26em; font-size: 1.05rem; font-weight: 600; }
.result-lose-text.small { font-size: .95rem; }
.replay { margin-top: 18px; color: var(--c-white); }

/* ---------- Effets ---------- */
/* Derrière la scène (z-index 1) : les confettis passent autour du contenu, jamais sur le texte */
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .bulb { opacity: .8; }
}
