/* ==================================================
   Sluak — styles communs à toutes les pages (hors accueil Building)
   ================================================== */

html,
body {
  width: 100%;
  height: 100%;
}

html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
  margin: 0;
  padding: 0;
  border: 0;
  font: inherit;
  vertical-align: baseline;
}

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

/* ==================================================
   Color System : thème clair et thème sombre
   Le thème suit le réglage du système ; le bouton jour/nuit de l'en-tête
   le force (attribut data-theme sur <html>, mémorisé par /common/theme.js).
   ================================================== */

:root {
  /* Layout : seules largeurs du site, utilisées par tous les modèles (aucun modèle ne les redéfinit). */
  --max-width: 1280px;
  --max-reading: 760px;
  --page-padding: 24px;

  /* Brand colors : la couleur de la marque est --color-primary, seule valeur à changer ; ses déclinaisons en
     découlent (color-mix), en mode clair comme en mode sombre. --color-secondary est la seconde couleur (accueil). */
  --color-primary: #39f27a;
  --color-primary-dark: color-mix(in oklab, var(--color-primary) 84%, black);
  /* Déclinaisons fixes, identiques dans les deux modes : foncée (texte sur fond clair) et pâle (fond clair). */
  --color-primary-deep: color-mix(in oklab, var(--color-primary) 60%, black);
  --color-primary-pale: color-mix(in oklab, var(--color-primary) 10%, #f4f6f2);
  --color-secondary: #c8f078;

  /* Shadow */
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);

  color-scheme: light;
  --color-background: #ffffff;
  --color-card: #ffffff;
  --color-surface: #f4f6f2;
  --color-surface-strong: #e9ede6;
  --color-border: #e2e6df;
  --color-text: #121512;
  --color-text-secondary: #4f564e;
  --color-muted: #7a8078;
  /* Le vert de la marque sert aux aplats ; sur fond clair, textes et liens prennent le vert foncé (contraste AA). */
  --color-accent: var(--color-primary-deep);
  --color-accent-soft: var(--color-primary-pale);
  --color-danger: #c2412d;
  --color-danger-soft: #fdecea;
  /* Aplats foncés (en-têtes de tableau, pastilles, encadré d'appel) et texte posé dessus. */
  --color-ink: #121512;
  --color-on-ink: #ffffff;
  --color-on-ink-secondary: rgba(255, 255, 255, .72);
  --color-field: #f3f5f2;
  --color-glass: rgba(255, 255, 255, .92);
  /* Halo vert du bandeau de tête (fiches, articles) : en mode jour seulement. */
  --color-hero-glow: color-mix(in srgb, var(--color-primary) 35%, transparent);
  --shadow-rgb: 18, 21, 18;
  --color-freemium: #2f6db5;
  --color-level-2: #b7791f;
  --color-level-3: #4f6b8a;
  --color-level-4: #2f9e5b;
  --color-tint-neutral: #eef2f6;
  --color-tint-seo: #e4f7ea;
  --color-tint-sea: #e7efff;
  --color-tint-geo: #f0e9ff;
  --color-tint-web: #fff0e6;
  --color-tint-mail: #e3faf6;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  color-scheme: dark;
  --color-background: #121212;
  --color-card: #1a1a1a;
  --color-surface: #1e1e1e;
  --color-surface-strong: #282828;
  --color-border: #2c2c2c;
  --color-text: #f2f2f2;
  --color-text-secondary: #b3b3b3;
  --color-muted: #8a8a8a;
  --color-accent: var(--color-primary);
  --color-accent-soft: color-mix(in srgb, var(--color-primary) 12%, transparent);
  --color-danger: #ff8a80;
  --color-danger-soft: rgba(255, 107, 94, .12);
  --color-ink: #2a2a2a;
  --color-on-ink: #f2f2f2;
  --color-on-ink-secondary: rgba(242, 242, 242, .72);
  --color-field: #1c1c1c;
  --color-glass: rgba(18, 18, 18, .92);
  --color-hero-glow: transparent;
  --shadow-rgb: 0, 0, 0;
  --color-freemium: #7fb0f0;
  --color-level-2: #e0a24a;
  --color-level-3: #8fa9c6;
  --color-level-4: #4fd18a;
  --color-tint-neutral: #242424;
  --color-tint-seo: #17301f;
  --color-tint-sea: #1c2536;
  --color-tint-geo: #261f36;
  --color-tint-web: #33251a;
  --color-tint-mail: #16302c;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --color-background: #121212;
  --color-card: #1a1a1a;
  --color-surface: #1e1e1e;
  --color-surface-strong: #282828;
  --color-border: #2c2c2c;
  --color-text: #f2f2f2;
  --color-text-secondary: #b3b3b3;
  --color-muted: #8a8a8a;
  --color-accent: var(--color-primary);
  --color-accent-soft: color-mix(in srgb, var(--color-primary) 12%, transparent);
  --color-danger: #ff8a80;
  --color-danger-soft: rgba(255, 107, 94, .12);
  --color-ink: #2a2a2a;
  --color-on-ink: #f2f2f2;
  --color-on-ink-secondary: rgba(242, 242, 242, .72);
  --color-field: #1c1c1c;
  --color-glass: rgba(18, 18, 18, .92);
  --color-hero-glow: transparent;
  --shadow-rgb: 0, 0, 0;
  --color-freemium: #7fb0f0;
  --color-level-2: #e0a24a;
  --color-level-3: #8fa9c6;
  --color-level-4: #4fd18a;
  --color-tint-neutral: #242424;
  --color-tint-seo: #17301f;
  --color-tint-sea: #1c2536;
  --color-tint-geo: #261f36;
  --color-tint-web: #33251a;
  --color-tint-mail: #16302c;
}

