/* ══════════════════════════════════════════════════════════════
   DES.CSS — PhysEdBoard — Lanceur de dés 3D
   Responsive: mobile 320px → tablette → desktop → TV/projecteur
══════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ══════════════════════════════════════════════════════════════
   VARIABLES GLOBALES — base mobile (< 768px)
══════════════════════════════════════════════════════════════ */
:root {
  /* Couleurs */
  --bg:             #061428;
  --accent:         #ffd43b;
  --accent-rgb:     255, 212, 59;
  --panel:          #0d2040;
  --border:         rgba(255,255,255,0.08);
  --text:           #fff;

  /* Dé */
  --die-size:       clamp(64px, 15vw, 100px);

  /* Boutons */
  --btn-fs:         12px;
  --btn-pad-v:      10px;
  --btn-pad-h:      20px;
  --btn-radius:     8px;

  /* Barre d'actions */
  --actions-bar-h:  56px;
}


/* ══════════════════════════════════════════════════════════════
   BASE
══════════════════════════════════════════════════════════════ */
html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Barlow Condensed', sans-serif;
  min-height: 100dvh;
  position: relative;
}

/* ── Couches de fond ── */
.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.bg-main {
  background:
    radial-gradient(ellipse 130% 70% at 50% 115%, rgba(0,80,200,0.22) 0%, transparent 65%),
    radial-gradient(ellipse 70% 50% at 12% 0%,   rgba(0,50,130,0.16) 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 88% 0%,   rgba(0,50,130,0.16) 0%, transparent 55%),
    linear-gradient(180deg, #04101e 0%, var(--bg) 40%, #091e3c 100%);
}
.bg-vignette {
  background: radial-gradient(ellipse 100% 100% at 50% 50%, transparent 35%, rgba(0,0,0,0.52) 100%);
}
.bg-scanlines {
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.05) 2px,
    rgba(0,0,0,0.05) 4px
  );
  opacity: 0.45;
}


/* ══════════════════════════════════════════════════════════════
   APP SHELL
══════════════════════════════════════════════════════════════ */
.app {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(10px, 2vh, 24px) clamp(10px, 2vw, 24px);
}


/* ══════════════════════════════════════════════════════════════
   LAYOUT DÉS
══════════════════════════════════════════════════════════════ */
.des-layout {
  display: flex;
  width: 100%;
  height: 100dvh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  overflow: hidden;
  padding-top: 64px;
  padding-bottom: var(--actions-bar-h);
}

/* ── Zone d'affichage des dés (canvas WebGL) ── */
#desDisplayZone {
  width: 100%;
  flex: 1;
  min-height: 0;
  position: relative;
}

#desDisplayZone canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* ── Total ── */
.des-total {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(15px, 2.8vw, 20px);
  line-height: 1;
  letter-spacing: 0.12em;
  color: var(--accent);
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-shrink: 0;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
  position: absolute;
  bottom: calc(var(--actions-bar-h) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}

body.des-ready .des-total {
  opacity: 1;
  visibility: visible;
}


/* ── Barre d'actions ── */
/* ══════════════════════════════════════════════════════════════
   BARRE D'ACTIONS
══════════════════════════════════════════════════════════════ */
.des-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--actions-bar-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.5vw, 18px);
  background: transparent;
  padding: 0 clamp(12px, 2vw, 32px);
  z-index: 20;
}


/* ══════════════════════════════════════════════════════════════
   BOUTONS PRINCIPAUX
══════════════════════════════════════════════════════════════ */
.des-roll-btn,
.des-reset-btn {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: var(--btn-fs);
  font-weight: 700;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  padding: var(--btn-pad-v) var(--btn-pad-h);
  border-radius: var(--btn-radius);
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.12);
  transition: all 0.15s;
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.des-roll-btn {
  background: var(--accent);
  color: #000;
  border-color: transparent;
  box-shadow: 0 4px 20px rgba(255,212,59,0.2);
}
.des-roll-btn:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 6px 28px rgba(255,212,59,0.35);
}
.des-roll-btn:active:not(:disabled) { transform: scale(0.97); }
.des-roll-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.des-reset-btn { background: transparent; color: rgba(255,255,255,0.35); }
.des-reset-btn:hover {
  border-color: rgba(255,255,255,0.28);
  color: rgba(255,255,255,0.75);
}
.des-reset-btn:active { transform: scale(0.97); }


/* ══════════════════════════════════════════════════════════════
   OVERLAY OPTIONS
══════════════════════════════════════════════════════════════ */
.des-options-overlay {
  display: none;
  position: fixed; inset: 0;
  z-index: 450;
  background: rgba(2,2,8,0.88);
  align-items: center; justify-content: center;
  backdrop-filter: blur(20px);
}
.des-options-overlay.visible {
  display: flex;
  animation: dFadeIn 0.18s ease;
}

