/* ==========================================================================
   AMSELYA — STYLES DE BASE
   --------------------------------------------------------------------------
   Chargé par functions.php (amselya_styles), sous le nom « amselya ».
   pages.css, app.css et academy.css en dépendent et se chargent après lui.

   Le style.css de la racine du thème ne contient que l'en-tête exigé par
   WordPress : ne pas y remettre de styles.

   SYSTÈME DE DESIGN
   Palette tirée du drapeau amazigh : bleu, vert, jaune, rouge du yaz.

   LA RÈGLE QUI ÉVITE LE SITE CRIARD : chaque couleur a UN rôle, et jamais
   plus de deux couleurs vives ne cohabitent dans un même composant.

     bleu   → action, navigation, liens        (la couleur de travail)
     vert   → succès, confirmation, quota sain
     jaune  → attention, mise en avant          (jamais en texte sur blanc)
     rouge  → la marque (yaz) et les erreurs    (la plus rare)

   Contrastes vérifiés (accessibilité) : texte blanc sur --vert = 5,2:1.
   Ne pas éclaircir --vert sous ce seuil.

   Le drapeau entier n'apparaît qu'en filet de 3 px en haut de page.
   ========================================================================== */
   
:root {
  /* --- Couleurs du drapeau --- */
  --bleu:        #1B7FC4;
  --bleu-fonce:  #145E92;
  --bleu-clair:  #E8F2FA;
  --vert:        #0C7D46;
  --vert-fonce:  #0A6B3C;
  --vert-clair:  #E6F4EC;
  --jaune:       #F2B705;
  --jaune-fonce: #A87C00;   /* seule variante lisible en texte sur blanc */
  --jaune-clair: #FDF6E3;
  --rouge:       #D4342A;
  --rouge-fonce: #9E2119;
  --rouge-clair: #FCEDEC;

  /* --- Neutres. Jamais de noir pur : un bleu-noir est plus doux à l'œil. */
  --encre:    #12212E;
  --ardoise:  #5B6875;
  --brume:    #E4E7EA;
  --papier:   #FBFAF8;
  --blanc:    #FFFFFF;

  /* --- Rôles --- */
  --action:        var(--bleu);
  --action-survol: var(--bleu-fonce);
  --succes:        var(--vert);
  --attention:     var(--jaune);
  --erreur:        var(--rouge);

  /* --- Typographie ---
     Pile système retenue pour une raison concrète : elle rend correctement
     ɣ ɛ ḥ ḍ ṛ ṣ ṭ ẓ č ǧ. Beaucoup de polices web échouent sur les points
     souscrits. Aucune police externe : performance, et CSP stricte possible. */
  --texte: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
           "Noto Sans", "Helvetica Neue", Arial, sans-serif;

  /* Échelle en quarte juste (1.333) */
  --t-xs:  0.75rem;
  --t-s:   0.875rem;
  --t-m:   1rem;
  --t-l:   1.333rem;
  --t-xl:  1.777rem;
  --t-2xl: 2.369rem;
  --t-3xl: 3.157rem;

  /* Rythme vertical de 8 px */
  --e-1: 0.5rem;
  --e-2: 1rem;
  --e-3: 1.5rem;
  --e-4: 2rem;
  --e-6: 3rem;
  --e-8: 4rem;

  --rayon:      8px;
  --rayon-l:    14px;
  --rayon-rond: 100px;

  /* Ombres très basses : le site est mat, pas en relief. */
  --ombre:   0 1px 2px rgba(18,33,46,.06), 0 2px 8px rgba(18,33,46,.04);
  --ombre-l: 0 2px 4px rgba(18,33,46,.06), 0 8px 24px rgba(18,33,46,.08);

  --colonne:       42rem;
  --colonne-app:   46rem;
  --colonne-large: 64rem;

  --transition: 140ms ease;
}

/* ==========================================================================
   BASE
   ========================================================================== */

body.amselya-app,
body.amselya-auth,
body.amselya-page {
  background: var(--papier);
  color: var(--encre);
  font-family: var(--texte);
  font-size: var(--t-m);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
}

