/* Cadre d'application : barre du haut et menu fixes, seule la zone de contenu change
   (spécification 19.1). Au-dessous de 1024 px, le menu devient un tiroir. */

.cadre {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--largeur-menu) minmax(0, 1fr);
  grid-template-rows: var(--hauteur-barre) minmax(0, 1fr);
  grid-template-areas: "barre barre" "menu contenu";
}

/* ---------- Barre de chargement : n'apparaît qu'après 1 s d'attente ---------- */
.barre-chargement {
  position: fixed; left: 0; right: 0; top: 0; z-index: 80;
  height: var(--trait-fort); background: var(--marque);
  transform-origin: left center; transform: scaleX(0); opacity: 0;
  pointer-events: none;
}
.barre-chargement[data-etat="cours"] { opacity: 1; transform: scaleX(0.85); transition: transform 1800ms cubic-bezier(0.1, 0.6, 0.3, 1); }
.barre-chargement[data-etat="fin"] { opacity: 0; transform: scaleX(1); transition: transform 200ms ease-out, opacity 300ms ease-out 200ms; }

/* ---------- Barre du haut ---------- */
.barre-haut {
  grid-area: barre;
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: var(--e-4);
  padding: 0 var(--e-5) 0 var(--e-4);
  background: var(--fond);
  border-bottom: var(--trait) solid var(--bordure);
}
.barre-haut__menu { display: none; }
.marque-app { display: flex; align-items: center; gap: var(--e-3); min-width: 0; text-decoration: none; color: inherit; flex: 0 0 auto; }
.marque-app:hover { color: inherit; }
.marque-app__motif { width: 22px; height: 28px; background: var(--marque); transform: skewX(-12deg); flex: 0 0 auto; }
.marque-app__textes { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.marque-app__nom { font-family: var(--police-titre); font-weight: 700; font-size: var(--t-l); white-space: nowrap; }
.marque-app__organisation { font-size: var(--t-xs); color: var(--texte-discret); white-space: nowrap; }

.recherche-rapide {
  flex: 1 1 360px; max-width: 520px; margin-left: var(--e-6);
  display: flex; align-items: center; gap: var(--e-2);
  min-height: 40px; padding: 0 var(--e-2) 0 var(--e-3);
  border: var(--trait) solid var(--bordure-controle);
  background: var(--fond); color: var(--texte-discret);
  text-align: left; cursor: pointer;
  transition: border-color var(--duree-survol) ease-out;
}
.recherche-rapide:hover { border-color: var(--texte); }
.recherche-rapide__texte { flex: 1; font-size: var(--t-m); }

.barre-haut__actions { display: flex; align-items: center; gap: var(--e-1); margin-left: auto; }
.compte-bouton { display: flex; align-items: center; gap: var(--e-3); min-height: var(--cible-tactile); padding: 0 var(--e-2); border: 0; background: transparent; cursor: pointer; text-align: left; }
.compte-bouton:hover { background: var(--fond-survol); }
.compte-bouton__textes { display: flex; flex-direction: column; line-height: 1.2; }
.compte-bouton__nom { font-weight: 700; font-size: var(--t-m); }
.compte-bouton__profil { font-size: var(--t-xs); color: var(--texte-discret); }

/* ---------- Menu latéral ---------- */
.menu-lateral {
  grid-area: menu;
  position: sticky; top: var(--hauteur-barre);
  height: calc(100vh - var(--hauteur-barre));
  overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--e-6);
  padding: var(--e-5) var(--e-3) var(--e-6);
  background: var(--fond-retrait);
  border-right: var(--trait) solid var(--bordure);
}
.menu-lateral__section { display: flex; flex-direction: column; gap: 2px; }
.menu-lateral__titre { padding: 0 var(--e-3) var(--e-2); font-size: var(--t-xs); font-weight: 700; color: var(--texte-discret); text-transform: uppercase; letter-spacing: 0.06em; }
.lien-menu {
  display: flex; align-items: center; gap: var(--e-3);
  min-height: var(--cible-tactile); padding: 0 var(--e-3);
  color: var(--texte); text-decoration: none;
  transition: background-color var(--duree-survol) ease-out;
}
.lien-menu:hover { background: var(--fond-survol); color: var(--texte); }
.lien-menu[aria-current="page"] { background: var(--fond); font-weight: 700; box-shadow: inset var(--trait-fort) 0 0 var(--marque); }
.lien-menu__libelle { flex: 1; min-width: 0; }
.lien-menu--a-venir { color: var(--texte-discret); cursor: default; }
.lien-menu--a-venir:hover { background: transparent; color: var(--texte-discret); }
.lien-menu__badge { font-size: var(--t-xs); color: var(--texte-discret); border: var(--trait) solid var(--bordure-controle); padding: 0 var(--e-1); line-height: 1.5; }
.menu-lateral__bas { margin-top: auto; font-size: var(--t-xs); color: var(--texte-discret); padding: 0 var(--e-3); }

