/* Outils de la famille « comptage » (js/outils/comptage.js), sauf le cadre de dix (outils.css). */

/* Chaque outil prend toute la place que l'écran lui laisse ; ses cases sont calculées sur la place
   qui reste (container-type: size, unités cqw/cqh) : en libre ou pendant un défi, texte agrandi ou
   non, sur téléphone comme sur iPad, tout tient sans défiler. */
.outil-jetons, .outil-tableau-cent, .outil-des {
  flex: 1 1 0; align-self: stretch; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.outil-jetons [aria-disabled='true'], .outil-des [aria-disabled='true'] { opacity: 0.45; }

/* ---------- les jetons bicolores : 20 au plus, par lignes de 5 ---------- */
.jetons-zone {
  flex: 1 1 0; min-height: 0; align-self: stretch;
  container: jetons / size;
  display: flex; align-items: center; justify-content: center;
}
.jetons-plateau {
  /* 4 lignes de 5 l'une sous l'autre (bords, marges et écarts : 44 px en largeur, 42 px en hauteur) */
  --pion: min(64px, calc((100cqw - 44px) / 5), calc((100cqh - 42px) / 4));
  display: grid; gap: 6px; padding: 8px 10px;
  background: var(--card); border: 3px solid var(--field-line); border-radius: 18px;
}
/* large et bas (téléphone en paysage) : deux lignes de 5 côte à côte, comme deux cadres */
@container jetons (min-aspect-ratio: 12/5) {
  .jetons-plateau { --pion: min(64px, calc((100cqw - 80px) / 10), calc((100cqh - 30px) / 2)); grid-template-columns: auto auto; column-gap: 18px; }
}
.jetons-ligne { display: grid; grid-template-columns: repeat(5, var(--pion)); grid-auto-rows: var(--pion); gap: 4px; }
.jetons-place { display: flex; align-items: center; justify-content: center; }
/* une place libre : un petit point, pour voir où ira le prochain jeton */
.jetons-place.vide::before { content: ''; width: 16%; height: 16%; border-radius: 50%; background: var(--field-line); }
.jetons-pion { width: 100%; height: 100%; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.jetons-pion[hidden] { display: none; }
.jetons-pion .jeton { width: 88%; height: 88%; }
.jetons-pion .jeton.jaune { outline-offset: calc(var(--pion) * -0.24); }
.jetons-pion.pop .jeton { animation: pop 0.25s ease-out; }
.jetons-total { font-size: 1.5rem; text-align: center; }

/* ---------- le tableau de cent : deux moitiés de 50, l'une sous l'autre ou côte à côte ---------- */
.outil-tableau-cent { container: cent-outil / size; }
.cent-corps { flex: 1 1 0; min-height: 0; align-self: stretch; display: flex; flex-direction: column; align-items: center; gap: 8px; }
/* très large et très bas (téléphone en paysage pendant un défi, grandes cibles) : les couleurs à droite */
@container cent-outil (min-aspect-ratio: 7/2) {
  .cent-corps { flex-direction: row; align-items: stretch; }
  .cent-commandes { flex-direction: column; flex-wrap: nowrap; justify-content: center; }
}
.cent-zone {
  flex: 1 1 0; min-height: 0; min-width: 0; align-self: stretch;
  container: cent / size;
  display: flex; align-items: center; justify-content: center;
}
.cent-tableau {
  /* 10 × 10 : 6 px de bords en largeur, 9 px en hauteur (le trait du milieu compris) */
  --cent: min(48px, calc((100cqw - 8px) / 10), calc((100cqh - 12px) / 10));
  display: flex; flex-direction: column;
}
.cent-moitie {
  display: grid; grid-template-columns: repeat(10, var(--cent)); grid-auto-rows: var(--cent);
  background: var(--card); border: 3px solid var(--ink); border-radius: 10px 10px 0 0;
}
.cent-moitie + .cent-moitie { border-top: 0; border-radius: 0 0 10px 10px; }
/* large et bas (téléphone en paysage) : 1 à 50 à gauche, 51 à 100 à droite */
@container cent (min-aspect-ratio: 2/1) {
  .cent-tableau { --cent: min(48px, calc((100cqw - 26px) / 20), calc((100cqh - 8px) / 5)); flex-direction: row; gap: 12px; }
  .cent-moitie, .cent-moitie + .cent-moitie { border: 3px solid var(--ink); border-radius: 10px; }
}
.cent-case {
  position: relative; width: var(--cent); height: var(--cent);
  display: flex; align-items: center; justify-content: center;
  font-size: max(10px, calc(var(--cent) * 0.42)); font-weight: 700; line-height: 1; color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--field-line);
}
.cent-case:focus-visible { z-index: 1; outline-offset: 0; border-radius: 4px; }
/* une case coloriée : la couleur, et un motif en plus (jamais la couleur seule) :
   un rond pointillé pour le jaune, un cadre épais pour le bleu ; le nom est écrit sur les boutons */
.cent-jaune { background: #ffd23f; }
.cent-bleu { background: #9fcfff; }
.cent-jaune::after, .cent-bleu::after { content: ''; position: absolute; pointer-events: none; }
.cent-jaune::after { inset: 10%; border: 2px dotted #7a5c00; border-radius: 50%; }
.cent-bleu::after { inset: 1px; border: 3px solid #0b4a8f; border-radius: 3px; }
.cent-pastille { position: relative; display: inline-block; width: 1.5em; height: 1.5em; border-radius: 4px; flex: none; }
/* petits téléphones en portrait (défi, texte agrandi) : quelques pixels de plus pour les cases */
@media (orientation: portrait) and (max-height: 760px) {
  .outil-tableau-cent .cent-corps { gap: 4px; }
  .cent-commandes .outil-btn { min-height: 44px; }
}

/* ---------- les dés et la roue ---------- */
.outil-des { container: des / size; }
.des-corps { flex: 1 1 0; min-height: 0; align-self: stretch; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.des-scene {
  flex: 1 1 0; min-height: 0; min-width: 0; align-self: stretch;
  container: des-scene / size;
  display: flex; align-items: center; justify-content: center;
}
.des-vue { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.outil-des[data-affiche='des'] .roue-seul, .outil-des[data-affiche='roue'] .des-seul { display: none !important; }
.des-commandes { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.des-reglage { display: flex; align-items: center; gap: 6px; }
.des-nb { padding: 6px 12px; }
.des-pm { width: 48px; padding: 0; font-size: 1.5rem; }
.roue-nb { font-weight: 700; text-align: center; white-space: nowrap; }
.des-lancer { background: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent-dark); padding: 6px 18px; }
/* large (téléphone en paysage) : l'outil à gauche, les boutons en colonne à droite */
@container des (min-aspect-ratio: 3/2) {
  .des-corps { flex-direction: row; align-items: stretch; }
  .des-commandes { flex: none; width: min(270px, 45cqw); }
}

/* les dés : 3 au plus, côte à côte */
.des-plateau { --de: min(96px, calc((100cqw - 30px) / 3), calc(100cqh - 56px)); display: flex; gap: 12px; justify-content: center; }
.des-de {
  position: relative; width: var(--de); height: var(--de); padding: calc(var(--de) * 0.12);
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  background: #fff; border: 3px solid var(--ink); border-radius: 18%; box-shadow: 0 4px 0 var(--line);
}
.des-de[hidden] { display: none; }
.des-de .des-point { width: 72%; height: 72%; margin: auto; border-radius: 50%; }
.des-de .des-point.on { background: var(--ink); }
.des-de.vierge::before {
  content: '?'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--de) * 0.45); font-weight: 700; color: var(--muted);
}
@keyframes des-roule {
  25% { transform: rotate(-14deg) translateY(-8%); }
  50% { transform: rotate(10deg); }
  75% { transform: rotate(-6deg) translateY(-4%); }
}
.des-plateau.roule .des-de { animation: des-roule 0.55s ease-in-out; }
.des-total { min-height: 1.1em; text-align: center; }

/* la roue : le disque tourne, la flèche reste en haut ; le résultat est aussi écrit dessous (ou à côté).
   Le dessin prend la place que le texte laisse (le SVG garde ses proportions). */
.des-vue.roue-seul { flex: 1 1 0; align-self: stretch; min-width: 0; min-height: 0; }
.roue-dessin { flex: 1 1 0; min-height: 0; width: 100%; max-height: 300px; }
.roue-svg { display: block; width: 100%; height: 100%; }
.roue-svg text { font-weight: 700; text-anchor: middle; dominant-baseline: central; }
/* 0,9 s, comme DUREE_ROUE (comptage.js) ; pas de rotation animée avec « réduire les animations » (style.css) */
.roue-tourne { transform-box: fill-box; transform-origin: center; transition: transform 0.9s cubic-bezier(0.15, 0.6, 0.25, 1); }
.roue-texte { text-align: center; }
.roue-resultat { margin: 0; min-height: 1.3em; font-weight: 700; font-size: 1.15rem; line-height: 1.3; }
.roue-avant { margin: 0; min-height: 1.25em; font-size: 0.95rem; line-height: 1.25; color: var(--muted); }
/* large et bas : la roue à gauche, le texte à droite */
@container des-scene (min-aspect-ratio: 8/5) {
  .des-vue.roue-seul { flex-direction: row; gap: 14px; }
  .roue-dessin { flex: none; width: min(300px, 100cqh, 55cqw); height: min(300px, 100cqh, 55cqw); max-height: none; }
  .roue-texte { flex: 0 1 auto; min-width: 0; text-align: left; }
  .roue-resultat { font-size: 1rem; }
  .roue-avant { font-size: 0.85rem; }
}