/* ==================================================
   Typography
   ================================================== */

body {
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-background);
}

/* Headings (unstyled by default) */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: inherit;
  line-height: 1.2;
}

/* Paragraph */
p {
  color: var(--color-text-secondary);
}

/* ==================================================
   Links
   ================================================== */

a {
  color: inherit;
  text-decoration: none;
}

/* ==================================================
   Media
   ================================================== */

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

/* ==================================================
   Utilities
   ================================================== */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Un élément masqué le reste, même si une règle lui donne un display. */
[hidden] {
  display: none !important;
}

/* Groupe de mots à ne pas couper (ex. « pouvons-nous »). */
.nowrap {
  white-space: nowrap;
}

/* ==================================================
   En-tête et pied de page communs (common/header/, common/footer/)
   ================================================== */

body {
  transition: background-color .2s ease, color .2s ease;
}

.site-header,
.site-footer {
  width: min(100% - 2 * var(--page-padding), var(--max-width));
  margin: 0 auto;
}

/* Contenu de toutes les pages : même largeur que l'en-tête et le pied de page (--max-width). Les modèles de lecture
   (contact, pages légales, page simple) ajoutent la classe .main-reading : colonne de --max-reading. */
body > main {
  flex: 1;
  width: min(100% - 2 * var(--page-padding), var(--max-width));
  margin: 0 auto;
}

body > main.main-reading {
  width: min(100% - 2 * var(--page-padding), var(--max-reading));
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  padding: 20px 0;
}

.site-header li,
.site-footer li {
  margin: 0;
  color: inherit;
  font-size: inherit;
  line-height: inherit;
}

.site-header .brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text);
}

/* Logo (common/header/document.php) : fond de l'icône à la couleur de la marque, nom au noir du site. */
.brand-icon {
  width: auto;
  height: 30px;
}

.brand-name {
  width: auto;
  height: 20px;
}

.logo-bg {
  fill: var(--color-primary);
}

.logo-name {
  fill: var(--color-text);
}

.site-nav {
  margin-right: auto;
}

.site-menu {
  display: flex;
  gap: 4px;
  list-style: none;
  font-size: 15px;
  font-weight: 700;
}

.site-menu a {
  display: block;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--color-text-secondary);
}

.site-menu a:hover,
.site-menu a[aria-current="page"] {
  background: var(--color-surface);
  color: var(--color-accent);
}

.site-search {
  position: relative;
  display: flex;
  align-items: center;
  width: min(100%, 320px);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-field);
}

.site-search:focus-within {
  border-color: var(--color-accent);
}

.site-search input {
  flex: 1;
  min-width: 0;
  padding: 10px 0 10px 18px;
  border: 0;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: 15px;
}

.site-search input:focus {
  outline: none;
}

.site-search input::placeholder {
  color: var(--color-muted);
}

