/* LES JEUX D'INTRODUCTION AU WEB
   L'habillage commun à tous les jeux du cours : la barre du haut et son
   menu, la consigne, le pied de page qui valide, les cartes, les boutons et
   le code. Les couleurs sont celles du cours, lues dans theme.css. */

:root {
  --jeu-fond: #f2f3f7;
  --jeu-papier: #ffffff;
  --jeu-trait: var(--brand-rule, #dcc39a);
  --jeu-encre: var(--ink, #2a2118);
  --jeu-discret: var(--muted, #6f6355);
  --jeu-juste: #2e9e5b;
  --jeu-oubli: #e08a00;
  --jeu-rate: #c0392b;
  --jeu-rate-pale: #fbeaea;
  --jeu-largeur: 1200px;
}

* {
  box-sizing: border-box;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--jeu-fond);
  color: var(--jeu-encre);
  font: 15px/1.5 'Open Sans', Arial, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

code {
  font-family: Menlo, Consolas, 'Liberation Mono', monospace;
  font-size: 0.92em;
  color: var(--brand-dark, #8a5510);
}

.jeu-cadre {
  width: 100%;
  max-width: var(--jeu-largeur);
  margin: 0 auto;
  padding: 0 20px;
}

/* LA BARRE DU HAUT */

.jeu-barre {
  position: relative;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 12px 20px;
  background: var(--brand, #c07c1f);
  color: white;
}

.jeu-barre__menu {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  background: transparent;
  color: white;
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
}

.jeu-barre__menu:hover,
.jeu-barre__menu[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.15);
}

.jeu-barre__titre {
  margin: 0;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 24px;
  font-weight: 900;
}

.jeu-niveaux {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-left: auto;
}

.jeu-niveaux__bouton {
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  background: transparent;
  color: white;
  font-size: 12px;
  font-weight: 600;
}

/* Un niveau réussi se fonce : il tranche sur l'ocre de la barre, quand le
   niveau en cours, lui, s'éclaire en blanc. */
.jeu-niveaux__bouton.is-fait {
  border-color: var(--brand-deep, #6f4009);
  background: var(--brand-deep, #6f4009);
}

.jeu-niveaux__bouton[aria-current="true"] {
  border-color: white;
  background: white;
  color: var(--brand-deep, #6f4009);
}

@media (max-width: 800px) {
  .jeu-niveaux {
    margin-left: 0;
  }
}

/* LE MENU
   Tous les jeux du cours, et l'avancée de chacun sur ses vingt niveaux. */

.jeu-menu {
  position: absolute;
  z-index: 30;
  top: 58px;
  left: 12px;
  width: min(340px, calc(100vw - 24px));
  padding: 8px;
  border: 1px solid var(--jeu-trait);
  border-radius: 10px;
  background: var(--jeu-papier);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.jeu-menu[hidden] {
  display: none;
}

.jeu-menu__liste {
  margin: 0;
  padding: 0;
  list-style: none;
}

.jeu-menu__groupe {
  padding: 10px 12px 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand-dark, #8a5510);
}

.jeu-menu__groupe:not(:first-child) {
  margin-top: 6px;
  border-top: 1px solid var(--jeu-trait);
}

.jeu-menu__lien {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--jeu-encre);
  text-decoration: none;
}

.jeu-menu__lien:hover,
.jeu-menu__lien:focus-visible {
  background: var(--brand-tint, #fdf8f0);
}

.jeu-menu__lien[aria-current="page"] {
  background: var(--brand-pale, #fbeedb);
}

.jeu-menu__nom {
  font-weight: 700;
}

.jeu-menu__avancee {
  font-size: 13px;
  color: var(--jeu-discret);
}

.jeu-menu__jauge {
  grid-column: 1 / -1;
  height: 4px;
  border-radius: 2px;
  background: var(--jeu-fond);
  overflow: hidden;
}

.jeu-menu__jauge span {
  display: block;
  height: 100%;
  background: var(--accent, #0f8b8d);
}

.jeu-menu__lien--retour {
  display: block;
  margin-top: 6px;
  border-top: 1px solid var(--jeu-trait);
  border-radius: 0 0 6px 6px;
  font-weight: 600;
  color: var(--brand-dark, #8a5510);
}

/* LA CONSIGNE
   Sans boîte, sur toute la largeur, collée à la barre. Trois places
   réservées : le niveau, la consigne, l'explication. L'explication garde sa
   hauteur même vide, pour que le jeu ne saute pas d'un niveau à l'autre. */

.jeu-consigne {
  padding: 16px 0 14px;
  border-bottom: 1px solid var(--jeu-trait);
  background: var(--jeu-papier);
}

.jeu-consigne__niveau {
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand-dark, #8a5510);
}

.jeu-consigne__but {
  margin: 0 0 4px;
  font-size: 21px;
  font-weight: 800;
}

.jeu-consigne__explication {
  min-height: 3em;
  margin: 0;
  font-size: 16px;
}

/* LA ZONE DE JEU */

.jeu-zone {
  flex: 1;
  width: 100%;
  max-width: var(--jeu-largeur);
  margin: 0 auto;
  padding: 16px 20px 24px;
}

.carte {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--jeu-trait);
  border-radius: 8px;
  background: var(--jeu-papier);
}

.carte__titre {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand-dark, #8a5510);
}

.carte__aide {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--jeu-discret);
}

/* LE CODE
   Comme dans les leçons : un fond crème et un filet de la marque. */

.code {
  margin: 0;
  padding: 12px 0;
  border-left: 4px solid var(--brand, #c07c1f);
  border-radius: 0 6px 6px 0;
  background: var(--brand-tint, #fdf8f0);
  color: var(--jeu-encre);
  font: 16px/2 Menlo, Consolas, 'Liberation Mono', monospace;
  overflow-x: auto;
}

.tk-balise { color: #a0522d; }
.tk-attribut { color: #2a7f62; }
.tk-valeur { color: var(--brand-dark, #8a5510); }
.tk-selecteur { color: #a0522d; }
.tk-propriete { color: #2a7f62; }

/* LES BOUTONS */

.bouton {
  padding: 8px 18px;
  border: 1px solid var(--jeu-trait);
  border-radius: 6px;
  background: var(--jeu-papier);
  color: var(--jeu-encre);
  font-size: 15px;
  font-weight: 600;
}

.bouton:hover:not(:disabled),
.bouton:focus-visible {
  border-color: var(--brand, #c07c1f);
}

.bouton:disabled {
  cursor: default;
  opacity: 0.45;
}

.bouton--plein {
  border-color: var(--accent, #0f8b8d);
  background: var(--accent, #0f8b8d);
  color: white;
}

.bouton--plein:hover:not(:disabled) {
  background: var(--accent-dark, #0b6d6f);
}

/* Un choix à faire avant de valider : il reste enfoncé. */
.choix {
  padding: 10px 20px;
  border: 2px solid var(--brand, #c07c1f);
  border-radius: 8px;
  background: var(--jeu-papier);
  color: var(--jeu-encre);
  font-size: 16px;
  font-weight: 700;
}

.choix:hover:not(:disabled),
.choix:focus-visible {
  background: var(--brand-tint, #fdf8f0);
}

.choix[aria-pressed="true"] {
  border-color: var(--brand-deep, #6f4009);
  background: var(--brand-pale, #fbeedb);
  box-shadow: inset 0 0 0 1px var(--brand-deep, #6f4009);
}

.choix:disabled {
  cursor: default;
  opacity: 0.45;
}

.choix.is-juste {
  border-color: var(--accent, #0f8b8d);
  background: var(--accent-pale, #e6f3f3);
  box-shadow: inset 0 0 0 1px var(--accent, #0f8b8d);
  opacity: 1;
}

.choix.is-faux {
  border-color: var(--jeu-rate);
  background: var(--jeu-rate-pale);
  box-shadow: inset 0 0 0 1px var(--jeu-rate);
  opacity: 1;
}

/* LE PIED DE PAGE
   Toujours visible en bas de l'écran : le résultat à gauche, l'action à
   droite. On valide, puis on passe à la suite, toujours au même endroit. */

.jeu-pied {
  position: sticky;
  z-index: 10;
  bottom: 0;
  border-top: 1px solid var(--jeu-trait);
  background: var(--jeu-papier);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.06);
}

.jeu-pied__cadre {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  min-height: 68px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.jeu-pied__choix {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 8px;
}

.jeu-pied__choix[hidden],
.jeu-pied__resultat[hidden] {
  display: none;
}

.jeu-pied__choix .choix {
  padding: 8px 16px;
}

.jeu-pied__resultat {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.jeu-pied__resultat.is-reussi {
  color: var(--accent-dark, #0b6d6f);
}

.jeu-pied__resultat.is-rate {
  color: var(--jeu-rate);
}

.jeu-pied__score {
  display: block;
  font-size: 14px;
  font-weight: 400;
  color: var(--jeu-encre);
}

.jeu-pied__secondaires {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.jeu-pied__secondaires:empty,
.jeu-pied__secondaires[hidden] {
  display: none;
}

.jeu-pied__secondaires .bouton {
  padding: 10px 18px;
  font-size: 16px;
}

.jeu-pied__action {
  flex: none;
  min-width: 140px;
  margin-left: auto;
  padding: 10px 22px;
  font-size: 16px;
  font-weight: 700;
}

/* Avec un bouton de plus à sa gauche, c'est ce dernier qui se cale à
   droite. */
.jeu-pied__secondaires:not(:empty):not([hidden]) + .jeu-pied__action {
  margin-left: 0;
}
