/* Hexapole — le jeu des treize marchés
   Copyright (c) 2026 Tristan Cazenave. Tous droits réservés — voir LICENSE.

   La carte occupe la place ; le panneau tient le reste. Sur un téléphone, la
   carte garde la place et le panneau devient une feuille au bas de l'écran. */
:root {
  --fond: #0f1620;
  --fond-2: #16202c;
  --fond-3: #1e2a38;
  --bord: #2c3a4c;
  --texte: #e6edf5;
  --texte-doux: #9aabbf;
  --accent: #d8a13a;
  --accent-sombre: #a9791f;
  --danger: #ef4444;
  --region: #223141;        /* une région sur laquelle personne n'a rien mis */
  --region-trait: #45596f;
  --rayon: 10px;
  --panneau-l: 386px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100dvh;
  background: var(--fond);
  color: var(--texte);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
.ecran { height: 100%; min-width: 0; }
[hidden] { display: none !important; }
.pousse { flex: 1; }

/* ─────────────────────────────── boutons ─────────────────────────────── */
.btn {
  border: 1px solid var(--bord); background: var(--fond-3); color: var(--texte);
  padding: 8px 14px; border-radius: var(--rayon); cursor: pointer;
  transition: background .12s, border-color .12s; white-space: nowrap;
}
@media (hover: hover) { .btn:hover:not(:disabled) { background: #27374a; border-color: #3d5069; } }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primaire {
  background: linear-gradient(180deg, #e7b955, var(--accent));
  border-color: var(--accent-sombre); color: #201704; font-weight: 650;
}
.btn-mini { padding: 6px 10px; font-size: 13px; }

/* ───────────────────────────── configuration ───────────────────────────── */
#ecran-config {
  display: grid; place-items: center; padding: 24px; overflow: auto;
  background: radial-gradient(1100px 620px at 50% -8%, #1d2c3e 0%, transparent 70%), var(--fond);
}
.boite {
  width: min(680px, 100%); background: var(--fond-2); border: 1px solid var(--bord);
  border-radius: 16px; box-shadow: 0 24px 70px #0008; display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}
.boite-tete {
  padding: 26px 28px 18px; border-bottom: 1px solid var(--bord); flex: 0 0 auto;
  display: flex; flex-direction: column;
}
/* le même sélecteur de langue que le reste de nestedplay, et le même réglage */
.langues {
  display: inline-flex; align-self: flex-end; margin-bottom: 6px;
  border: 1px solid var(--bord); border-radius: 9px;
  overflow: hidden; background: var(--fond-3);
}
.langues button {
  border: 0; background: transparent; color: var(--texte-doux); font: inherit;
  font-size: 11px; letter-spacing: .08em; padding: 3px 9px; cursor: pointer;
}
.langues button + button { border-left: 1px solid var(--bord); }
.langues button[aria-pressed="true"] { background: var(--accent); color: #201704; }
.boite-tete h1 { margin: 0; font-size: 28px; letter-spacing: -.4px; }
.sous-titre { margin: 8px 0 0; color: var(--texte-doux); font-size: 14px; }
.sous-titre .rappel { opacity: .75; font-size: 13px; }
.boite-corps { padding: 22px 28px; display: grid; gap: 18px; overflow-y: auto;
  flex: 1 1 auto; min-height: 0; }
.boite-pied {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 16px 28px; border-top: 1px solid var(--bord); background: #121b26;
  flex: 0 0 auto;
}

.champ { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.champ > label { font-weight: 600; min-width: 118px; }
.libre { font-weight: 400 !important; color: var(--texte-doux); font-size: 14px; }
.segment { display: flex; gap: 6px; flex-wrap: wrap; }
.segment button {
  min-width: 46px; min-height: 40px; padding: 0 12px;
  border: 1px solid var(--bord); background: var(--fond-3);
  border-radius: 9px; cursor: pointer; font-weight: 600;
}
.segment.large button { min-width: 128px; }
.segment button[aria-checked="true"] {
  background: var(--accent); color: #201704; border-color: var(--accent-sombre);
}
.segment button:disabled { opacity: .4; cursor: not-allowed; }

/* Les sièges : une ligne par entreprise, son nom puis qui la tient. À six, la
   liste tient sur deux colonnes plutôt que de pousser le pied de la boîte hors
   de l'écran. */
.champ-sieges { align-items: flex-start; }
#choix-qui { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 6px 14px; flex: 1 1 260px; }
.siege { display: flex; align-items: center; gap: 10px; }
.siege-nom { font-size: 13.5px; color: var(--texte-doux); flex: 1 1 auto;
  white-space: nowrap; }
.siege .segment button { min-height: 32px; min-width: 78px; font-size: 13px;
  font-weight: 500; }

/* ───────────────────────────────── jeu ───────────────────────────────── */
#ecran-jeu { display: grid; grid-template-rows: auto 1fr; height: 100%; min-width: 0; }
#barre {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0;
  padding: 9px 14px; padding-top: max(9px, env(safe-area-inset-top));
  background: var(--fond-2); border-bottom: 1px solid var(--bord);
}
.etiquette {
  font-size: 12.5px; color: var(--texte-doux);
  border: 1px solid var(--bord); background: var(--fond-3);
  padding: 3px 10px; border-radius: 999px;
}
.etiquette.attente { color: var(--accent); border-color: var(--accent-sombre);
  background: #2a2109; }
#qui-decide.alerte { color: #ffb4b4; border-color: var(--danger);
  background: #7f1d1d33; }

#plateau { display: grid; grid-template-columns: 1fr var(--panneau-l);
  min-height: 0; min-width: 0; }

/* ─────────────────────────────── la carte ───────────────────────────────
   Elle n'est pas une illustration : c'est sur elle qu'on clique pour dire où va
   la publicité et où partent les caisses. */
#zone-carte {
  min-width: 0; min-height: 0; overflow: hidden; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px;
  background: #0d1a26;
}
#ou { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 0 0 auto; }
#ou .segment button { min-height: 34px; min-width: 104px; font-size: 13.5px; }
#legende { margin: 0; flex: 0 0 auto; }
#carte { width: 100%; flex: 1 1 auto; min-height: 0; display: block;
  touch-action: manipulation; }
.source { margin: 0; flex: 0 0 auto; font-size: 11px; color: var(--texte-doux);
  opacity: .7; }

.region { cursor: pointer; }
.region:focus { outline: none; }
.region:focus-visible .trace { stroke: var(--accent); stroke-width: 2.5; }
.trace {
  stroke: var(--region-trait); stroke-width: 1.1;
  vector-effect: non-scaling-stroke;
}
@media (hover: hover) {
  .region:hover .trace { stroke: var(--accent); stroke-width: 2; }
}
.trace.choisie { stroke: var(--accent); stroke-width: 2.4; }
/* Les étiquettes se lisent sur une région sombre comme sur une région saturée :
   le texte clair est cerné d'un liseré sombre, posé sous lui. */
.r-nom {
  fill: #f2f6fb; font-weight: 700; font-family: inherit;
  stroke: #0b131ce0; stroke-width: 3.4; paint-order: stroke fill;
  pointer-events: none; user-select: none;
}
.r-sous {
  fill: #cfdae7; font-family: inherit;
  stroke: #0b131ce0; stroke-width: 3; paint-order: stroke fill;
  pointer-events: none; user-select: none;
}
.r-pastille { fill: var(--accent); stroke: #12140f; stroke-width: 1.2;
  pointer-events: none; }
.r-nombre {
  fill: #201704; font-weight: 700; font-family: inherit;
  pointer-events: none; user-select: none;
}

/* ─────────────────────────────── panneau ─────────────────────────────── */
#panneau {
  background: var(--fond-2); border-left: 1px solid var(--bord);
  overflow: hidden; display: flex; flex-direction: column; min-width: 0;
}
.corps-panneau { flex: 1 1 auto; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; }
.bloc { padding: 13px 15px; border-bottom: 1px solid var(--bord); }
.bloc h3 {
  margin: 0 0 9px; font-size: 12px; text-transform: uppercase;
  letter-spacing: .1em; color: var(--texte-doux);
}
.bloc h4 { margin: 14px 0 4px; font-size: 12px; color: var(--texte-doux);
  font-weight: 600; }
.bloc-journal { flex: 1; min-height: 120px; display: flex; flex-direction: column; }
.aide { color: var(--texte-doux); font-size: 13.5px; margin: 0; }

.actions { display: grid; gap: 8px; }

/* Les curseurs de répartition : la valeur se lit dans le libellé, et le curseur
   occupe toute la largeur — c'est un réglage, pas un formulaire. */
.curseur-champ { margin-bottom: 10px; }
.curseur-champ label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13.5px; margin-bottom: 2px;
}
.curseur-champ label b { font-variant-numeric: tabular-nums; color: var(--accent); }
.curseur-champ input[type="range"] { width: 100%; accent-color: var(--accent);
  height: 22px; }

.tableau {
  display: grid; grid-template-columns: 1fr auto; gap: 3px 12px;
  margin: 12px 0; font-size: 13.5px;
}
.tableau dt { color: var(--texte-doux); }
.tableau dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 650; }

