/* =================================================================
   Tombola — interface joueur
   Thème estival, épuré et festif. Les 3 couleurs de la marque sont
   injectées via --c1 / --c2 / --c3.
   ================================================================= */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --ink: #10233a;
  --ink-soft: #55708c;
  --sand: #fff7ec;
  --sky-top: #d8f3ff;
  --sky-mid: #eaf8ff;
  --white: #ffffff;
  --radius: 22px;
  --radius-lg: 30px;
  --shadow-sm: 0 2px 8px rgba(16, 35, 58, .06);
  --shadow: 0 14px 40px -18px rgba(16, 35, 58, .35);
  --shadow-lg: 0 30px 70px -30px rgba(16, 35, 58, .45);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --wheel-size: min(88vw, 430px);
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 34%, var(--sand) 72%, #ffeed8 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body.rtl { direction: rtl; }

/* ------------------------- Décor de fond ------------------------- */

.scene { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }

.sun {
  position: absolute; top: -90px; inset-inline-end: -70px;
  width: 320px; height: 320px; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, var(--c3) 0%, color-mix(in srgb, var(--c3) 55%, transparent) 45%, transparent 70%);
  filter: blur(2px); opacity: .75;
  animation: breathe 9s ease-in-out infinite;
  will-change: opacity;
}

.glow { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .28; }
.glow-a { width: 340px; height: 340px; top: 22%; inset-inline-start: -110px; background: var(--c2); }
.glow-b { width: 300px; height: 300px; bottom: 8%; inset-inline-end: -120px; background: var(--c1); opacity: .10; }

.waves { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 190px; }

@keyframes breathe { 0%,100% { opacity: .72; } 50% { opacity: .92; } }

/* ---------------------------- Topbar ----------------------------- */

.topbar {
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px clamp(16px, 4vw, 32px);
}

.brand { display: inline-flex; align-items: center; text-decoration: none; }
.brand-logo { height: 42px; width: auto; max-width: 190px; object-fit: contain; display: block; }
.brand-name { font-weight: 800; font-size: 20px; color: var(--c1); letter-spacing: -.02em; }

.topbar-actions { display: flex; gap: 8px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; height: 40px; padding: 0 12px;
  border: 1px solid rgba(16,35,58,.09); border-radius: 999px;
  background: rgba(255,255,255,.72); backdrop-filter: blur(10px);
  color: var(--ink); font: inherit; font-weight: 700; font-size: 15px;
  text-decoration: none; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform .18s ease, background .18s ease;
}
.icon-btn:hover { transform: translateY(-1px); background: #fff; }
.icon-btn.muted { opacity: .45; }

/* ----------------------------- Scène ----------------------------- */

.stage {
  position: relative; z-index: 2;
  max-width: 720px; margin: 0 auto;
  padding: clamp(6px, 2vw, 18px) clamp(16px, 5vw, 28px) 48px;
  display: flex; flex-direction: column; align-items: center;
}

.hero { text-align: center; margin: 4px 0 clamp(14px, 3vw, 24px); }

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 7.4vw, 44px);
  line-height: 1.08; letter-spacing: -.035em; font-weight: 800;
  color: var(--ink);
  text-wrap: balance;
}
.hero .sub {
  margin: 0 auto; max-width: 30ch;
  font-size: clamp(15px, 3.6vw, 17px); line-height: 1.5;
  color: var(--ink-soft); text-wrap: balance;
}

/* ----------------------------- Roue ------------------------------ */

.wheel-section { display: flex; flex-direction: column; align-items: center; width: 100%; }

.wheel-wrap {
  position: relative;
  width: var(--wheel-size); height: var(--wheel-size);
  display: grid; place-items: center;
}
/* Ombre portee statique : un filtre drop-shadow sur un canvas anime
   force le navigateur a recalculer l'ombre a chaque image (tres couteux). */
.wheel-wrap::before {
  content: ''; position: absolute; inset: 4%; border-radius: 50%;
  box-shadow: 0 30px 48px -8px rgba(16,35,58,.42);
  z-index: 0;
}
#wheel {
  position: relative; z-index: 1;
  width: 100%; height: 100%; display: block; border-radius: 50%;
  transition: transform .5s ease;   /* retour en douceur quand le balancement s'arrete */
}

