/* =====================================================================
   Spinoo (roue aléatoire) — styles propres à l'outil
   S'appuie sur otoolia.css (variables --ot-*, .ot-btn, .ot-panel, .ot-chip…).
   Tout est préfixé .rw pour ne jamais toucher à l'en-tête ni au pied de page.
   ===================================================================== */

.rw {
  --rw-rim: #1b1b29;          /* jante et moyeu de la roue */
  --rw-gold: #f5b301;         /* liseré du secteur gagnant */
  --rw-ok: var(--ot-success);
  --rw-final: #b45309;
  position: relative;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .rw { --rw-rim: #2d2d40; --rw-final: #fbbf24; }
}
:root[data-theme="dark"] .rw { --rw-rim: #2d2d40; --rw-final: #fbbf24; }

.rw-head h1 { font-size: clamp(1.5rem, 3.4vw, 2.1rem); margin-bottom: .25em; }
.rw-head p { margin-bottom: var(--ot-space); }

/* ---------- Mise en page ---------- */
.rw-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--ot-space); align-items: start; }
.rw-layout > * { min-width: 0; overflow-wrap: break-word; }
.rw-stage { display: flex; flex-direction: column; align-items: center; padding: var(--ot-space); }
.rw-side {
  position: sticky; top: 76px;              /* sous l'en-tête Otoolia (60 px) */
  max-height: calc(100vh - 92px); overflow-y: auto;
  padding: 6px var(--ot-space) var(--ot-space);
  display: flex; flex-direction: column;
}
@media (max-width: 860px) {
  .rw-layout { grid-template-columns: 1fr; }
  .rw-side { position: static; max-height: none; overflow: visible; }
}

/* ---------- Roue ---------- */
.rw-tabs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 8px; }
.rw-tab-wrap { position: relative; display: inline-flex; }
.rw-tab { font-size: .85rem; padding: 4px 14px; }
.rw-tab-del {
  position: absolute; top: -7px; right: -7px; width: 18px; height: 18px; padding: 0;
  display: grid; place-items: center; border-radius: 50%; cursor: pointer;
  font: 700 12px/1 var(--ot-font); background: var(--ot-surface); color: var(--ot-danger);
  border: 1.5px solid var(--ot-danger);
}
.rw-tab-del:hover { background: var(--ot-danger); color: #fff; }
.rw-tab-add { border-style: dashed; padding: 4px 12px; }

.rw-wheel-wrap {
  position: relative; margin: 0 auto;
  width: min(100%, max(280px, calc((100vh - 300px) * 1.28)), 720px);
}
.rw-wheel { width: 100%; height: auto; display: block; }
.rw-wheel text { font-family: var(--ot-font); }
.rw-rim { fill: var(--rw-rim); }

/* Compte à rebours, posé sur le disque de la roue */
.rw-countdown {
  position: absolute; left: 50%; top: 49.7%; width: 76.4%; aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%); border-radius: 50%; z-index: 5; pointer-events: none;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle, rgba(2,6,23,.82) 0%, rgba(2,6,23,.6) 65%, rgba(2,6,23,.35) 100%);
}
.rw-countdown.show { display: flex; }
.rw-countdown b { font-size: clamp(3rem, 12vw, 6rem); line-height: 1; color: #fff; animation: rw-pop .3s ease;
  text-shadow: 0 4px 30px rgba(0,0,0,.8); }
