@font-face { font-family: "Andika"; font-weight: 400; font-display: swap; src: url(fonts/andika-400.woff2) format("woff2"); }
@font-face { font-family: "Andika"; font-weight: 700; font-display: swap; src: url(fonts/andika-700.woff2) format("woff2"); }
@font-face { font-family: "Grandstander"; font-weight: 600 800; font-display: swap; src: url(fonts/grandstander-800.woff2) format("woff2"); }

:root {
  --nuit: #1B2462;
  --nuit-2: #273383;
  --encre: #2A2350;
  --papier: #FFFDF7;
  --bois: #D48A45;
  --bois-fonce: #9A5A26;
  --soleil: #FFC93C;
  --fraise: #FF6F91;
  --menthe: #36C9A0;
  --orange: #FF9F43;
  --lilas: #9B87F5;
  --texte-nuit: #F3F1FF;
  --doux-nuit: #B9C0F0;
  --r-carte: 22px;
  --ombre-papier: 0 3px 0 rgba(20, 16, 60, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 72% 9%, #fff9 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 88% 32%, #fff6 50%, transparent 51%),
    radial-gradient(1px 1px at 34% 7%, #fff7 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 26%, #fff5 50%, transparent 51%),
    linear-gradient(180deg, var(--nuit) 0%, #222C78 60%, #2B2F7A 100%);
  background-attachment: fixed;
  color: var(--texte-nuit);
  font: 400 1.125rem/1.5 "Andika", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 4px solid var(--soleil); outline-offset: 3px; border-radius: 12px; }
[hidden] { display: none !important; }

.ecran {
  max-width: 1100px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom));
}
.marque {
  font: 800 clamp(2.2rem, 7vw, 3.6rem)/1 "Grandstander", "Andika", sans-serif;
  margin: 0;
  color: var(--soleil);
  letter-spacing: .01em;
  text-shadow: 0 4px 0 var(--bois-fonce);
}
.tete { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; min-height: 64px; }
.petit { color: var(--doux-nuit); font-size: 1rem; text-align: center; margin: .3rem 0; }

/* ---------- Le théâtre de papier : cadre en bois, fond de nuit, cartes découpées ---------- */
.theatre {
  position: relative;
  border-radius: 28px;
  padding: 14px;
  background: linear-gradient(180deg, #E09A55, var(--bois) 40%, #BE7735);
  box-shadow: inset 0 -6px 0 var(--bois-fonce), 0 10px 0 rgba(10, 10, 40, .35);
}
.theatre::before { /* les deux battants du kamishibaï, ouverts */
  content: "";
  position: absolute;
  inset: 22px -10px;
  border-left: 10px solid var(--bois-fonce);
  border-right: 10px solid var(--bois-fonce);
  border-radius: 10px;
  pointer-events: none;
}
.scene {
  position: relative;
  min-height: 150px;
  border-radius: 18px;
  background:
    radial-gradient(2px 2px at 20% 25%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 80% 20%, #fffc 50%, transparent 51%),
    radial-gradient(2px 2px at 60% 12%, #fffa 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 40% 40%, #fff8 50%, transparent 51%),
    radial-gradient(120% 70% at 50% 110%, #3C4AB0 0%, transparent 60%),
    linear-gradient(180deg, #151C52, #24308A);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(6px, 2vw, 18px);
  padding: 18px 12px 16px;
  overflow: hidden;
}
.scene::after { /* le plancher */
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 16px;
  background: linear-gradient(180deg, #6B3F1C, #4E2C12);
}
.theatre-grand .scene { min-height: clamp(220px, 42vh, 380px); }
.decoupe {
  position: relative;
  z-index: 1;
  width: clamp(84px, 17vw, 170px);
  aspect-ratio: 1;
  margin-bottom: 8px;
  border-radius: 50% 50% 18px 18px;
  background: var(--papier);
  padding: 7px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .3);
  transform: rotate(var(--r, -3deg));
  transition: transform .35s cubic-bezier(.3, 1.6, .5, 1);
}
.decoupe img { width: 100%; height: 100%; object-fit: cover; border-radius: 50% 50% 13px 13px; display: block; }
.scene.avec-decor { background-size: cover; background-position: center 70%; }
.scene.avec-decor::before { /* un peu de nuit en haut et de pénombre en bas : les découpages ressortent */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, #151C5299 0%, transparent 35%, transparent 70%, #151C5266 100%);
}
.scene.rideau { animation: rideau .7s ease-out both; }
@keyframes rideau { from { filter: brightness(.2) saturate(.3); } }
.theatre-grand .decoupe, .theatre-accueil .decoupe { width: clamp(92px, 25vw, 210px); }
.theatre-grand .scene[data-n="4"] .decoupe, .theatre-grand .scene[data-n="5"] .decoupe { width: clamp(70px, 19vw, 180px); }
.decoupe.objet { width: clamp(64px, 13vw, 130px) !important; }
.decoupe.entre { animation: entree .5s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes entree { from { transform: translateY(120%) rotate(0); } }
.scene-vivante .decoupe, .joue .decoupe { animation: danse 2.4s ease-in-out infinite; animation-delay: calc(var(--i, 0) * -.6s); }
@keyframes danse { 50% { transform: translateY(-10px) rotate(calc(var(--r, -3deg) * -1)); } }
.scene-vide {
  position: relative; z-index: 1; align-self: center;
  color: var(--doux-nuit); font: 600 1.25rem "Grandstander", sans-serif; text-align: center; margin: 0 0 12px;
}

/* ---------- Accueil ---------- */
.theatre-accueil .scene { min-height: clamp(220px, 40vh, 380px); }
.accueil-bouton { display: flex; justify-content: center; margin-top: -64px; position: relative; z-index: 3; }
.gros-bouton {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  border: 0; border-radius: 999px;
  width: clamp(170px, 36vw, 230px); aspect-ratio: 1;
  justify-content: center;
  background: var(--soleil); color: var(--encre);
  font: 800 clamp(1.15rem, 3.4vw, 1.45rem)/1.1 "Grandstander", sans-serif;
  box-shadow: 0 8px 0 #C9921A, 0 0 0 10px #FFC93C33;
  padding: 18px;
  transition: transform .12s;
}
.gros-bouton svg { width: 64px; height: 64px; }
.gros-bouton:active { transform: translateY(4px); box-shadow: 0 4px 0 #C9921A, 0 0 0 10px #FFC93C33; }
.titre-etagere { font: 800 1.6rem "Grandstander", sans-serif; margin: 34px 4px 12px; color: var(--texte-nuit); }
.etagere {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 18px;
}
.livret {
  width: 100%; border: 0; padding: 0; background: none; text-align: left;
  display: flex; flex-direction: column; gap: 8px;
}
.couverture {
  position: relative; width: 100%; aspect-ratio: 1; border-radius: 10px 18px 18px 10px;
  background: var(--papier); padding: 6px; overflow: hidden;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  box-shadow: inset 8px 0 0 var(--c, var(--fraise)), 0 6px 0 rgba(0, 0, 0, .3);
  padding-left: 14px;
}
.couverture img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.couverture.une { grid-template-columns: 1fr; }
.couverture .pastille {
  position: absolute; right: 8px; top: 8px; background: var(--soleil); color: var(--encre);
  font: 800 .95rem "Grandstander", sans-serif; border-radius: 999px; padding: 2px 10px;
}
.couverture.en-cours { opacity: .75; }
.livret-titre { font: 700 1.02rem/1.25 "Andika", sans-serif; color: var(--texte-nuit); }

/* ---------- Choisir ---------- */
.tete-choisir { justify-content: space-between; }
.rond {
  width: 64px; height: 64px; flex: none; border-radius: 50%; border: 0;
  background: var(--nuit-2); color: var(--texte-nuit); display: grid; place-items: center;
  box-shadow: 0 5px 0 #121848;
}
.rond svg { width: 34px; height: 34px; }
.rond:active { transform: translateY(3px); box-shadow: 0 2px 0 #121848; }
.rond-grand { width: 84px; height: 84px; background: var(--menthe); color: var(--encre); box-shadow: 0 6px 0 #1E8C6E; }
.rond-grand svg { width: 44px; height: 44px; }
.suite-de, .chapitre { margin: 0; font: 800 1.25rem "Grandstander", sans-serif; color: var(--soleil); }
.etapes { display: flex; gap: 10px; justify-content: center; margin: 22px 0 14px; flex-wrap: wrap; }
.etape {
  --c: var(--fraise);
  display: flex; align-items: center; gap: 8px; border: 0;
  border-radius: 999px; padding: 10px 18px 10px 12px;
  background: transparent; color: var(--texte-nuit);
  box-shadow: inset 0 0 0 3px var(--c);
  font: 800 1.15rem "Grandstander", sans-serif;
}
.etape svg { width: 34px; height: 34px; color: var(--c); }
.etape[aria-current="step"] { background: var(--c); color: var(--encre); }
.etape[aria-current="step"] svg { color: var(--encre); }
.etape .compte { min-width: 1.6em; height: 1.6em; border-radius: 999px; background: var(--papier); color: var(--encre); display: grid; place-items: center; font-size: .9rem; }
.cat-qui { --c: var(--fraise); }
.cat-ou { --c: var(--menthe); }
.cat-quoi { --c: var(--orange); }
.cat-comment { --c: var(--lilas); }

.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 42vw), 1fr)); gap: 16px; padding-bottom: 120px; }
.carte {
  --c: var(--fraise);
  position: relative; border: 0; padding: 8px 8px 10px; border-radius: var(--r-carte);
  background: var(--papier); color: var(--encre);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  box-shadow: 0 6px 0 rgba(10, 10, 40, .45);
  transition: transform .15s;
}
.carte img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: calc(var(--r-carte) - 8px); display: block; }
.carte span { font: 700 1.05rem/1.2 "Andika", sans-serif; text-align: center; }
.carte:active { transform: scale(.96); }
.carte[aria-pressed="true"] { box-shadow: 0 0 0 6px var(--c), 0 6px 0 rgba(10, 10, 40, .45); transform: rotate(-2deg); }
.carte[aria-pressed="true"]::after {
  content: ""; position: absolute; top: -12px; right: -12px; width: 44px; height: 44px; border-radius: 50%;
  background: var(--c) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='%232A2350' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/26px no-repeat;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .25);
}
.carte:disabled { opacity: .35; }
.barre-bas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: center; align-items: center; gap: 18px;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, #141A4Fee 35%);
}

/* ---------- Boutons ---------- */
.bouton {
  --c: var(--soleil); --o: #C9921A;
  border: 0; border-radius: 999px; padding: 16px 30px; min-height: 64px;
  background: var(--c); color: var(--encre);
  font: 800 1.35rem "Grandstander", sans-serif;
  box-shadow: 0 6px 0 var(--o);
  transition: transform .1s;
}
.bouton:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 var(--o); }
.bouton:disabled { filter: grayscale(.7); opacity: .5; cursor: not-allowed; }
.bouton-soleil { --c: var(--soleil); --o: #C9921A; }
.bouton-menthe { --c: var(--menthe); --o: #1E8C6E; }
.bouton-fraise { --c: var(--fraise); --o: #C2456A; }
.bouton-lilas { --c: var(--lilas); --o: #6A55C9; }
.bouton-raconte { font-size: 1.7rem; padding: 18px 44px; min-height: 84px; }
.lien { background: none; border: 0; color: var(--doux-nuit); text-decoration: underline; padding: 12px 0; font-size: 1rem; }

/* ---------- Attente ---------- */
.ciel-progres { position: absolute; left: 34px; right: 34px; top: 26px; height: 60px; pointer-events: none; }
.ciel-progres::before { content: ""; position: absolute; left: 0; right: 0; top: 30px; border-top: 4px dotted #FFFFFF55; }
.lune {
  position: absolute; top: 8px; left: 0; width: 46px; height: 46px; border-radius: 50%;
  background: var(--soleil); box-shadow: 0 0 24px #FFC93Caa, inset -10px -4px 0 #E8A91C;
  transform: translateX(-50%); transition: left 1.2s ease-out;
}
.etat-attente { text-align: center; font: 800 clamp(1.4rem, 4.5vw, 2rem) "Grandstander", sans-serif; margin: 30px 0 4px; }

/* ---------- Écoute ---------- */
.titre-histoire { text-align: center; font: 800 clamp(1.6rem, 5vw, 2.4rem)/1.15 "Grandstander", sans-serif; margin: 26px 0 18px; text-wrap: balance; }
.lecteur { display: flex; align-items: center; gap: 18px; max-width: 640px; margin: 0 auto; }
.play {
  width: 104px; height: 104px; flex: none; border-radius: 50%; border: 0;
  background: var(--soleil); color: var(--encre); display: grid; place-items: center;
  box-shadow: 0 7px 0 #C9921A, 0 0 0 10px #FFC93C2a;
}
.play svg { width: 54px; height: 54px; }
.play:active { transform: translateY(4px); box-shadow: 0 3px 0 #C9921A, 0 0 0 10px #FFC93C2a; }
.piste { flex: 1; }
.piste input { width: 100%; accent-color: var(--soleil); height: 34px; }
.temps { display: flex; justify-content: space-between; color: var(--doux-nuit); font-size: 1rem; }
.actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin: 30px 0 10px; }
.texte-parents { max-width: 68ch; margin: 30px auto 0; background: #0F154288; border-radius: 18px; padding: 6px 20px; }
.texte-parents summary { cursor: pointer; padding: 12px 0; color: var(--doux-nuit); font-weight: 700; }
.texte-parents p { margin: 0 0 .7em; line-height: 1.6; }
.texte-parents .replique { padding-left: 14px; border-left: 4px solid var(--c, var(--fraise)); }
.texte-parents .qui { font-weight: 700; color: var(--soleil); }

/* ---------- Porte ---------- */
.porte { max-width: 420px; margin: 12vh auto 0; text-align: center; }
.porte p { color: var(--doux-nuit); }
.porte form { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; text-align: left; }
.porte label { font-weight: 700; }
.porte input { font: inherit; padding: 14px 16px; border-radius: 14px; border: 3px solid var(--nuit-2); background: var(--papier); color: var(--encre); }
.erreur { color: #FFB3C4; min-height: 1.5em; margin: 0; }

@media (max-width: 560px) {
  .etape { padding: 8px 12px 8px 8px; font-size: 1rem; }
  .etape svg { width: 28px; height: 28px; }
  .play { width: 88px; height: 88px; }
  .bouton-raconte { padding: 16px 30px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
