/* ============================================================
   CIVI : feuille commune du site (accueil et partie guides)
   Polices servies en local, couleurs, base, en-tête et pied de page.
   Mobile d'abord : styles de base = téléphone, puis 769 px (ordinateur) et 1024 px.
   ============================================================ */

@font-face {
  font-family: "Cormorant Garamond";
  src: url("../assets/fonts/cormorant-garamond-regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: "Cormorant Garamond";
  src: url("../assets/fonts/cormorant-garamond-italic.woff2") format("woff2");
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("../assets/fonts/plus-jakarta-sans-variable.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
}

:root {
  --sp-primary: #1b2a4a;
  --sp-secondary: #2d4a7a;
  --sp-accent: #c5a55a;
  --sp-accent-deep: #7a652a;
  --sp-background: #faf7f2;
  --sp-surface: #faf7f2;
  --sp-surface-alt: #f0ece6;
  --sp-text: #1b2a4a;
  --sp-text-secondary: #6b7280;
  --sp-correct: #2e7d32;
  --sp-incorrect: #c62828;
  --sp-press-red: #b33a3a;
  --sp-rule: rgba(27, 42, 74, 0.14);
  --sp-radius-sm: 4px;
  --sp-radius-md: 8px;
  --sp-radius-lg: 12px;
  --sp-radius-xl: 20px;
  --sp-radius-full: 999px;
  --sp-shadow-md: 0 4px 12px rgba(27, 42, 74, 0.1);
  --sp-shadow-lg: 0 8px 24px rgba(27, 42, 74, 0.14);
  --display: "Cormorant Garamond", Georgia, serif;
  --sans: "Plus Jakarta Sans", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
/* scroll-padding : une ancre ne se cache jamais sous l'en-tête collant. */
/* overflow-x: clip et non hidden : hidden fait de html un conteneur de défilement et Safari iOS ne colle plus l'en-tête (position: sticky). */
html { overflow-x: clip; scroll-behavior: smooth; scroll-padding-top: 80px; background: var(--sp-background); }
body { min-width: 320px; margin: 0; overflow-x: clip; color: var(--sp-text); background: var(--sp-background); font: 400 16px/1.65 var(--sans); -webkit-font-smoothing: antialiased; }
img { display: block; max-width: 100%; height: auto; }
button, input { font: inherit; }
:focus-visible { outline: 3px solid var(--sp-accent); outline-offset: 3px; }

.skip-link { position: fixed; z-index: 50; top: 8px; left: 8px; padding: 10px 14px; transform: translateY(-160%); border-radius: var(--sp-radius-md); color: var(--sp-surface); background: var(--sp-primary); font-weight: 800; }
.skip-link:focus { transform: none; }

.button,
.touch-target {
  min-height: 44px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--sp-radius-md);
  color: var(--sp-primary);
  font-weight: 800;
  text-decoration: none;
}

.button--primary {
  color: var(--sp-surface);
  background: var(--sp-primary);
}
.button--primary:hover { background: var(--sp-secondary); }

.button--secondary {
  background: var(--sp-surface-alt);
  border-color: var(--sp-rule);
}

.button--text {
  background: transparent;
  border-color: var(--sp-primary);
}

/* ---- En-tête : collé en haut, fond crème voilé, lisible au défilement ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 60px;
  padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--sp-rule);
  background: var(--sp-background);
  background: color-mix(in srgb, var(--sp-background) 90%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
}

/* Marque : le monogramme de l'icône du site, puis le nom en italique. */
.brand { display: inline-flex; flex: none; align-items: center; gap: 9px; min-height: 44px; color: var(--sp-primary); text-decoration: none; }
.brand__mark { position: relative; display: grid; width: 30px; height: 30px; padding-right: 2px; place-items: center; border-radius: 9px; color: var(--sp-background); background: var(--sp-primary); box-shadow: 0 1px 3px rgba(27, 42, 74, 0.18); font: italic 600 1.3rem/1 var(--display); }
.brand__mark::after { position: absolute; top: 5px; right: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--sp-accent); content: ""; }
.brand__name { font: italic 700 1.5rem/1 var(--display); letter-spacing: -0.01em; }
/* Sous 360 px, dans l'en-tête : le nom reste lu (aria-label du lien), masqué à l'œil pour garder une vraie marge. Le pied de page le garde. */
.site-header .brand__name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* Téléphone : seul « Guides » reste dans la navigation, entre la marque et le bouton. */
.site-header nav { display: flex; min-width: 0; align-items: center; gap: 2px; margin-left: auto; }
.site-header nav a { display: none; }
.site-header nav .nav-jouer, .site-header nav .nav-guides { display: inline-flex; min-height: 44px; align-items: center; padding-inline: 8px; border-radius: var(--sp-radius-full); color: var(--sp-primary); font-size: 0.875rem; font-weight: 700; text-decoration: none; white-space: nowrap; }
.site-header nav a:hover { background: var(--sp-surface-alt); }
/* Lien actif : fond doux et contour complet, jamais de trait sur un seul bord. */
.site-header nav a[aria-current] { background: var(--sp-surface-alt); box-shadow: inset 0 0 0 1px var(--sp-rule); font-weight: 800; }

.site-header__cta { display: inline-flex; flex: none; min-height: 44px; align-items: center; gap: 7px; padding: 0 12px; border-radius: var(--sp-radius-full); color: var(--sp-background); background: var(--sp-primary); font-size: 0.875rem; font-weight: 800; text-decoration: none; white-space: nowrap; }
.site-header__cta:hover { background: var(--sp-secondary); }
.site-header__icon { display: none; flex: none; }
/* « l'app » reste lu par les lecteurs d'écran, masqué à l'œil sur téléphone. */
.site-header__cta-more { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* ---- Pied de page commun ---- */
/* Au-dessus des zones de lecture de l'accueil (z-index 5) et de leur halo crème. */
.site-footer { position: relative; z-index: 6; padding: 44px 0 calc(28px + env(safe-area-inset-bottom)); border-top: 1px solid var(--sp-rule); background: var(--sp-surface-alt); }
.site-footer__inner { display: grid; gap: 28px; width: min(100% - 32px, 1180px); margin-inline: auto; }
/* Texte discret du pied de page : marine adouci (le gris manquerait de contraste sur ce fond). */
.site-footer__brand p { max-width: 32ch; margin: 6px 0 0; color: rgba(27, 42, 74, 0.8); font-size: 0.9375rem; line-height: 1.5; }
.site-footer__nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 16px; }
.site-footer__col { display: flex; min-width: 0; flex-direction: column; align-items: flex-start; }
.site-footer__title { margin: 0 0 2px; color: var(--sp-press-red); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.site-footer a { display: inline-flex; min-width: 44px; min-height: 44px; align-items: center; color: var(--sp-primary); font-size: 0.9375rem; font-weight: 600; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; text-underline-offset: 3px; }
.site-footer__note { margin: 0; padding-top: 20px; border-top: 1px solid var(--sp-rule); color: rgba(27, 42, 74, 0.8); font-size: 0.8125rem; line-height: 1.55; }
/* Focus bien visible sur le crème : contour marine plutôt que doré. */
.site-header :focus-visible,
.site-footer :focus-visible { outline-color: var(--sp-secondary); }
.site-footer__note a { display: inline; min-width: 0; min-height: 0; color: var(--sp-secondary); font-size: inherit; text-decoration: underline; }

/* ---- Jeu intégré : l'état actif, commun à l'accueil et aux pages de contenu ----
   jeu-embed.js remplace le contenu du bloc .jeu-embed par le jeu (iframe) et pose
   ces classes. L'affiche des pages de contenu (carte, Civi, « Jouer ») est dans
   guides.css ; l'accueil règle sa propre largeur dans landing.css. Le sélecteur
   double (.jeu-embed.jeu-embed--actif) passe devant l'affiche, chargée après. */
.jeu-embed.jeu-embed--actif { position: relative; display: block; padding: 0; border: 0; border-radius: 0; background: none; }
/* Téléphone : 85vh suit la grande fenêtre (barre d'outils de Safari repliée) et
   le pied du jeu (« Valider », « Suivant ») finirait sous la barre. Le cadre
   suit donc la petite fenêtre (svh), moins l'en-tête collant ; 85vh reste en
   repli pour les navigateurs sans svh. */
.jeu-embed__frame { display: block; width: 100%; height: min(720px, 85vh); height: min(720px, calc(100svh - 104px)); border: 0; }
/* Pendant le chargement : Civi et le message couvrent le cadre, qui garde déjà
   sa taille (le jeu se met en page à la bonne largeur, rien ne saute ensuite). */
.jeu-embed--chargement .jeu-embed__frame { visibility: hidden; }
.jeu-embed__chargement { position: absolute; z-index: 1; inset: 0; display: grid; align-content: center; justify-items: center; gap: 12px; padding: 20px 16px; border: 1px solid var(--sp-rule); border-radius: 20px; background: var(--sp-surface-alt); text-align: center; }
.jeu-embed__chargement:focus { outline: none; }
.jeu-embed__chargement-texte { margin: 0; font-weight: 700; line-height: 1.4; }
.jeu-embed__chargement img { width: 96px; height: auto; }
/* Barre d'attente : un reflet marine qui glisse sur un rail discret. */
.jeu-embed__chargement::after { width: 96px; height: 4px; border-radius: var(--sp-radius-full); background: linear-gradient(90deg, transparent, var(--sp-primary), transparent) -100% 0 / 50% 100% no-repeat, var(--sp-rule); animation: jeu-embed-attente 1.2s ease-in-out infinite; content: ""; }
@keyframes jeu-embed-attente {
  to { background-position: 200% 0, 0 0; }
}

/* Dès 360 px : retour aux espacements confortables (en dessous, Jouer + Guides + bouton doivent tenir). */
@media (min-width: 360px) {
  .site-header { gap: 6px; }
  .site-header { padding-inline: max(16px, env(safe-area-inset-left), env(safe-area-inset-right)); }
  .site-header .brand__name { position: static; width: auto; height: auto; overflow: visible; clip: auto; clip-path: none; }
  .brand__name { font-size: 1.65rem; }
  .site-header nav .nav-jouer, .site-header nav .nav-guides { padding-inline: 12px; }
  .site-header__cta { padding-inline: 14px; }
}

@media (min-width: 375px) {
  .site-header__icon { display: block; }
}

@media (min-width: 769px) {
  .site-header { gap: 12px; min-height: 68px; padding-inline: max(32px, calc((100vw - 1180px) / 2)); }
  .brand__mark { width: 34px; height: 34px; font-size: 1.45rem; }
  .brand__name { font-size: 1.85rem; }
  .site-header nav .nav-jouer, .site-header nav .nav-guides { padding-inline: 14px; font-size: 0.9375rem; }
  .site-header__cta { padding-inline: 18px; font-size: 0.9375rem; }
  .site-header__cta-more { position: static; width: auto; height: auto; overflow: visible; clip: auto; clip-path: none; }
  .site-footer { padding-top: 64px; }
  .site-footer__inner { grid-template-columns: minmax(220px, 1fr) minmax(0, 2.2fr); gap: 32px 64px; }
  .site-footer__nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .site-footer__note { grid-column: 1 / -1; }
  .jeu-embed.jeu-embed--actif { border: 1px solid var(--sp-rule); border-radius: 20px; overflow: hidden; }
  .jeu-embed__frame { height: min(720px, 85vh); }
  .jeu-embed__chargement { border: 0; border-radius: 0; }
}

/* Navigation complète dès qu'elle tient sur une ligne avec la marque et le bouton. */
@media (min-width: 1024px) {
  .site-header nav { gap: 4px; }
  .site-header nav a { display: inline-flex; min-height: 44px; align-items: center; padding-inline: 14px; border-radius: var(--sp-radius-full); color: var(--sp-primary); font-size: 0.9375rem; font-weight: 700; text-decoration: none; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .jeu-embed__chargement::after { animation: none; background-position: 50% 0, 0 0; }
}
