/* =========================================================================
   Académie — format appli : barre d'onglets du bas, mise à jour, installation, réglages
   ========================================================================= */

/* ---------- Barre d'onglets du bas ----------
   Mobile (≤ 760 px) et appli installée. Sur ordinateur, dans le navigateur : pas de barre.
   --barre-bas-h réserve la place en bas de page ; --bas-libre sert aux éléments flottants. */
.barre-bas { display: none; }
@media (max-width: 760px) {
  :root { --barre-bas-h: calc(54px + env(safe-area-inset-bottom, 0px)); --bas-libre: var(--barre-bas-h); }
  .barre-bas { display: block; }
  .pied { padding-bottom: 40px; }
}
html.appli { --barre-bas-h: calc(54px + env(safe-area-inset-bottom, 0px)); --bas-libre: var(--barre-bas-h); }
html.appli .barre-bas { display: block; }
html.appli .pied { padding-bottom: 40px; }
/* les héros plein écran gardent leur bas au-dessus de la barre */
.scene--accueil, .scene--domaine, .scene--parcours { padding-bottom: calc(9vh + 28px + var(--barre-bas-h)); }

.barre-bas {
  position: fixed;
  z-index: 60;
  left: 0; right: 0; bottom: 0;
  padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  background: var(--verre);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 -1px 0 var(--filet);
  view-transition-name: barre-bas;
}
.barre-bas-in {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  height: 54px;
  max-width: 560px;
  margin: 0 auto;
}
.barre-onglet {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding-top: 2px;
  color: var(--texte-2);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .01em;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  transition: color .2s;
}
.barre-icone {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .25s var(--courbe);
}
.barre-onglet:hover { color: var(--texte); }
.barre-onglet:active .barre-icone { transform: scale(.9); }
.barre-onglet[aria-current="page"] { color: var(--accent-texte); }
.barre-onglet[aria-current="page"] .barre-icone { stroke-width: 1.8; }
.barre-onglet[aria-disabled="true"] { opacity: .4; pointer-events: none; }
.barre-onglet:focus-visible { outline-offset: -4px; border-radius: 12px; }

/* Appli installée sur un grand écran (Mac, tablette) : capsule flottante centrée */
@media (min-width: 761px) {
  html.appli { --barre-bas-h: calc(80px + env(safe-area-inset-bottom, 0px)); }
  html.appli .barre-bas {
    left: 50%;
    right: auto;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    padding: 0;
    transform: translateX(-50%);
    border-radius: 999px;
    background: var(--verre-fort);
    box-shadow: var(--ombre-flottant), inset 0 0 0 1px var(--filet);
  }
  html.appli .barre-bas-in { display: flex; align-items: center; gap: 2px; height: 52px; padding: 0 6px; }
  html.appli .barre-onglet {
    flex-direction: row;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border-radius: 999px;
    font-size: 13.5px;
    transition: color .2s, background-color .2s;
  }
  html.appli .barre-onglet[aria-current="page"] { background: var(--surface); }
  html.appli .barre-icone { width: 20px; height: 20px; }
}

/* la barre ne bouge pas pendant les transitions de page */
::view-transition-group(barre-bas) { animation: none; }
::view-transition-old(barre-bas) { animation: none; opacity: 0; }
::view-transition-new(barre-bas) { animation: none; opacity: 1; }

/* ---------- Toast « Nouvelle version disponible » ---------- */
.toast--maj { z-index: 94; padding: 8px 8px 8px 20px; }
.toast-texte { flex: 1 1 auto; }
.toast-boutons { display: flex; align-items: center; gap: 4px; flex: none; }
.toast-action {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--texte);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: opacity .2s;
}
.toast-action:hover { opacity: .88; }
.toast-action[disabled] { opacity: .6; cursor: default; }
.toast-plus-tard {
  padding: 8px 10px;
  border-radius: 999px;
  color: rgba(var(--bg-rgb), .72);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.toast-plus-tard:hover { color: var(--bg); }
@media (max-width: 520px) {
  .toast--maj .toast-boutons { justify-content: center; }
}

/* ---------- Feuilles : installation, confirmation ---------- */
.install-titre, .confirmer-titre {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-bottom: 8px;
}
.install .gris { font-size: 16px; line-height: 1.5; }
.install-etapes { margin-top: 18px; }
.install-etapes li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--filet);
  font-size: 16px;
  line-height: 1.45;
}
.install-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 600;
}
.confirmer-texte p { font-size: 16px; line-height: 1.5; color: var(--texte-2); }
.confirmer-texte p + p { margin-top: 10px; }
.confirmer-actions { display: flex; gap: 10px; margin-top: 24px; }
.confirmer-actions .bouton { flex: 1 1 0; }