.des-options-modal {
  background: #0a0a14;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: clamp(12px, 2vw, 16px);
  width: clamp(300px, 90vw, 360px);
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 40px 80px rgba(0,0,0,0.9), 0 0 0 1px rgba(255,255,255,0.03);
  animation: dPop 0.3s cubic-bezier(0.34,1.4,0.64,1);
  max-height: 92dvh;
  overflow-y: auto;
}

/* Reuse co- classes from cartes for consistency */
.do-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: clamp(12px, 2vh, 16px) clamp(14px, 2vw, 18px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: sticky; top: 0;
  background: #0a0a14; z-index: 1;
}
.do-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.45em; text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  display: flex; align-items: center; gap: 8px;
}
.do-close {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 50%;
  color: rgba(255,255,255,0.35);
  width: 44px; height: 44px;
  font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0;
  touch-action: manipulation;
}
.do-close:hover { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.8); }

.do-section {
  padding: clamp(14px, 2vh, 18px) clamp(14px, 2vw, 18px);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex; flex-direction: column; gap: 14px;
}
.do-section-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.45em; text-transform: uppercase;
  color: rgba(255,255,255,0.2);
}

.do-count-row {
  display: flex; align-items: center; justify-content: center; gap: 16px;
}
.do-count-btn {
  width: 44px; height: 44px; border-radius: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.5);
  font-size: 22px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.13s; user-select: none;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.do-count-btn:hover {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.9);
  border-color: rgba(255,255,255,0.2);
}
.do-count-btn:active { transform: scale(0.92); }

.do-count-input {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 42px; width: 72px;
  text-align: center;
  background: transparent; border: none;
  color: var(--accent); outline: none;
  pointer-events: none;
}

.do-footer {
  display: flex; gap: 10px;
  padding: clamp(12px, 1.8vh, 14px) clamp(14px, 2vw, 18px);
}
.do-btn-done {
  flex: 1;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.2em; text-transform: uppercase;
  padding: 12px 10px; border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.55);
}
.do-btn-done:hover  { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.25); color: rgba(255,255,255,0.9); }
.do-btn-done:active { transform: scale(0.97); }


/* ══════════════════════════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════════════════════════ */
@keyframes dieAppear {
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes dieRoll {
  0%   { transform: rotateX(0deg)    rotateY(0deg)    rotateZ(0deg); }
  20%  { transform: rotateX(360deg)  rotateY(180deg)  rotateZ(90deg); }
  50%  { transform: rotateX(720deg)  rotateY(360deg)  rotateZ(180deg); }
  75%  { transform: rotateX(1080deg) rotateY(540deg)  rotateZ(270deg); }
  100% { transform: rotateX(1440deg) rotateY(720deg)  rotateZ(360deg); }
}

@keyframes dFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes dPop {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}


/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════ */

/* ── 1. Tablette portrait (768px+) ── */
@media (min-width: 768px) {
  :root {
    --die-size:       clamp(90px, 14vw, 130px);
    --btn-fs:         13px;
    --btn-pad-v:      11px;
    --btn-pad-h:      28px;
    --actions-bar-h:  64px;
  }
}

/* ── 2. Tablette paysage / laptop (1024px+) ── */
@media (min-width: 1024px) {
  :root {
    --die-size:       clamp(100px, 12vw, 150px);
    --btn-fs:         14px;
    --btn-pad-v:      12px;
    --btn-pad-h:      36px;
    --actions-bar-h:  70px;
  }
}

/* ── 3. Laptop standard (1280px+) ── */
@media (min-width: 1280px) {
  :root {
    --die-size:       clamp(110px, 10vw, 160px);
    --btn-fs:         15px;
    --btn-pad-v:      13px;
    --btn-pad-h:      42px;
    --actions-bar-h:  72px;
  }
}

/* ── 4. Laptop HD (1536px+) ── */
@media (min-width: 1536px) {
  :root {
    --die-size:       clamp(120px, 9vw, 180px);
    --btn-fs:         15px;
    --btn-pad-v:      14px;
    --btn-pad-h:      48px;
    --actions-bar-h:  76px;
  }
}

/* ── 5. Grand écran (1920px+) ── */
@media (min-width: 1920px) {
  :root {
    --die-size:       clamp(140px, 8vw, 200px);
    --btn-fs:         17px;
    --btn-pad-v:      16px;
    --btn-pad-h:      56px;
    --btn-radius:     10px;
    --actions-bar-h:  80px;
  }
}
