/* ============================================================
   DZS Lucky Wheel — Design System
   Palette sombre, glassmorphism léger, micro-interactions.
   Animations limitées à transform/opacity (GPU), 60 FPS.
   ============================================================ */

/* Police : Inter via Google Fonts (chargement non bloquant via display=swap).
   Fallback système immédiat pour rester < 1 s même hors-ligne. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ---------- Tokens ---------- */
:root {
  /* Fonds */
  --bg-0: #0B1020;
  --bg-1: #10182B;
  --bg-elev: rgba(255, 255, 255, 0.04);
  --bg-elev-2: rgba(255, 255, 255, 0.07);

  /* Bordures / verre */
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --glass: rgba(16, 24, 43, 0.55);

  /* Accent */
  --accent: #FFD24A;
  --accent-soft: rgba(255, 210, 74, 0.16);
  --accent-ink: #1a1305;

  /* Texte */
  --text: #FFFFFF;
  --text-dim: #D8DEE9;
  --text-mute: #8B95A7;

  /* États */
  --success: #36D399;
  --danger: #ff6b6b;

  /* Ombres réalistes */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 30px 80px -24px rgba(0, 0, 0, 0.7);
  --glow: 0 0 0 1px var(--accent-soft), 0 12px 40px -8px rgba(255, 210, 74, 0.35);

  /* Rayons */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-pill: 999px;

  /* Rythme */
  --gap: 20px;
  --pad: clamp(16px, 2.4vw, 28px);

  /* Typo */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  /* Transitions */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 140ms var(--ease);
  --t-med: 260ms var(--ease);
}

/* Thème clair automatique pour ceux qui le préfèrent (bonus) */
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg-0: #f4f6fb;
    --bg-1: #ffffff;
    --bg-elev: rgba(11, 16, 32, 0.03);
    --bg-elev-2: rgba(11, 16, 32, 0.06);
    --line: rgba(11, 16, 32, 0.10);
    --line-strong: rgba(11, 16, 32, 0.18);
    --glass: rgba(255, 255, 255, 0.7);
    --text: #0B1020;
    --text-dim: #34405a;
    --text-mute: #6b7690;
    --accent-ink: #1a1305;
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 800px at 85% -10%, rgba(255, 210, 74, 0.10), transparent 55%),
    radial-gradient(900px 700px at -10% 110%, rgba(54, 211, 153, 0.08), transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
  background-attachment: fixed;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
textarea { font: inherit; }
kbd { font-family: var(--font); }

/* Accessibilité : masquer visuellement sans masquer pour lecteurs d'écran */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; top: 12px; left: 12px; z-index: 200;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: var(--r-sm);
  font-weight: 700; text-decoration: none;
  transform: translateY(-150%);
  transition: transform var(--t-fast);
}
.skip-link:focus { transform: translateY(0); }

/* Focus visible cohérent partout */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Header ---------- */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: clamp(14px, 2vw, 22px) var(--pad);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  background: linear-gradient(180deg, rgba(11, 16, 32, 0.7), rgba(11, 16, 32, 0));
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: -0.02em; }
.brand__name { font-size: 1.05rem; }
.brand__logo {
  width: 30px; height: 30px; display: block;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
}
.app-header__actions { display: flex; gap: 10px; }

.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--bg-elev); color: var(--text-dim);
  transition: transform var(--t-fast), background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.icon-btn:hover { background: var(--bg-elev-2); color: var(--text); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0) scale(0.96); }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon--sound-off { display: none; }
.icon-btn[aria-pressed="false"] .icon--sound-on { display: none; }
.icon-btn[aria-pressed="false"] .icon--sound-off { display: block; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr minmax(280px, 360px);
  gap: var(--gap);
  align-items: start;
  padding: var(--pad);
  max-width: 1680px;
  margin: 0 auto;
}

.panel {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--pad);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  box-shadow: var(--shadow-md);
}
.panel--stage {
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 0;
}

.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel__head-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.panel__title { font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-mute); }
.panel__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }

.badge {
  min-width: 30px; padding: 4px 10px; text-align: center;
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 0.85rem;
  color: var(--accent); background: var(--accent-soft);
  border-radius: var(--r-pill);
}

