/* ============================================================================
 * game.css — Styles mutualisés des jeux de l'espace Outils (5M Innov)
 *
 * Classes .gm-* consommées par tools/_game.js et les pages de jeu
 * (tools/firewall-rush, tools/bitflip, tools/sprint-fit…).
 * Palette : tokens de CSS/tokens.css (clair à :root, sombre via .dark-mode).
 * ========================================================================== */

.gm-wrap { max-width: 960px; margin: 0 auto; padding: 6.5rem 1.2rem 5rem; }

/* ---- Héros (même famille visuelle que les héros d'outils) ----------------- */
.gm-hero {
  text-align: center;
  padding: 2.6rem 1.5rem;
  border-radius: var(--radius-glass, 22px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(ellipse 75% 120% at 50% -10%, rgba(55, 239, 186, 0.18), transparent 60%),
    linear-gradient(160deg, rgba(24, 29, 40, 0.94), rgba(11, 14, 20, 0.97));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35), 0 0 60px rgba(55, 239, 186, 0.10);
  margin-bottom: 2rem;
  color: #f4fbff;
}
.gm-hero-icon {
  width: 62px; height: 62px; margin: 0 auto 1rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 18px; font-size: 1.7rem; color: #37EFBA;
  background: linear-gradient(140deg, rgba(55, 239, 186, 0.2), rgba(0, 212, 255, 0.12));
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.gm-hero h1 { font-size: 2.2rem; margin-bottom: 0.6rem; }
.gm-hero h1 b {
  background: linear-gradient(110deg, #37EFBA, #00d4ff 50%, #7b5cff 80%, #37EFBA);
  background-size: 250% auto;
  background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  animation: lgTitleFlow 8s linear infinite;
}
.gm-hero p { opacity: 0.92; max-width: 660px; margin: 0 auto; line-height: 1.6; }

/* ---- Panneau générique ---------------------------------------------------- */
.gm-panel {
  background: var(--glass-bg, rgba(20, 24, 33, 0.62));
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.14));
  -webkit-backdrop-filter: blur(var(--glass-blur, 18px));
  backdrop-filter: blur(var(--glass-blur, 18px));
  border-radius: var(--radius-glass, 22px);
  padding: 1.6rem 1.8rem;
  margin-bottom: 1.4rem;
}