.site-search button,
.site-theme {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.site-search button:hover,
.site-theme:hover {
  color: var(--color-accent);
}

.site-theme {
  border: 1px solid var(--color-border);
}

/* Suggestions sous la barre de recherche (common/header.js). */
.site-search-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 30;
  padding: 6px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-card);
  box-shadow: 0 16px 40px rgba(var(--shadow-rgb), .14);
  list-style: none;
}

.site-search-suggestions[hidden] {
  display: none;
}

.site-search-suggestions a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--color-text);
  font-size: 15px;
}

.site-search-suggestions a:hover,
.site-search-suggestions [aria-selected="true"] a {
  background: var(--color-surface);
}

.site-search-suggestion-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-search-suggestion-type {
  flex: none;
  color: var(--color-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* Lune en mode jour (passer à la nuit), soleil en mode nuit (passer au jour). */
.site-theme .icon-sun {
  display: none;
}

:root[data-theme="dark"] .site-theme .icon-sun {
  display: block;
}

:root[data-theme="dark"] .site-theme .icon-moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .site-theme .icon-sun {
    display: block;
  }

  :root:not([data-theme="light"]) .site-theme .icon-moon {
    display: none;
  }
}

/* Menu Actualités : liste dépliante sans JavaScript, ouverte sous l'entrée du menu. */
.site-menu-dropdown {
  position: relative;
}

.site-menu-dropdown summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--color-text-secondary);
  list-style: none;
  cursor: pointer;
}

.site-menu-dropdown summary::-webkit-details-marker {
  display: none;
}

.site-menu-dropdown summary::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.site-menu-dropdown summary:hover,
.site-menu-dropdown summary.is-current,
.site-menu-dropdown[open] summary {
  background: var(--color-surface);
  color: var(--color-accent);
}

.site-menu-dropdown ul {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-card);
  box-shadow: 0 16px 40px rgba(var(--shadow-rgb), .14);
  list-style: none;
}

.site-menu .site-menu-dropdown a {
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--color-text);
  white-space: nowrap;
}

.site-menu .site-menu-dropdown .site-menu-sub a {
  padding-left: 28px;
  color: var(--color-muted);
}

.site-menu .site-menu-dropdown a:hover {
  background: var(--color-surface);
  color: var(--color-text);
}

.site-menu .site-menu-dropdown a[aria-current="page"] {
  background: transparent;
  color: var(--color-accent);
}

/* Sélecteur de langue : liste dépliante sans JavaScript. */
.site-languages {
  position: relative;
}

.site-languages summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-text);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .06em;
  list-style: none;
  cursor: pointer;
}

.site-languages summary::-webkit-details-marker {
  display: none;
}

.site-languages summary::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.site-languages ul {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-card);
  box-shadow: 0 16px 40px rgba(var(--shadow-rgb), .14);
  list-style: none;
}

.site-languages a {
  display: block;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--color-text);
  font-size: 15px;
}

.site-languages a:hover {
  background: var(--color-surface);
}

.site-languages a[aria-current="true"] {
  color: var(--color-accent);
  font-weight: 700;
}

.site-languages-note {
  color: var(--color-muted);
  font-size: 13px;
}

.site-footer {
  padding: 32px 0;
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 13px;
}

.site-footer p {
  margin: 0;
  color: inherit;
  font-size: inherit;
}

/* Liens du pied de page : contact, plan du site, pages légales. */
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-bottom: 16px;
  list-style: none;
}

.footer-links a {
  color: var(--color-text-secondary);
}

.footer-links a:hover,
.footer-links a[aria-current="page"] {
  color: var(--color-accent);
}

.footer-links li {
  font-size: 14px;
}

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

@media (max-width: 720px) {
  /* Sur mobile : marque, langue et thème sur la première ligne, menu sur la deuxième, recherche sur la troisième. */
  .site-nav {
    order: 4;
    width: 100%;
    margin-right: 0;
  }

  .site-menu {
    margin-left: -12px;
  }

  /* Sur mobile, le menu est à droite de l'écran : la liste s'aligne sur son bord droit. */
  .site-menu-dropdown ul {
    right: 0;
    left: auto;
  }

  .site-header .brand {
    margin-right: auto;
  }

  .site-search {
    order: 5;
    width: 100%;
  }
}

/* Cible d’un lien interne (common/header.js) : focus donné pour le clavier, sans contour visible. */
[tabindex="-1"]:focus { outline: none; }