/* ---------- Zone de contenu ---------- */
.contenu { grid-area: contenu; min-width: 0; display: flex; flex-direction: column; }
.contenu__interieur { flex: 1; width: 100%; max-width: var(--largeur-contenu); padding: var(--e-6) var(--e-7) var(--e-10); display: flex; flex-direction: column; gap: var(--e-6); }
.contenu[aria-busy="true"] .contenu__interieur { opacity: 0.6; transition: opacity var(--duree-entree) ease-out 300ms; }

.ariane ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--e-1); font-size: var(--t-s); color: var(--texte-discret); }
.ariane li { display: inline-flex; align-items: center; gap: var(--e-1); }
.ariane a { color: inherit; }
.ariane [aria-current="page"] { color: var(--texte); }

.entete-page {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--e-4);
  padding-bottom: var(--e-5); border-bottom: var(--trait) solid var(--bordure-controle);
}
.entete-page__titres { display: flex; align-items: center; gap: var(--e-5); min-width: 0; }
.motif-marque { width: 36px; height: 46px; background: var(--marque); transform: skewX(-12deg); flex: 0 0 auto; }
.entete-page__sous-titre { margin-top: var(--e-1); color: var(--texte-discret); }
.entete-page__actions { display: flex; flex-wrap: wrap; gap: var(--e-3); }
.entete-page h1:focus { outline: none; }

/* ---------- Pied de page : bandeau rouge de la charte ---------- */
.pied {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--e-2) var(--e-6);
  min-height: 40px; padding: 0 var(--e-7);
  background: var(--marque); color: var(--sur-marque);
  font-size: var(--t-m);
}
.pied__droite { margin-left: auto; }

/* ---------- Palette de commandes ---------- */
.palette__saisie { display: flex; align-items: center; gap: var(--e-3); padding: 0 var(--e-4); border-bottom: var(--trait) solid var(--bordure); }
.palette__saisie input { flex: 1; min-height: 56px; border: 0; background: transparent; font-size: var(--t-l); }
.palette__saisie input:focus-visible { outline: none; }
.palette__liste { list-style: none; margin: 0; padding: var(--e-2) 0; max-height: min(60vh, 420px); overflow-y: auto; }
.palette__groupe { padding: var(--e-2) var(--e-4) var(--e-1); font-size: var(--t-xs); font-weight: 700; color: var(--texte-discret); text-transform: uppercase; letter-spacing: 0.06em; }
.palette__liste--groupe { padding: 0; max-height: none; overflow: visible; }
.palette__element > a, .palette__element > button {
  display: flex; align-items: center; gap: var(--e-3); width: 100%;
  min-height: var(--cible-tactile); padding: 0 var(--e-4);
  border: 0; background: transparent; color: var(--texte); text-align: left; text-decoration: none; cursor: pointer;
}
.palette__element[aria-selected="true"] { background: var(--fond-survol); box-shadow: inset var(--trait-fort) 0 0 var(--marque); }
.palette__element > a:hover, .palette__element > button:hover { color: var(--texte); background: var(--fond-survol); }
.palette__aide { display: flex; flex-wrap: wrap; gap: var(--e-4); padding: var(--e-3) var(--e-4); border-top: var(--trait) solid var(--bordure); font-size: var(--t-xs); color: var(--texte-discret); }
.palette__vide { padding: var(--e-5) var(--e-4); color: var(--texte-discret); }

