/* La feuille de style de l'épisode — palette commune de la série astronomie. */

:root {
  --bg: #0b1020;
  --bg2: #0e1530;
  --surface: #121a33;
  --surface-2: #1c2540;
  --border: #26304f;
  --text: #e9edf8;
  --muted: #9aa5c3;
  --sun: #ffcf5c;
  --sun-deep: #ff9f1c;
  --rose: #ff6b9d;
  --teal: #46c2a5;
  --violet: #a98bff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: radial-gradient(circle at 20% -10%, var(--bg2), var(--bg) 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
  padding: 20px 14px 40px;
}

main, header.entete, footer.pied-serie {
  max-width: 1060px;
  margin: 0 auto;
}

/* ---------- En-tête ---------- */

.entete { text-align: center; padding: 12px 0 26px; }

.kicker {
  color: var(--violet);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.entete h1 {
  font-size: 2rem;
  margin: 10px 0 12px;
  color: var(--sun);
}

.tagline {
  color: var(--muted);
  max-width: 620px;
  margin: 0 auto;
  font-size: 1.05rem;
}

/* ---------- Cartes ---------- */

.carte {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 18px 18px 16px;
  margin-bottom: 18px;
  box-shadow: 0 12px 30px rgba(2, 5, 15, 0.35);
}

.carte h2 { font-size: 1.15rem; }

.sous-titre { color: var(--muted); font-size: 0.92rem; margin: 4px 0 12px; }

/* ---------- Les deux vues ---------- */

.vues { display: block; }

@media (min-width: 880px) {
  .vues {
    display: grid;
    grid-template-columns: 1fr 1.25fr;
    gap: 18px;
    align-items: stretch;
  }
  .vues .carte { margin-bottom: 18px; }
}

.cadre-canvas {
  position: relative;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  background: #070b17;
  border: 1px solid var(--border);
}

/* Hauteur par ratio, avec repli pour les vieux mobiles. */
.cadre-canvas { height: 0; padding-bottom: 78%; }
.carte-hublot .cadre-canvas { padding-bottom: 92%; }

@supports (aspect-ratio: 1 / 1) {
  .cadre-canvas { height: auto; padding-bottom: 0; aspect-ratio: 9 / 7; }
  .carte-hublot .cadre-canvas { aspect-ratio: 13 / 12; }
}

.cadre-canvas canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.carte-orbite canvas { cursor: grab; }
.carte-orbite canvas.attrape { cursor: grabbing; }

.astuce {
  text-align: center;
  color: var(--rose);
  font-weight: 600;
  margin-top: 10px;
}

.phrase-soir {
  text-align: center;
  margin-top: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--sun);
  min-height: 1.6em;
}

/* ---------- Curseur maître ---------- */

.carte-curseur h2 { margin-bottom: 6px; }

.piste-emojis {
  display: flex;
  justify-content: space-between;
  font-size: 1.3rem;
  padding: 4px 2px 0;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 34px;
  background: transparent;
  margin: 2px 0 4px;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--bg2), var(--violet) 25%, var(--sun) 50%, var(--violet) 75%, var(--bg2));
  border: 1px solid var(--border);
}

input[type="range"]::-moz-range-track {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--bg2), var(--violet) 25%, var(--sun) 50%, var(--violet) 75%, var(--bg2));
  border: 1px solid var(--border);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--violet);
  margin-top: -10px;
  box-shadow: 0 2px 8px rgba(2, 5, 15, 0.6);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--violet);
  cursor: pointer;
}

input[type="range"]:focus-visible { outline: 3px solid var(--rose); outline-offset: 4px; border-radius: 999px; }

.legende-curseur { color: var(--muted); font-size: 0.9rem; text-align: center; }

/* ---------- Scénarios ---------- */

.titre-avec-bouton {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.bouton-son {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 1rem;
  padding: 8px 14px;
  cursor: pointer;
}

.bouton-son[aria-pressed="true"] { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(70, 194, 165, 0.35); }

.bouton-ecouter { font-weight: 600; }

.menu-voix {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px;
  max-width: 200px;
  font-size: 0.9rem;
}

.boutons-voix { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.grille-scenarios {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 720px) {
  .grille-scenarios { grid-template-columns: repeat(4, 1fr); }
}

.bouton-scenario {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text);
  padding: 12px 10px;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  -webkit-transform: translateZ(0);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.bouton-scenario:hover { border-color: var(--violet); }

.bouton-scenario[aria-pressed="true"] {
  border-color: var(--sun);
  background: rgba(255, 207, 92, 0.08);
}

.bouton-scenario .emoji { font-size: 1.8rem; display: block; }

.bouton-scenario .titre { font-weight: 700; display: block; margin-top: 4px; font-size: 0.95rem; }

.bouton-scenario .sous { color: var(--muted); font-size: 0.8rem; display: block; }

.histoire {
  margin-top: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--sun);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 1rem;
}

/* ---------- Explication ---------- */

.carte-explication p { margin-bottom: 10px; font-size: 1.02rem; }

.conseil-voix { color: var(--muted); font-size: 0.88rem; }

/* Le résumé repliable ne sert que sur mobile : sur ordinateur il est masqué
 * et main.js garde la boîte ouverte (le titre reste celui de la rangée). */
.resume-explication { display: none; }

@media (max-width: 879px) {
  .carte-explication { padding: 6px 18px 8px; }
  .carte-explication[open] { padding-bottom: 16px; }

  .resume-explication {
    display: block;
    cursor: pointer;
    padding: 12px 0;
    list-style: none;
  }
  .resume-explication::-webkit-details-marker { display: none; }
  .resume-explication::before { content: '▸ '; color: var(--sun); font-weight: 700; }
  .carte-explication[open] .resume-explication::before { content: '▾ '; }
  .resume-explication h2 { display: inline; font-size: 1.1rem; }

  .indice-pli {
    display: block;
    margin: 3px 0 0 1.4em;
    font-size: 0.8rem;
    color: var(--muted);
  }

  /* Sur mobile, le titre vit dans le résumé : celui de la rangée disparaît. */
  .carte-explication .titre-avec-bouton h2 { display: none; }
}

/* ---------- Jeu ---------- */

.bouton-jeu {
  background: var(--rose);
  color: #240a14;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  padding: 9px 20px;
  font-size: 1rem;
  cursor: pointer;
  font-family: inherit;
}

.bouton-jeu:hover { background: #ff87b0; }

.consigne-jeu { color: var(--muted); }

.vues-jeu {
  display: block;
  margin: 12px 0;
}

.vues-jeu .cadre-canvas { margin-bottom: 12px; }

.vues-jeu .cadre-canvas { height: 0; padding-bottom: 78%; }

@supports (aspect-ratio: 1 / 1) {
  .vues-jeu .cadre-canvas { height: auto; padding-bottom: 0; aspect-ratio: 9 / 7; }
}

@media (min-width: 720px) {
  .vues-jeu {
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    gap: 12px;
  }
  .vues-jeu .cadre-canvas { margin-bottom: 0; }
}

#canvas-orbite-jeu { cursor: grab; }
#canvas-orbite-jeu.attrape { cursor: grabbing; }

.defi {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 8px 0;
  color: var(--teal);
}

.bravo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--sun);
  margin: 8px 0;
}

