/* ╔══════════════════════════════════════════════════════════╗
   MISE EN PAGE

   Titre, colonnes (liste / roue / résultat) et adaptations
   ordinateur (≥ 820 px) et mobile.
   ╚══════════════════════════════════════════════════════════╝ */

/* ─── Titre ─── */
header {
  position: relative;
  z-index: 1;
  text-align: center;
  margin-bottom: 28px;
}
.title-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3.4rem);
  letter-spacing: 1px;
}
.title-badge-text {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 800;
  filter: drop-shadow(0 0 18px var(--gold2));
}
.subtitle {
  font-size: .95rem;
  color: rgba(255,248,240,.5);
  margin-top: 2px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* ─── Layout principal ─── */
.main {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 36px;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  max-width: 1050px;
}

/* ─── Panneau gauche (liste) ─── */
.panel {
  flex: 1 1 280px;
  max-width: 340px;
  background: rgba(255,255,255,0.045);
  border: 1px solid rgba(255,215,0,0.18);
  border-radius: 20px;
  padding: 24px 22px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}
.panel h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--gold);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel h2 span { font-size: 1.3rem; }

/* ─── Panneau droite (infos tirage) — mobile: caché, desktop: visible ─── */
.panel-right {
  flex: 1 1 220px;
  max-width: 280px;
  display: none; /* caché sur mobile */
  flex-direction: column;
  gap: 16px;
}
.panel-right-inner {
  background: rgba(255,255,255,0.045);
  border: 1px solid rgba(255,215,0,0.18);
  border-radius: 20px;
  padding: 22px 20px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

@media (min-width: 820px) {
  html, body {
    overflow: hidden;
  }
  body {
    padding: 0;
    justify-content: flex-start;
    height: calc(100vh - var(--footer-h));
    /* Sans ça, min-height: 100vh (variables.css) l'emporte : la page passait
       sous le footer et la roue était centrée 19 px trop bas. */
    min-height: 0;
    overflow: hidden;
  }
  header {
    display: none;
  }
  .main {
    flex-wrap: nowrap;
    align-items: stretch;
    max-width: 100%;
    width: 100%;
    height: 100%;
    gap: 0;
    padding: 0;
  }

  /* Colonne gauche : s'étire sur toute la hauteur du .main */
  .panel {
    flex: 1 1 0;
    min-width: 160px;
    max-width: 340px;
    align-self: stretch;
    border-radius: 0;
    border-top: none;
    border-bottom: none;
    border-left: none;
    overflow-y: auto;
    padding: 28px 22px;
    box-shadow: 4px 0 30px rgba(0,0,0,0.35);
  }
  /* Titre replacé dans le panneau gauche sur desktop — contenu injecté par JS */
  .panel::before {
    content: none;
  }
  .panel-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255,215,0,0.15);
  }
  .panel-title .title-badge-text {
    font-size: 1.5rem;
  }

  /* Colonne centre : carré strict, centré */
  .wheel-zone {
    flex: 0 0 auto;
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0 26px;
  }
  .wheel-wrapper {
    /* La roue reste centrée : la marge (40 px de chaque côté, ou la place du
       titre --title-space s'il est plus haut, roue.css) est la même en haut
       et en bas ; le titre se loge dans celle du haut. */
    --size: min(calc(100vh - var(--footer-h) - max(80px, calc(2 * var(--title-space)))), calc(100vw - 700px));
    width: var(--size);
    height: var(--size);
    aspect-ratio: unset;
  }

  /* Cacher le bouton tourner mobile sur desktop */
  .wheel-zone .btn-spin {
    display: none !important;
  }

  /* Colonne droite : toute la largeur restante, fond transparent = fond du body */
  .panel-right {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    align-self: stretch;
    display: flex;
    overflow: visible;
    position: relative;
    background: transparent;
  }
  .panel-right-inner {
    border: none;
    box-shadow: none;
    background: transparent;
    width: 100%;
    padding: 28px 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: static;
    pointer-events: none;
  }
  /* Bouton Tourner : centré sur la flèche */
  #btnSpinD {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translateX(-50%) translateY(-50%);
    /* Jamais plus large que le panneau de droite (étroit vers 1024-1366 px) */
    width: min(300px, calc(100% - 16px)) !important;
    padding: 20px 0 !important;
    font-size: 1.65rem !important;
    white-space: nowrap;
    z-index: 20;
    pointer-events: auto;
  }
  /* Ancienne règle btnActionsD supprimée — gérée dans #spinGroupD */
  /* Groupe résultat + boutons : wrapper centré sur la flèche */
  #spinGroupD {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translateX(-50%) translateY(-50%);
    width: min(330px, calc(100% - 16px));
    z-index: 20;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  /* Résultat desktop dans le wrapper */
  #resultBannerD {
    text-align: center;
    min-height: 0 !important;
    visibility: hidden;
    opacity: 0;
    transition: opacity .3s;
  }
  #resultBannerD.visible {
    visibility: visible;
    opacity: 1;
    animation: pop-in .4s cubic-bezier(.34,1.56,.64,1) both;
  }
  #resultBannerD .result-value {
    font-size: clamp(2.4rem, 4.2vw, 3.6rem);
  }
  /* Boutons dans le wrapper */
  #btnActionsD {
    position: static;
    transform: none;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
  }
  #btnActionsD.visible {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }
  #btnActionsD .btn-remove,
  #btnActionsD .btn-keep {
    width: 100%;
    font-size: 1.5rem;
    padding: 16px 24px;
  }
  /* Historique caché sur desktop */
  #historySectionD { display: none !important; }

  /* Sur desktop, ces éléments sont dans le panneau droit → on les retire du flux mobile */
  .wheel-zone .result-banner,
  .wheel-zone .btn-actions,
  .wheel-zone .final-banner,
  .wheel-zone .history-section {
    display: none !important;
  }

  /* wheel-zone ne doit pas intercepter les clics destinés au panneau droit */
  .wheel-zone {
    pointer-events: none;
  }
  .wheel-zone .wheel-wrapper,
  .wheel-zone .hub,
  .wheel-zone .btn-spin {
    pointer-events: auto;
  }
}

