/* =====================================================================
   Lautrec en fête · Calendrier de l'avent
   Mise en page : mobile d'abord, une colonne centrée, grille de 3 cases
   (4 sur grand écran). Deux pistes de design : data-style="nuit" | "jour".
   Couleurs tirées du logo 2024.
   ===================================================================== */

:root {
  /* Couleurs du logo */
  --jaune: #FFDD00;
  --jaune-fonce: #F4B400;
  --vert-fonce: #0B7A3E;
  --vert-sapin: #0a3a22;
  --vert-prairie: #4DB52E;
  --rouge-oc: #C8102E;
  --corail: #F07A5A;
  --peche: #F4A06B;
  --canard: #2C6E6A;
  --turquoise: #7EC8C8;
  --encre: #1f2418;
  --creme: #FFFBE6;

  /* Piste « nuit » par défaut */
  --fond: var(--vert-sapin);
  --fond-2: #062616;
  --texte: #FFF8D6;
  --texte-doux: #cfe3c6;
  --titre: var(--jaune);
  --colline-fond: #e9f2ee;
  --colline: #ffffff;
  --sol: #f4f8f6;
  --flocon: 255, 255, 255;

  --police-titre: "Lilita One", "Arial Rounded MT Bold", "Arial Black", system-ui, sans-serif;
  --police-texte: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --police-script: "Pacifico", "Brush Script MT", cursive;

  --bord-dessin: 255px 18px 225px 18px / 18px 225px 18px 255px;
  color-scheme: dark;
}