/* ---------- Champs ---------- */
.field {
  width: 100%; min-height: 220px; resize: vertical;
  padding: 14px 16px; border-radius: var(--r-md);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  color: var(--text); line-height: 1.7;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.field::placeholder { color: var(--text-mute); }
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: rgba(0, 0, 0, 0.28); }
.hint { margin-top: 8px; font-size: 0.8rem; color: var(--text-mute); }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 0.86rem; color: var(--text-dim); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track { width: 40px; height: 24px; border-radius: var(--r-pill); background: var(--bg-elev-2); border: 1px solid var(--line-strong); position: relative; transition: background var(--t-fast); flex: none; }
.switch__thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-dim); transition: transform var(--t-med), background var(--t-fast); }
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track .switch__thumb { transform: translateX(16px); background: var(--accent-ink); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Boutons ---------- */
.btn {
  --btn-bg: var(--bg-elev);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 18px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--btn-bg); color: var(--text);
  font-weight: 600; letter-spacing: -0.01em;
  transition: transform var(--t-fast), background var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast), opacity var(--t-fast);
}
.btn:hover { transform: translateY(-1px); background: var(--bg-elev-2); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--text-dim); }
.btn--ghost:hover { color: var(--text); background: var(--bg-elev); }
.btn--sm { padding: 7px 12px; font-size: 0.8rem; border-radius: var(--r-sm); }