/* ---------- Le médaillon flottant (mobile) ---------- */

.medaillon-lune {
  position: fixed;
  right: 14px;
  top: 14px;
  width: 60px;
  height: 60px;
  padding: 0;
  border-radius: 50%;
  /* Anneau doré (la couleur du récit du soir) : le violet reste réservé à la
   * Lune qu'on attrape dans la vue de l'espace. */
  border: 2px solid var(--sun);
  background: #070b17;
  box-shadow: 0 6px 18px rgba(2, 5, 15, 0.65);
  cursor: pointer;
  z-index: 10;
}

.medaillon-lune canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

/* Jamais sur ordinateur : le hublot y est toujours à portée d'œil. */
@media (min-width: 880px) {
  .medaillon-lune { display: none !important; }
}

/* ---------- Le jeu sur mobile : une seule vue, tout tient à l'écran ---------- */

@media (max-width: 879px) {
  .vues-jeu > .cadre-canvas:last-child { display: none; }
  .carte-jeu { padding: 14px 14px 12px; }
  .consigne-jeu { font-size: 0.88rem; }
  .defi { font-size: 1.15rem; margin: 6px 0; }
  .bravo { font-size: 1.1rem; margin: 6px 0; }
  .vues-jeu { margin: 10px 0; }

  /* La scène du geste-signature en carré : l'orbite gagne ~27 % de rayon,
   * les petits doigts visent plus large. */
  .carte-orbite .cadre-canvas,
  .vues-jeu .cadre-canvas { padding-bottom: 100%; }

  @supports (aspect-ratio: 1 / 1) {
    .carte-orbite .cadre-canvas,
    .vues-jeu .cadre-canvas { padding-bottom: 0; aspect-ratio: 1 / 1; }
  }

  /* Cibles tactiles généreuses (public : des doigts de 5 ans). */
  .bouton-son,
  .bouton-jeu { min-height: 44px; }

  input[type="range"] { height: 44px; }

  input[type="range"]::-webkit-slider-thumb {
    width: 36px;
    height: 36px;
    margin-top: -13px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 32px;
    height: 32px;
  }

  .pied-serie ul { gap: 2px 12px; }
  .pied-serie a { display: inline-block; padding: 8px 6px; }

  /* Le hublot se compacte en bandeau paysage (la Lune au-dessus du jardin) :
   * la vue de l'espace arrive plus tôt sous le pouce, et le médaillon-fenêtre
   * prend le relais dès que le bandeau sort de l'écran. */
  .carte-hublot { padding: 12px 14px 10px; }

  .carte-hublot h2 { font-size: 1rem; }
  .carte-hublot .sous-titre { margin: 2px 0 8px; }

  .carte-hublot .cadre-canvas { padding-bottom: 46%; }

  @supports (aspect-ratio: 1 / 1) {
    .carte-hublot .cadre-canvas { padding-bottom: 0; aspect-ratio: 13 / 6; }
  }

  .phrase-soir { font-size: 0.95rem; margin-top: 8px; min-height: 1.5em; }
}

/* ---------- Note aux parents ---------- */

.note-parents {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px 18px;
  margin-bottom: 18px;
  color: var(--muted);
}

.note-parents summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
  font-size: 1rem;
}

.note-parents ul { margin: 12px 0 4px 20px; font-size: 0.94rem; }

.note-parents li { margin-bottom: 8px; }

.note-parents strong { color: var(--text); }

.note-parents a { color: var(--violet); }

/* ---------- Pied de série ---------- */

.pied-serie {
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
  padding-top: 8px;
}

.pied-serie p { font-weight: 700; margin-bottom: 6px; }

.pied-serie ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 18px;
}

.pied-serie a { color: var(--violet); }

.pied-serie li[aria-current="page"] { color: var(--sun); font-weight: 600; }

/* ---------- Divers ---------- */

/* Pas de flash gris au tap, pas de texte sélectionné en tapotant vite. */
button, summary {
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.bouton-scenario:active { border-color: var(--violet); }
.bouton-son:active { border-color: var(--violet); }
.bouton-jeu:active { background: #ff87b0; }

[hidden] { display: none !important; }

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