/* Balancement au repos : animation composee par le GPU, aucun repaint du
   canvas, donc un cout processeur nul. Les libelles restent a l'endroit. */
#wheel.wheel-idle { animation: sway 6s ease-in-out infinite; }
@keyframes sway {
  0%, 100% { transform: rotate(-2.6deg); }
  50%      { transform: rotate(2.6deg); }
}

.wheel-pointer {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  width: 40px; height: 52px; z-index: 4;
  filter: drop-shadow(0 5px 10px rgba(16,35,58,.35));
  transform-origin: 50% 20%;
}
.wheel-pointer svg { width: 100%; height: 100%; display: block; }
.wheel-pointer.tick { animation: tick .07s ease-out; }
@keyframes tick {
  0% { transform: translateX(-50%) rotate(0deg); }
  50% { transform: translateX(-50%) rotate(-13deg); }
  100% { transform: translateX(-50%) rotate(0deg); }
}

.wheel-hub {
  position: absolute; z-index: 3;
  width: 25%; height: 25%; border-radius: 50%;
  border: 0; padding: 0; cursor: pointer;
  background: #fff;
  box-shadow: 0 8px 22px rgba(16,35,58,.28), inset 0 0 0 6px color-mix(in srgb, var(--c1) 90%, #fff);
  display: grid; place-items: center;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1);
}
.wheel-hub:hover { transform: scale(1.06); }
.wheel-hub:active { transform: scale(.96); }
.hub-inner {
  font-weight: 900; font-size: clamp(15px, 3.6vw, 19px); letter-spacing: .02em;
  color: var(--c1);
}
.wheel-hub[disabled] { cursor: default; opacity: .75; }

/* ---------------------------- Boutons ---------------------------- */

.cta {
  margin-top: clamp(18px, 4vw, 26px);
  border: 0; cursor: pointer;
  padding: 16px 30px; border-radius: 999px;
  font: inherit; font-size: 17px; font-weight: 800; letter-spacing: -.01em;
  color: #fff;
  background: linear-gradient(135deg, var(--c1) 0%, color-mix(in srgb, var(--c1) 70%, var(--c3)) 100%);
  box-shadow: 0 12px 26px -10px color-mix(in srgb, var(--c1) 75%, transparent), inset 0 -2px 0 rgba(0,0,0,.12);
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease, filter .2s ease;
  display: inline-flex; align-items: center; gap: 10px;
}
.cta:hover { transform: translateY(-2px); filter: brightness(1.04); }
.cta:active { transform: translateY(0) scale(.98); }
.cta[disabled] { opacity: .6; cursor: default; transform: none; }
.cta-spark { animation: spark 2.4s ease-in-out infinite; }
@keyframes spark { 0%,100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.25) rotate(12deg); } }

.cta-submit { width: 100%; justify-content: center; margin-top: 20px; }
.cta-ghost {
  background: transparent; color: var(--ink-soft);
  box-shadow: none; font-weight: 700; padding: 12px 22px;
}
.cta-ghost:hover { background: rgba(16,35,58,.05); filter: none; }

/* ----------------------------- Lots ------------------------------ */

