/* Pool de hockey — feuille de style unique.
   Aucun framework : la page doit rester légère et se charger d'un coup sur un
   téléphone au bord de la patinoire. */

:root {
  color-scheme: light dark;

  --nuit: #0B1B2B;
  --accent: #D4232E;
  --accent-doux: #f8e7e8;

  --fond: #F4F7FA;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --bord: #dde4ec;
  --texte: #0B1B2B;
  --texte-doux: #5d6b7d;
  --ombre: 0 1px 2px rgba(11,27,43,.06), 0 4px 16px rgba(11,27,43,.06);

  --or: #c9a227;
  --argent: #9aa5b1;
  --bronze: #b07d42;

  --r: 12px;
  --r-s: 8px;
  --gouttiere: 16px;
  --police: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #0B1B2B;
    --surface: #12263a;
    --surface-2: #18314a;
    --bord: #23415e;
    --texte: #E8ECF1;
    --texte-doux: #93a6bb;
    --accent-doux: #3a1b1f;
    --ombre: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  --fond: #0B1B2B;
  --surface: #12263a;
  --surface-2: #18314a;
  --bord: #23415e;
  --texte: #E8ECF1;
  --texte-doux: #93a6bb;
  --accent-doux: #3a1b1f;
  --ombre: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--police);
  font-size: 15px;
  line-height: 1.5;
  background: var(--fond);
  color: var(--texte);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; letter-spacing: -.015em; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
a { color: var(--accent); }

/* ---------------- structure ---------------- */

.enveloppe { max-width: 1100px; margin: 0 auto; padding: 0 var(--gouttiere); }

header.principal {
  background: var(--surface);
  border-bottom: 1px solid var(--bord);
  position: sticky; top: 0; z-index: 20;
}

/* La barre de marque reste bleu nuit dans les deux thèmes.
   Le logo est chargé en <img> : un SVG servi ainsi est un document isolé, son
   « currentColor » n'hérite donc jamais de la page et retombe sur le noir. Le
   mot-symbole est par conséquent figé en blanc, et c'est à la barre de lui
   garantir un fond foncé — sinon il disparaît selon le thème. */
.barre-marque { background: var(--nuit); }
.barre { display: flex; align-items: center; gap: 12px; height: 58px; }
.barre .logo { height: 30px; width: auto; flex: none; }
.barre .titre-pool { color: #fff; }
.barre button {
  background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.22); color: #fff;
}
.barre button:hover { background: rgba(255,255,255,.2); }
.barre .titre-pool {
  font-weight: 700; font-size: .95rem; margin-left: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.barre .pousse { margin-left: auto; }

nav.onglets {
  display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--bord); background: var(--surface);
}
nav.onglets::-webkit-scrollbar { display: none; }
nav.onglets a {
  padding: 11px 14px; font-size: .9rem; font-weight: 600; white-space: nowrap;
  color: var(--texte-doux); text-decoration: none; border-bottom: 2px solid transparent;
}
nav.onglets a:hover { color: var(--texte); }
nav.onglets a.actif { color: var(--accent); border-bottom-color: var(--accent); }

main { padding: 20px 0 60px; }

/* ---------------- cartes et grilles ---------------- */

