/* ==========================================================================
   Détecteur — feuille de style d'entrée du site (aucune ressource externe).

   Direction : « terminal de bourse » sobre. Fond quadrillé discret, chiffres
   en chasse fixe tabulaire, titres condensés, un rail coloré à gauche des
   lignes selon le niveau. Le niveau n'est jamais porté par la couleur seule :
   la pastille affiche toujours emoji + texte.

   Thèmes : valeurs claires dans :root, valeurs sombres redéfinies sous
   @media (prefers-color-scheme: dark) :root:not([data-theme="clair"]) et
   :root[data-theme="sombre"] (pas de light-dark() : Safari < 17.5).
   theme.js pose data-theme (clair/sombre) sur <html> ; sans JS, on suit le
   système.

   Classes à réutiliser (Tasks 15–16), définies dans composants.css sauf
   la coque, l'en-tête de page et les utilitaires :
   - Coque       body.coque > header.nav (montée par monterNavigation :
                 marque, nav.nav__principale > ul.nav__liens, actions)
                 + main.contenu
   - En-tête     .entete-page > h1.titre-page + p.sous-titre ; .micro (étiquette)
   - Boutons     .bouton (+ --primaire | --discret | --danger | --icone),
                 aria-busy="true" = en cours ; .groupe-boutons
   - Champs      .champ > label + .saisie (input/select/textarea) + .champ__aide ;
                 .champ--erreur ; .formulaire (pile verticale) ;
                 .ligne-champs (champs côte à côte, repli en colonne)
   - Interrupteur label.ligne-interrupteur > input[type=checkbox].interrupteur
                 (role="switch") + texte
   - Pastilles   .pastille--rouge | --orange | --stock | --neutre (pastilleNiveau)
   - Badges      .badge (source, marchand, catégorie) ; .badge--alerte
   - Cartes      .carte (+ .carte__titre) ; .grille-cartes
   - Lignes      ul.liste-lignes > li.ligne (+ --rouge | --orange | --stock) :
                 .ligne__corps, .ligne__titre, .ligne__meta, .ligne__prix
   - Prix        .prix, .prix--barre, .remise (chiffres tabulaires)
   - États       .etat (+ --vide | --chargement | --erreur) > .etat__titre +
                 .etat__detail ; .squelette (bloc de chargement)
   - Annonces    #annonces.toasts (aria-live) > .toast (+ --succes | --erreur)
   - Utilitaires .masque-visuel (lecteurs d'écran seulement), .chiffres
   - Offres      (offres.css) .filtres*, li.ligne.ligne-offre (+ --nouvelle),
                 .vignette, .ligne__badges, .badge--nouveau, .reference,
                 .pagination, .nouveautes ; fiche : .fiche*, .courbe*, .tableau
   - Gestion     (gestion.css) .titre-section, .statut[data-etat] (retour
                 d'enregistrement), .champ__erreur, .confirmation, .bandeau ;
                 alertes : .segments/.segment, .jour*, .ligne-alerte ;
                 réglages : .panneau-etat*, .choix*, .curseur* ;
                 recherches : .formulaire-recherche, .apercu*, .recherche*,
                 .puces/.puce ; sources : .source*, .voyant--*, .etat-source--*
   ========================================================================== */

/* Composants (boutons, champs, pastilles, lignes, états, annonces) */
@import url("/static/css/composants.css");
/* Pages Offres et Fiche produit, courbe de prix */
@import url("/static/css/offres.css");
/* Pages Alertes, Réglages, Recherches et Sources */
@import url("/static/css/gestion.css");

