/* Le calendrier de l'Avent : les portes, le lecteur d'histoire, le bloc des
   parents et la barre de l'aperçu. Partagé par avent.html (les familles) et
   avent-apercu.html (la direction) pour qu'ils restent identiques.
   25/11/2026 : une histoire ET un dessin par jour. La porte s'ouvre vraiment
   (son battant pivote), puis un livre se déplie : l'histoire d'un côté, le
   dessin de l'enfant de l'autre — empilés sur téléphone, le dessin d'abord. */

/* ── Les portes ────────────────────────────────────────────── */
.av-etat { text-align: center; font-family: 'Baloo 2', sans-serif; font-weight: 700;
  font-size: 1.2rem; line-height: 1.35; margin: 0 auto 8px; max-width: 640px; text-wrap: balance; }
.av-intro { max-width: 640px; margin: 0 auto 22px; text-align: center; color: var(--gris); }
.av-message { text-align: center; min-height: 1.6em; margin: 16px auto 0; color: var(--gris); font-size: .95rem; }
.av-ouvrir-jour { display: flex; justify-content: center; margin: 14px 0 4px; }
.av-ouvrir-jour[hidden] { display: none; }

.av-grille { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; max-width: 760px;
  margin: 22px auto 0; padding: 0; list-style: none; }
@media (min-width: 760px) { .av-grille { grid-template-columns: repeat(6, 1fr); gap: 14px; } }

/* La porte = un cadre (le bouton) et un battant qui pivote sur sa gauche.
   Derrière le battant : une petite lumière d'or, ce qu'on découvre en ouvrant. */
.av-porte { position: relative; width: 100%; aspect-ratio: 1 / 1.08; display: block; padding: 0; cursor: pointer;
  font-family: 'Baloo 2', sans-serif; border: var(--trait) solid var(--contour);
  border-radius: var(--rayon); box-shadow: var(--colle); perspective: 700px;
  background: radial-gradient(circle at 50% 45%, var(--or) 0, var(--or-fonce) 28%, var(--encre) 72%);
  transition: transform var(--sans-rebond), box-shadow var(--sans-rebond); }
.av-porte__dedans { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; color: var(--blanc); }
.av-porte__battant { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; padding: 4px; border-radius: calc(var(--rayon) - 3px);
  transform-origin: left center; transition: transform .55s cubic-bezier(.3, .7, .2, 1); }
.av-porte__n { font-size: 1.95rem; font-weight: 800; line-height: 1; }
.av-porte__s { font-size: .72rem; font-weight: 700; line-height: 1.1; text-align: center; }
/* Les quatre couleurs de la marque, en alternance : en décembre, le thème
   de Noël les repeint en rouge, vert, or et bleu sans qu'on y touche. */
.av-porte--c0 .av-porte__battant { background: var(--violet); color: var(--blanc); }
.av-porte--c1 .av-porte__battant { background: var(--rose); color: var(--blanc); }
.av-porte--c2 .av-porte__battant { background: var(--or); color: var(--encre); }
.av-porte--c3 .av-porte__battant { background: var(--cyan); color: var(--encre); }
.av-porte--ouverte:hover, .av-porte--ouverte:focus-visible {
  transform: translate(-2px, -3px) rotate(-1.5deg); box-shadow: var(--colle-fort); }
/* Au survol, la porte s'entrouvre : on devine qu'elle s'ouvre. */
.av-porte--ouverte:hover .av-porte__battant, .av-porte--ouverte:focus-visible .av-porte__battant { transform: rotateY(-22deg); }
.av-porte--battante .av-porte__battant,
.av-porte--battante:hover .av-porte__battant { transform: rotateY(-108deg); }
/* Une porte fermée reste lisible (numéro et date), mais en pointillés : on
   la reconnaît sans avoir à deviner qu'elle est « éteinte ». */