:root[data-style="jour"] {
  --fond: var(--jaune);
  --fond-2: #ffe94d;
  --texte: #0B4F2A;
  --texte-doux: #31623f;
  --titre: var(--vert-fonce);
  --colline-fond: var(--vert-prairie);
  --colline: #ffffff;
  --sol: #f7fbf8;
  --flocon: 255, 255, 255;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background:
    radial-gradient(120% 900px at 50% 0%, var(--fond) 0%, var(--fond-2) 100%),
    var(--fond);
  color: var(--texte);
  font-family: var(--police-texte);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

:root[data-style="jour"] body {
  background:
    radial-gradient(120% 900px at 50% 0%, #fff6a8 0%, var(--jaune) 60%, #ffd000 100%),
    var(--jaune);
}

#neige {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* ---------- Guirlande lumineuse ---------- */
.guirlande {
  height: 46px;
  position: relative;
  z-index: 2;
  overflow: hidden;
}
.guirlande svg { display: block; width: 100%; height: 46px; }
.guirlande .fil { fill: none; stroke: #9fbf98; stroke-width: 2; }
:root[data-style="jour"] .guirlande .fil { stroke: #0B4F2A; }
.guirlande .culot { fill: #3b4a35; }
.guirlande .ampoule {
  stroke: rgba(0,0,0,.35); stroke-width: 1;
  animation: scintille 2.4s ease-in-out infinite;
}
@keyframes scintille {
  0%, 100% { opacity: 1; filter: drop-shadow(0 0 5px currentColor); }
  50% { opacity: .55; filter: none; }
}

/* ---------- En-tête ---------- */
.entete {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  max-width: 640px;
  margin: 0 auto;
  padding-block: 4px 0;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.logo {
  width: 108px; height: auto;
  flex: none;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.35));
  transform: rotate(-4deg);
}
.entete-texte { min-width: 0; }
.surtitre {
  margin: 0;
  font-weight: 800;
  font-size: .92rem;
  line-height: 1.25;
  color: var(--texte-doux);
  text-wrap: balance;
}
h1 {
  margin: 2px 0 0;
  font-family: var(--police-titre);
  font-weight: 400;
  font-size: clamp(2rem, 9vw, 3.2rem);
  line-height: .98;
  color: var(--titre);
  text-shadow: 3px 3px 0 var(--encre);
  text-wrap: balance;
}
:root[data-style="jour"] h1 { text-shadow: 3px 3px 0 #fff; }
.devise {
  margin: 6px 0 0;
  font-family: var(--police-script);
  font-size: 1.05rem;
  color: var(--texte);
}

/* ---------- Fanions ---------- */
.fanions { height: 40px; margin-top: 10px; position: relative; z-index: 2; }
.fanions svg { display: block; width: 100%; height: 40px; }
.fanions .corde { fill: none; stroke: #20301f; stroke-width: 1.6; }
:root[data-style="nuit"] .fanions .corde { stroke: #cfe3c6; }
.fanions .fanion { stroke: rgba(0,0,0,.4); stroke-width: 1; stroke-linejoin: round; }

/* ---------- Contenu ---------- */
.contenu {
  position: relative;
  z-index: 2;
  max-width: 640px;
  margin: 0 auto;
  padding-block: 8px 24px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.bandeau {
  margin: 0 auto 18px;
  font-size: .95rem;
  max-width: 34em;
  text-align: center;
  font-weight: 700;
  color: var(--texte);
  text-wrap: balance;
}
.bandeau strong { color: var(--titre); }

/* ---------- Grille des cases ---------- */
.grille {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.grille > li { min-width: 0; }

.case {
  --c: var(--rouge-oc);
  --c-texte: #fff;
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1.08;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--c-texte);
  cursor: pointer;
  perspective: 700px;
  border-radius: var(--bord-dessin);
  touch-action: manipulation;
}
.case.large { aspect-ratio: auto; height: 100%; min-height: 120px; }

/* Le « fond » de la case, visible quand la porte s'ouvre */
.case-fond {
  position: absolute; inset: 0;
  border-radius: var(--bord-dessin);
  background:
    radial-gradient(circle at 50% 40%, #fff6b0 0%, #FFDD00 45%, #F4B400 100%);
  border: 3px solid var(--encre);
  display: grid; place-items: center;
  color: var(--encre);
  overflow: hidden;
}
.case-fond svg { width: 46%; height: 46%; opacity: .85; }

/* La « porte » (face avant de la case) */
.case-porte {
  position: absolute; inset: 0;
  border-radius: var(--bord-dessin);
  background: var(--c);
  border: 3px solid var(--encre);
  box-shadow: 4px 5px 0 var(--encre);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transform-origin: 0 50%;
  transition: transform .7s cubic-bezier(.3,1.4,.5,1), box-shadow .2s;
  backface-visibility: hidden;
  overflow: hidden;
}
.case-porte::before { /* couture façon papier découpé */
  content: "";
  position: absolute; inset: 6px;
  border: 2px dashed rgba(255,255,255,.45);
  border-radius: var(--bord-dessin);
  pointer-events: none;
}
.case-porte::after { /* neige sur le haut de la case */
  content: "";
  position: absolute; left: -3px; right: -3px; top: -3px;
  height: 16px;
  background:
    radial-gradient(circle at 10% 0, #fff 9px, transparent 10px),
    radial-gradient(circle at 32% 0, #fff 11px, transparent 12px),
    radial-gradient(circle at 55% 0, #fff 8px, transparent 9px),
    radial-gradient(circle at 76% 0, #fff 12px, transparent 13px),
    radial-gradient(circle at 96% 0, #fff 9px, transparent 10px);
  pointer-events: none;
}
.case-numero {
  font-family: var(--police-titre);
  font-size: clamp(2.1rem, 11vw, 3rem);
  line-height: 1;
  text-shadow: 2px 2px 0 rgba(0,0,0,.35);
}
.case-icone { width: 28%; height: auto; opacity: .9; }
.case-icone svg, .case-icone { display: block; }
.case-etiquette {
  font-weight: 800;
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .9;
}
.case.large .case-numero { font-size: 3.4rem; }
.case.large .case-porte { flex-direction: row; gap: 14px; }
.case.large .case-icone { width: 54px; }

.case:focus-visible { outline: 3px solid var(--texte); outline-offset: 4px; }
.case:active .case-porte { transform: translate(2px, 2px); box-shadow: 2px 3px 0 var(--encre); }

/* Aujourd'hui */
.case.aujourdhui .case-porte {
  animation: appel 1.8s ease-in-out infinite;
}
.case.aujourdhui::after {
  content: "Aujourd'hui";
  position: absolute; left: 50%; bottom: -9px;
  transform: translateX(-50%) rotate(-3deg);
  background: var(--creme);
  color: var(--rouge-oc);
  border: 2px solid var(--encre);
  border-radius: 999px;
  padding: 0 8px;
  font-weight: 800;
  font-size: .66rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
  z-index: 3;
}
@keyframes appel {
  0%, 100% { transform: rotate(0); box-shadow: 4px 5px 0 var(--encre), 0 0 0 0 rgba(255,221,0,.0); }
  50% { transform: rotate(-2deg) scale(1.03); box-shadow: 4px 5px 0 var(--encre), 0 0 22px 6px rgba(255,221,0,.55); }
}

/* Verrouillée */
.case.verrouillee { cursor: not-allowed; }
.case.verrouillee .case-porte { filter: saturate(.55) brightness(.82); }
.case.verrouillee .case-icone { opacity: .55; }
.case-cadenas {
  position: absolute; right: 8px; bottom: 8px;
  width: 20px; height: 20px;
  color: #fff; opacity: .85;
}
.case.secoue .case-porte { animation: secoue .4s; }
@keyframes secoue {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-5px) rotate(-2deg); }
  75% { transform: translateX(5px) rotate(2deg); }
}

/* Déjà ouverte : la porte reste entrouverte */
.case.ouverte .case-porte { transform: rotateY(-62deg); box-shadow: 1px 2px 0 var(--encre); }
.case.ouvre .case-porte { transform: rotateY(-105deg); }
.case.ouverte .case-fond::after {
  content: "Revoir";
  position: absolute; right: 6px; bottom: 6px;
  font-weight: 800; font-size: .62rem; text-transform: uppercase; letter-spacing: .06em;
}

/* Mode grattage : la case ouverte affiche un ticket gratté */
[data-ouverture="grattage"] .case.ouverte .case-porte { transform: none; }
[data-ouverture="grattage"] .case.ouverte .case-porte::before { border-style: solid; border-color: rgba(255,255,255,.8); }
[data-ouverture="grattage"] .case.ouverte .case-etiquette::before { content: "✓ "; }

/* ---------- Pied de page ---------- */
.pied { position: relative; z-index: 2; margin-top: 18px; }
.scene { display: block; width: 100%; height: auto; }
.scene .trait, .scene .trait * { stroke: var(--encre); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.scene .colline-fond { fill: var(--colline-fond); }
.scene .colline { fill: var(--colline); stroke: none; }
.scene .sol { fill: var(--sol); }
.scene .mur { fill: #e7d9a6; }
.scene .toit { fill: #3a3a3a; }
.scene .ailes path { fill: none; stroke: var(--encre); stroke-width: 3; }
.scene .ailes { transform-box: fill-box; transform-origin: center; animation: tourne 14s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
.scene .fut { fill: #c9d0d4; }
.scene .fut-cercle { fill: none; }
.scene .fut-haut { fill: #eef1f3; }
.scene .bonnet { fill: var(--rouge-oc); }
.scene .bonnet-blanc { fill: #fff; }
.scene .neige-toit { fill: #fff; }
.scene .mousse { fill: #fff; }
.scene .biere { fill: var(--jaune-fonce); }
.scene .etincelle { fill: none; stroke: var(--jaune) !important; stroke-width: 2.5 !important; }
.scene .notes path { fill: none; }
.scene .notes circle { fill: var(--encre); }
.pied-texte {
  background: var(--sol);
  color: #22432c;
  text-align: center;
  padding-block: 0 calc(22px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  margin-top: -2px;
}
.pied-texte p { margin: 0; }
.pied-texte .petit { font-size: .85rem; opacity: .8; margin-top: 4px; }

/* ---------- Fenêtre (carte) ---------- */
.carte {
  border: 0; padding: 0;
  background: transparent;
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  color: var(--encre);
  overflow: visible;
}
.carte::backdrop { background: rgba(5, 25, 14, .72); backdrop-filter: blur(3px); }
.carte[open] .carte-cadre { animation: apparait .45s cubic-bezier(.3,1.5,.5,1); }
@keyframes apparait { from { transform: scale(.6) rotate(-6deg); opacity: 0; } }
.carte-cadre {
  position: relative;
  background: var(--creme);
  border: 3px solid var(--encre);
  border-radius: 22px 10px 24px 12px / 12px 24px 10px 22px;
  box-shadow: 6px 8px 0 var(--encre);
  padding: 18px 16px 16px;
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.carte-cadre::before { /* petite guirlande de fanions en haut de la carte */
  content: "";
  position: absolute; left: 16px; right: 16px; top: -3px; height: 14px;
  background: repeating-linear-gradient(90deg,
    var(--rouge-oc) 0 18px, transparent 18px 22px,
    var(--jaune) 22px 40px, transparent 40px 44px,
    var(--canard) 44px 62px, transparent 62px 66px,
    var(--corail) 66px 84px, transparent 84px 88px);
  clip-path: polygon(0 0, 100% 0, 100% 40%, 0 40%);
}
.carte-fermer {
  position: absolute; top: -14px; right: -12px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 3px solid var(--encre);
  background: var(--rouge-oc);
  color: #fff;
  font-size: 1.6rem; line-height: 1;
  cursor: pointer;
  box-shadow: 2px 3px 0 var(--encre);
  z-index: 4;
}
.carte-date {
  margin: 0;
  font-weight: 800;
  font-size: .78rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--vert-fonce);
}

.ticket {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  flex: 1 1 auto;
}
.ticket.cache { min-height: 240px; max-height: 58dvh; }
.ticket.devoile { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.ticket-contenu { padding: 4px 2px 6px; }
.ticket-contenu h2 {
  margin: 0 0 8px;
  font-family: var(--police-titre);
  font-weight: 400;
  font-size: 1.7rem;
  line-height: 1.05;
  color: var(--vert-fonce);
  text-wrap: balance;
}
.ticket-contenu p { margin: 0 0 10px; }
.ticket-contenu strong { color: var(--rouge-oc); }
.ticket-contenu figure { margin: 4px 0 12px; }
.ticket-contenu img {
  display: block; width: 100%; max-width: 100%; height: auto; max-height: 46dvh;
  object-fit: contain;
  border-radius: 10px;
  background: #fff3a6;
}
.ticket-contenu figcaption { font-size: .82rem; color: #4b5a45; margin-top: 4px; font-style: italic; }
.video {
  position: relative; width: 100%; max-width: 100%; aspect-ratio: 16 / 9;
  border-radius: 10px; overflow: hidden; background: var(--encre); margin: 4px 0 12px;
}
.video iframe, .video video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-attente {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  color: var(--jaune); font-weight: 800; padding: 12px;
}
.video-attente span { display: block; font-size: 2.4rem; line-height: 1; }

.grattoir {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  touch-action: none;
  cursor: grab;
  transition: opacity .6s;
}
.grattoir.fini { opacity: 0; pointer-events: none; }
.grattoir[hidden] { display: none; }

.carte-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.carte-actions .bouton { flex: 1 1 140px; }
.bouton {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px;
  padding: 8px 16px;
  border: 3px solid var(--encre);
  border-radius: 999px;
  background: var(--vert-fonce);
  color: #fff;
  font: 800 .95rem var(--police-texte);
  text-decoration: none;
  box-shadow: 2px 3px 0 var(--encre);
  cursor: pointer;
}
.bouton:active { transform: translate(2px, 2px); box-shadow: 0 1px 0 var(--encre); }
.bouton:focus-visible { outline: 3px solid var(--rouge-oc); outline-offset: 2px; }
.bouton-secondaire { background: var(--jaune); color: var(--encre); }
.bouton-lien { background: var(--rouge-oc); margin-top: 4px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 140%);
  max-width: calc(100vw - 32px);
  background: var(--creme);
  color: var(--encre);
  border: 3px solid var(--encre);
  border-radius: 16px;
  box-shadow: 3px 4px 0 var(--encre);
  padding: 10px 16px;
  font-weight: 800;
  text-align: center;
  z-index: 50;
  visibility: hidden;
  transition: transform .35s cubic-bezier(.3,1.4,.5,1), visibility 0s .35s;
}
.toast.visible { transform: translate(-50%, 0); visibility: visible; transition: transform .35s cubic-bezier(.3,1.4,.5,1); }

/* ---------- Confettis ---------- */
.confetti {
  position: fixed; top: 0; left: 0;
  width: 9px; height: 14px;
  z-index: 60; pointer-events: none;
  border-radius: 2px;
}

/* ---------- Barre d'aperçu (uniquement en mode ?apercu) ---------- */
.apercu {
  position: sticky; top: env(safe-area-inset-top, 0px);
  z-index: 40;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  background: #111; color: #fff;
  font: 700 .8rem var(--police-texte);
  padding-block: 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.apercu b { color: var(--jaune); }
.apercu label { display: inline-flex; align-items: center; gap: 6px; }
.apercu select, .apercu input { font: inherit; background: #222; color: #fff; border: 1px solid #555; border-radius: 6px; padding: 3px 6px; }
.apercu button { font: inherit; background: var(--jaune); color: #111; border: 0; border-radius: 6px; padding: 4px 8px; cursor: pointer; }

/* ---------- Grand écran ---------- */
@media (min-width: 700px) {
  .entete, .contenu { max-width: 860px; }
  .grille { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
  .logo { width: 150px; }
  .case-numero { font-size: 3.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Réseaux sociaux (pied de page) ---------- */
.reseaux { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 12px !important; }
.reseau {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 6px 16px 6px 10px;
  border: 3px solid var(--encre); border-radius: 999px;
  background: var(--vert-fonce); color: #fff;
  font-weight: 800; text-decoration: none;
  box-shadow: 2px 3px 0 var(--encre);
}
.reseau svg { width: 24px; height: 24px; }
.reseau:nth-child(2) { background: var(--rouge-oc); }
.reseau:active { transform: translate(2px, 2px); box-shadow: 0 1px 0 var(--encre); }
.reseau:focus-visible { outline: 3px solid var(--rouge-oc); outline-offset: 2px; }

/* Calques au-dessus du fond des cases (utile aux animations spéciales) */
.case-numero { position: relative; z-index: 1; }
.case-icone, .case-etiquette, .case-cadenas { position: relative; z-index: 1; transition: opacity .25s; }

/* ---------- Questions fréquentes ---------- */
.faq { margin-top: 34px; }
.faq h2 {
  margin: 0 0 12px;
  text-align: center;
  font-family: var(--police-titre);
  font-weight: 400;
  font-size: 1.8rem;
  color: var(--titre);
  text-shadow: 2px 2px 0 #fff;
}
:root[data-style="nuit"] .faq h2 { text-shadow: 2px 2px 0 var(--encre); }
.faq-liste { display: flex; flex-direction: column; gap: 10px; }
.faq-item {
  background: var(--creme);
  color: var(--encre);
  border: 3px solid var(--encre);
  border-radius: 16px 8px 18px 10px / 10px 18px 8px 16px;
  box-shadow: 3px 4px 0 var(--encre);
}
.faq-item summary {
  list-style: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 48px;
  padding: 10px 14px;
  font-weight: 800;
  color: var(--vert-fonce);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  flex: none;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border: 2px solid var(--encre);
  border-radius: 50%;
  background: var(--jaune);
  color: var(--encre);
  font: 400 1.2rem/1 var(--police-titre);
  transition: transform .25s;
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item summary:focus-visible { outline: 3px solid var(--rouge-oc); outline-offset: 2px; border-radius: 12px; }
.faq-item p { margin: 0 14px 12px; }

/* ---------- Étiquette de catégorie dans une case ouverte ---------- */
.categorie {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border: 2px solid var(--encre);
  border-radius: 999px;
  font-size: .68rem;
  letter-spacing: .06em;
  color: var(--encre);
  vertical-align: 1px;
}
.categorie-annonce { background: var(--vert-prairie); color: #fff; }
.categorie-souvenir { background: #E85BB0; color: #fff; }
.categorie-jeu { background: var(--jaune); }
