/* ============================================================
   Polices auto-hébergées (au lieu de Google Fonts) : évite d'envoyer
   l'adresse IP du visiteur à un tiers sans consentement (RGPD).
   ============================================================ */

@font-face {
  font-family: "Baloo 2";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/baloo2-500.woff2") format("woff2");
}

@font-face {
  font-family: "Baloo 2";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/baloo2-700.woff2") format("woff2");
}

@font-face {
  font-family: "Atkinson Hyperlegible";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/atkinson-400.woff2") format("woff2");
}

@font-face {
  font-family: "Atkinson Hyperlegible";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/atkinson-700.woff2") format("woff2");
}

/* ============================================================
   Lexicobra — feuille de style partagée
   Palette inspirée du clavier orange/jaune de la Dictée Magique
   et de la mascotte cobra.
   ============================================================ */

:root {
  --cream: #FFF8EC;
  --paper: #FFFFFF;
  --ink: #3B2A1E;
  --ink-soft: #6B5744;
  --ink-faint: #9C8A78;

  --orange: #EE8A2F;
  --orange-dark: #9C4E0D;
  --yellow: #F3D250;
  --yellow-dark: #C99E1E;
  --teal: #3FAE9C;
  --teal-dark: #2C7A6D;
  --coral: #EF6C57;
  --coral-dark: #C24B39;

  --radius-block: 18px;
  --radius-control: 12px;
  --focus-ring: 3px solid #1C5FD8;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.6;
}

h1, h2, h3, .headline {
  font-family: "Baloo 2", "Atkinson Hyperlegible", sans-serif;
  font-weight: 700;
  line-height: 1.15;
  color: var(--ink);
  margin: 0 0 0.5em 0;
}

h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: 1.3rem; }

p { max-width: 62ch; }

a { color: var(--teal-dark); }

/* Lien d'évitement pour la navigation clavier */
.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  background: var(--ink);
  color: #fff;
  padding: 0.8em 1.2em;
  border-radius: 0 0 var(--radius-control) 0;
  z-index: 100;
}
.skip-link:focus {
  left: 0;
  top: 0;
}

/* Focus visible sur tous les éléments interactifs */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ---------- structure générale ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 6vw;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--ink);
}

.brand svg { width: 42px; height: 42px; flex: none; }

.brand-name {
  font-family: "Baloo 2", sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  flex-wrap: wrap;
}

.site-nav a {
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 700;
}

.site-nav a[aria-current="page"] {
  color: var(--orange-dark);
}

/* Sélecteur de tranche d'âge : pilule à bascule */
.age-switch {
  display: flex;
  gap: 0.3rem;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0.25rem;
  flex-wrap: wrap;
}

.age-switch button {
  border: none;
  background: transparent;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink-soft);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
}

.age-switch button[aria-pressed="true"] {
  background: var(--yellow);
  color: var(--ink);
}

.case-switch {
  display: flex;
  gap: 0.3rem;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0.25rem;
}

.case-switch button {
  border: none;
  background: transparent;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink-soft);
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
}

.case-switch button[aria-pressed="true"] {
  background: var(--yellow);
  color: var(--ink);
}

.switch-control {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0.4rem 0.9rem 0.4rem 0.4rem;
  background: var(--paper);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
  cursor: pointer;
}

.switch-control .switch-track {
  width: 2.6rem;
  height: 1.4rem;
  border-radius: 999px;
  background: var(--ink-faint);
  position: relative;
  flex: none;
  transition: background 0.15s ease;
}

.switch-control .switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}

.switch-control[aria-checked="true"] .switch-track { background: var(--teal-dark); }
.switch-control[aria-checked="true"] .switch-thumb { transform: translateX(1.2rem); }

.voice-settings {
  position: relative;
}

.voice-settings summary {
  list-style: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.5rem 1rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
}

.voice-settings summary::-webkit-details-marker { display: none; }

.voice-settings[open] summary {
  background: var(--yellow);
}

.voice-settings-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  z-index: 20;
  width: 280px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--radius-block);
  box-shadow: 5px 5px 0 var(--ink);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.voice-settings-hint {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0;
}

.voice-settings-panel label {
  font-weight: 700;
  font-size: 0.9rem;
}