.rw-countdown span { color: rgba(255,255,255,.8); font-size: .9rem; margin-top: 4px; }
@keyframes rw-pop { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Commandes ---------- */
.rw-controls { justify-content: center; margin-top: 14px; }
.rw-spin { font-size: 1.1rem; padding: 10px 36px; min-height: 48px; }
.rw-controls .ot-btn--ghost[aria-pressed="true"] { background: var(--ot-brand); color: var(--ot-brand-ink); border-color: var(--ot-brand); }
.rw-theme-btn { display: none; }
.rw.rw-standalone .rw-theme-btn, .rw.is-fs .rw-theme-btn { display: inline-flex; }
.rw-shortcuts, .rw-fs-hint, .rw-status { text-align: center; color: var(--ot-text-soft); font-size: .8rem; margin: 10px 0 0; }
.rw-fs-hint { display: none; }
.rw.is-fs .rw-fs-hint { display: block; }
.rw kbd { background: var(--ot-surface-2); border: 1px solid var(--ot-border); border-radius: 4px;
  padding: 0 5px; font: inherit; font-size: .9em; }

/* ---------- Résultat ---------- */
.rw-result {
  display: none; margin-top: 16px; text-align: center; padding: 14px 22px; border-radius: var(--ot-radius);
  border: 2px solid color-mix(in srgb, var(--rw-ok) 55%, transparent);
  background: color-mix(in srgb, var(--rw-ok) 10%, var(--ot-surface));
  max-width: 100%;
}
.rw-result.show { display: block; }
.rw-result__label { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: var(--rw-ok); }
.rw-result__name { font-size: 1.6rem; font-weight: 800; color: var(--ot-text); overflow-wrap: anywhere; }
.rw-result.final { border-color: color-mix(in srgb, var(--rw-final) 60%, transparent);
  background: color-mix(in srgb, var(--rw-final) 10%, var(--ot-surface)); }
.rw-result.final .rw-result__label { color: var(--rw-final); }
.rw-result .ot-row { justify-content: center; margin-top: 10px; }
.rw-btn-s { min-height: 34px; padding: 5px 14px; font-size: .85rem; }
.rw-btn-danger { background: var(--ot-danger); color: #fff; }

/* ---------- Panneau de réglages ---------- */
.rw-sec { border-top: 1px solid var(--ot-border); padding: 4px 0; }
.rw-sec:first-child { border-top: 0; }
.rw-sec > summary {
  list-style: none; cursor: pointer; user-select: none; display: flex; align-items: center; gap: 8px;
  padding: 8px 0; font-weight: 700; font-size: .92rem;
}
.rw-sec > summary::-webkit-details-marker { display: none; }
.rw-sec > summary::before { content: "▸"; color: var(--ot-text-soft); transition: transform .15s; }
.rw-sec[open] > summary::before { transform: rotate(90deg); }
.rw-sec > summary:hover { color: var(--ot-brand); }
.rw-sec__body { padding-bottom: 10px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.rw-sec__body > .ot-textarea, .rw-sec__body > .rw-full { width: 100%; }
.rw-hint { font-size: .8rem; color: var(--ot-text-soft); margin: 0; }
.rw-hint code { font-family: var(--ot-mono); background: var(--ot-surface-2); padding: 0 4px; border-radius: 4px; }
.rw .ot-textarea { min-height: 120px; font-size: .9rem; }
.rw-error { color: var(--ot-danger); font-size: .8rem; font-weight: 600; margin: 0; }
.rw-check { display: flex; align-items: flex-start; gap: 8px; font-size: .88rem; cursor: pointer; }
.rw-check input { accent-color: var(--ot-brand); width: 16px; height: 16px; margin-top: 3px; flex: none; }
.rw-check input.rw-num { width: 68px; height: auto; margin: 0; padding: 4px 8px; accent-color: auto; }

.rw-palettes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.rw-pal { border: 2px solid var(--ot-border); border-radius: var(--ot-radius-s); padding: 4px;
  background: var(--ot-surface); cursor: pointer; font: inherit; color: inherit; min-width: 0; }
.rw-pal:hover { border-color: var(--ot-text-soft); }
.rw-pal[aria-pressed="true"] { border-color: var(--ot-brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ot-brand) 22%, transparent); }
.rw-pal i { display: block; height: 18px; border-radius: 5px; }
.rw-pal span { display: block; font-size: .7rem; color: var(--ot-text-soft); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.rw-history { width: 100%; max-height: 200px; overflow-y: auto; border: 1px solid var(--ot-border); border-radius: var(--ot-radius-s); }
.rw-history__item { display: flex; justify-content: space-between; gap: 8px; padding: 6px 10px; font-size: .82rem;
  border-bottom: 1px solid var(--ot-border); }
.rw-history__item:last-child { border-bottom: 0; }
.rw-history__item b { overflow-wrap: anywhere; }
.rw-history__item span { color: var(--ot-text-soft); font-size: .72rem; white-space: nowrap; }
.rw-history__empty { padding: 12px; text-align: center; font-size: .8rem; color: var(--ot-text-soft); }

.rw-teams { display: grid; gap: 8px; width: 100%; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.rw-team { background: var(--ot-surface-2); border: 1px solid var(--ot-border); border-radius: var(--ot-radius-s); padding: 8px 10px; }
.rw-team h4 { margin: 0 0 4px; font-size: .82rem; }
.rw-team ul { list-style: none; margin: 0; padding: 0; font-size: .82rem; }
.rw-team li { padding: 2px 0; border-bottom: 1px dashed var(--ot-border); overflow-wrap: anywhere; }
.rw-team li:last-child { border-bottom: 0; }

/* ---------- Calques plein écran (annonce, confettis, fenêtres) ---------- */
.rw-confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 100; }
.rw-confetti i { position: absolute; top: -20px; animation: rw-fall linear forwards; }
@keyframes rw-fall { to { transform: translateY(105vh) rotate(720deg); opacity: 0; } }

.rw-overlay { position: fixed; inset: 0; z-index: 90; display: none; align-items: center; justify-content: center;
  padding: var(--ot-space); background: rgba(2,6,23,.92); cursor: pointer; text-align: center; }
.rw-overlay.show { display: flex; }
.rw-overlay__label { color: rgba(255,255,255,.75); font-size: .8rem; text-transform: uppercase; letter-spacing: .2em; font-weight: 700; margin-bottom: 10px; }
.rw-overlay__name { color: #fff; font-size: clamp(2.2rem, 8vw, 4rem); font-weight: 800; line-height: 1.1; overflow-wrap: anywhere;
  text-shadow: 0 4px 30px rgba(0,0,0,.8), 0 0 60px color-mix(in srgb, var(--ot-brand) 60%, transparent); }
.rw-overlay__hint { color: rgba(255,255,255,.55); font-size: .8rem; margin-top: 16px; }

.rw-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 80; display: none; text-align: center;
  padding: 8px 16px; font-size: .85rem; font-weight: 700; background: var(--ot-brand); color: var(--ot-brand-ink); }
.rw-banner.show { display: block; }

.rw-modal { position: fixed; inset: 0; z-index: 95; display: none; align-items: center; justify-content: center;
  background: rgba(2,6,23,.75); padding: var(--ot-space); }
.rw-modal.show { display: flex; }
.rw-modal__box { width: 100%; max-width: 360px; max-height: 90vh; overflow-y: auto; text-align: center; }
.rw-modal__box--wide { max-width: 540px; text-align: left; }
.rw-modal__box h3 { margin-bottom: 4px; }
.rw-modal .ot-row { justify-content: center; margin-top: 12px; }
.rw-modal__box--wide .ot-row { justify-content: space-between; }
.rw-canvas-wrap { display: inline-block; border-radius: var(--ot-radius); overflow: hidden; touch-action: none; margin-top: 10px; max-width: 100%; }
.rw-canvas-wrap canvas { display: block; cursor: grab; max-width: 100%; height: auto; }
.rw-zoom { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: .85rem; margin-top: 10px; }
.rw-zoom input { flex: 0 1 170px; accent-color: var(--ot-brand); }
.rw-cert { font-family: var(--ot-mono); font-size: .72rem; white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0;
  padding: 10px; border-radius: var(--ot-radius-s); background: var(--ot-surface-2); border: 1px solid var(--ot-border); }
.rw-cert.ok { border-color: var(--ot-success); background: color-mix(in srgb, var(--ot-success) 10%, var(--ot-surface)); }
.rw-cert.ko { border-color: var(--ot-danger); background: color-mix(in srgb, var(--ot-danger) 10%, var(--ot-surface)); }
.rw-modal textarea { font-family: var(--ot-mono); font-size: .75rem; min-height: 90px; }

/* ---------- Plein écran : seul l'outil est affiché (en-tête et pied masqués) ---------- */
.rw.is-fs { background: var(--ot-bg); color: var(--ot-text); padding: var(--ot-space); overflow: auto; height: 100%; }
.rw.is-fs .rw-layout { grid-template-columns: minmax(0, 1fr) 300px; height: 100%; align-items: stretch; }
/* Centrage vertical « sûr » : si le contenu dépasse, il défile au lieu d'être rogné en haut et en bas
   (justify-content: center couperait le haut de la roue, inatteignable par le défilement) */
.rw.is-fs .rw-stage { justify-content: flex-start; overflow-y: auto; }
.rw.is-fs .rw-stage > .rw-tabs { margin-top: auto; }
.rw.is-fs .rw-stage > .rw-status { margin-bottom: auto; }
.rw.is-fs .rw-side { position: static; max-height: none; }
.rw.is-fs .rw-wheel-wrap { width: min(100%, max(280px, calc((100vh - 230px) * 1.28))); transition: width .3s ease; }
/* Gagnant affiché : la roue rapetisse pour laisser la place à la boîte du résultat (≈ 150 px) */
.rw.is-fs .rw-stage:has(.rw-result.show) .rw-wheel-wrap { width: min(100%, max(240px, calc((100vh - 400px) * 1.28))); }
.rw.is-fs .rw-shortcuts { display: none; }
@media (max-width: 860px) {
  .rw.is-fs .rw-layout { grid-template-columns: 1fr; height: auto; }
}

/* ---------- Texte d'aide sous l'outil ---------- */
.rw-about { margin-top: calc(var(--ot-space) * 2.5); }

@media (max-width: 480px) {
  .rw-stage { padding: 10px; }
  .rw-spin { width: 100%; }
  .rw-palettes { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .rw-countdown b { animation: none; }
}