.carte {
  background: var(--surface); border: 1px solid var(--bord);
  border-radius: var(--r); box-shadow: var(--ombre); padding: 18px; margin-bottom: 16px;
}
.carte > h2:first-child, .carte > h3:first-child { margin-top: 0; }
.grille { display: grid; gap: 16px; }
.grille.deux { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.rangee { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.rangee.serree { gap: 6px; }
.pousse { margin-left: auto; }
.doux { color: var(--texte-doux); }
.petit { font-size: .82rem; }
.centre { text-align: center; }

/* ---------------- contrôles ---------------- */

button, .bouton {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 9px 16px; border-radius: var(--r-s);
  border: 1px solid var(--bord); background: var(--surface-2); color: var(--texte);
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  transition: filter .12s;
}
button:hover:not(:disabled), .bouton:hover { filter: brightness(.96); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primaire, .bouton.primaire { background: var(--accent); border-color: var(--accent); color: #fff; }
button.sombre { background: var(--nuit); border-color: var(--nuit); color: #fff; }
button.mini { padding: 5px 10px; font-size: .82rem; }
button.lien {
  background: none; border: none; color: var(--accent); padding: 2px 4px; text-decoration: underline;
}

input, select, textarea {
  font: inherit; padding: 9px 11px; border-radius: var(--r-s);
  border: 1px solid var(--bord); background: var(--surface); color: var(--texte);
  width: 100%; max-width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
label { display: block; font-size: .84rem; font-weight: 600; color: var(--texte-doux); margin-bottom: 4px; }
.champ { margin-bottom: 14px; }
.champ-court { max-width: 130px; }

/* ---------------- tableaux ---------------- */

.tableau-defile { overflow-x: auto; margin: 0 calc(var(--gouttiere) * -1); padding: 0 var(--gouttiere); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--texte-doux); font-weight: 700; padding: 8px 10px;
  border-bottom: 1px solid var(--bord); white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--bord); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.gras { font-weight: 700; }

/* Le classement : le rang doit sauter aux yeux, c'est la première chose qu'on
   vient voir. */
.rang { font-weight: 800; font-size: 1rem; width: 34px; display: inline-block; }
tr.podium-1 .rang { color: var(--or); }
tr.podium-2 .rang { color: var(--argent); }
tr.podium-3 .rang { color: #b07d42; }
tr.moi { background: var(--accent-doux); }
tr.moi:hover { background: var(--accent-doux); }

/* ---------------- pastilles ---------------- */

.pastille {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .02em;
  background: var(--surface-2); color: var(--texte-doux); border: 1px solid var(--bord);
}
.pastille.A { background: #e8f0fe; color: #1a56c4; border-color: #cfe0fb; }
.pastille.D { background: #e9f7ee; color: #1a7f42; border-color: #cdead8; }
.pastille.G { background: #fdeee9; color: #c2410c; border-color: #f7d8cb; }
.pastille.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pastille.A { background: #12305e; color: #9ec2ff; border-color: #1d4a7a; }
  :root:not([data-theme="light"]) .pastille.D { background: #123a24; color: #8fdcae; border-color: #1c4f32; }
  :root:not([data-theme="light"]) .pastille.G { background: #46230f; color: #ffb48a; border-color: #5d3018; }
}

/* ---------------- joueurs ---------------- */

.joueur { display: flex; align-items: center; gap: 10px; min-width: 0; }
.joueur img {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: none;
  background: var(--surface-2); border: 1px solid var(--bord);
}
.joueur .nom { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.joueur .meta { font-size: .76rem; color: var(--texte-doux); }

/* ---------------- repêchage ---------------- */

.tour {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--nuit); color: #fff; border-radius: var(--r); padding: 16px 18px;
}
.tour.mon-tour { background: var(--accent); }
.tour .qui { font-size: 1.25rem; font-weight: 800; }
.tour .minuterie {
  font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums;
  margin-left: auto; letter-spacing: -.02em;
}
.tour .minuterie.urgent { animation: pulsation 1s infinite; }
@keyframes pulsation { 50% { opacity: .4; } }

.fil-choix { max-height: 420px; overflow-y: auto; }
.fil-choix li {
  display: flex; gap: 10px; align-items: center; padding: 8px 0;
  border-bottom: 1px solid var(--bord); list-style: none;
}
.fil-choix { margin: 0; padding: 0; }
.fil-choix .no { font-weight: 800; color: var(--texte-doux); width: 34px; font-variant-numeric: tabular-nums; }

/* ---------------- divers ---------------- */

.bandeau {
  padding: 11px 14px; border-radius: var(--r-s); margin-bottom: 14px;
  border: 1px solid var(--bord); background: var(--surface-2); font-size: .9rem;
}
/* Un bandeau qui clôt une carte suit toujours quelque chose — en général une
   rangée de boutons. Sans marge haute il se colle dessus et on le lit comme
   une partie du bouton. */
.carte > .bandeau:last-child { margin-top: 14px; margin-bottom: 0; }

.bandeau.erreur { background: var(--accent-doux); border-color: var(--accent); color: var(--accent); }
.bandeau.succes { background: #e9f7ee; border-color: #9ed9b5; color: #1a7f42; }

.vide { text-align: center; padding: 40px 20px; color: var(--texte-doux); }
.chargement { text-align: center; padding: 40px; color: var(--texte-doux); }

dialog {
  border: 1px solid var(--bord); border-radius: var(--r); padding: 20px;
  background: var(--surface); color: var(--texte); max-width: 520px; width: calc(100% - 32px);
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(11,27,43,.5); }

.connexion {
  max-width: 380px; margin: 8vh auto; padding: 0 var(--gouttiere);
}
/* Même raison qu'en en-tête : le logo a besoin de son fond foncé. */
.connexion .bloc-logo {
  background: var(--nuit); border-radius: var(--r);
  padding: 22px; margin-bottom: 22px; text-align: center;
}
.connexion .logo { display: block; margin: 0 auto; height: 46px; }

/* ---------------- responsive ---------------- */

@media (max-width: 620px) {
  h1 { font-size: 1.35rem; }
  .carte { padding: 14px; }
  .barre .titre-pool { display: none; }
  .tour .minuterie { font-size: 1.6rem; }
  th, td { padding: 8px 7px; }
  .masque-mobile { display: none; }
}

/* Barre d'actions collée en bas de l'écran sur la page des règles.
   Elle flotte au-dessus du contenu qui défile : sans fond opaque ni ombre,
   le texte des cartes se lirait au travers et la barre semblerait cassée. */
.barre-actions {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; gap: 10px; flex-wrap: wrap;
  margin: 8px calc(var(--gouttiere) * -1) 0;
  padding: 12px var(--gouttiere);
  background: var(--surface);
  border-top: 1px solid var(--bord);
  box-shadow: 0 -4px 16px rgba(11,27,43,.08);
}

/* ---------------- fiche de joueur dépliée ---------------- */

tr.joueur-ligne { cursor: pointer; }
tr.joueur-ligne:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
tr.joueur-ligne .chevron { transition: transform .15s; display: inline-block; width: 14px; }
tr.joueur-ligne.ouvert { background: var(--surface-2); }
tr.joueur-ligne.ouvert .chevron { transform: rotate(180deg); }

tr.detail-joueur > td { background: var(--surface-2); padding: 0; }
tr.detail-joueur .fiche { padding: 14px 12px 16px; }
.titre-fiche {
  margin: 0 0 8px; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--texte-doux); font-weight: 700;
}
/* Tout sous-titre qui n'ouvre pas la fiche respire au-dessus, quel que soit
   l'élément qui le précède (tableau ou note explicative). */
.fiche .titre-fiche:not(:first-child) { margin-top: 20px; }

/* Le tableau imbriqué ne doit pas réutiliser les séparateurs de la liste : deux
   grilles de bordures superposées rendent la fiche illisible. */
table.mini-tableau { font-size: .84rem; background: var(--surface); border-radius: var(--r-s); }
table.mini-tableau th { padding: 6px 9px; border-bottom: 1px solid var(--bord); }
table.mini-tableau td { padding: 6px 9px; border-bottom: 1px solid var(--bord); }
table.mini-tableau tbody tr:last-child td { border-bottom: none; }
table.mini-tableau tbody tr:hover { background: var(--surface-2); }
table.mini-tableau tr.saison-courante td { background: var(--accent-doux); }