.av-porte--fermee { background: var(--lilas-voile); border-style: dashed; box-shadow: none; cursor: default; }
.av-porte--fermee .av-porte__battant { background: var(--lilas-voile); color: var(--gris); }
.av-porte--fermee .av-porte__dedans { display: none; }
.av-porte--aujourdhui { outline: 4px solid var(--or-fonce); outline-offset: 3px; animation: av-appel 2.4s ease-in-out infinite; }
@keyframes av-appel { 50% { box-shadow: var(--colle), 0 0 0 9px color-mix(in srgb, var(--or) 35%, transparent); } }
.av-porte__badge { position: absolute; z-index: 2; top: -10px; right: -6px; background: var(--encre); color: var(--blanc);
  font-size: .66rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; letter-spacing: .02em; }
.av-porte:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
.av-porte--secoue { animation: av-secoue .35s; }
@keyframes av-secoue { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ── Le bloc « pour les parents » ──────────────────────────── */
.av-parents { max-width: 640px; margin: 34px auto 0; padding: 18px 20px; text-align: center;
  background: var(--lilas-voile); border: var(--trait) solid var(--contour); border-radius: var(--rayon); }
.av-parents h2 { font-size: 1.1rem; margin: 0 0 6px; }
.av-parents p { margin: 0 0 12px; color: var(--gris); }

/* ── Le lecteur : un livre ouvert ──────────────────────────── */
/* « margin: auto » : le site remet toutes les marges à zéro (* { margin: 0 }),
   ce qui annulerait le centrage natif de la fenêtre sur grand écran. */
.av-lecteur { margin: auto; border: 0; padding: 0; background: transparent; width: min(1080px, 96vw); max-height: 94vh; }
.av-lecteur::backdrop { background: rgba(46, 31, 77, .6); }
.av-lecteur__carte { background: var(--creme, var(--blanc)); border: var(--trait) solid var(--contour);
  border-radius: var(--rayon-lg); box-shadow: var(--colle-fort); padding: 16px 22px 18px;
  max-height: 92vh; overflow-y: auto; }
/* La date et « Fermer » restent en haut pendant qu'on fait défiler une longue
   histoire (top négatif = le retrait intérieur de la carte). */
.av-lecteur__tete { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  position: sticky; top: -16px; z-index: 3; background: var(--creme, var(--blanc));
  margin: -6px -4px 10px; padding: 6px 4px 8px; }
.av-lecteur__jour { font-family: 'Baloo 2', sans-serif; font-weight: 700; font-size: .85rem;
  letter-spacing: .07em; text-transform: uppercase; color: var(--violet); }

.av-livre { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.av-livre__page { min-width: 0; margin: 0; }
.av-lecteur h2 { font-size: 1.65rem; line-height: 1.2; margin: 2px 0 14px; text-wrap: balance; }
.av-texte p { font-size: 1.1rem; line-height: 1.85; margin: 0 0 1em; max-width: 62ch; }

/* Le dessin, comme une feuille scotchée sur la page. */
.av-dessin { position: relative; background: var(--blanc); padding: 10px; border: var(--trait) solid var(--contour);
  border-radius: 6px; box-shadow: var(--colle); transform: rotate(1.2deg); }
.av-dessin::before, .av-dessin::after { content: ''; position: absolute; top: -11px; width: 70px; height: 22px;
  background: color-mix(in srgb, var(--or) 55%, transparent); border-radius: 3px; }
.av-dessin::before { left: 14%; transform: rotate(-6deg); }
.av-dessin::after { right: 14%; transform: rotate(5deg); }
.av-dessin img { display: block; width: 100%; height: auto; max-height: 64vh; object-fit: contain; border-radius: 3px; }
.av-dessin img[hidden] { display: none; }
.av-dessin__attente { margin: 0; min-height: 220px; display: flex; align-items: center; justify-content: center;
  text-align: center; color: var(--gris); font-family: 'Baloo 2', sans-serif; font-weight: 700; font-size: 1.05rem;
  background: var(--lilas-voile); border-radius: 3px; }
.av-dessin__attente[hidden] { display: none; }
.av-illustration figcaption { margin-top: 12px; text-align: center; font-size: .88rem; color: var(--gris); font-style: italic; }
.av-illustration figcaption[hidden] { display: none; }

/* Téléphone : le dessin d'abord, l'histoire dessous. */
@media (max-width: 859px) {
  .av-livre__page--dessin { order: -1; padding: 8px 6px 0; }
}
/* Grand écran : les deux pages côte à côte, avec le pli du livre au milieu.
   Le dessin reste en vue pendant qu'on lit une longue histoire. */
@media (min-width: 860px) {
  .av-livre { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 0;
    background: linear-gradient(90deg, transparent calc(51.2% - 16px), rgba(46, 31, 77, .10) 51.2%, transparent calc(51.2% + 16px)); }
  .av-livre__page--texte { padding: 6px 40px 6px 10px; }
  .av-livre__page--dessin { padding: 18px 10px 6px 40px; position: sticky; top: 44px; align-self: start; }
}

.av-fin { text-align: center; font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 1.4rem;
  letter-spacing: .12em; margin: 20px 0 6px; color: var(--violet); }
.av-fin small { display: block; font-size: .85rem; font-weight: 600; letter-spacing: 0; color: var(--gris); margin-top: 4px; }
.av-lecteur .av-parents { margin-top: 18px; }
.av-lecteur__pied { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.av-lecteur__pied .btn[disabled] { opacity: .4; cursor: default; }

/* Le livre qui s'ouvre : la fenêtre grandit, la page du dessin se déplie depuis
   le pli (de haut en bas sur téléphone), le texte monte doucement. Rejoué à
   chaque histoire. */
.av-livre__page--dessin { transform-origin: left center; }
@media (max-width: 859px) { .av-livre__page--dessin { transform-origin: center top; } }
.av-lecteur[open] .av-lecteur__carte { animation: av-zoom .32s ease-out both; }
.av-livre--ouvre .av-livre__page--dessin { animation: av-deplie .8s cubic-bezier(.2, .75, .25, 1) .08s both; }
.av-livre--ouvre .av-livre__page--texte { animation: av-monte .5s ease-out .12s both; }
@media (max-width: 859px) { .av-livre--ouvre .av-livre__page--dessin { animation-name: av-deplie-haut; } }
@keyframes av-zoom { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes av-deplie { from { transform: perspective(1400px) rotateY(-86deg); opacity: .15; } to { transform: none; opacity: 1; } }
@keyframes av-deplie-haut { from { transform: perspective(1200px) rotateX(78deg); opacity: .15; } to { transform: none; opacity: 1; } }
@keyframes av-monte { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .av-porte, .av-porte__battant { transition: none; }
  .av-porte--secoue, .av-porte--aujourdhui, .av-lecteur[open] .av-lecteur__carte,
  .av-livre--ouvre .av-livre__page--dessin, .av-livre--ouvre .av-livre__page--texte { animation: none; }
}

/* ── Les effets (js/avent-effets.js) ───────────────────────── */
/* La gerbe d'étoiles : tout l'écran, sans jamais gêner un clic. */
.av-gerbe { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 60; }
/* La neige tombe DERRIÈRE les portes : le canvas sous la grille. */
.av-avec-neige { position: relative; }
.av-avec-neige > .conteneur { position: relative; z-index: 1; }
.av-neige { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

/* ── La barre de l'aperçu (visible seulement dans avent-apercu.html) ── */
.av-apercu { background: var(--encre); color: var(--blanc); padding: 12px 0; font-size: .92rem; }
.av-apercu[hidden] { display: none; }
.av-apercu .conteneur { display: flex; flex-wrap: wrap; gap: 10px 24px; align-items: center; justify-content: space-between; }
.av-apercu__outils { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; }
.av-apercu label { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.av-apercu select { font: inherit; padding: 6px 10px; border-radius: 8px; border: 2px solid var(--blanc);
  background: var(--blanc); color: var(--encre); }
.av-apercu a { color: var(--or); font-weight: 700; }
.av-apercu__info { opacity: .85; font-weight: 400; }