.voice-settings-panel input[type="range"] {
  width: 100%;
}

.voice-settings-panel output {
  font-weight: 700;
  align-self: flex-end;
}

main { padding: 0 6vw; }

.static-page {
  max-width: 70ch;
  margin: 0 auto;
  padding-bottom: 4rem;
}

.site-footer {
  margin-top: 4rem;
  padding: 2rem 6vw 3rem;
  border-top: 3px solid var(--ink);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.site-footer a { color: var(--ink-soft); }

/* ---------- hero ---------- */

.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 2.5rem;
  align-items: center;
  padding: 2rem 0 3rem;
}

@media (max-width: 800px) {
  .hero { grid-template-columns: 1fr; text-align: left; }
}

.hero-copy .eyebrow {
  display: inline-block;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 700;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: "Baloo 2", sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0.85rem 1.6rem;
  border-radius: var(--radius-control);
  text-decoration: none;
  cursor: pointer;
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover, .btn:focus-visible { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }

.btn-primary { background: var(--orange); color: var(--ink); }
.btn-secondary { background: var(--paper); color: var(--ink); }

.hero-art { display: flex; justify-content: center; }
.hero-art svg { width: 100%; max-width: 340px; height: auto; }

/* ---------- grille de jeux, façon cubes de lettres ---------- */

.games-section { padding: 2rem 0 3rem; }

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.6rem;
  margin-top: 2rem;
  list-style: none;
  padding: 0;
}

.game-block {
  --block-color: var(--orange);
  background: var(--block-color);
  border: 3px solid var(--ink);
  border-radius: var(--radius-block);
  box-shadow: 5px 5px 0 var(--ink);
  padding: 1.4rem;
  transform: rotate(var(--tilt, -1.5deg));
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.game-block:nth-child(2n) { --tilt: 1.5deg; }
.game-block:nth-child(3n) { --tilt: -1deg; }

.game-block:hover, .game-block:focus-within {
  transform: rotate(0deg) translateY(-2px);
  box-shadow: 7px 7px 0 var(--ink);
}

.game-block a {
  text-decoration: none;
  color: var(--ink);
  display: block;
}

.game-block .letter-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 8px;
  font-family: "Baloo 2", sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  margin-bottom: 0.8rem;
}

.game-block h3 { margin-bottom: 0.3rem; }
.game-block p { font-size: 0.95rem; color: var(--ink); margin: 0; }

.game-block.locked {
  --block-color: #EFE7D8;
  opacity: 0.85;
}
.game-block.locked .badge-soon {
  display: inline-block;
  margin-top: 0.8rem;
  font-size: 0.85rem;
  font-weight: 700;
  background: var(--ink);
  color: var(--cream);
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
}

.game-block.premium {
  --block-color: #F3E7D6;
  border-style: dashed;
}
.game-block.premium .badge-soon {
  background: var(--orange-dark);
}

.games-subheading {
  margin-top: 3rem;
}

/* ---------- section freemium ---------- */

.plans-section { padding: 2rem 0 3rem; }

.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.6rem;
  margin-top: 2rem;
}

.plan-card {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--radius-block);
  padding: 1.6rem;
}

.plan-card.is-featured { background: #FFF3D9; }

.plan-card ul { padding-left: 1.2rem; }
.plan-card li { margin-bottom: 0.5rem; }

/* ---------- page de jeu : mot mystère ---------- */

.game-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.game-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.score-pill {
  background: var(--teal);
  color: var(--ink);
  font-weight: 700;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 2px solid var(--ink);
}

.word-display {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 2rem 0;
}

.word-display .letter-box {
  width: 2.6rem;
  height: 3.2rem;
  border-bottom: 4px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Baloo 2", sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
}

.word-display .letter-box.target-letter {
  width: 3.4rem;
  height: 4rem;
  font-size: 2.2rem;
}

.mascot-status {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  justify-content: center;
  margin: 1.5rem 0;
}

.mascot-status svg { width: 90px; height: auto; flex: none; }

@keyframes mascot-bounce {
  0% { transform: translateY(0); }
  35% { transform: translateY(-10px); }
  60% { transform: translateY(2px); }
  100% { transform: translateY(0); }
}
@keyframes mascot-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px) rotate(-4deg); }
  75% { transform: translateX(6px) rotate(4deg); }
}
@keyframes mascot-winjump {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-16px) scale(1.06); }
  55% { transform: translateY(0) scale(1); }
  75% { transform: translateY(-6px) scale(1.03); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes mascot-slump {
  0% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(4px) rotate(-3deg); }
  100% { transform: translateY(2px) rotate(-2deg); }
}