.prizes { margin-top: clamp(30px, 6vw, 44px); text-align: center; width: 100%; }
.prizes h2 {
  margin: 0 0 14px; font-size: 13px; font-weight: 700;
  letter-spacing: .13em; text-transform: uppercase; color: var(--ink-soft);
}
.prizes ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
}
.prizes li {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: 999px;
  background: rgba(255,255,255,.82);
  border: 1px solid rgba(16,35,58,.07);
  font-size: 14px; font-weight: 600; color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.pz-ico { font-size: 16px; }

.legal {
  margin-top: 34px; max-width: 46ch; text-align: center;
  font-size: 12px; line-height: 1.6; color: var(--ink-soft); opacity: .85;
}

/* -------------------------- Feuille form -------------------------- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 8;
  background: rgba(10, 26, 45, .5); backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none; transition: opacity .3s ease;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed; z-index: 9; left: 0; right: 0; bottom: 0;
  max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 12px clamp(20px, 6vw, 34px) max(26px, env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg);
  transform: translateY(102%);
  transition: transform .38s cubic-bezier(.32,.72,0,1), visibility 0s linear .38s;
  pointer-events: none; visibility: hidden;
}
.sheet.open {
  transform: translateY(0); pointer-events: auto; visibility: visible;
  transition: transform .38s cubic-bezier(.32,.72,0,1), visibility 0s;
}

.sheet-handle {
  width: 42px; height: 4px; border-radius: 99px; background: rgba(16,35,58,.16);
  margin: 4px auto 12px;
}
.sheet-close {
  position: absolute; top: 14px; inset-inline-end: 16px;
  width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(16,35,58,.06); color: var(--ink-soft); font-size: 15px;
}
.sheet-close:hover { background: rgba(16,35,58,.11); }

.sheet h2 { margin: 0 0 4px; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.sheet-intro { margin: 0 0 20px; color: var(--ink-soft); font-size: 15px; }

@media (min-width: 640px) {
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%; width: 540px;
    border-radius: var(--radius-lg);
    transform: translate(-50%, -46%) scale(.96); opacity: 0;
    transition: transform .34s cubic-bezier(.32,.72,0,1), opacity .24s ease, visibility 0s linear .34s;
    padding-top: 26px;
  }
  .sheet.open {
    transform: translate(-50%, -50%) scale(1); opacity: 1;
    transition: transform .34s cubic-bezier(.32,.72,0,1), opacity .24s ease, visibility 0s;
  }
  .sheet-handle { display: none; }
}

/* --------------------------- Formulaire --------------------------- */

.field { margin-bottom: 16px; border: 0; padding: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .grid-2 { grid-template-columns: 1fr; gap: 0; } }

.field label, .field legend {
  display: block; margin-bottom: 7px; padding: 0;
  font-size: 13.5px; font-weight: 700; color: var(--ink);
}

.field input[type="text"], .field input[type="email"] {
  width: 100%; padding: 14px 16px;
  border: 1.5px solid rgba(16,35,58,.12); border-radius: 14px;
  background: #fbfcfe; font: inherit; font-size: 16px; color: var(--ink);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.field input:focus {
  outline: 0; background: #fff; border-color: var(--c1);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c1) 16%, transparent);
}
.field input.invalid { border-color: #e5484d; background: #fff5f5; }

.q-field { margin-bottom: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip span {
  display: inline-block; padding: 10px 15px; border-radius: 999px;
  border: 1.5px solid rgba(16,35,58,.12); background: #fbfcfe;
  font-size: 14.5px; font-weight: 600; color: var(--ink-soft);
  transition: all .18s ease;
}
.chip:hover span { border-color: rgba(16,35,58,.24); }
.chip input:checked + span {
  background: var(--c1); border-color: var(--c1); color: #fff;
  box-shadow: 0 6px 14px -6px color-mix(in srgb, var(--c1) 80%, transparent);
}
.chip input:focus-visible + span { box-shadow: 0 0 0 4px color-mix(in srgb, var(--c1) 20%, transparent); }
.q-field.invalid legend { color: #d1383c; }

.consent {
  display: flex; gap: 12px; align-items: flex-start;
  margin-top: 20px; padding: 15px; border-radius: 16px;
  background: color-mix(in srgb, var(--c2) 8%, #fbfcfe);
  border: 1.5px solid color-mix(in srgb, var(--c2) 22%, transparent);
  font-size: 13.5px; line-height: 1.55; color: var(--ink-soft); cursor: pointer;
  transition: border-color .18s ease;
}
.consent.invalid { border-color: #e5484d; background: #fff5f5; }
.consent input {
  flex: 0 0 auto; width: 20px; height: 20px; margin: 1px 0 0;
  accent-color: var(--c1); cursor: pointer;
}

.form-error {
  min-height: 0; margin: 14px 0 0; color: #d1383c;
  font-size: 13.5px; font-weight: 600;
}
.form-error:empty { margin: 0; }

/* Champ piège : sorti de l'écran sans display:none, que certains robots ignorent. */
.hp-field {
  position: absolute !important; left: -9999px !important; top: auto !important;
  width: 1px; height: 1px; overflow: hidden;
}

/* --------------------------- Résultat ---------------------------- */

.modal {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center; padding: 20px;
  background: rgba(10, 26, 45, .58); backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity .35s ease;
}
.modal.open { opacity: 1; pointer-events: auto; }

.confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.modal-card {
  position: relative; z-index: 2;
  width: min(100%, 430px); text-align: center;
  background: #fff; border-radius: var(--radius-lg);
  padding: 34px clamp(22px, 6vw, 34px) 24px;
  box-shadow: var(--shadow-lg);
  transform: scale(.9) translateY(14px); opacity: 0;
  transition: transform .42s cubic-bezier(.34,1.4,.64,1), opacity .3s ease;
  max-height: 92dvh; overflow-y: auto;
}
.modal.open .modal-card { transform: scale(1) translateY(0); opacity: 1; }

.result-emoji { font-size: 54px; line-height: 1; margin-bottom: 10px; animation: pop .55s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes pop { from { transform: scale(0) rotate(-25deg); } to { transform: scale(1) rotate(0); } }

.modal-card h2 { margin: 0 0 6px; font-size: 26px; font-weight: 800; letter-spacing: -.025em; }
.result-prize { margin: 0 0 20px; font-size: 19px; font-weight: 700; color: var(--c1); }
.result-prize:empty { display: none; }
.result-text { margin: 0; color: var(--ink-soft); font-size: 15px; line-height: 1.55; }
.result-text:empty { display: none; }

.code-box {
  display: none; flex-direction: column; align-items: center; gap: 8px;
  padding: 20px 16px; border-radius: 20px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c3) 22%, #fff), color-mix(in srgb, var(--c2) 10%, #fff));
  border: 1.5px dashed color-mix(in srgb, var(--c1) 35%, transparent);
}
.code-box.show { display: flex; }
.code-label { font-size: 11.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.code-value {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: clamp(21px, 5.6vw, 27px); font-weight: 700; letter-spacing: .06em; color: var(--ink);
}
.barcode { width: 190px; height: 34px; }
.code-help { font-size: 12.5px; color: var(--ink-soft); max-width: 26ch; line-height: 1.45; }

.demo-note {
  margin: 16px 0 0; font-size: 11.5px; color: var(--ink-soft); opacity: .7;
  font-style: italic;
}

/* ----------------------- États fermés / home ---------------------- */

.closed-wrap { position: relative; z-index: 2; display: grid; place-items: center; min-height: 70dvh; padding: 20px; }
.card {
  background: #fff; border-radius: var(--radius-lg); padding: 40px 32px;
  text-align: center; box-shadow: var(--shadow); max-width: 420px;
}
.closed-emoji { font-size: 46px; margin-bottom: 12px; }
.closed-card h1 { margin: 0 0 8px; font-size: 26px; letter-spacing: -.02em; }
.closed-card p { margin: 0; color: var(--ink-soft); line-height: 1.55; }

.home {
  position: relative; z-index: 2; max-width: 760px; margin: 0 auto;
  padding: clamp(40px, 10vw, 90px) 24px 60px; text-align: center;
}
.home h1 { margin: 0 0 8px; font-size: clamp(30px, 6vw, 42px); letter-spacing: -.035em; font-weight: 800; }
.home .sub { margin: 0 0 36px; color: var(--ink-soft); font-size: 16px; }
.brand-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.brand-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  min-height: 150px; padding: 26px; border-radius: var(--radius);
  background: #fff; text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow); border-top: 4px solid var(--bc1);
  transition: transform .22s cubic-bezier(.34,1.4,.64,1), box-shadow .22s ease;
}
.brand-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.brand-card img { height: 46px; max-width: 170px; object-fit: contain; }
.brand-card span { font-weight: 700; }
.brand-card-go { font-size: 13.5px; font-weight: 700; color: var(--bc2); }
.admin-link {
  display: inline-block; margin-top: 40px; color: var(--ink-soft);
  font-size: 14px; font-weight: 600; text-decoration: none;
}
.admin-link:hover { color: var(--ink); }

/* ---------------------------- Réglages --------------------------- */

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .12s !important; }
}