/* ---------- Réglages ---------- */
.reglages { max-width: calc(760px + 2 * var(--gouttiere)); }
.reglages-tete { padding: clamp(56px, 9vw, 110px) 0 clamp(28px, 4vw, 44px); }
.reglages-tete .surtitre { margin-bottom: 14px; }
.reglages-tete .chapeau { margin-top: 18px; max-width: 560px; }
.reglages-groupe + .reglages-groupe { margin-top: 36px; }
.reglages-titre { margin: 0 0 10px 4px; }
.reglages-carte { border-radius: 22px; background: var(--surface); overflow: hidden; }
.reglages-carte > * + * { border-top: 1px solid var(--filet); }
.reglages-note { margin: 10px 4px 0; font-size: 13px; line-height: 1.45; color: var(--texte-2); }
/* dans une carte grise, les boutons doux passent d'un cran au-dessus */
.reglages-carte .bouton-doux { background: var(--surface-2); }
.reglages-carte .bouton-doux:hover { background: rgba(var(--texte-rgb), .12); }
.reglage {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px 24px;
  padding: 18px 22px;
}
.reglage-textes { flex: 1 1 auto; min-width: 0; }
.reglage-lib { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.3; }
.reglage-desc { margin-top: 4px; font-size: 14.5px; line-height: 1.45; color: var(--texte-2); }
.reglage-desc--erreur, .reglage-erreur { color: var(--ko); }
.reglage-erreur { padding: 12px 22px 16px; font-size: 14.5px; line-height: 1.45; }
.reglage-controle { flex: none; display: flex; align-items: center; gap: 8px; }
.reglage--large { flex-wrap: wrap; }
.reglage--large .reglage-textes { flex: 1 1 240px; }
.reglage--large .reglage-controle { flex: 0 1 420px; justify-content: flex-end; }
.reglage--code { flex-direction: column; align-items: flex-start; }
.code-sync { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.code-sync-valeur {
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--filet-2);
  font-size: clamp(16px, 2.2vw, 20px);
  font-weight: 600;
  letter-spacing: .04em;
  white-space: nowrap;
  -webkit-user-select: all;
  user-select: all;
}
.reglage--neuf .code-sync-valeur { box-shadow: inset 0 0 0 1.5px var(--accent); }
.champ {
  height: 44px;
  min-width: 0;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--filet-2);
  font-size: 16px; /* 16 px : pas de zoom automatique sur iPhone */
  -webkit-appearance: none;
  appearance: none;
  transition: box-shadow .2s;
}
.champ:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.champ--code { flex: 1 1 auto; font-family: var(--mono); letter-spacing: .03em; text-transform: uppercase; }
.champ--code::placeholder { color: var(--texte-3); }
.champ-ligne { display: flex; gap: 8px; width: 100%; }
.champ-ligne .bouton { flex: none; min-height: 44px; }
@media (max-width: 560px) {
  .reglage { flex-direction: column; align-items: stretch; gap: 12px; padding: 16px 18px; }
  .reglage .reglage-textes, .reglage--large .reglage-textes { flex: none; }
  .reglage-controle { justify-content: flex-start; flex-wrap: wrap; }
  .reglage--large .reglage-controle { flex: 1 1 auto; }
  .reglage--large .segmente { width: 100%; }
  .champ-ligne { width: 100%; }
  .reglage-erreur { padding: 10px 18px 14px; }
}