/* Un tableau de gestion se lit en colonnes : chiffres à droite, alignés. */
.tableau-marche { overflow-x: auto; }
.tableau-marche table { border-collapse: collapse; width: 100%; font-size: 13px; }
.tableau-marche th {
  text-align: right; font-weight: 600; color: var(--texte-doux); font-size: 11.5px;
  padding: 4px 6px; border-bottom: 1px solid var(--bord); white-space: nowrap;
}
.tableau-marche th:first-child, .tableau-marche td:first-child { text-align: left; }
.tableau-marche td {
  text-align: right; padding: 4px 6px; border-bottom: 1px solid #ffffff0a;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.tableau-marche tr.moi td { background: #ffffff08; font-weight: 650; }
.tableau-marche tr.morte td { opacity: .45; }
.tableau-marche td.gain { color: #7FBF6A; }
.tableau-marche td.perte { color: #E27B6E; }
.pastille { display: inline-block; width: 9px; height: 9px; border-radius: 2px;
  margin-right: 7px; vertical-align: baseline; }

.graphes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-top: 12px; }
.graphe svg { width: 100%; height: 92px; display: block; }
.barre-nom {
  fill: #f2f6fb; font-size: 6px; font-weight: 700; font-family: system-ui, sans-serif;
  stroke: #0b131ccc; stroke-width: 1.6; paint-order: stroke fill;
}
.zero { stroke: #ffffff33; stroke-width: 1; vector-effect: non-scaling-stroke;
  stroke-dasharray: 3 3; }

.faillites {
  margin: 10px 0 0; padding: 8px 12px; border-radius: 8px; font-weight: 650;
  background: #7f1d1d33; border: 1px solid #a0303055; color: #ffb4b4;
}

#journal {
  margin: 0; padding: 0 0 0 4px; list-style: none; overflow-y: auto; flex: 1;
  font-size: 13px; color: var(--texte-doux); font-variant-numeric: tabular-nums;
}
#journal li { padding: 2px 0; border-bottom: 1px solid #ffffff08; }

/* ─────────────────────────────── modale ─────────────────────────────── */
.modale {
  position: fixed; inset: 0; background: #000a; display: grid; place-items: center;
  z-index: 50; padding: 20px;
}
.modale-boite {
  background: var(--fond-2); border: 1px solid var(--bord); border-radius: 14px;
  width: min(640px, 100%); max-height: 85dvh; display: flex; flex-direction: column;
  box-shadow: 0 26px 70px #000b;
}
.modale-tete { display: flex; align-items: center; gap: 12px; padding: 15px 18px;
  border-bottom: 1px solid var(--bord); }
.modale-tete h2 { margin: 0; font-size: 19px; }
.modale-tete button { margin-left: auto; }
.modale-corps { padding: 18px; overflow-y: auto; }
.modale-corps h4 { margin: 16px 0 6px; color: var(--accent); font-size: 14px; }
.modale-corps h4:first-child { margin-top: 0; }
.modale-corps p { font-size: 14px; color: #cfdae7; }
.modale-pied { display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 18px; border-top: 1px solid var(--bord); }

/* ─────────────────────────── l'écran de passage ───────────────────────────
   Il ne montre rien de la carte : c'est tout son office. */
#ecran-passage {
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(900px 520px at 50% -10%, #2a1d0b 0%, transparent 70%), var(--fond);
}
.boite.passage {
  text-align: center; padding: 34px 26px; max-width: 460px;
  display: flex; flex-direction: column; gap: 14px; align-items: center;
}
.boite.passage h2 { margin: 0; font-size: 26px; }
.passage-a { margin: 0; font-size: 19px; font-weight: 650; color: var(--accent); }
.boite.passage .rappel { margin: 0; color: var(--texte-doux); font-size: 14px; }
.btn-grand { font-size: 17px; padding: 14px 24px; width: 100%; }

/* ───────────────────── téléphones et tablettes ─────────────────────
   La carte garde la place ; le panneau devient une feuille au bas de l'écran. */
@media (max-width: 900px) {
  .graphes { grid-template-columns: 1fr; }
}
@media (max-width: 860px) and (min-height: 560px) {
  #plateau { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  #panneau { border-left: none; border-top: 1px solid var(--bord); max-height: 40dvh; }
  .corps-panneau { padding-bottom: env(safe-area-inset-bottom); }
  #barre { gap: 8px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); }
  #zone-carte { padding: 6px 8px; }
  /* La barre des postes et les deux raccourcis tiennent sur UNE ligne : deux
     lignes de commandes, c'est autant de carte en moins. */
  #zone-carte { gap: 4px; }
  #ou { gap: 5px; flex-wrap: nowrap; overflow-x: auto; }
  #ou .segment { flex-wrap: nowrap; }
  #ou .segment button { min-width: 0; padding: 0 9px; font-size: 12.5px; }
  #ou .pousse { display: none; }
  #ou .btn-mini { padding: 6px 8px; font-size: 12px; }
  #legende { font-size: 12.5px; }
  .source { font-size: 10px; }
  .btn-mini { padding: 6px 9px; font-size: 12.5px; }
  .bloc { padding: 11px 13px; }
  /* Les tailles des étiquettes ne sont pas ici : c'est `placeEtiquettes` qui
     les règle, parce que la pastille, le nom et la ligne du dessous doivent
     bouger ensemble pour ne pas se chevaucher. */
}

@media (max-width: 560px) {
  #ecran-config { padding: 0; place-items: stretch; overflow: hidden; }
  .boite { width: 100%; border: 0; border-radius: 0; box-shadow: none; }
  .boite-tete { padding: 16px; padding-top: max(16px, env(safe-area-inset-top)); }
  .boite-tete h1 { font-size: 23px; }
  .boite-corps { padding: 16px; gap: 14px; }
  .boite-pied { padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .boite-pied .btn { flex: 1 1 auto; }
  .champ > label { min-width: 0; flex: 1 0 100%; }
  .segment.large button { min-width: 100px; flex: 1; }
  .modale { padding: 10px; }
  .modale-boite { max-height: 88dvh; }
  .modale-pied { flex-wrap: wrap; }
  .modale-pied .btn { flex: 1 1 auto; }
}

/* RIEN NE ZOOME TOUT SEUL SUR UN ÉCRAN TACTILE. Deux appuis rapprochés sur un
   bouton sont lus par Safari, sur iPhone et iPad, comme un double appui — c'est
   à dire comme un ordre de grossir : le navigateur met alors le BOUTON à la
   largeur de l'écran, et le jeu sort du cadre. Le geste se fait sans y penser
   quand on presse deux fois « Annuler » pour revenir de deux coups en arrière.

   `manipulation` dit au navigateur qu'il n'y a pas de double appui à attendre
   ici : l'appui simple part aussitôt, le défilement reste, et le pincement — le
   zoom VOULU — reste lui aussi. On ne retire que le zoom accidentel, et jamais
   par `user-scalable=no`, qui fermerait les deux.

   Le plateau était protégé depuis longtemps ; les commandes ne l'étaient pas.
   La propriété ne s'hérite pas — le navigateur croise celle de la cible avec
   celle de ses ancêtres, de sorte que la première ligne suffirait —, mais on la
   redit sur les commandes : c'est là que le geste a lieu, et la protection ne
   doit pas dépendre d'un ancêtre qui changerait d'avis. */
html, body { touch-action: manipulation; }
button, select, input, textarea, a, label, summary { touch-action: manipulation; }

/* ET RIEN NE ZOOME NON PLUS EN ENTRANT DANS UN CHAMP : sous seize pixels,
   Safari grossit la page dès qu'un `input`, un `select` ou un `textarea` prend
   le focus — il rend le texte lisible — et il ne la redescend pas en sortant.
   Même symptôme que le double appui, autre cause. Seize pixels sur les écrans
   tactiles SEULEMENT : à la souris, les commandes restent discrètes.

   Mesuré avant d'être posé, sur l'écran d'un téléphone : aucun champ du site ne
   dépassait seize pixels — la règle ne rétrécit donc rien —, et aucune page ne
   déborde. */
@media (pointer: coarse) {
  input, select, textarea { font-size: 16px; }
}