/* ---------- Pages d'authentification et d'erreur ---------- */
.page-seule { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.page-seule__marque {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; gap: var(--e-7);
  padding: var(--e-9) var(--e-8);
  background: var(--panneau-marque); color: var(--sur-panneau-marque);
}
.page-seule__marque::after {
  content: ""; position: absolute; right: -6%; bottom: -6%;
  width: 26%; height: 34%; background: var(--marque); transform: skewX(-12deg);
}
.page-seule__accroche { position: relative; z-index: 1; font-family: var(--police-titre); font-size: var(--t-5xl); font-weight: 700; line-height: 1.1; max-width: 14ch; }
.page-seule__texte { position: relative; z-index: 1; max-width: 38ch; margin-top: var(--e-4); color: var(--sur-panneau-marque); }
.page-seule__formulaire { display: flex; align-items: center; justify-content: center; padding: var(--e-9) var(--e-6); }
.page-seule__carte { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: var(--e-6); }
.page-seule__carte form { display: flex; flex-direction: column; }
.page-seule__carte .bouton { margin-top: var(--e-6); }

.page-erreur { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--e-7); }
.page-erreur__carte { max-width: 560px; display: flex; flex-direction: column; gap: var(--e-4); align-items: flex-start; }
.page-erreur__code { font-family: var(--police-titre); font-size: 64px; font-weight: 700; line-height: 1; color: var(--marque); }

/* ---------- Écrans étroits ---------- */
@media (max-width: 1023px) {
  .cadre { grid-template-columns: minmax(0, 1fr); grid-template-areas: "barre" "contenu"; }
  .barre-haut__menu { display: inline-flex; }
  .recherche-rapide { margin-left: 0; }
  .menu-lateral {
    position: fixed; z-index: 50; top: 0; left: 0; bottom: 0;
    height: auto; width: min(86vw, var(--largeur-menu));
    transform: translateX(-100%);
    transition: transform var(--duree-panneau) var(--courbe), visibility 0s linear var(--duree-panneau);
    visibility: hidden;
    box-shadow: var(--ombre-flottant);
  }
  .cadre[data-menu="ouvert"] .menu-lateral { transform: none; visibility: visible; transition: transform var(--duree-panneau) var(--courbe); }
  .voile { position: fixed; inset: 0; z-index: 45; background: rgba(22, 20, 21, 0.45); }
  .contenu__interieur { padding: var(--e-5) var(--e-5) var(--e-9); }
  .pied { padding: 0 var(--e-5); }
}
@media (max-width: 760px) {
  .marque-app__organisation, .compte-bouton__textes, .recherche-rapide__texte, .recherche-rapide .touche { display: none; }
  .recherche-rapide { flex: 0 0 var(--cible-tactile); min-height: var(--cible-tactile); justify-content: center; padding: 0; border-color: transparent; }
  .barre-haut { gap: var(--e-2); padding: 0 var(--e-2); }
  .marque-app__nom { font-size: var(--t-m); white-space: normal; line-height: 1.15; }
  .marque-app__motif { width: 16px; height: 22px; }
  .barre-haut__aide, .compte-bouton__chevron { display: none; }
  .marque-app { flex: 1 1 auto; }
  .barre-haut .bouton, .recherche-rapide, .compte-bouton { flex-shrink: 0; }
  .barre-haut__actions { gap: 0; }
  .compte-bouton { padding: 0 var(--e-1); }
  .page-seule { grid-template-columns: minmax(0, 1fr); }
  .page-seule__marque { padding: var(--e-6) var(--e-5); min-height: 0; }
  .page-seule__marque::after { width: 64px; height: 84px; right: -16px; bottom: -16px; }
  .page-seule__accroche { font-size: var(--t-4xl); }
  .page-seule__formulaire { padding: var(--e-6) var(--e-5) var(--e-9); align-items: flex-start; }
  h1 { font-size: var(--t-3xl); }
  .motif-marque { width: 24px; height: 32px; }
}
@media (min-width: 1024px) { .voile { display: none; } }
@media (max-width: 420px) { .marque-app__nom { font-size: var(--t-s); } }
