/* Bernardet&Co — palette plage
   écume #F2FBF8 · lagon #1B8584 · mer profonde #12363D · sable #E9D2A3 · soleil #F2B84B
   Mise en page : la scène 3D occupe tout l'écran ; les textes apparaissent par chapitres,
   en surimpression, à gauche, à droite ou au centre selon le plan. */

:root {
  --ecume: #f2fbf8;
  --ciel: #d9eeea;
  --sable: #e9d2a3;
  --sable-clair: #f6ead0;
  --lagon: #1b8584;
  --lagon-fonce: #136463;
  --soleil: #f2b84b;
  --encre: #12363d;
  --encre-douce: #33545a;
  /* Au crépuscule, au-dessus de l'eau comme dessous : texte clair sur halo sombre */
  --texte-couleur: var(--ecume);
  --texte-doux: #e6f3f6;
  --halo-texte: 0 0 22px rgba(8, 18, 40, .7), 0 1px 2px rgba(8, 18, 40, .55);

  --display: "Fraunces", Georgia, serif;
  --texte: "Figtree", system-ui, sans-serif;
  --gouttiere: max(16px, 4vw);
  --mesure: 30rem;
}

/* Sous l'eau, le texte passe en écume */
:root[data-zone="mer"], :root[data-zone="grotte"] {
  --texte-couleur: var(--ecume);
  --texte-doux: #e2f7f3;
  --halo-texte: 0 0 22px rgba(10, 70, 78, .55), 0 1px 2px rgba(10, 70, 78, .4);
}

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