@media (max-width: 819px) {
  /* Panneau droit caché, plein écran caché */
  .panel-right { display: none !important; }
  .btn-reopen, #btnToggleFS { display: none !important; }
  /* Historique caché */
  #historySection { display: none !important; }
  /* Titre du panneau caché (le header le remplace) ; les listes
     sauvegardées restent visibles, en pastilles (panneau.css) */
  #panelTitle { display: none !important; }

  /* ── Compacter le body et le header ── */
  body {
    padding-top: 10px;
    padding-bottom: calc(var(--footer-h) + 4px); /* hauteur réelle : footer-height.js */
  }
  header {
    margin-bottom: 8px;
  }
  .title-badge {
    font-size: 1.6rem;
  }
  .subtitle {
    display: none;
  }

  /* ── Réduire le gap du layout ── */
  .main {
    gap: 10px;
  }

  /* ── Panneau gauche compact ── */
  .panel {
    width: 100%;
    max-width: 100%;
    padding: 10px 14px;
    flex: 0 0 auto;
  }
  .btn-manage-list {
    padding: 8px 14px;
    font-size: .88rem;
  }
  .mobile-active-list {
    margin-top: 6px;
    padding: 7px 12px;
    font-size: .85rem;
  }

  /* ── Roue calibrée pour iPhone 15 ──
     Une seule valeur --sz appliquée width ET height → toujours carré, jamais déformé.
     min() prend la plus petite des deux contraintes :
       • 78vw       : ne pas déborder en largeur
       • svh - 390px: laisser la place aux boutons en hauteur */
  .wheel-wrapper {
    --sz: min(78vw, calc(100svh - 390px));
    width: var(--sz);
    height: var(--sz);
  }

  /* ── Marges minimales autour de la roue ── */
  .wheel-zone .btn-spin { margin-top: 8px; }
  .result-banner        { margin-top: 6px; }
  .btn-actions          { margin-top: 6px; gap: 8px; }

  /* ── Boutons post-tirage compacts ── */
  .btn-remove, .btn-keep {
    padding: 10px 12px;
    font-size: .9rem;
  }

  /* ── Bouton Tourner compact ── */
  .btn-spin {
    padding: 11px 36px;
    font-size: 1rem;
  }
}

textarea {
  width: 100%;
  min-height: 160px;
  background: rgba(0,0,0,0.35);
  border: 1.5px solid rgba(255,215,0,0.25);
  border-radius: 12px;
  color: var(--white);
  font-family: var(--font-body);
  font-size: .95rem;
  padding: 12px 14px;
  resize: vertical;
  outline: none;
  transition: border-color .25s;
  line-height: 1.7;
}
textarea::placeholder { color: rgba(255,248,240,.3); }
textarea:focus { border-color: var(--gold); }

