/* =============================================================
   styles-layout.css — Dobble : tokens, layout, HUD, arène, cartes
   ============================================================= */

/* ── 1. DESIGN TOKENS ─────────────────────────────────────── */
:root {
  --dobble-bg:           var(--bg);
  --dobble-surface:      var(--bg-card);
  --dobble-text:         var(--ink);
  --dobble-muted:        var(--ink-muted);
  --dobble-accent:       var(--accent);
  --dobble-accent-light: var(--accent-light);
  --dobble-danger:       #c0392b;
  --dobble-warning:      #d4820a;
  --dobble-success:      #27864a;
  --dobble-player-left:  var(--accent);
  --dobble-player-right: #2d6a4f;
  --dobble-radius:       12px;
  --dobble-radius-sm:    6px;
  --dobble-shadow:       0 4px 24px rgba(0,0,0,0.07);
  --dobble-transition:   0.2s ease;
  --dobble-card-bg:      var(--bg-card);
  --dobble-card-border:  var(--border-light);
}

/* ── 2. APP WRAPPER ───────────────────────────────────────── */
.dp-app {
  position: relative;
  min-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
}

/* ── 3. ÉCRANS (single-page navigation) ──────────────────── */
.dp-screen {
  display: none;
  flex-direction: column;
  flex: 1;
}
.dp-screen.dp-active { display: flex; }
.dp-screen[hidden]   { display: none !important; }
.dp-screen:not([hidden]).dp-active { display: flex; }

/* ── 4. HUD ───────────────────────────────────────────────── */
.dp-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: var(--dobble-surface);
  border-bottom: 1px solid var(--dobble-card-border);
}

.dp-hud-scores {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.dp-score-display {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--dobble-accent);
  min-width: 2ch;
  text-align: center;
}

.dp-score-right-val { color: var(--dobble-player-right); }

.dp-vs {
  font-size: 0.8rem;
  color: var(--dobble-muted);
  font-weight: 500;
}

.dp-combo {
  display: inline-block;
  background: var(--dobble-accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  border-radius: 100px;
  margin-left: 0.25rem;
}

.dp-chrono {
  font-family: 'Source Sans 3', system-ui, sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--dobble-text);
  min-width: 3ch;
  text-align: right;
  transition: color 0.3s;
}

.dp-chrono.dp-warning { color: var(--dobble-warning); }
.dp-chrono.dp-danger  { color: var(--dobble-danger); }

/* Barre de progression */
.dp-progress-track {
  height: 4px;
  background: var(--border-light);
  width: 100%;
}

.dp-progress-bar {
  height: 100%;
  background: var(--dobble-accent);
  width: 100%;
  transition: width 0.25s linear, background 0.3s;
}

.dp-progress-bar.dp-warning { background: var(--dobble-warning); }
.dp-progress-bar.dp-danger  { background: var(--dobble-danger); }

/* Labels duel */
.dp-duel-labels {
  display: flex;
  justify-content: space-around;
  padding: 0.3rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.dp-label-left  { color: var(--dobble-player-left); }
.dp-label-right { color: var(--dobble-player-right); }

/* Avertissement portrait étroit */
.dp-rotate-hint {
  display: none;
  font-size: 0.75rem;
  color: var(--dobble-muted);
  text-align: center;
  padding: 0.25rem;
}

/* ── 5. ARÈNE ET CARTES ───────────────────────────────────── */
.dp-arena {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 0.75rem;
  position: relative;
}

.dp-card {
  position: relative;
  width: 44%;
  aspect-ratio: 1 / 1;
  background: var(--dobble-card-bg);
  border: 1px solid var(--dobble-card-border);
  border-radius: var(--dobble-radius);
  box-shadow: var(--dobble-shadow);
  flex-shrink: 0;
  overflow: visible;
  /* Contexte pour container queries (symboles en cqw) */
  container-type: inline-size;
}

.dp-separator {
  width: 1px;
  align-self: stretch;
  margin: 0.75rem;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    var(--border-light) 20%,
    var(--border-light) 80%,
    transparent 100%
  );
  flex-shrink: 0;
}

/* ── 6. SYMBOLES ──────────────────────────────────────────── */
.dp-symbol {
  position: absolute;
  transform: translate(-50%, -50%);
  /* Taille de fallback (navigateurs sans container queries) */
  width: 44px;
  min-height: 44px;
  font-size: clamp(1.4rem, 4.5vw, 2.2rem);
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  line-height: 1;
  padding: 0;
  transition: transform 0.1s ease;
}

/*
 * Container query : symboles dimensionnés en % de la carte (cqw).
 * Distances min entre positions = 31 % → bouton à 18 cqw = radius 9 %
 * → gap min = 31 - 18 = 13 % de carte (≥ 36 px sur 280 px) : pas de chevauchement.
 */
@container (min-width: 150px) {
  .dp-symbol {
    font-size: clamp(1.4rem, 16cqw, 3.2rem);
    width: clamp(44px, 18cqw, 90px);
    min-height: clamp(44px, 18cqw, 90px);
  }
}

.dp-symbol:focus-visible {
  outline: 2px solid var(--dobble-accent);
  outline-offset: 2px;
}

.dp-symbol img {
  width: 1.1em;
  height: 1.1em;
  object-fit: contain;
  display: block;
}

/* Flash overlay */
.dp-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 10;
  transition: opacity 200ms ease;
}

/* ── 7. RESPONSIVE LAYOUT ─────────────────────────────────── */
@media (max-width: 600px) {
  .dp-card      { width: 46%; }
  .dp-arena     { padding: 0.5rem; }
  .dp-separator { margin: 0.5rem 0.4rem; }
  .dp-chrono    { font-size: 1.4rem; }
  .dp-score-display { font-size: 1.3rem; }
}

@media (max-width: 400px) { .dp-rotate-hint { display: block; } }

@media (min-width: 900px) {
  .dp-arena { max-width: 900px; margin: 0 auto; width: 100%; }
}

/* ── Portrait : cartes empilées verticalement ────────────── */
@media (orientation: portrait) {
  .dp-arena {
    flex-direction: column;
    align-items: center;
    justify-content: space-evenly;
  }

  .dp-card {
    /* Limité par la hauteur disponible (~50 vh moins HUD) */
    width: min(80vw, 40vh);
  }

  .dp-separator {
    width: 50%;
    height: 1px;
    align-self: center;
    margin: 0.25rem 0;
    background: linear-gradient(
      to right,
      transparent 0%,
      var(--border-light) 20%,
      var(--border-light) 80%,
      transparent 100%
    );
  }
}

@media (prefers-reduced-motion: reduce) {
  .dp-flash        { transition: none !important; }
  .dp-progress-bar { transition: width 0.25s linear; }
}