html { background: var(--ciel); }
body {
  margin: 0;
  color: var(--texte-couleur);
  font: 400 1.0625rem/1.6 var(--texte);
  background: var(--ciel);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Voile d'ouverture : la scène apparaît depuis l'écume */
.voile {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #000;
  z-index: 20;
  pointer-events: none;
  transition: opacity 1.6s ease .7s;
}
.est-pret .voile { opacity: 0; }

/* Chargeur : le logo reste fixe, l'eau l'ondule au passage de la souris ; le pourcentage suit le chargement réel */
.chargeur { z-index: 1; display: grid; justify-items: center; gap: 1.6rem; width: 100%; color: var(--ecume); }
.chargeur { position: relative; }
.chargeur__fond { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.chargeur__logo { display: block; max-width: 100%; }
.chargeur__logo canvas { display: block; max-width: 100%; }
.chargeur__pct {
  margin: 0;
  font: 350 clamp(1.4rem, 3.2vw, 2rem)/1 var(--display);
  letter-spacing: .04em;
  color: #bfe9ee;
  font-variant-numeric: tabular-nums;
}
.chargeur__trait { width: min(16rem, 60vw); height: 2px; background: rgba(191, 233, 238, .2); border-radius: 2px; overflow: hidden; }
.chargeur__rempli { display: block; height: 100%; background: #6fe6e0; transform: scaleX(0); transform-origin: left; }

.defilement { height: 1500vh; }

a { color: inherit; }
:focus-visible { outline: 2px solid var(--soleil); outline-offset: 4px; border-radius: 4px; }

/* ---------- Navigation ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(20px + env(safe-area-inset-top, 0px)) var(--gouttiere) 20px;
  text-shadow: var(--halo-texte);
  transition: color .6s;
}
.nav__logo {
  font-family: var(--display);
  font-variation-settings: "SOFT" 100, "WONK" 1;
  font-size: 1.3rem;
  text-decoration: none;
}
.nav__liens {
  display: flex;
  gap: clamp(14px, 2.4vw, 36px);
  list-style: none;
  margin: 0; padding: 0;
  font-weight: 500;
  font-size: .95rem;
}
.nav__liens a {
  text-decoration: none;
  background: linear-gradient(currentColor, currentColor) left bottom / 0 1px no-repeat;
  padding-bottom: 3px;
  transition: background-size .3s;
}
.nav__liens a:hover { background-size: 100% 1px; }
@media (max-width: 720px) { .nav__liens { display: none; } }

/* ---------- Chapitres ---------- */
.chapitre {
  position: fixed;
  z-index: 5;
  top: 50%;
  width: min(calc(100% - 2 * var(--gouttiere)), var(--mesure));
  margin-top: 0;
  opacity: 0;
  text-shadow: var(--halo-texte);
  transition: color .6s;
  will-change: opacity, transform;
  translate: 0 -50%;
}
/* Voile doux derrière le texte : la scène reste visible, le texte reste lisible sur les troncs et le feuillage */
.chapitre--gauche::before, .chapitre--droite::before {
  content: "";
  position: absolute;
  inset: -40px -56px;
  z-index: -1;
  background: radial-gradient(closest-side, rgba(10, 20, 44, .5), rgba(10, 20, 44, 0));
  pointer-events: none;
}
:root[data-zone="mer"] .chapitre--gauche::before, :root[data-zone="mer"] .chapitre--droite::before {
  background: radial-gradient(closest-side, rgba(10, 70, 78, .42), rgba(10, 70, 78, 0));
}
:root[data-zone="grotte"] .chapitre--gauche::before, :root[data-zone="grotte"] .chapitre--droite::before {
  background: radial-gradient(closest-side, rgba(3, 16, 26, .55), rgba(3, 16, 26, 0));
}
:root[data-zone="grotte"] .adresse { color: #7ff0ea !important; }
:root[data-zone="grotte"] .etapes li::before, :root[data-zone="grotte"] .marque .esperluette { color: #7ff0ea; }
.chapitre--gauche { left: var(--gouttiere); }
.chapitre--droite { right: var(--gouttiere); }
.chapitre--centre {
  left: 50%;
  width: calc(100% - 2 * var(--gouttiere));
  translate: -50% -50%;
  text-align: center;
}

h1, h2 {
  font-family: var(--display);
  font-variation-settings: "SOFT" 100, "WONK" 1;
  font-weight: 400;
  margin: 0 0 1.2rem;
  text-wrap: balance;
}
h2 {
  font-size: clamp(2rem, 4.2vw, 3.4rem);
  line-height: 1.04;
  letter-spacing: -0.015em;
}
.chapitre p { margin: 0 0 1rem; font-size: 1.12rem; color: var(--texte-doux); }

.marque {
  font-size: clamp(2.8rem, 10.5vw, 10.5rem);
  line-height: .9;
  letter-spacing: -0.035em;
  font-weight: 350;
  display: flex;
  justify-content: center;
  white-space: nowrap;
  margin-bottom: 1.4rem;
}
.marque .esperluette { color: #6fe6e0; font-style: italic; font-weight: 300; }
/* Titre long (« Mon calendrier de l'Avent ») : plus petit, et sur deux lignes sur téléphone */
.marque--longue { font-size: clamp(2.4rem, 6.4vw, 6.6rem); flex-wrap: wrap; white-space: normal; text-align: center; }
.marque--longue span { white-space: nowrap; }
.bouton {
  display: inline-block;
  margin-top: .4rem;
  padding: .85rem 1.6rem;
  border-radius: 999px;
  background: var(--lagon-fonce, #0f6f78);
  color: #fff !important;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  transition: transform .2s ease, box-shadow .2s ease;
}
.bouton:hover, .bouton:focus-visible { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0, 0, 0, .24); }
.accroche { font-size: clamp(1.1rem, 2vw, 1.4rem) !important; }

.savoirs { margin: 0; display: grid; gap: 1.3rem; }
.savoirs dt {
  font-family: var(--display);
  font-variation-settings: "SOFT" 100, "WONK" 0;
  font-size: 1.4rem;
  line-height: 1.2;
}
.savoirs dd { margin: .3rem 0 0; color: var(--texte-doux); }

/* Méthode : une vraie séquence, donc numérotée */
.etapes { list-style: none; counter-reset: etape; margin: 0; padding: 0; display: grid; gap: 1.1rem; }
.etapes li { counter-increment: etape; display: grid; grid-template-columns: 2.4rem 1fr; column-gap: .8rem; }
.etapes li::before {
  content: counter(etape);
  grid-row: span 2;
  font-family: var(--display);
  font-size: 2rem;
  line-height: 1;
  color: #6fe6e0;
}
.etapes strong { font-size: 1.15rem; font-weight: 600; }
.etapes span { color: var(--texte-doux); }

.projets { list-style: none; margin: 0; padding: 0; }
.projets li {
  display: grid;
  gap: 2px;
  padding: 16px 0;
  border-top: 1px solid color-mix(in srgb, var(--texte-couleur) 25%, transparent);
}
.projets li:last-child { border-bottom: 1px solid color-mix(in srgb, var(--texte-couleur) 25%, transparent); }
.projet__nom {
  font-family: var(--display);
  font-variation-settings: "SOFT" 100, "WONK" 1;
  font-size: clamp(1.6rem, 3.4vw, 2.4rem);
  line-height: 1.05;
}
.projet__type { color: var(--texte-doux); }

.adresse {
  font-family: var(--display);
  font-size: clamp(1.4rem, 3vw, 2.2rem) !important;
  color: #7ff0ea !important;
  user-select: all;
  overflow-wrap: anywhere;
}

/* ---------- Repères en bas d'écran ---------- */
.reperes {
  position: fixed;
  z-index: 10;
  left: var(--gouttiere);
  right: var(--gouttiere);
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: .85rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-shadow: var(--halo-texte);
}
.reperes__chapitre { min-width: 7.5em; }
.reperes__releve { min-width: 11em; text-align: right; }
.reperes__trait {
  flex: 1;
  height: 1px;
  background: color-mix(in srgb, var(--texte-couleur) 25%, transparent);
  position: relative;
  overflow: hidden;
}
.reperes__niveau {
  position: absolute;
  inset: 0;
  background: currentColor;
  transform-origin: left;
  transform: scaleX(0);
}

.indice {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: calc(62px + env(safe-area-inset-bottom, 0px));
  translate: -50% 0;
  margin: 0;
  font-size: .9rem;
  font-weight: 500;
  text-shadow: var(--halo-texte);
  animation: respire 2.4s ease-in-out infinite;
}
@keyframes respire { 50% { transform: translateY(5px); } }

@media (max-width: 720px) {
  .chapitre--gauche, .chapitre--droite { left: var(--gouttiere); right: auto; top: auto; bottom: 90px; translate: none; }
  .reperes__chapitre { min-width: 0; }
  .reperes__releve { min-width: 0; }
}

/* ---------- Sans WebGL : une page classique, lisible ---------- */
.sans-3d body { background: linear-gradient(var(--ciel), var(--sable) 60%, #c79d68); }
.sans-3d #scene, .sans-3d .defilement, .sans-3d .reperes, .sans-3d .indice, .sans-3d .voile { display: none; }
.sans-3d .chapitre {
  position: static;
  opacity: 1 !important;
  transform: none !important;
  translate: none;
  margin: 18vh auto;
  width: min(calc(100% - 2 * var(--gouttiere)), 40rem);
}
.sans-3d .chapitres { padding-top: 10vh; }

@media (prefers-reduced-motion: reduce) {
  .indice { animation: none; }
  .voile { transition: none; }
}