/* ---- HUD (score / vies / série…) ------------------------------------------ */
.gm-hud { display: flex; flex-wrap: wrap; gap: 0.7rem; justify-content: center; margin-bottom: 1.2rem; }
.gm-chip {
  display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
  min-width: 86px; padding: 0.5rem 0.9rem; border-radius: 14px;
  background: var(--glass-bg, rgba(20, 24, 33, 0.62));
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.14));
}
.gm-chip .k { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.65; font-weight: 700; }
.gm-chip .v { font-size: 1.25rem; font-weight: 800; color: var(--accent-text, #37EFBA); line-height: 1.2; }
.gm-chip.gm-chip-warn .v { color: var(--warn-text, #ffb020); }
.gm-chip.gm-chip-bad .v { color: var(--bad-text, #ff6a6a); }

/* ---- Scène de jeu + overlays ---------------------------------------------- */
.gm-stage { position: relative; min-height: 340px; }

/* ---- Bouton plein écran (auto-injecté par _game.js sur chaque .gm-stage) --- */
.gm-fs-btn {
  position: absolute; top: 0.7rem; right: 0.7rem; z-index: 40;
  width: 40px; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1rem; color: #d7fff2;
  background: rgba(8, 12, 18, 0.6);
  border: 1px solid rgba(55, 239, 186, 0.35);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.gm-fs-btn:hover { background: rgba(55, 239, 186, 0.16); border-color: rgba(55, 239, 186, 0.7); }
.gm-fs-btn:active { transform: scale(0.94); }

/* ---- Barre supérieure du mode immersif (créée par _game.js) ---------------- */
.gm-imm-bar { display: none; }
body.gm-immersive .gm-imm-bar {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid rgba(55, 239, 186, 0.18);
  background: rgba(9, 12, 18, 0.85);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.gm-imm-brand { display: flex; align-items: center; gap: 0.8rem; min-width: 0; }
.gm-imm-logo { display: inline-flex; align-items: center; flex: 0 0 auto; }
.gm-imm-logo img { height: 26px; width: auto; display: block; }
.gm-imm-sep { width: 1px; height: 22px; background: rgba(255, 255, 255, 0.16); flex: 0 0 auto; }
@media (max-width: 560px) { .gm-imm-logo img { height: 22px; } }
.gm-imm-game { display: inline-flex; align-items: center; gap: 0.5rem; min-width: 0; color: #eafff8; }
.gm-imm-game i { color: #37EFBA; font-size: 1rem; }
.gm-imm-title { font-weight: 800; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gm-imm-close {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: inherit; font-size: 0.9rem; font-weight: 700; cursor: pointer;
  padding: 0.5rem 0.9rem; border-radius: 999px; color: #eafff8;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.gm-imm-close i { font-size: 1.05rem; }
.gm-imm-close:hover { background: rgba(255, 106, 106, 0.16); border-color: rgba(255, 106, 106, 0.6); color: #ff8f8f; }
.gm-imm-close:active { transform: scale(0.96); }
@media (max-width: 560px) { .gm-imm-close span { display: none; } .gm-imm-close { padding: 0.5rem 0.65rem; } }

/* ---- Mode immersif (plein écran) ------------------------------------------ */
body.gm-immersive { overflow: hidden; }
/* Le header/footer sont injectés par layout.js comme <header>/<footer> (les id
   #site-header/#site-footer sont remplacés) → on cible bien les balises. */
body.gm-immersive > header,
body.gm-immersive header,
body.gm-immersive footer,
body.gm-immersive .skip-link,
body.gm-immersive .gm-fs-btn { display: none !important; }
body.gm-immersive .body-content { margin: 0; padding: 0; }
body.gm-immersive .gm-wrap {
  position: fixed; inset: 0; z-index: 100000;
  max-width: none; width: 100%; margin: 0; padding: 0;
  display: flex; flex-direction: column;
  background:
    radial-gradient(ellipse 90% 60% at 50% 0%, rgba(55, 239, 186, 0.10), transparent 60%),
    #06090f;
  overflow: hidden;
}
body.gm-immersive .gm-hero,
body.gm-immersive .gm-help,
body.gm-immersive .gm-back { display: none; }
body.gm-immersive .gm-hud {
  flex: 0 0 auto; margin: 0; padding: 0.9rem 0.8rem 0.6rem; gap: 0.7rem;
}
/* HUD toujours en « surface sombre » en immersif (quel que soit le thème du
   site) : le fond est forcé sombre, donc on impose le traitement verre foncé +
   vert vif — sinon les puces claires du thème light paraissent grises et le
   texte vert foncé illisible. Style raffiné, aligné sur le design system. */
body.gm-immersive .gm-chip {
  min-width: 102px; padding: 0.5rem 1.1rem; border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.015)),
    rgba(16, 21, 29, 0.7);
  border: 1px solid rgba(55, 239, 186, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 6px 18px rgba(0, 0, 0, 0.35);
}
body.gm-immersive .gm-chip .k {
  color: #93a7a1; opacity: 1; font-size: 0.63rem; letter-spacing: 0.09em;
}
body.gm-immersive .gm-chip .v {
  color: #37EFBA; font-size: 1.4rem; font-variant-numeric: tabular-nums;
  text-shadow: 0 0 20px rgba(55, 239, 186, 0.28);
}
body.gm-immersive .gm-chip.gm-chip-warn .v { color: #ffce6b; text-shadow: 0 0 20px rgba(255, 176, 32, 0.28); }
body.gm-immersive .gm-chip.gm-chip-bad .v { color: #ff8a8a; text-shadow: 0 0 20px rgba(255, 106, 106, 0.28); }
body.gm-immersive .gm-stage {
  flex: 1 1 auto; min-height: 0; margin: 0; overflow-y: auto;
  border: 0; border-radius: 0;
  /* La scène se fond dans le fond immersif sombre : pas de panneau « verre »
     clair autour du plateau (seul le canvas, avec son propre fond, ressort). */
  background: transparent;
  -webkit-backdrop-filter: none; backdrop-filter: none;
  display: flex; flex-direction: column; align-items: center;
  /* « safe center » : centre quand il y a la place, sinon aligne en haut sans
     rogner (piège flex classique) — les jeux au contenu haut restent scrollables. */
  justify-content: safe center;
}
.gm-overlay {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center; padding: 1.2rem;
  border-radius: var(--radius-glass, 22px);
  background: rgba(8, 12, 18, 0.72);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: gmFadeIn 0.25s ease-out both;
  /* Si le contenu (fin de partie : titre + stats + boutons) dépasse la hauteur
     de la scène, on défile à l'intérieur plutôt que de laisser déborder. */
  overflow-y: auto;
}
/* margin:auto centre verticalement quand il y a de la place, sans rogner le
   haut quand le contenu est plus grand que l'overlay (piège connu de flex). */
.gm-overlay-box { text-align: center; width: 100%; max-width: 460px; margin: auto; color: #f4fbff; }
.gm-overlay-box .gm-ov-icon { font-size: 2.4rem; color: #37EFBA; margin-bottom: 0.6rem; }
.gm-overlay-box h2 { font-size: 1.5rem; margin: 0 0 0.6rem; color: #fff; }
.gm-overlay-box p { line-height: 1.6; opacity: 0.92; margin: 0 0 0.5rem; }
.gm-ov-stats { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; margin: 0.9rem 0 1.1rem; }
.gm-ov-stats .gm-chip { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.16); }
.gm-ov-stats .gm-chip .v { color: #37EFBA; }
.gm-ov-btns { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; margin-top: 0.4rem; }
.gm-ov-btns .gm-btn { max-width: 100%; }
/* Mobile : les boutons de fin de partie s'empilent en pleine largeur — plus
   aucun risque de débordement horizontal, quelle que soit la longueur du
   libellé ou la police (« Copier mon score »…). */
@media (max-width: 560px) {
  .gm-ov-btns { flex-direction: column; align-items: stretch; width: 100%; max-width: 300px; margin-left: auto; margin-right: auto; }
  .gm-ov-btns .gm-btn { width: 100%; }
}
@keyframes gmFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---- Boutons --------------------------------------------------------------- */
.gm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-family: inherit; font-size: 0.95rem; font-weight: 700; cursor: pointer;
  padding: 0.7rem 1.4rem; border-radius: 999px;
  border: 1px solid rgba(55, 239, 186, 0.45);
  background: transparent; color: inherit;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease, filter 0.2s ease;
}
.gm-btn:hover { background: rgba(55, 239, 186, 0.12); border-color: rgba(55, 239, 186, 0.7); }
.gm-btn:active { transform: scale(0.97); }
.gm-btn.primary {
  background: linear-gradient(135deg, #37EFBA, #00d4aa);
  border-color: transparent; color: #12241d;
}
.gm-btn.primary:hover { filter: brightness(1.07); background: linear-gradient(135deg, #37EFBA, #00d4aa); }
.gm-btn.danger { border-color: rgba(255, 106, 106, 0.55); color: var(--bad-text, #ff6a6a); }
.gm-btn.danger:hover { background: rgba(255, 106, 106, 0.12); border-color: rgba(255, 106, 106, 0.8); }
.gm-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.gm-btn:disabled:hover { background: transparent; }
.gm-btn.primary:disabled:hover { background: linear-gradient(135deg, #37EFBA, #00d4aa); filter: none; }

/* ---- Vies (cœurs) ----------------------------------------------------------- */
.gm-lives { display: inline-flex; gap: 0.25rem; font-size: 1.05rem; }
.gm-lives .on { color: #ff5a7a; }
.gm-lives .off { opacity: 0.25; }

/* ---- Feedback / toast ------------------------------------------------------- */
.gm-feedback {
  display: flex; gap: 0.6rem; align-items: flex-start;
  border-radius: 14px; padding: 0.8rem 1rem; margin-top: 0.9rem;
  font-size: 0.92rem; line-height: 1.55;
  animation: gmFadeIn 0.2s ease-out both;
}
.gm-feedback.good { background: rgba(55, 239, 186, 0.10); border: 1px solid rgba(55, 239, 186, 0.30); }
.gm-feedback.good i { color: var(--accent-text, #37EFBA); margin-top: 0.15rem; }
.gm-feedback.bad { background: rgba(255, 106, 106, 0.10); border: 1px solid rgba(255, 106, 106, 0.30); }
.gm-feedback.bad i { color: var(--bad-text, #ff6a6a); margin-top: 0.15rem; }

.gm-toast {
  position: fixed; left: 50%; bottom: 2rem; transform: translateX(-50%);
  z-index: 10000; padding: 0.7rem 1.3rem; border-radius: 999px;
  background: linear-gradient(135deg, #37EFBA, #00d4aa); color: #12241d;
  font-weight: 700; font-size: 0.92rem; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  animation: gmFadeIn 0.2s ease-out both;
}

/* ---- Barre de temps --------------------------------------------------------- */
.gm-timer { height: 8px; border-radius: 999px; overflow: hidden; background: rgba(127, 127, 127, 0.22); }
.gm-timer > span {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, #37EFBA, #00d4aa);
  transition: width 0.1s linear;
}
.gm-timer.warn > span { background: linear-gradient(90deg, #ffb020, #ff6a6a); }

/* ---- Aide « Comment jouer » -------------------------------------------------- */
.gm-help { margin-top: 1.4rem; }
.gm-help summary {
  cursor: pointer; font-weight: 700; color: var(--accent-text, #37EFBA);
  display: inline-flex; align-items: center; gap: 0.5rem;
}
.gm-help[open] summary { margin-bottom: 0.6rem; }
.gm-help .gm-help-body { line-height: 1.65; font-size: 0.94rem; opacity: 0.92; }
.gm-help .gm-help-body ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.gm-help .gm-help-body li { margin-bottom: 0.35rem; }

/* Annule le style global « section ul li » (carte) sur les listes des jeux */
.body-content section p, .body-content section ul { max-width: none; }
.body-content section ul li { background: none; padding: 0; border-left: 0; }

.gm-back { text-align: center; margin-top: 2.2rem; }
.gm-back a { color: var(--accent-text, #37EFBA); font-weight: 600; text-decoration: none; }
.gm-back a:hover { text-decoration: underline; }

@media (max-width: 600px) {
  /* Le header fixe fait ~108 px de haut en mobile : on réserve assez d'espace
     pour que le héros ne passe pas dessous (avant : 5.5rem = 88 px → chevauchement). */
  .gm-wrap { padding-top: 7rem; }
  .gm-hero h1 { font-size: 1.7rem; }
  .gm-panel { padding: 1.2rem 1.1rem; }
  .gm-chip { min-width: 74px; padding: 0.4rem 0.7rem; }
  .gm-chip .v { font-size: 1.1rem; }
}