:root {
  color-scheme: light;

  /* Surfaces et texte (contraste AA vérifié sur --surface et --fond) */
  --fond: #f3f2ee;
  --surface: #ffffff;
  --surface-2: #f8f7f4;
  --bord: #d8d5cc;
  --bord-fort: #878275; /* >= 3:1 (WCAG 1.4.11) */
  --texte: #15181d;
  --texte-doux: #4d5560;
  --grille: rgb(20 24 29 / 0.045);

  /* Accent : bleu « téléscripteur » */
  --accent: #0a5ca3;
  --accent-fond: #e6f0fa;
  --sur-accent: #ffffff;
  --focus: #0a5ca3;

  /* Niveaux (texte sur teinte >= 4.5:1) */
  --rouge: #b3261e;
  --rouge-fond: #fdecea;
  --orange: #9c4700;
  --orange-fond: #fff0de;
  --stock: #1c6a2e;
  --stock-fond: #e5f3e8;

  /* Typographie : polices système uniquement */
  --police-texte: system-ui, -apple-system, "Segoe UI", sans-serif;
  --police-titre: "DIN Alternate", "DIN Condensed", "Bahnschrift",
    "Avenir Next Condensed", "Arial Narrow", system-ui, sans-serif;
  --police-chiffres: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas,
    monospace;

  /* Rythme : base 4 px */
  --e1: 0.25rem;
  --e2: 0.5rem;
  --e3: 0.75rem;
  --e4: 1rem;
  --e5: 1.5rem;
  --e6: 2rem;
  --e7: 3rem;
  --rayon: 6px;
  --rayon-grand: 10px;
  --cible: 44px;
  --largeur-nav: 15rem;
  --hauteur-onglets: 4rem;
  --ombre: 0 1px 0 rgb(0 0 0 / 0.04), 0 8px 24px -12px rgb(0 0 0 / 0.25);
  --duree: 160ms;

  /* Plans (z-index) */
  --plan-nav: 20;
  --plan-toasts: 50;
}

/* Jetons sombres : système sombre sans choix manuel, ou choix « sombre ».
   Les deux blocs doivent rester identiques. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="clair"]) {
    color-scheme: dark;
    --fond: #0c0e11;
    --surface: #14171c;
    --surface-2: #1b1f25;
    --bord: #2b3038;
    --bord-fort: #646c78;
    --texte: #e9ebee;
    --texte-doux: #a0a8b3;
    --grille: rgb(233 235 238 / 0.035);
    --accent: #63c5ff;
    --accent-fond: #0f2a3d;
    --sur-accent: #041621;
    --focus: #8fd6ff;
    --rouge: #ff7b72;
    --rouge-fond: #3a1614;
    --orange: #ffb454;
    --orange-fond: #382408;
    --stock: #7fd890;
    --stock-fond: #0f2a19;
  }
}

:root[data-theme="sombre"] {
  color-scheme: dark;
  --fond: #0c0e11;
  --surface: #14171c;
  --surface-2: #1b1f25;
  --bord: #2b3038;
  --bord-fort: #646c78;
  --texte: #e9ebee;
  --texte-doux: #a0a8b3;
  --grille: rgb(233 235 238 / 0.035);
  --accent: #63c5ff;
  --accent-fond: #0f2a3d;
  --sur-accent: #041621;
  --focus: #8fd6ff;
  --rouge: #ff7b72;
  --rouge-fond: #3a1614;
  --orange: #ffb454;
  --orange-fond: #382408;
  --stock: #7fd890;
  --stock-fond: #0f2a19;
}

:root[data-theme="clair"] {
  color-scheme: light;
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font: 400 1rem/1.5 var(--police-texte);
  color: var(--texte);
  background-color: var(--fond);
  background-image: linear-gradient(var(--grille) 1px, transparent 1px),
    linear-gradient(90deg, var(--grille) 1px, transparent 1px);
  background-size: 24px 24px;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--police-titre);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.15;
}

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

.masque-visuel {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.lien-evitement {
  position: absolute;
  top: var(--e2);
  left: var(--e2);
  z-index: var(--plan-toasts);
  padding: var(--e2) var(--e4);
  font-weight: 700;
  color: var(--sur-accent);
  background: var(--accent);
  border-radius: var(--rayon);
  transform: translateY(-200%);
}

.lien-evitement:focus {
  transform: none;
}

.chiffres,
.prix,
.remise {
  font-family: var(--police-chiffres);
  font-variant-numeric: tabular-nums;
}

.micro {
  font: 600 0.72rem/1.2 var(--police-chiffres);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--texte-doux);
}

/* ---------- Coque et navigation ---------- */

.coque {
  padding-bottom: calc(var(--hauteur-onglets) + env(safe-area-inset-bottom));
}

.contenu {
  width: 100%;
  max-width: 72rem;
  margin: 0 auto;
  padding: var(--e5) var(--e4) var(--e7);
}

/* Rythme vertical entre les blocs de premier niveau */
.contenu > * + * {
  margin-top: var(--e5);
}