body.amselya-app a,
body.amselya-auth a,
body.amselya-page a {
  color: var(--action);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
body.amselya-app a:hover,
body.amselya-auth a:hover,
body.amselya-page a:hover { color: var(--action-survol); }

.sm-wrap {
  max-width: var(--colonne-app);
  margin: 0 auto;
  padding: var(--e-4) 1.25rem var(--e-8);
}
.sm-wrap--etroit { max-width: 25rem; }
.sm-wrap--large  { max-width: var(--colonne-large); }

/* Focus toujours visible, jamais retiré : c'est le seul repère d'une
   personne qui navigue au clavier. Contour rouge yaz — la couleur la plus
   rare du site, donc la plus lisible comme signal. */
:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--rouge);
  outline-offset: 2px;
  border-radius: 4px;
}

.sm-saut-contenu {
  position: absolute; left: -9999px;
  background: var(--encre); color: #fff;
  padding: .7rem 1.2rem; border-radius: 0 0 var(--rayon) 0; z-index: 999;
}
.sm-saut-contenu:focus { left: 0; top: 0; }

.sm-visuellement-cache {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* Taille de base des icônes.
   Sans cette règle, un SVG placé dans un conteneur flex n'a aucune largeur
   intrinsèque et occupe tout l'espace disponible : l'icône devient énorme.
   `flex:none` empêche en plus qu'elle soit étirée par le conteneur. */
.sm-icone {
  width: 1.15em; height: 1.15em;
  flex: none; display: block;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   ENTÊTE ET PIED
   ========================================================================== */

/* Le drapeau, en filet. Seul endroit du site où les bandes cohabitent. */
.sm-filet-drapeau {
  height: 3px;
  background: linear-gradient(90deg,
    var(--bleu) 0 33.33%, var(--vert) 33.33% 66.66%, var(--jaune) 66.66% 100%);
}

.sm-entete {
  background: var(--blanc);
  border-bottom: 1px solid var(--brume);
  position: sticky; top: 0; z-index: 50;
}
.sm-entete__inner {
  max-width: var(--colonne-large); margin: 0 auto;
  padding: .7rem 1.25rem;
  display: flex; align-items: center; gap: var(--e-3); position: relative;
}
.sm-logo {
  display: flex; align-items: center; gap: .55rem;
  font-weight: 700; font-size: var(--t-l); letter-spacing: -.02em;
  color: var(--encre) !important; text-decoration: none;
}
.sm-logo svg { width: 26px; height: 26px; flex: 0 0 auto; }

.sm-nav { display: flex; gap: .2rem; margin-left: auto; align-items: center; }
.sm-nav a {
  padding: .5rem .8rem; border-radius: var(--rayon);
  font-size: var(--t-s); font-weight: 500;
  color: var(--ardoise) !important; text-decoration: none;
  transition: var(--transition);
}
.sm-nav a:hover { background: var(--bleu-clair); color: var(--bleu-fonce) !important; }
.sm-nav a[aria-current] { color: var(--encre) !important; font-weight: 600; }
.sm-nav .sm-bouton { margin-left: .4rem; }

.sm-burger {
  display: none; margin-left: auto; background: none;
  border: 1px solid var(--brume); border-radius: var(--rayon);
  padding: .45rem .6rem; cursor: pointer; line-height: 1;
}

.sm-pied-page {
  background: var(--encre); color: #B9C3CD;
  margin-top: var(--e-8); padding: var(--e-6) 1.25rem var(--e-4);
  font-size: var(--t-s);
}
.sm-pied-page__inner {
  max-width: var(--colonne-large); margin: 0 auto;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: var(--e-4);
}
.sm-pied-page h3 {
  color: var(--blanc); font-size: var(--t-s); margin: 0 0 .6rem; font-weight: 600;
}
.sm-pied-page ul { list-style: none; padding: 0; margin: 0; }
.sm-pied-page li { margin: 0 0 .35rem; }
.sm-pied-page a { color: #B9C3CD !important; text-decoration: none; }
.sm-pied-page a:hover { color: var(--blanc) !important; text-decoration: underline; }
.sm-pied-page__bas {
  max-width: var(--colonne-large); margin: var(--e-4) auto 0;
  padding-top: var(--e-2); border-top: 1px solid rgba(255,255,255,.12);
  display: flex; flex-wrap: wrap; gap: var(--e-2);
  justify-content: space-between; color: #8A97A4; font-size: var(--t-xs);
}

/* ==========================================================================
   TYPOGRAPHIE
   ========================================================================== */

.sm-titre {
  font-size: var(--t-xl); line-height: 1.18; font-weight: 700;
  letter-spacing: -.02em; margin: 0 0 .4rem;
}
.sm-intro { color: var(--ardoise); margin: 0 0 var(--e-4); max-width: 46ch; }
.sm-label {
  display: block; font-size: var(--t-s); font-weight: 600;
  color: var(--ardoise); margin: 0 0 .5rem;
}
.sm-faible { color: var(--ardoise); font-weight: 400; }
.sm-note   { font-size: var(--t-s); color: var(--ardoise); margin: .6rem 0 0; }
.sm-aide   { font-size: var(--t-xs); color: var(--ardoise); margin: .35rem 0 0; }
.sm-bloc   { margin: 0 0 var(--e-4); }

/* Titre de section avec un court trait de couleur : le rappel discret du
   drapeau, sans bandeau coloré. */
.sm-section__titre {
  font-size: var(--t-xl); font-weight: 700; letter-spacing: -.02em;
  margin: var(--e-6) 0 .5rem; padding-top: .8rem; position: relative;
}
.sm-section__titre::before {
  content: ""; position: absolute; top: 0; left: 0;
  width: 2.4rem; height: 3px; border-radius: 2px; background: var(--bleu);
}
.sm-section__titre--vert::before  { background: var(--vert); }
.sm-section__titre--jaune::before { background: var(--jaune); }
.sm-section__titre--rouge::before { background: var(--rouge); }
.sm-section__intro { color: var(--ardoise); margin: 0 0 var(--e-3); max-width: 52ch; }

/* ==========================================================================
   BOUTONS
   ========================================================================== */

.sm-bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .68rem 1.15rem;
  border: 1px solid var(--brume); border-radius: var(--rayon);
  background: var(--blanc); color: var(--encre) !important;
  font-family: inherit; font-size: var(--t-s); font-weight: 600;
  line-height: 1.2; text-decoration: none; cursor: pointer;
  transition: var(--transition);
}
.sm-bouton .sm-icone { width: 1.05em; height: 1.05em; }
.sm-bouton:hover:not(:disabled):not([aria-disabled="true"]) {
  border-color: var(--bleu); background: var(--bleu-clair);
  color: var(--bleu-fonce) !important;
}
.sm-bouton:active:not(:disabled) { transform: translateY(1px); }
.sm-bouton:disabled, .sm-bouton[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.sm-bouton[aria-busy="true"] { opacity: .7; cursor: progress; }

.sm-bouton--principal {
  background: var(--vert); border-color: var(--vert); color: #fff !important;
  box-shadow: var(--ombre);
}
.sm-bouton--principal:hover:not(:disabled) {
  background: var(--vert-fonce); border-color: var(--vert-fonce); color: #fff !important;
}
.sm-bouton--succes {
  background: var(--vert); border-color: var(--vert); color: #fff !important;
}
.sm-bouton--succes:hover:not(:disabled) {
  background: var(--vert-fonce); border-color: var(--vert-fonce); color: #fff !important;
}
.sm-bouton--fantome {
  background: transparent; border-color: transparent;
  color: var(--ardoise) !important; font-weight: 500;
}
.sm-bouton--fantome:hover { background: var(--brume); color: var(--encre) !important; }
.sm-bouton--large { width: 100%; padding: .85rem; font-size: var(--t-m); }

/* Bouton verrouillé : il doit donner envie, pas frustrer. Teinte jaune —
   attention, pas interdiction. */
.sm-bouton--verrou {
  border-style: dashed; border-color: var(--jaune);
  background: var(--jaune-clair); color: var(--jaune-fonce) !important;
}
.sm-bouton--verrou::after { content: "🔒"; font-size: .85em; }
.sm-bouton--verrou:hover {
  background: #FBEFCF; border-color: var(--jaune-fonce); color: var(--jaune-fonce) !important;
}

/* ==========================================================================
   FORMULAIRES
   ========================================================================== */

.sm-champ { margin: 0 0 var(--e-3); }
.sm-champ > label {
  display: block; font-size: var(--t-s); font-weight: 600; margin: 0 0 .35rem;
}
.sm-champ input[type=email],
.sm-champ input[type=password],
.sm-champ input[type=text],
.sm-champ input[type=number],
.sm-champ select,
.sm-champ textarea {
  width: 100%; box-sizing: border-box; padding: .72rem .9rem;
  font-family: inherit; font-size: var(--t-m); color: var(--encre);
  background: var(--blanc);
  border: 1px solid var(--brume); border-radius: var(--rayon);
  transition: var(--transition);
}
.sm-champ input:focus, .sm-champ select:focus, .sm-champ textarea:focus {
  border-color: var(--bleu);
  outline: 3px solid rgba(27,127,196,.16); outline-offset: 0;
}
.sm-champ--case { display: flex; align-items: flex-start; gap: .6rem; font-size: var(--t-s); }
.sm-champ--case label { font-weight: 400; margin: 0; }
.sm-champ--case input { margin-top: .25rem; accent-color: var(--bleu); flex: 0 0 auto; }
.sm-pied { margin-top: var(--e-3); font-size: var(--t-s); color: var(--ardoise); }

/* Champ piège : masqué autrement que par display:none, que certains robots
   savent détecter. */
.sm-piege {
  position: absolute; left: -9999px; top: -9999px;
  width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none;
}

/* ==========================================================================
   MESSAGES — une couleur du drapeau par statut
   ========================================================================== */

.sm-message {
  padding: .85rem 1rem .85rem 1.1rem;
  border-radius: var(--rayon); border-left: 4px solid;
  margin: 0 0 var(--e-3); font-size: var(--t-s);
}
.sm-message p { margin: 0 0 .35rem; }
.sm-message p:last-child { margin: 0; }
.sm-message--erreur    { background: var(--rouge-clair); border-color: var(--rouge); color: var(--rouge-fonce); }
.sm-message--attention { background: var(--jaune-clair); border-color: var(--jaune); color: #6B4F07; }
.sm-message--succes    { background: var(--vert-clair);  border-color: var(--vert);  color: var(--vert-fonce); }
.sm-message--info      { background: var(--bleu-clair);  border-color: var(--bleu);  color: var(--bleu-fonce); }

/* ==========================================================================
   MOBILE
   ========================================================================== */

@media (max-width: 860px) {
  .sm-nav { display: none; }
  .sm-nav.est-ouvert {
    display: flex; flex-direction: column; align-items: stretch;
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--blanc); border-bottom: 1px solid var(--brume);
    padding: .5rem; gap: .1rem; box-shadow: var(--ombre-l);
  }
  .sm-nav a { padding: .75rem .9rem; }
  .sm-burger { display: block; }
}

@media (max-width: 640px) {
  .sm-wrap { padding: var(--e-3) 1rem var(--e-6); }
  .sm-titre { font-size: var(--t-l); }
}

/* Menu déroulant « Mon compte » (survol, clavier, tactile via :focus-within) */
.sm-compte-menu { position: relative; }
.sm-compte-menu__fleche { font-size: .75rem; margin-left: .15rem; color: var(--ardoise); }
.sm-compte-menu__liste {
  position: absolute; top: 100%; right: 0; z-index: 60; min-width: 13rem;
  margin: 0; padding: .4rem; list-style: none;
  background: var(--blanc); border: 1px solid var(--brume); border-top: 3px solid var(--bleu);
  border-radius: 12px; box-shadow: 0 12px 30px rgba(18,33,46,.15);
  opacity: 0; visibility: hidden; transform: translateY(6px); transition: opacity .15s, transform .15s, visibility .15s;
}
.sm-compte-menu:hover .sm-compte-menu__liste,
.sm-compte-menu:focus-within .sm-compte-menu__liste { opacity: 1; visibility: visible; transform: translateY(0); }
.sm-compte-menu__liste a {
  display: block; padding: .55rem .8rem; border-radius: 8px;
  color: var(--encre); font-weight: 700; text-decoration: none; white-space: nowrap;
}
.sm-compte-menu__liste a:hover, .sm-compte-menu__liste a:focus-visible { background: var(--bleu-clair); color: var(--bleu-fonce); }
.sm-compte-menu__liste li:last-child a { color: #E3262B; }
@media (prefers-reduced-motion: reduce) { .sm-compte-menu__liste { transition: none; } }

/* Suppression d'un audio (Mon compte → Mes audios) */
.sm-historique__suppr summary { cursor: pointer; color: #E3262B; font-weight: 700; font-size: .9rem; list-style: none; margin-top: .3rem; }
.sm-historique__suppr summary::-webkit-details-marker { display: none; }
.sm-historique__suppr form { margin-top: .4rem; }
.sm-bouton--danger { background: #E3262B; border-color: #E3262B; color: #fff; }