.btn--primary {
  color: var(--accent-ink);
  background: linear-gradient(180deg, #ffe082, var(--accent));
  border-color: rgba(255, 210, 74, 0.6);
  font-weight: 700;
  box-shadow: var(--glow);
}
.btn--primary:hover { background: linear-gradient(180deg, #ffe89c, #ffd968); }

.btn--spin { margin-top: 22px; padding: 16px 28px; font-size: 1.05rem; }
.btn__text { line-height: 1; }

.kbd {
  font-size: 0.7rem; font-weight: 600;
  padding: 3px 7px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  color: inherit; opacity: 0.8;
}
.btn--primary .kbd { background: rgba(26, 19, 5, 0.18); border-color: rgba(26, 19, 5, 0.2); }

/* ---------- Stage / Roue ---------- */
.stage { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.wheel-wrap {
  position: relative;
  width: min(72vmin, 560px);
  aspect-ratio: 1;
  display: grid; place-items: center;
}
.wheel {
  width: 100%; height: 100%;
  display: block; border-radius: 50%;
  /* l'ombre donne la profondeur ; rotation gérée en JS via transform */
  box-shadow:
    0 0 0 10px rgba(255, 255, 255, 0.03),
    0 0 0 11px var(--line),
    var(--shadow-lg);
  will-change: transform;
  transform: translateZ(0);
}

/* Pointeur fixe en haut */
.pointer {
  position: absolute; top: -6px; left: 50%;
  width: 0; height: 0; z-index: 6;
  transform: translateX(-50%);
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-top: 28px solid var(--accent);
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
}
.pointer::after {
  content: ""; position: absolute; top: -34px; left: -7px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* Moyeu central cliquable */
.hub {
  position: absolute; z-index: 5;
  width: 23%; height: 23%; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--accent-ink); font-weight: 800; letter-spacing: 0.04em;
  background: radial-gradient(circle at 35% 30%, #ffe89c, var(--accent) 70%);
  border: 4px solid var(--bg-0);
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.7), inset 0 2px 6px rgba(255, 255, 255, 0.4);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.hub:hover { transform: scale(1.05); }
.hub:active { transform: scale(0.96); }
.hub:disabled { cursor: not-allowed; filter: saturate(0.6); }
.hub__label { font-size: clamp(0.9rem, 2.4vmin, 1.3rem); }

.status { min-height: 1.4em; margin-top: 16px; color: var(--text-dim); font-weight: 500; text-align: center; }

/* ---------- Participants récents ---------- */
.recent { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.recent__summary { cursor: pointer; font-size: 0.82rem; color: var(--text-mute); font-weight: 600; list-style: none; }
.recent__summary::-webkit-details-marker { display: none; }
.recent__summary::before { content: "▸ "; transition: none; }
.recent[open] .recent__summary::before { content: "▾ "; }
.recent__list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--r-pill);
  background: var(--bg-elev); border: 1px solid var(--line);
  font-size: 0.82rem; color: var(--text-dim);
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.chip:hover { background: var(--accent-soft); color: var(--accent); transform: translateY(-1px); }
.chip__count { font-size: 0.72rem; color: var(--text-mute); }

/* ---------- Historique ---------- */
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto; }
.history__item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--r-md);
  background: var(--bg-elev); border: 1px solid var(--line);
  animation: rise var(--t-med) both;
}
.history__medal { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 1rem; }
.history__body { flex: 1; min-width: 0; }
.history__winner { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history__meta { font-size: 0.76rem; color: var(--text-mute); }
.history__del {
  flex: none; width: 30px; height: 30px; border-radius: 8px;
  background: transparent; border: 1px solid var(--line); color: var(--text-mute);
  display: grid; place-items: center; transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.history__del:hover { color: var(--danger); border-color: var(--danger); }
.empty { color: var(--text-mute); font-size: 0.86rem; text-align: center; padding: 24px 0; }

/* ---------- Mode Hype ---------- */
.hype {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: radial-gradient(800px 800px at 50% 40%, rgba(255, 210, 74, 0.14), rgba(11, 16, 32, 0.92) 70%);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: 0; transition: opacity var(--t-med);
}
.hype[hidden] { display: none; }
.hype.is-on { opacity: 1; }
.confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.hype__inner { position: relative; text-align: center; padding: 24px; transform: scale(0.8); opacity: 0; }
.hype.is-on .hype__inner { animation: hype-reveal 700ms var(--ease) 120ms forwards; }
.hype__kicker { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.1em; color: var(--accent); text-transform: uppercase; }
.hype__name {
  font-size: clamp(2.6rem, 11vw, 7rem);
  font-weight: 800; letter-spacing: -0.03em; line-height: 1.05;
  margin: 8px 0 28px;
  background: linear-gradient(180deg, #fff, var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 60px rgba(255, 210, 74, 0.4);
  word-break: break-word;
}
.hype__actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* Halo lumineux derrière le nom */
.hype__inner::before {
  content: ""; position: absolute; left: 50%; top: 42%;
  width: 60vmin; height: 60vmin; transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 210, 74, 0.35), transparent 60%);
  filter: blur(20px); z-index: -1;
  animation: halo 3s ease-in-out infinite;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 120;
  transform: translate(-50%, 20px);
  padding: 12px 18px; border-radius: var(--r-pill);
  background: var(--bg-1); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-md); color: var(--text);
  font-size: 0.88rem; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-med), transform var(--t-med);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Splash ---------- */
.splash {
  position: fixed; inset: 0; z-index: 300;
  display: grid; place-items: center; gap: 20px;
  background: var(--bg-0);
  transition: opacity 500ms var(--ease);
}
.splash.is-gone { opacity: 0; pointer-events: none; }
.splash__mark { position: relative; width: 64px; height: 64px; }
.splash__ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 900ms linear infinite;
}
.splash__dot { position: absolute; inset: 26px; border-radius: 50%; background: var(--accent); box-shadow: var(--glow); }
.splash__word { font-weight: 800; letter-spacing: -0.02em; color: var(--text-dim); animation: pulse 1.4s ease-in-out infinite; }

/* ---------- Keyframes (transform/opacity uniquement) ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes halo { 0%, 100% { opacity: 0.7; transform: translate(-50%, -50%) scale(1); } 50% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); } }
@keyframes hype-reveal {
  0% { opacity: 0; transform: scale(0.8); }
  60% { opacity: 1; transform: scale(1.04); }
  100% { opacity: 1; transform: scale(1); }
}

/* ---------- Responsive ---------- */
/* Tablette : on replie l'historique sous la roue, input à gauche */
@media (max-width: 1180px) {
  .layout { grid-template-columns: minmax(260px, 320px) 1fr; }
  .panel--history { grid-column: 1 / -1; }
}

/* Mobile / petite tablette : pile verticale, roue en premier */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; gap: 16px; }
  .panel--stage { order: -1; }
  .wheel-wrap { width: min(86vw, 460px); }
  .field { min-height: 160px; }
  .history { max-height: 40vh; }
}

@media (max-width: 380px) {
  :root { --pad: 14px; }
  .brand__name { display: none; }
  .btn--spin { width: 100%; }
}

/* Très grands écrans 4K : on agrandit la scène et on borne la largeur */
@media (min-width: 2200px) {
  body { font-size: 18px; }
  .layout { grid-template-columns: 420px 1fr 420px; gap: 32px; }
  .wheel-wrap { width: min(60vmin, 760px); }
}

/* Orientation paysage sur mobile : on réduit la roue pour tout voir */
@media (max-height: 560px) and (orientation: landscape) {
  .wheel-wrap { width: min(70vh, 320px); }
  .btn--spin { margin-top: 12px; padding: 12px 20px; }
}

/* ---------- Préférences utilisateur ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
