/* I HAVE A DRINK — Spin & Win */
:root {
  --glass: #16291f;      /* verre de bouteille, fond */
  --glass-2: #213d2f;
  --limestone: #ece6d8;  /* calcaire, papier de l'étiquette */
  --paper-line: #d6ccb6;
  --wine: #6e1a2f;       /* lie de vin */
  --wine-deep: #4c1020;
  --gold: #e9c873;       /* or d'étiquette */
  --gold-deep: #b48a3c;
  --ink: #1c1a16;
  --ink-soft: #5b5447;
  --danger: #a3262f;

  --serif: "Gloock", Georgia, "Times New Roman", serif;
  --sans: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --wheel: min(88vw, 440px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--limestone);
  background:
    radial-gradient(120% 80% at 30% 35%, var(--glass-2) 0%, var(--glass) 55%, #0f1d16 100%);
  background-color: var(--glass);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
/* grain léger, comme un papier d'étiquette pressé */
.grain {
  position: fixed; inset: 0; pointer-events: none; opacity: .07; z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* ---------- En-tête ---------- */
.top {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  padding-top: max(18px, env(safe-area-inset-top));
}
.brand {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: .22em;
  text-decoration: none;
  color: var(--limestone);
}
.sound {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid rgba(236,230,216,.25);
  background: transparent; color: var(--limestone);
  display: grid; place-items: center; cursor: pointer;
}
.sound[aria-pressed="false"] .wave { opacity: 0; }
.sound[aria-pressed="false"] { color: rgba(236,230,216,.55); }

/* ---------- Mise en page ---------- */
.stage {
  position: relative; z-index: 1;
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 4px 16px 32px;
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 28px;
}
@media (min-width: 900px) {
  :root { --wheel: min(46vw, 540px); }
  .stage {
    grid-template-columns: 1.15fr .85fr;
    align-items: center;
    gap: 56px;
    padding: 16px 32px 48px;
  }
  .wheel-col { justify-self: end; }
  .panel-col { justify-self: start; }
}

/* ---------- La roue ---------- */
.wheel-wrap {
  position: relative;
  width: var(--wheel);
  aspect-ratio: 1;
  margin-top: 26px; /* place pour le pointeur */
}
#wheel {
  width: 100%; height: 100%; display: block;
  filter: drop-shadow(0 28px 40px rgba(0,0,0,.45));
}
.pointer {
  position: absolute;
  left: 50%; top: -24px;
  width: calc(var(--wheel) * .095); min-width: 38px;
  transform: translateX(-50%) rotate(var(--flick, 0deg));
  transform-origin: 50% 30%;
  filter: drop-shadow(0 4px 4px rgba(0,0,0,.4));
  z-index: 3;
  transition: transform .08s ease-out;
}
.hub {
  position: absolute; left: 50%; top: 50%;
  width: 26%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid var(--gold);
  background: radial-gradient(circle at 35% 30%, #8a2a40, var(--wine) 45%, var(--wine-deep) 100%);
  color: var(--limestone);
  font-family: var(--serif);
  font-size: clamp(15px, calc(var(--wheel) * .045), 22px);
  cursor: pointer;
  box-shadow: 0 0 0 6px rgba(22,41,31,.55), inset 0 -6px 14px rgba(0,0,0,.35);
  transition: transform .15s ease;
  z-index: 2;
}
.hub:hover:not(:disabled) { transform: translate(-50%, -50%) scale(1.04); }
.hub:active:not(:disabled) { transform: translate(-50%, -50%) scale(.97); }
.hub:disabled { cursor: default; }
.hub span { display: block; }

/* ---------- Panneau "étiquette" ---------- */
.panel {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--limestone);
  color: var(--ink);
  padding: 30px 26px 24px;
  border-radius: 3px;
  /* double filet doré façon étiquette de vin */
  box-shadow:
    inset 0 0 0 6px var(--limestone),
    inset 0 0 0 7px var(--gold-deep),
    inset 0 0 0 10px var(--limestone),
    inset 0 0 0 11px var(--gold-deep),
    0 24px 50px rgba(0,0,0,.35);
}
.panel[hidden] { display: none; }
@media (min-width: 420px) { .panel { padding: 36px 34px 28px; } }

h1, h2 {
  font-family: var(--serif);
  font-weight: 400;
  margin: 0 0 10px;
  line-height: 1.05;
  color: var(--wine);
}
h1 { font-size: clamp(34px, 8vw, 46px); }
h2 { font-size: clamp(28px, 6.5vw, 36px); }
.lede { margin: 0 0 22px; color: var(--ink-soft); font-size: 16px; max-width: 34ch; }

.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field input {
  width: 100%;
  font: inherit; font-size: 17px;
  padding: 12px 14px;
  border: 1.5px solid var(--paper-line);
  border-radius: 6px;
  background: #faf7f0;
  color: var(--ink);
}
.field input:focus { outline: none; border-color: var(--wine); box-shadow: 0 0 0 3px rgba(110,26,47,.15); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field small { display: block; margin-top: 5px; color: var(--ink-soft); font-size: 13px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.check {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 14px; line-height: 1.4;
  margin: 10px 0;
  cursor: pointer;
}
.check input {
  appearance: none; -webkit-appearance: none;
  flex: none;
  width: 20px; height: 20px; margin: 0;
  border: 1.5px solid var(--ink-soft);
  border-radius: 4px;
  background: #faf7f0;
  display: grid; place-items: center;
  cursor: pointer;
}
.check input:checked { background: var(--wine); border-color: var(--wine); }
.check input:checked::after {
  content: ""; width: 10px; height: 6px;
  border: 2px solid var(--limestone); border-top: 0; border-right: 0;
  transform: translateY(-1px) rotate(-45deg);
}
.check input[aria-invalid="true"] { border-color: var(--danger); }
.check a { color: var(--wine); }

.error {
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 14px; font-weight: 500;
}

.cta {
  display: block; width: 100%;
  margin-top: 18px;
  padding: 15px 20px;
  border: 0; border-radius: 999px;
  background: var(--wine);
  color: var(--limestone);
  font: 600 17px/1.2 var(--sans);
  text-align: center; text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease;
}
.cta:hover { background: var(--wine-deep); }
.cta:active { transform: scale(.985); }
.cta:disabled { opacity: .6; cursor: progress; }

.fine { margin: 12px 0 0; text-align: center; font-size: 12.5px; color: var(--ink-soft); }

/* ---------- Résultat ---------- */
.result { text-align: center; }
.result:focus { outline: none; }
.result-kicker { margin: 0 0 6px; font-family: var(--serif); font-size: 20px; color: var(--gold-deep); }
.result h2 { margin-bottom: 20px; }
.ticket {
  border: 1.5px dashed var(--gold-deep);
  background: #f6efdf;
  padding: 16px 12px 14px;
  border-radius: 6px;
  display: grid; gap: 6px; justify-items: center;
}
.ticket-label { font-size: 13px; color: var(--ink-soft); }
.code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: clamp(22px, 6vw, 28px);
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--wine-deep);
  background: none; border: 0; padding: 2px 6px; cursor: copy;
  border-radius: 4px;
}
.code:hover { background: rgba(110,26,47,.07); }
.ticket-meta { font-size: 13px; color: var(--ink-soft); }
.how { margin: 18px auto 0; max-width: 32ch; font-size: 15px; }

/* ---------- Pied de page ---------- */
.foot {
  position: relative; z-index: 1;
  text-align: center;
  padding: 18px 16px 24px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  font-size: 12px;
  color: rgba(236,230,216,.6);
}
.foot p { margin: 2px 0; }

/* ---------- Confettis & toast ---------- */
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20; }
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 30;
  transform: translate(-50%, 20px);
  background: var(--ink); color: var(--limestone);
  padding: 10px 18px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Le panneau résultat apparaît en pivotant comme une étiquette qu'on retourne */
.result.reveal { animation: flipIn .6s cubic-bezier(.2,.8,.2,1) both; }
@keyframes flipIn {
  from { opacity: 0; transform: perspective(900px) rotateY(-70deg); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .result.reveal { animation: none; }
  .pointer, .hub, .cta, .toast { transition: none; }
}
