/* Global dice roller — FAB, panel, polyhedral faces, flip animation.
   Font sizes in rem only (1rem = 18px). */

.dice-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1080;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: linear-gradient(145deg, var(--accent), var(--muted));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5); /* one-off shadow, no matching token */
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.dice-fab:hover { transform: scale(1.06); }
.dice-fab:active { transform: scale(0.96); }

.dice-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1400; /* au-dessus des modals de combat (1300) : le lanceur de des reste utilisable depuis le HUD et les modals */
  background: transparent;
}

.dice-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: 1401;
  width: 400px;
  max-width: calc(100vw - 32px);
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6); /* one-off shadow, no matching token */
  color: var(--ink);
}

.dice-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.dice-panel-title {
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.dice-panel-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.dice-type-row { display: flex; gap: 6px; margin-bottom: 12px; }
.dice-type-btn {
  flex: 1;
  padding: 6px 0;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
}
.dice-type-btn.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface-2);
}

.dice-controls { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 12px; flex-wrap: wrap; }
.dice-field { display: flex; flex-direction: column; gap: 4px; }
.dice-field-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}
.dice-field input[type='number'] {
  width: 64px;
  padding: 5px 8px;
  font-size: 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--ink);
}
.dice-field--check { flex-direction: row; align-items: center; gap: 6px; }
.dice-color-input {
  width: 40px;
  height: 30px;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.dice-mode-toggle { display: flex; gap: 6px; margin-bottom: 12px; }
.dice-mode-btn {
  flex: 1;
  padding: 5px 0;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
}
.dice-mode-btn.is-active { border-color: var(--accent); color: var(--accent); }
.dice-mode-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.dice-roll-btn {
  width: 100%;
  padding: 9px 0;
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: linear-gradient(145deg, var(--accent), var(--muted));
  color: var(--on-accent);
  cursor: pointer;
}

.dice-result { margin-top: 14px; text-align: center; }
.dice-empty { color: var(--muted); font-size: 0.85rem; }
.dice-tray { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.dice-3d-tray { width: 100%; height: 300px; position: relative; margin-bottom: 12px; }
.dice-3d-tray canvas { width: 100%; height: 100%; display: block; }

.dice-face-wrap { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; }
.dice-face {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5); /* one-off shadow, no matching token */
}
.dice-face-value {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--dice-fg, var(--ink));
}
.dice-face-breakdown { font-size: 0.8rem; color: var(--muted); }

/* Shapes (clip-path silhouettes). d6 uses a rounded square with pips.
   Each face background falls back to a per-type colour when --dice-color is unset.
   --dice-color/--dice-fg are always supplied inline by dice-roller.js / dice-request/panel.js
   (see trayStyle), so these var() fallbacks are defensive/unreachable in normal use — mapped to
   theme tokens by hue family rather than kept as fixed literals since they carry no real visual
   meaning for users. */
.dice-face--pips {
  background: var(--dice-color, linear-gradient(145deg, var(--surface), var(--surface-2)));
  border-radius: 10px;
}
.dice-face--triangle {
  background: var(--dice-color, var(--warning));
  clip-path: polygon(50% 4%, 96% 96%, 4% 96%);
}
.dice-face--triangle .dice-face-value { transform: translateY(6px); }
.dice-face--kite {
  background: var(--dice-color, var(--success));
  clip-path: polygon(50% 0, 90% 38%, 50% 100%, 10% 38%);
}
.dice-face--hexagon {
  background: var(--dice-color, var(--accent));
  clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
}
.dice-face--pentagon {
  background: var(--dice-color, var(--psychic));
  clip-path: polygon(50% 0, 100% 38%, 82% 100%, 18% 100%, 0 38%);
}

/* d6 pips */
.dice-pips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  padding: 8px;
}
.dice-pip { align-self: center; justify-self: center; width: 8px; height: 8px; border-radius: 50%; background: transparent; }
.dice-pip--on { background: var(--dice-fg, var(--ink)); }

/* Flip animation. Each roll rebuilds the face nodes, so the keyframes restart naturally. */
@keyframes dice-flip { 0% { transform: rotateX(0); } 100% { transform: rotateX(1440deg); } }
.dice-face--spin { animation: dice-flip 0.65s cubic-bezier(0.3, 0.1, 0.2, 1); }

@media (prefers-reduced-motion: reduce) {
  .dice-face--spin { animation: none; }
  .dice-fab { transition: none; }
}

/* Téléphone : le bas de l'écran appartient à la barre de navigation. Le déclencheur
   des dés vit alors dans la bannière du haut (cf. dashboard.hbs). L'état d'ouverture
   étant dans le service dice-panel, les deux déclencheurs pilotent le même panneau.

   Ce bloc remplace un `@media (max-width: 480px)` qui repositionnait le FAB
   (`bottom: 16px; right: 16px` — mort désormais, le FAB n'est plus affiché) et
   rétrécissait le panneau (`width: calc(100vw - 24px); right: 12px; bottom: 84px`).
   Le conserver aurait été pire qu'inutile : à spécificité égale il venait APRÈS dans
   le fichier, donc sous 480 px il aurait repris la main sur `width`/`right`/`bottom`
   et annulé la feuille pleine largeur ci-dessous. Mesuré en le réinjectant après ce
   bloc, à 360 px : panneau large de 336 px au lieu de 360, bord bas à 606 px au lieu
   de 640 — soit 34 px de vide entre le panneau et la barre. */
@media (max-width: 767.98px) {
  .dice-fab { display: none; }

  /* 400 px de large sur un écran de 422 : le panneau devient une feuille pleine
     largeur, ancrée juste au-dessus de la barre de navigation (mesuré à 360 et
     422 px : bord bas à 640 px pour un bord haut de barre à 640,16 px).
     `max-height: 70vh` laisse de quoi voir la bannière du haut (56 px mesurés) et
     la barre d'onglets ; au-delà, le contenu défile À L'INTÉRIEUR du panneau —
     mesuré avec 25 dés au plateau : scrollHeight 750 px pour clientHeight 481 px,
     panneau toujours dans l'écran (haut à 157 px). */
  .dice-panel {
    left: 0;
    right: 0;
    bottom: var(--bottomnav-h);
    width: auto;
    max-width: none;
    max-height: 70vh;
    overflow-y: auto;
    border-radius: 12px 12px 0 0;
  }
}

/* Shared roll overlay (dice-request) — centered, above every other layer
   (combat modal backdrop 1050, toast container 1090). */
.dice-request-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1402;
  background: var(--scrim);
}
.dice-request-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1403;
  width: 400px;
  max-width: calc(100vw - 32px);
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6); /* one-off shadow, no matching token */
  color: var(--ink);
}
.dice-request-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
}
