/* ================================================================
   territoire.css — couche commune du site (direction « territoire »,
   2026-10-16). Chargée par TOUTES les pages, avant leur propre style :
     1. la police d'affichage (Archivo, auto-hébergée, largeur variable) ;
     2. les couleurs de contraintes, les mêmes partout ;
     3. l'en-tête unique (HTML : site_header.py) ;
     4. la typographie des pages éditoriales (body.lt-page).
   Autonome : les pages guides ne chargent ni styles.css ni tokens.css,
   d'où les valeurs de repli dans chaque var().
   ================================================================ */

@font-face {
  font-family: "Archivo";
  src: url("/vendor/archivo/archivo-wdth.woff2") format("woff2-variations"),
       url("/vendor/archivo/archivo-wdth.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Une couleur par contrainte. Règle : la même couleur veut dire la même
     chose sur la carte, la fiche, le rapport et les pages villes. */
  --lt-inondable: #3FA9FF;
  --lt-agricole: #D9C46A;   /* blé */
  --lt-humide: #34D3C0;     /* sarcelle */
  --lt-foret: #4FB37A;
  --lt-glissement: #FF8A5B;
  --lt-valeur: #F0B84E;     /* or : la valeur au rôle */
  --lt-lot: #7FA6E8;        /* un lot sans contrainte */
  --lt-nuit: #070A12;
  --lt-titre: "Archivo", "Arial Narrow", system-ui, sans-serif;
}

.lh {
  position: sticky;
  top: 0;
  z-index: 900;
  background: rgba(10, 14, 26, 0.88);
  backdrop-filter: saturate(140%) blur(16px);
  -webkit-backdrop-filter: saturate(140%) blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  /* Neutralise les anciennes règles « header {…} » de styles.css. */
  display: block;
  padding: 0;
  min-height: 0;
  height: auto;
}
.lh * { box-sizing: border-box; }

.lh-in {
  max-width: 1200px;
  margin: 0 auto;
  min-height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

/* ── Logo ─────────────────────────────────────────────────────── */
.lh-logo {
  font-family: var(--lt-titre);
  font-stretch: 112%;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  color: var(--text-primary, #F1F5FE);
  text-decoration: none;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1;
}
.lh-logo b { color: var(--lt-lot); font-weight: 800; }
.lh-logo:hover { color: var(--text-primary, #F1F5FE); }
.lh-marque path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
}

/* ── Recherche ────────────────────────────────────────────────── */
.lh-recherche {
  position: relative;
  flex: 1 1 280px;
  max-width: 340px;
  min-width: 170px;
  margin: 0;
}
.lh-recherche svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  fill: none;
  stroke: #7D89A2;
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}
.lh-recherche input {
  width: 100%;
  height: 40px;
  margin: 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: #141B2A;
  color: var(--text-primary, #F1F5FE);
  padding: 0 12px 0 38px;
  font: inherit;
  font-size: 14.5px;
  -webkit-appearance: none;
  appearance: none;
}
.lh-recherche input::placeholder { color: #7D89A2; }
.lh-recherche input:focus {
  outline: none;
  border-color: var(--blue-vivid, #3B82F6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* ── Liens ────────────────────────────────────────────────────── */
.lh-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}
.lh-nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  color: #B6C1D6;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.lh-nav a:hover { color: #FFFFFF; background: rgba(255, 255, 255, 0.06); }
.lh-nav a[aria-current="page"] { color: #FFFFFF; }
.lh-nav a.lh-or { color: var(--lt-valeur); }
.lh-nav a.lh-or:hover { color: #F3CF7E; background: rgba(226, 182, 87, 0.10); }
.lh a:focus-visible, .lh button:focus-visible {
  outline: 2px solid var(--blue-bright, #60A5FA);
  outline-offset: 2px;
}

/* Le compte : le seul bouton plein de l'en-tête. */
.lh-nav a.lh-compte {
  margin-left: 10px;
  padding: 9px 16px;
  background: var(--blue-vivid, #3B82F6);
  color: #FFFFFF;
  font-weight: 600;
  font-size: 14.5px;
}
.lh-nav a.lh-compte:hover { background: #2F6FE0; color: #FFFFFF; }
/* Connecté : une pastille avec l'initiale, plus le nom. */
.lh-nav a.lh-compte.lh-connecte {
  background: transparent;
  color: #DCE4F2;
  padding: 4px 10px 4px 4px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 999px;
}
.lh-nav a.lh-compte.lh-connecte:hover { background: rgba(255, 255, 255, 0.06); }
.lh-av {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--blue-vivid, #3B82F6);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  flex: 0 0 auto;
}
.lh-av.lh-av-pro { background: #C9A24B; color: #1A1404; }
.lh-nom {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Icônes du téléphone (loupe, menu) ────────────────────────── */
.lh-ico {
  display: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #DCE4F2;
  cursor: pointer;
  padding: 0;
  place-items: center;
}
.lh-ico:hover { background: rgba(255, 255, 255, 0.06); }
.lh-ico svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.lh-cache {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ── Téléphone et tablette : une seule rangée, le reste derrière ☰ ── */
@media (max-width: 1000px) {
  .lh-in { min-height: 56px; padding: 0 12px 0 16px; gap: 4px; }
  .lh-logo { margin-right: auto; font-size: 20px; }
  .lh-ico { display: inline-grid; }
  .lh-recherche, .lh-nav { display: none; }

  .lh[data-ouvert] .lh-recherche,
  .lh[data-ouvert] .lh-nav {
    display: flex;
    order: 10;
    flex-basis: 100%;
    max-width: none;
  }
  .lh[data-ouvert] .lh-recherche { display: block; margin: 4px 4px 6px 0; }
  .lh[data-ouvert] .lh-recherche input { height: 46px; font-size: 16px; }
  .lh[data-ouvert] .lh-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0 4px 14px 0;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
  }
  .lh[data-ouvert] .lh-nav a { font-size: 17px; padding: 13px 8px; }
  .lh[data-ouvert] .lh-nav a.lh-compte {
    margin: 10px 0 0;
    justify-content: center;
    padding: 13px 16px;
    font-size: 16px;
  }
  .lh[data-ouvert] .lh-nav a.lh-compte.lh-connecte {
    justify-content: flex-start;
    border-radius: 12px;
    padding: 8px 12px;
  }
  .lh[data-ouvert] { max-height: 100vh; overflow-y: auto; }
}

/* Raccourci clavier dans le champ (⌘K / Ctrl+K le met au focus). */
.lh-recherche kbd {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  font: 600 11px/1 Inter, system-ui, sans-serif;
  color: #8B97B0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  padding: 3px 6px;
  pointer-events: none;
}
.lh-recherche input { padding-right: 52px; }
@media (max-width: 1000px) { .lh-recherche kbd { display: none; } .lh-recherche input { padding-right: 12px; } }

/* ── Pages éditoriales (guides, villes, familles) ────────────────
   Le même squelette de classes partout (.hero, .stat-value, main h2) :
   cette couche leur donne la typographie du site sans toucher à leur
   mise en page. Spécificité body.lt-page > leurs règles locales. */
body.lt-page .hero h1 {
  font-family: var(--lt-titre);
  font-stretch: 118%;
  font-weight: 820;
  letter-spacing: -0.03em;
  line-height: 1.02;
  font-size: clamp(2.05rem, 4.4vw, 3.3rem);
  text-wrap: balance;
}
body.lt-page .hero .eyebrow,
body.lt-page .stat-label {
  font-family: var(--lt-titre);
  font-stretch: 75%;
  font-weight: 600;
  letter-spacing: 0.16em;
}
body.lt-page .stat-value {
  font-family: var(--lt-titre);
  font-stretch: 96%;
  font-weight: 800;
  letter-spacing: -0.02em;
  /* « 312 500 $ » sur une ligne : à 110 % de chasse le symbole tombait
     seul sous le nombre dans une carte de 180 px. */
  font-size: clamp(1.3rem, 2.1vw, 1.8rem);
  white-space: nowrap;
}
body.lt-page main h2 {
  font-family: var(--lt-titre);
  font-stretch: 108%;
  font-weight: 780;
  letter-spacing: -0.015em;
  font-size: clamp(1.35rem, 2.2vw, 1.7rem);
  text-wrap: balance;
}

/* ── La carte d'une contrainte (pages par contrainte, nuage.js en mode
      « carte ») : le Québec entier, une seule couche allumée. La place est
      réservée d'avance (pas de saut de mise en page) ; sans WebGL ou sur
      connexion lente, nuage.js pose .nuage-echec et la figure disparaît. */
.nuage-carte { margin: 6px 0 30px; }
.nuage-carte-cadre {
  position: relative; aspect-ratio: 16 / 9; max-width: 100%;
  border: 1px solid rgba(127, 166, 232, .16); border-radius: 16px; overflow: hidden;
  background: radial-gradient(ellipse at 50% 60%, #111a30 0%, #0a0e1a 70%);
}
.nuage-carte canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 1.2s ease; }
body.nuage-pret .nuage-carte canvas { opacity: 1; }
.nuage-carte figcaption { margin-top: 10px; font-size: .86rem; color: var(--text-secondary, #9aa8c0); line-height: 1.5; }
.nuage-carte figcaption i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); margin-right: 8px; vertical-align: 1px; }
body.nuage-echec .nuage-carte { display: none; }

/* ── Le nuage de lots de l'accueil (nuage.js) ───────────────────────── */
.nuage-scene {
  position: absolute; top: 0; left: 0; right: 0;
  height: min(100svh, 940px);
  z-index: 1; pointer-events: none; overflow: hidden;
  /* le nuage s'éteint vers le bas, sous les exemples */
  -webkit-mask-image: linear-gradient(to bottom, #000 62%, transparent);
          mask-image: linear-gradient(to bottom, #000 62%, transparent);
}
.nuage-scene canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; transition: opacity 1.2s ease;
}
body.nuage-pret .nuage-scene canvas { opacity: 1; }
/* Un voile au centre : le texte reste lisible au-dessus des points. */
.nuage-scene::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse 46% 42% at 50% 38%, rgba(7, 10, 18, .9) 45%, rgba(7, 10, 18, 0) 85%);
  transition: opacity .6s ease;
}
/* Ceinture : une ombre sous le texte, pour les bords que le voile touche moins. */
body.nuage-pret .search-hint-v4,
body.nuage-pret .nuage-legende { text-shadow: 0 0 2px rgba(7, 10, 18, .95), 0 1px 10px rgba(7, 10, 18, .95); }
body.nuage-pret .search-hint-v4 { background: rgba(7, 10, 18, .72); border-radius: 999px; padding: 4px 12px; width: fit-content; margin-inline: auto; }
body.nuage-pret .hero-v4 p { text-shadow: 0 0 2px rgba(7, 10, 18, .9), 0 1px 14px rgba(7, 10, 18, .95); }
body.nuage-pret .bg-grid { opacity: 0; transition: opacity 1.2s ease; }

/* Pendant le vol, le texte s'efface : on regarde le Québec. */
body.nuage-vol .nuage-scene::after { opacity: 0; }
body.nuage-theme .nuage-scene::after { opacity: .55; }
/* filter et non opacity : .hero porte une animation « both » qui fige l'opacité. */
main > .hero-v4, .search-section-v4 > * { transition: filter .45s ease; }
body.nuage-vol main > .hero-v4,
body.nuage-vol .search-section-v4 > :not(.search-wrap) { filter: opacity(0); }
body.chat-mode .nuage-scene, body.embed-mode .nuage-scene { display: none; }

.nuage-marque {
  position: absolute; top: 0; left: 0; width: 0; height: 0;
  pointer-events: none;
}
.nuage-marque::before, .nuage-marque::after {
  content: ""; position: absolute; left: -9px; top: -9px; width: 18px; height: 18px;
  border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 4px rgba(127, 166, 232, .35);
  opacity: 0; transform: scale(.4); transition: opacity .3s ease, transform .3s ease;
}
.nuage-marque::after { border-color: var(--lt-lot); box-shadow: none; }
.nuage-marque.vue::before { opacity: 1; transform: scale(1); }
.nuage-marque.vue::after { opacity: 1; animation: nuage-onde 1.1s ease-out infinite; }
@keyframes nuage-onde { from { transform: scale(1); opacity: .9; } to { transform: scale(3.2); opacity: 0; } }

.nuage-couches {
  display: none; flex-wrap: wrap; justify-content: center; gap: 6px;
  margin: 18px auto 0; max-width: 640px;
}
body.nuage-pret .nuage-couches { display: flex; }
.nuage-couches button {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 11px; border-radius: 999px; cursor: pointer;
  font-family: inherit; font-weight: 500; font-size: 12.5px; line-height: 1; color: rgba(226, 232, 245, .78);
  background: rgba(10, 14, 26, .62); border: 1px solid rgba(127, 166, 232, .16);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.nuage-couches button i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.nuage-couches button:hover { color: #fff; border-color: rgba(127, 166, 232, .35); }
.nuage-couches button[aria-pressed="true"] { color: #fff; border-color: var(--c); background: rgba(16, 22, 40, .85); }
.nuage-legende {
  display: none; margin: 10px auto 0; text-align: center;
  font-size: 12px; color: rgba(160, 174, 200, .75);
}
body.nuage-pret .nuage-legende { display: block; }
@media (max-width: 640px) {
  .nuage-couches { gap: 5px; }
  .nuage-couches button { padding: 6px 9px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .nuage-scene canvas, .nuage-marque::before { transition: none; }
  .nuage-marque.vue::after { animation: none; }
}
@media (max-width: 640px) {
  /* Au téléphone le texte de l'accueil descend presque jusqu'à la barre de
     recherche : le voile doit le couvrir en entier, sinon le paragraphe se
     lit par-dessus les points (signalé par Nick le 16 oct.). */
  .nuage-scene::after { background: radial-gradient(ellipse 100% 34% at 50% 30%, rgba(7, 10, 18, .92) 50%, rgba(7, 10, 18, 0) 95%); }
  /* Le paragraphe de définition reste entier dans la page (moteurs et
     lecteurs d'écran), mais tient en trois lignes : le reste de l'écran
     appartient aux points. */
  body.nuage-pret .hero-def-v4 {
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  }
}