.nav {
  position: sticky;
  top: 0;
  z-index: var(--plan-nav);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--e3);
  padding: var(--e2) var(--e4);
  padding-top: max(var(--e2), env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--bord);
}

.nav__marque {
  display: flex;
  align-items: center;
  gap: var(--e2);
  font: 700 1.15rem/1 var(--police-titre);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--texte);
  text-decoration: none;
  min-height: var(--cible);
}

.nav__signal {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--stock);
  box-shadow: 0 0 0 3px var(--stock-fond);
}

.nav__liens {
  position: fixed;
  inset: auto 0 0 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin: 0;
  padding: 0 0 env(safe-area-inset-bottom);
  list-style: none;
  background: var(--surface);
  border-top: 1px solid var(--bord);
}

.nav__lien {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--hauteur-onglets);
  padding: var(--e1);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--texte-doux);
  text-decoration: none;
  transition: color var(--duree), background-color var(--duree);
}

.nav__lien svg {
  width: 22px;
  height: 22px;
}

.nav__lien:hover {
  color: var(--texte);
}

.nav__lien[aria-current="page"] {
  color: var(--accent);
  box-shadow: inset 0 3px 0 var(--accent);
}

.nav__actions {
  display: flex;
  gap: var(--e1);
}

@media (min-width: 900px) {
  .coque {
    display: grid;
    grid-template-columns: var(--largeur-nav) minmax(0, 1fr);
    padding-bottom: 0;
  }

  .nav {
    height: 100dvh;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: var(--e5) var(--e3);
    border-bottom: 0;
    border-right: 1px solid var(--bord);
  }

  .nav__marque {
    padding: 0 var(--e2) var(--e5);
  }

  .nav__principale {
    display: flex;
    flex: 1;
    flex-direction: column;
  }

  .nav__liens {
    position: static;
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    padding: 0;
    border: 0;
    background: none;
  }

  .nav__lien {
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--e3);
    min-height: var(--cible);
    padding: 0 var(--e3);
    border-radius: var(--rayon);
    font-size: 0.95rem;
  }

  .nav__lien:hover {
    background: var(--surface-2);
  }

  .nav__lien[aria-current="page"] {
    background: var(--accent-fond);
    box-shadow: inset 3px 0 0 var(--accent);
  }

  .nav__actions {
    padding-top: var(--e3);
    border-top: 1px solid var(--bord);
  }

  .contenu {
    padding: var(--e6) var(--e6) var(--e7);
  }
}

/* ---------- En-tête de page ---------- */

.entete-page {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: var(--e3);
  margin-bottom: var(--e5);
}

.titre-page {
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sous-titre {
  margin: var(--e1) 0 0;
  color: var(--texte-doux);
}

/* ---------- Page de connexion ---------- */

.page-connexion {
  display: grid;
  place-items: center;
  padding: var(--e5) var(--e4);
}

.connexion {
  width: min(100%, 24rem);
  display: grid;
  gap: var(--e5);
}

.connexion__marque {
  display: grid;
  gap: var(--e2);
}

.connexion__nom {
  display: flex;
  align-items: center;
  gap: var(--e2);
  font-size: 1.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Téléscripteur décoratif : un prix barré qui chute (aria-hidden) */
.connexion__ticker {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--e2) var(--e3);
  padding: var(--e3) var(--e4);
  font-family: var(--police-chiffres);
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  border: 1px solid var(--bord);
  border-left: 4px solid var(--rouge);
  border-radius: var(--rayon);
}

.connexion__ancien {
  color: var(--texte-doux);
  text-decoration: line-through;
}

.connexion__nouveau {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--rouge);
}

.connexion__message {
  min-height: 1.5em;
  margin: 0;
  font-weight: 600;
  color: var(--rouge);
}

.connexion__pied {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.saisie-mot-de-passe {
  display: flex;
  gap: var(--e2);
}

.saisie-mot-de-passe .saisie {
  flex: 1;
}

/* ---------- Animations ---------- */

@keyframes rotation {
  to {
    transform: rotate(360deg);
  }
}

@keyframes balayage {
  from {
    background-position: 100% 0;
  }

  to {
    background-position: -100% 0;
  }
}

@keyframes apparition {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
