/* Calendrier de l'Avent : écran d'accueil et fenêtres à ouvrir (chargé seulement par index.html).
 * Mobile d'abord (360-390 px). Aucune image, aucune police externe : tout est en CSS et en SVG inline.
 * Les jeux ne chargent PAS ce fichier : ils gardent commun/style.css seul. */

:root { --bois: #7a4a2b; --bois-clair: #a8693d; --or: #ffd54a; --sapin: #2c6e49; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* ---------- Écran d'accueil ---------- */
.accueil { position: relative; z-index: 1; min-height: min(78vh, 640px); min-height: min(78svh, 640px); margin-top: 8px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 28px 18px 96px; overflow: hidden; }
.accueil .montagnes { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 30%; z-index: -1; }
.accueil .lune { position: absolute; top: 14px; right: 8%; width: 40px; height: 40px; border-radius: 50%;
  box-shadow: inset -10px 4px 0 0 #fff7d6; filter: drop-shadow(0 0 14px rgba(255,247,214,.45)); z-index: -1; }
.bouton[hidden] { display: none; }
.marque { margin: 0; font-size: clamp(2.4rem, 13vw, 4rem); font-weight: 900; letter-spacing: -.02em; line-height: 1;
  color: #fff; text-shadow: 0 3px 0 var(--rouge), 0 8px 24px rgba(0,0,0,.4); }
.accueil h1 { margin: 10px 0 6px; font-size: 1.25rem; font-weight: 700; color: var(--glace); }
.accueil .sous-titre { margin: 0 auto; max-width: 30em; color: var(--doux); font-size: .98rem; }
.compte { margin: 16px 0 0; min-height: 1.5em; font-size: .95rem; font-variant-numeric: tabular-nums;
  background: rgba(0,0,0,.28); padding: 6px 14px; border-radius: 999px; }
.compte.test { background: #8a5a00; }
.accueil .actions { margin: 18px 0 0; }
.bouton.grand { font-size: 1.08rem; padding: 14px 24px; background: var(--rouge); color: #fff;
  box-shadow: 0 0 0 3px #fff, 0 8px 20px rgba(0,0,0,.35); }
.bouton.grand:active { background: var(--rouge-fonce); }
.fictif { margin: 14px 0 0; font-size: .8rem; color: var(--doux); }
.fleche { position: absolute; bottom: 52px; left: 50%; width: 44px; height: 44px; margin-left: -22px;
  border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; text-decoration: none; font-size: 1.3rem;
  line-height: 44px; animation: flotte 2.4s ease-in-out infinite; }
@keyframes flotte { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(6px); } }

/* ---------- Le calendrier ---------- */
.calendrier-titre { text-align: center; font-size: 1.15rem; margin: 6px 0 4px; }
.mode-passes { text-align: center; color: var(--doux); font-size: .82rem; margin: 0 0 14px; }
.date-du-jour { display: block; width: max-content; margin: 0 auto 12px; }

.fenetres { list-style: none; margin: 0; padding: 4px; display: grid; gap: 10px;
  grid-template-columns: repeat(4, 1fr); grid-auto-flow: dense; }
@media (min-width: 640px) { .fenetres { grid-template-columns: repeat(6, 1fr); gap: 12px; } }

.fenetre { position: relative; aspect-ratio: 1 / 1.12; }
/* 23 cases + la grande case (le jour même, ou le 1er avant et après l'Avent) sur 2 colonnes + le 24 sur toute la ligne :
   24 unités, donc 6 lignes pleines sur 4 colonnes et 4 lignes sur 6 colonnes. */
.fenetre.grande { grid-column: span 2; aspect-ratio: 2.125 / 1.12; }
.fenetre.noel { grid-column: 1 / -1; aspect-ratio: auto; height: 132px; }
.fenetre.noel .porte .devant { background-color: var(--rouge); }
.fenetre.ouverte { z-index: 2; }

/* L'intérieur, derrière la porte */
.interieur { position: absolute; inset: 0; border-radius: var(--rayon); overflow: hidden; display: flex;
  flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 6px; text-align: center;
  background: radial-gradient(circle at 50% 30%, #fff8e1 0%, #ffe9b0 55%, #e8c27a 100%); color: var(--nuit);
  box-shadow: inset 0 0 0 3px rgba(0,0,0,.18), inset 0 6px 14px rgba(0,0,0,.25); text-decoration: none; }
a.interieur:active { filter: brightness(.94); }
.interieur.avec-titre { padding-top: 16px; }
.interieur .n { position: absolute; top: 3px; left: 7px; font-size: .78rem; font-weight: 900; opacity: .55; }
.interieur .titre { font-size: .7rem; font-weight: 700; line-height: 1.12; overflow-wrap: break-word; hyphens: auto;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.interieur .record { font-size: .66rem; opacity: .8; }
.interieur .action { margin-top: 2px; font-size: .66rem; font-weight: 800; color: #fff; background: var(--rouge);
  padding: 4px 10px; border-radius: 999px; }
.grande .interieur .titre, .noel .interieur .titre { font-size: .95rem; -webkit-line-clamp: 2; }
.grande .interieur .titre { font-size: .86rem; }
.grande .interieur.avec-titre { padding-top: 10px; }   /* le titre entier (2 lignes) + le bouton tiennent dans la grande case */
.grande .interieur .n, .noel .interieur .n { font-size: 1rem; }
.du-jour .interieur .action { font-size: .82rem; padding: 5px 14px; animation: battement 1.8s ease-in-out infinite; }
/* W1103 : en 320 px, le titre (2 lignes) était encore écrasé par le bouton « Jouer » : il ne rétrécit plus, et tout est un peu plus petit */
.interieur .titre { flex-shrink: 0; }
@media (max-width: 359px) {
  .grande .interieur.avec-titre { padding-top: 8px; gap: 2px; }
  .grande .interieur .titre { font-size: .76rem; line-height: 1.08; }
  .du-jour .interieur .action { font-size: .76rem; padding: 4px 12px; margin-top: 0; }
}
.souvenir .interieur { background: radial-gradient(circle at 50% 30%, #eef4fb 0%, #c9d9ea 70%, #a7bdd6 100%);
  filter: saturate(.7); }
.souvenir .interieur .action { background: #5b7393; }
.rejouable .interieur .action { background: var(--sapin); }
.preparation .interieur .action { background: #6b2a36; }
.motif { width: 34%; max-width: 60px; height: auto; }
.grande .motif { width: 22%; }
.noel .motif { width: 54px; }
/* Case avec titre : le dessin reste, en grand et pâle derrière le texte (chaque case garde son visuel). */
.fenetre:not(.noel) .interieur.avec-titre .motif { position: absolute; left: 50%; top: 46%; width: 74%; max-width: 76px;
  transform: translate(-50%, -50%); opacity: .3; pointer-events: none; }
.interieur.avec-titre .titre, .interieur.avec-titre .record, .interieur.avec-titre .action { position: relative; }

/* La porte (deux faces : devant décoré, dos en bois).
   Mémoire graphique (W1549) : la 3D (perspective, deux faces) ne sert QUE pour la porte qui bouge : celle du jour
   (elle « appelle ») et celle qu'on ouvre (classe .trois-d posée par calendrier.js juste avant). Les autres portes
   restent plates, même dessin : avant, chaque porte fermée gardait 3 calques 3D (60 calques pour 20 portes). */
.porte { position: absolute; inset: 0; padding: 0; border: 0; margin: 0; background: none; cursor: pointer; font: inherit;
  color: #fff; transform-origin: 0 50%;
  transition: transform .95s cubic-bezier(.25, 1.35, .45, 1); border-radius: var(--rayon); }
.porte .devant, .porte .dos { position: absolute; inset: 0; border-radius: var(--rayon);
  display: flex; flex-direction: column; align-items: center; justify-content: center; }
.porte .dos { display: none; }
.fenetre.trois-d { perspective: 700px; perspective-origin: 0 50%; }
.trois-d .porte { transform-style: preserve-3d; }
.trois-d .porte .devant, .trois-d .porte .dos { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.trois-d .porte .dos { display: flex; }
.porte .devant { background-color: var(--teinte, var(--rouge));
  background-image: radial-gradient(circle at 20% 15%, rgba(255,255,255,.22) 0 2px, transparent 3px),
    radial-gradient(circle at 78% 70%, rgba(255,255,255,.18) 0 2px, transparent 3px),
    linear-gradient(160deg, rgba(255,255,255,.18), rgba(0,0,0,.18));
  background-size: 28px 28px, 34px 34px, 100% 100%;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.35), 0 5px 14px rgba(0,0,0,.35); }
.porte .devant::after { content: ""; position: absolute; right: 9%; top: 50%; width: 7px; height: 7px; margin-top: -3px;
  border-radius: 50%; background: var(--or); box-shadow: 0 1px 2px rgba(0,0,0,.5); }   /* la poignée */
.porte .dos { transform: rotateY(180deg); background: linear-gradient(90deg, var(--bois), var(--bois-clair));
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.25); }
.porte .num { font-size: 1.75rem; font-weight: 900; line-height: 1; text-shadow: 0 2px 0 rgba(0,0,0,.3); }
.porte .indice { font-size: .68rem; margin-top: 5px; font-weight: 700; }
.grande .porte .num { font-size: 2.6rem; }
.noel .porte .num { font-size: 3.2rem; }
.porte:focus-visible { outline: 3px solid var(--or); outline-offset: 3px; }
.fenetre.avenir .porte .devant { filter: saturate(.55) brightness(.85); }
.fenetre.du-jour .porte .devant { background-color: var(--rouge); }
.fenetre.du-jour:not(.ouverte) .porte .devant { box-shadow: inset 0 0 0 3px #fff, 0 0 0 3px var(--or), 0 0 26px 4px rgba(255,213,74,.55); }
.fenetre.du-jour:not(.ouverte) .porte { animation: appel 2.4s ease-in-out infinite; }
@keyframes appel { 0%, 100% { transform: rotateY(0); } 8% { transform: rotateY(-14deg); } 16% { transform: rotateY(0); }
  22% { transform: rotateY(-8deg); } 28% { transform: rotateY(0); } }

/* Ouverte : la porte pivote puis s'efface (sinon, vue en perspective, elle cacherait la case voisine). */
.fenetre.ouverte .porte { transform: rotateY(-115deg); opacity: 0; visibility: hidden; pointer-events: none; animation: none;
  transition: transform .95s cubic-bezier(.25, 1.35, .45, 1), opacity .3s ease .65s, visibility 0s linear .95s; }
.fenetre.ouverte .interieur { box-shadow: inset 0 0 0 3px var(--bois), inset 0 6px 14px rgba(0,0,0,.3); }
.fenetre.secoue .porte { animation: secoue .45s ease-in-out; }
@keyframes secoue { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-5px) rotate(-2deg); }
  40% { transform: translateX(5px) rotate(2deg); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }

/* Étincelles à l'ouverture */
.etincelle { position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px; border-radius: 50%;
  background: var(--or); pointer-events: none; z-index: 3; animation: eclat .85s ease-out forwards; }
.etincelle.blanche { background: #fff; }
@keyframes eclat { 0% { transform: translate(0, 0) scale(.4); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 0; } }

/* Bandeau d'information (tap sur une case fermée) */
.bulle { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 20; max-width: min(92vw, 420px);
  transform: translate(-50%, calc(100% + 40px)); visibility: hidden; transition: transform .3s ease, visibility 0s linear .3s; background: #fff; color: var(--nuit);
  padding: 12px 18px; border-radius: 16px; box-shadow: 0 8px 26px rgba(0,0,0,.4); font-size: .95rem; text-align: center; }
.bulle.vue { transform: translate(-50%, 0); visibility: visible; transition: transform .3s ease; }

.bloc.fiction { border-left: 4px solid var(--or); }

@media (prefers-reduced-motion: reduce) {
  .porte { transition: none; }
  .fenetre.du-jour:not(.ouverte) .porte, .du-jour .interieur .action, .fleche { animation: none; }
  .etincelle { display: none; }
}

/* Repos (W1540, batterie) : après 20 s sans toucher ni défiler, calendrier.js met « repos » sur <body> :
 * les animations en boucle s'arrêtent en position de repos (sinon tout l'écran est redessiné 60 fois par seconde). Un toucher les relance. */
body.repos .fleche, body.repos .fenetre.du-jour:not(.ouverte) .porte, body.repos .du-jour .interieur .action, body.repos .case.ouvert.pret a { animation: none; }
/* Hors de l'écran (W1549) : la flèche de l'accueil et la porte du jour se mettent en pause (calendrier.js, IntersectionObserver). */
.hors-vue .fleche, .fenetre.hors-vue .porte, .fenetre.hors-vue .interieur .action { animation-play-state: paused; }
/* W1069 : lien vers mentions/ (audit W1517), assez grand pour le doigt */
.pied-lien { margin-top: 6px; }
.pied-lien a { display: inline-block; min-height: 44px; padding: 12px 10px; box-sizing: border-box; }