.mascot-status svg.anim-bounce { animation: mascot-bounce 0.4s ease; }
.mascot-status svg.anim-shake { animation: mascot-shake 0.35s ease; }
.mascot-status svg.anim-winjump { animation: mascot-winjump 0.7s ease; }
.mascot-status svg.anim-slump { animation: mascot-slump 0.5s ease forwards; }

#feedback-message {
  font-weight: 700;
  font-size: 1.1rem;
  min-height: 1.6em;
}

.keyboard {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 2rem;
}

.keyboard-row {
  display: grid;
  grid-template-columns: repeat(10, minmax(2.2rem, 1fr));
  gap: 0.5rem;
}

.keyboard button {
  font-family: "Baloo 2", sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  padding: 0.7rem 0;
  border-radius: var(--radius-control);
  border: 2px solid var(--ink);
  color: var(--ink);
  cursor: pointer;
}

/* Code couleur repris de l'appareil d'origine : consonnes en orange,
   voyelles (A E I O U Y) en jaune — cette couleur reste visible même une
   fois la lettre essayée, seul un anneau + un symbole indique l'état,
   pour ne jamais dépendre de la couleur seule (accessibilité). */
.keyboard button.key-consonant { background: var(--orange); }
.keyboard button.key-vowel { background: var(--yellow); }

.keyboard button:hover:not(:disabled) { filter: brightness(1.08); }

.keyboard button:disabled {
  cursor: not-allowed;
}

.keyboard button.correct {
  box-shadow: inset 0 0 0 3px var(--teal-dark);
}
.keyboard button.correct::after { content: " \2713"; }

.keyboard button.incorrect {
  box-shadow: inset 0 0 0 3px var(--coral-dark);
}
.keyboard button.incorrect::after { content: " \2715"; }

.game-controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.attempts-note {
  text-align: center;
  color: var(--ink-soft);
  margin-top: 0.5rem;
}

.keyboard-row-accents {
  margin-top: 0.5rem;
  padding-top: 0.6rem;
  border-top: 2px dashed var(--ink-faint);
}

#hint-text {
  text-align: center;
  font-style: italic;
  color: var(--ink-soft);
  margin-top: 1rem;
}

.reading-word {
  text-align: center;
  font-family: "Baloo 2", sans-serif;
  font-size: 2.4rem;
  font-weight: 700;
  margin: 1.5rem 0;
}

.sentence-display {
  text-align: center;
  font-family: "Baloo 2", sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.5;
  margin: 1.5rem auto;
  max-width: 32rem;
}

.choices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  max-width: 40rem;
  margin: 0 auto 1.5rem;
}

.choices-grid button {
  font-family: "Baloo 2", sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  padding: 1rem;
  border-radius: var(--radius-block);
  border: 3px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink);
}

.choices-grid button:hover:not(:disabled) { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }

.choices-grid button.correct {
  background: #E3F5F1;
  box-shadow: inset 0 0 0 3px var(--teal-dark), 4px 4px 0 var(--ink);
}
.choices-grid button.correct::after { content: " \2713"; }

.choices-grid button.incorrect {
  background: var(--coral-dark);
  color: #fff;
  box-shadow: inset 0 0 0 3px var(--coral-dark), 4px 4px 0 var(--ink);
}
.choices-grid button.incorrect::after { content: " \2715"; }

.choices-grid button:disabled { cursor: not-allowed; }

@media (max-width: 480px) {
  .site-header,
  .game-main {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .age-switch {
    width: 100%;
    justify-content: center;
    border-radius: var(--radius-control);
  }

  .age-switch button {
    flex: 1 1 5.5rem;
    padding-left: 0.45rem;
    padding-right: 0.45rem;
  }

  .keyboard-row {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.35rem;
  }

  .keyboard button {
    min-width: 0;
    padding: 0.65rem 0.15rem;
  }
}
