/* =========================================================
   Học tiếng Việt — thème « Bao cấp » (Hanoï d'autrefois)
   Source unique des couleurs, polices et composants.
   ========================================================= */

@import url("https://fonts.googleapis.com/css2?family=Bitter:wght@500;700;800&family=Be+Vietnam+Pro:wght@400;500;600&family=Patrick+Hand&display=swap");

:root {
  /* Papier et encre */
  --htv-papier: #EFE4C8;
  --htv-papier-clair: #F7F0DE;
  --htv-papier-fonce: #DCCDA6;
  --htv-papier-eteint: #EADFC3;
  --htv-encre: #2A2620;
  --htv-texte-2: #4A443A;
  --htv-texte-3: #5E584C;
  --htv-pointille: #8C7A58;

  /* Couleurs de l'époque */
  --htv-olive: #4F5D33;
  --htv-olive-fonce: #2E3A22;
  --htv-rouge: #A8322A;
  --htv-rouge-fonce: #7E2219;
  --htv-bois: #6E4630;
  --htv-bois-clair: #8C5A3C;
  --htv-tableau: #2F3A2A;
  --htv-craie: #F3E9CF;
  --htv-craie-2: #E8D9B5;
  --htv-succes-fond: #DDE6C8;
  --htv-succes: #2B4A27;
  --htv-erreur-fond: #F3D9D2;

  /* Les 6 tons — fond clair */
  --ton-ngang: #5E584C;
  --ton-huyen: #2E5A87;
  --ton-sac: #A8322A;
  --ton-hoi: #8A5E0E;
  --ton-nga: #3F6B3A;
  --ton-nang: #5B3A6B;

  /* Polices */
  --htv-titre: "Bitter", Georgia, serif;
  --htv-texte: "Be Vietnam Pro", "Noto Sans", system-ui, sans-serif;
  --htv-main: "Patrick Hand", "Comic Neue", cursive;

  /* Formes */
  --htv-trait: 2px solid var(--htv-encre);
  --htv-rayon: 4px;
  --htv-ombre: 5px 5px 0 var(--htv-encre);
  --htv-ombre-olive: 6px 6px 0 var(--htv-olive);
  --htv-largeur: 1180px;
  --htv-rayon-tuile: 6px;

  /* Mouvement — durées et courbes uniques pour tout le site (CSS et JS via getComputedStyle) */
  --htv-duree-rapide: 180ms;
  --htv-duree: 420ms;
  --htv-duree-lente: 800ms;
  --htv-ressort: cubic-bezier(.34, 1.56, .64, 1); /* rebond */
  --htv-sortie: cubic-bezier(.22, 1, .36, 1);     /* douce */

  /* Grain de papier : bruit SVG en niveaux de gris, posé en calque fixe (voir body::after) */
  --htv-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.4 -.35'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  --htv-grain-opacite: .05;

  /* Couleur du mur de l'illustration du café (cafe-hero.svg), pour la prolonger */
  --htv-illu-mur: var(--htv-craie-2);
}

/* Les tons sur tableau noir */
.tableau {
  --ton-ngang: #F3E9CF;
  --ton-huyen: #9DBFE3;
  --ton-sac: #F0A48F;
  --ton-hoi: #E8C277;
  --ton-nga: #A9CF94;
  --ton-nang: #C9A6DA;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--htv-papier);
  color: var(--htv-encre);
  font-family: var(--htv-texte);
  font-size: 16px;
  line-height: 1.6;
}
h1, h2, h3 { font-family: var(--htv-titre); font-weight: 700; color: var(--htv-olive-fonce); line-height: 1.1; margin: 0; }
h1 { font-size: clamp(2.2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.25rem); }
h3 { font-size: 1.375rem; color: var(--htv-encre); }
/* Grain de papier sur tout le site : calque fixe, ne capte aucun clic */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 1000; pointer-events: none;
  background-image: var(--htv-grain); background-size: 220px 220px;
  opacity: var(--htv-grain-opacite);
}
a { color: var(--htv-rouge); }
a:hover { color: var(--htv-rouge-fonce); }
:focus-visible { outline: 3px solid var(--htv-rouge); outline-offset: 2px; }

.conteneur { max-width: var(--htv-largeur); margin: 0 auto; padding: 0 24px; }
.manuscrit { font-family: var(--htv-main); color: var(--htv-rouge); font-size: 1.4rem; }
.discret { color: var(--htv-texte-3); }

/* ---------- Tons ---------- */
.ton-ngang { color: var(--ton-ngang); }
.ton-huyen { color: var(--ton-huyen); }
.ton-sac   { color: var(--ton-sac); }
.ton-hoi   { color: var(--ton-hoi); }
.ton-nga   { color: var(--ton-nga); }
.ton-nang  { color: var(--ton-nang); }

/* ---------- En-tête ---------- */
.entete { background: var(--htv-olive); border-bottom: 4px solid var(--htv-olive-fonce); }
.entete .conteneur { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-block: 14px; }
.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.plaque { background: var(--htv-rouge); padding: 4px; border-radius: var(--htv-rayon); }
.plaque > span {
  display: flex; align-items: center; gap: 10px;
  border: 2px solid var(--htv-craie); border-radius: 2px; padding: 4px 14px;
  font-family: var(--htv-titre); font-weight: 700; font-size: 1.25rem; letter-spacing: .06em; color: var(--htv-craie);
}
.logo .manuscrit { color: var(--htv-craie-2); font-size: 1.25rem; }
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav a { color: var(--htv-craie); text-decoration: none; padding: 10px 16px; border-radius: var(--htv-rayon); font-weight: 500; font-size: .95rem; }
.nav a:hover { background: var(--htv-olive-fonce); color: var(--htv-craie); }
.nav a[aria-current="page"] { background: var(--htv-craie); color: var(--htv-encre); }

/* ---------- Pied de page ---------- */
.pied { background: var(--htv-olive-fonce); color: var(--htv-craie-2); border-top: 4px solid var(--htv-olive); font-size: .875rem; }
.pied .conteneur { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-block: 22px; }

/* ---------- Sections ---------- */
.section { padding: 40px 0 56px; border-top: var(--htv-trait); }
.section-tete { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.section-tete p { margin: 4px 0 0; color: var(--htv-texte-2); }

/* ---------- Boutons ---------- */
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 22px;
  font: 600 1rem var(--htv-texte); text-decoration: none; cursor: pointer;
  background: var(--htv-papier-clair); color: var(--htv-encre);
  border: var(--htv-trait); border-radius: var(--htv-rayon);
}
.bouton:hover { background: var(--htv-papier-fonce); color: var(--htv-encre); }
.bouton--principal { background: var(--htv-rouge); color: var(--htv-papier-clair); box-shadow: 3px 3px 0 var(--htv-encre); }
.bouton--principal:hover { background: var(--htv-rouge-fonce); color: var(--htv-papier-clair); }
.bouton--principal:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--htv-encre); }
.bouton, .ticket, .carte-ton { transition: transform var(--htv-duree-rapide) var(--htv-sortie); }
.bouton-audio {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%;
  border: var(--htv-trait); background: transparent; color: inherit; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.tableau .bouton-audio { border-color: var(--htv-craie); }

/* ---------- Barre de progression ---------- */
.progression { height: 12px; background: var(--htv-papier-fonce); border: 1.5px solid var(--htv-encre); border-radius: 2px; overflow: hidden; }
.progression > span { display: block; height: 100%; background: var(--htv-olive); }
.progression--rouge > span { background: var(--htv-rouge); }

/* ---------- Carte papier ---------- */
.carte { background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon); padding: 24px 28px; }
.carte--ombre { box-shadow: var(--htv-ombre-olive); }

/* ---------- Ticket de leçon (tem phiếu) ---------- */
.tickets { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.ticket {
  position: relative; display: flex; flex-direction: column;
  background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon);
  padding: 10px; color: var(--htv-encre); text-decoration: none;
}
.ticket__interieur { border: 1.5px dashed var(--htv-pointille); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ticket__numero { display: flex; justify-content: space-between; font: 700 .8rem var(--htv-titre); letter-spacing: .1em; color: var(--htv-texte-3); }
.ticket__image { background: #EFE2C2; border: 1.5px solid var(--htv-encre); }
.ticket__image img { display: block; width: 100%; height: auto; }
.ticket__pied { border-top: 1.5px dashed var(--htv-pointille); padding-top: 8px; font-size: .875rem; font-weight: 600; }
.ticket--encours { border: 3px solid var(--htv-rouge); padding: 9px; box-shadow: var(--htv-ombre); }
.ticket--encours .ticket__numero { color: var(--htv-rouge); }
.ticket--verrou { background: var(--htv-papier-eteint); border-color: var(--htv-pointille); }
.ticket:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--htv-encre); }

/* Tampon « ĐÃ HỌC » */
.tampon {
  position: absolute; right: 18px; top: 112px; transform: rotate(-14deg);
  width: 74px; height: 74px; border: 3px solid var(--htv-rouge); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font: 700 .875rem/1.1 var(--htv-titre); color: var(--htv-rouge);
  background: rgba(247, 240, 222, .8);
}

/* Onde d'encre au moment où le tampon touche le papier (js/animations.js) */
.tampon-onde {
  position: absolute; right: 18px; top: 112px; width: 74px; height: 74px;
  border: 2px solid var(--htv-rouge); border-radius: 50%; opacity: 0; pointer-events: none;
}

/* ---------- Tableau noir ---------- */
.tableau {
  background: var(--htv-tableau); color: var(--htv-craie);
  border: 10px solid var(--htv-bois); border-radius: var(--htv-rayon);
  padding: 28px 32px; box-shadow: 6px 6px 0 var(--htv-encre);
  font-family: var(--htv-main);
}
.tableau .grand { font-size: clamp(2.5rem, 6vw, 4rem); line-height: 1.05; margin: 0; }

/* ---------- Calendrier à feuilles (lịch bóc) ---------- */
.calendrier { background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon); overflow: hidden; }
.calendrier__tete { background: var(--htv-rouge); color: var(--htv-papier-clair); padding: 12px 24px; border-bottom: var(--htv-trait); font: 700 1rem var(--htv-titre); letter-spacing: .08em; }
.calendrier__chiffre { font: 700 6.5rem/1 var(--htv-titre); color: var(--htv-rouge); }

/* ---------- Carte de ton ---------- */
.tons { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.carte-ton {
  background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon);
  padding: 0 0 16px; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer; font: inherit; color: inherit;
}
.carte-ton::before { content: ""; width: 100%; height: 8px; background: currentColor; }
.carte-ton__nom { font-size: .8rem; font-weight: 600; letter-spacing: .08em; padding-top: 8px; }
.carte-ton__mot { font: 700 3rem/1.1 var(--htv-titre); }
.carte-ton__sens { font-size: .95rem; color: var(--htv-texte-2); }

/* ---------- Dialogue ---------- */
.replique { display: flex; gap: 12px; align-items: flex-start; }
.avatar {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%; border: var(--htv-trait);
  display: flex; align-items: center; justify-content: center;
  font: 700 1rem var(--htv-titre); color: var(--htv-craie); background: var(--htv-olive);
}
.avatar--moi { background: var(--htv-rouge); }
.replique__vi { margin: 0; font-size: 1.25rem; font-weight: 500; }
.replique__fr { margin: 0; font-size: .95rem; color: var(--htv-texte-3); }

/* ---------- Quiz ---------- */
.choix { display: flex; gap: 12px; flex-wrap: wrap; }
.choix button {
  min-width: 120px; min-height: 48px; padding: 10px 22px; cursor: pointer;
  font: 700 1.375rem var(--htv-titre); background: var(--htv-papier-clair); color: var(--htv-encre);
  border: var(--htv-trait); border-radius: var(--htv-rayon);
}
.choix button[data-etat="bon"] { background: var(--ton-nga); color: var(--htv-papier-clair); }
.choix button[data-etat="faux"] { background: var(--htv-rouge); color: var(--htv-papier-clair); }
.retour { margin: 0; padding: 12px 16px; font-weight: 500; overflow-wrap: anywhere; } /* chemins de fichiers longs dans les messages d'erreur */
.retour--bon { background: var(--htv-succes-fond); border: 1.5px solid var(--ton-nga); color: var(--htv-succes); }
.retour--faux { background: var(--htv-erreur-fond); border: 1.5px solid var(--htv-rouge); color: var(--htv-rouge-fonce); }

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

/* =========================================================
   Composants des pages (accueil, leçon) — mêmes variables
   ========================================================= */

/* ---------- Utilitaires ---------- */
[hidden] { display: none !important; }
.visuellement-cache {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
main { display: block; }
.fil { padding: 18px 0 0; font-size: .95rem; }
.fil a { font-weight: 600; text-decoration: none; }
.fil a:hover { text-decoration: underline; }
.etiquette { font: 700 .8rem var(--htv-titre); letter-spacing: .12em; color: var(--htv-texte-3); text-transform: uppercase; }
.lien-fleche { font-weight: 600; text-decoration: none; }
.lien-fleche:hover { text-decoration: underline; }
.message-erreur { margin: 40px 0; }

/* ---------- Bouton audio : états ---------- */
.bouton-audio:hover { background: var(--htv-papier-fonce); }
.tableau .bouton-audio:hover { background: var(--htv-olive-fonce); }
.bouton-audio[data-etat="lecture"] { background: var(--htv-olive); color: var(--htv-craie); }
.bouton-audio[data-etat="indispo"] { border-style: dashed; opacity: .55; }

/* ---------- Annonce (zone aria-live) ---------- */
.annonce {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 10;
  max-width: calc(100% - 32px); padding: 12px 18px;
  background: var(--htv-encre); color: var(--htv-papier-clair);
  border-radius: var(--htv-rayon); box-shadow: 4px 4px 0 var(--htv-rouge);
  font-weight: 500; font-size: .95rem;
}
.annonce:empty, .annonce[data-visible="non"] { display: none; }

/* ---------- Accueil : la une ---------- */
.une { padding: 44px 0 52px; }
.une .conteneur { display: grid; grid-template-columns: 1.05fr 1fr; gap: 40px; align-items: center; }
.une__titre { margin: 6px 0 12px; }
.une__intro { margin: 0 0 24px; font-size: 1.1rem; color: var(--htv-texte-2); max-width: 34em; }
.une__illustration { border: var(--htv-trait); border-radius: var(--htv-rayon); box-shadow: var(--htv-ombre); background: var(--htv-papier-clair); overflow: hidden; }
.une__illustration img { display: block; width: 100%; height: auto; }
.reprise { display: flex; flex-direction: column; gap: 12px; }
.reprise__titre { font: 700 1.5rem var(--htv-titre); margin: 0; }
.reprise__fr { margin: 0; color: var(--htv-texte-2); }
.reprise__ligne { display: flex; align-items: center; gap: 12px; font-size: .9rem; color: var(--htv-texte-3); }
.reprise__ligne .progression { flex: 1; }

/* ---------- Accueil : mot du jour + série ---------- */
.duo { display: grid; grid-template-columns: 2fr 1fr; gap: 28px; align-items: stretch; }
.mot-jour__tete { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--htv-craie-2); font-size: 1.25rem; }
.mot-jour__ligne { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin: 12px 0 8px; }
.mot-jour__fr { margin: 0; font-size: 1.6rem; }
.mot-jour__note { margin: 6px 0 0; font-size: 1.15rem; color: var(--htv-craie-2); }
.calendrier__corps { padding: 18px 24px 22px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.calendrier__texte { margin: 0; font-weight: 600; }
.calendrier__date { margin: 8px 0 0; font-family: var(--htv-main); font-size: 1.2rem; color: var(--htv-texte-3); }

/* ---------- Tickets : compléments ---------- */
.ticket__titre { margin: 0; font: 700 1.5rem var(--htv-titre); }
.ticket__fr { margin: 0; color: var(--htv-texte-2); font-size: .95rem; }
.ticket--verrou { color: var(--htv-texte-3); cursor: default; }
.ticket--verrou .ticket__image { opacity: .55; }
.ticket--verrou:hover { transform: none; box-shadow: none; }
.ticket--encours:hover { box-shadow: 7px 7px 0 var(--htv-encre); }
.ticket .tampon { pointer-events: none; }

/* ---------- Page leçon : en-tête ---------- */
.lecon-tete { padding: 18px 0 32px; }
.lecon-tete__grille { display: grid; grid-template-columns: 1fr 300px; gap: 32px; align-items: center; }
.lecon-tete h1 { margin: 6px 0 10px; }
.lecon-tete__fr { margin: 0 0 18px; font-size: 1.1rem; color: var(--htv-texte-2); }
.lecon-tete__image { margin: 0; background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon); padding: 8px; box-shadow: var(--htv-ombre); }
.lecon-tete__image img { display: block; width: 100%; height: auto; border: 1.5px dashed var(--htv-pointille); }
.lecon-tete__avance { display: flex; align-items: center; gap: 12px; font-size: .9rem; color: var(--htv-texte-3); max-width: 480px; }
.lecon-tete__avance .progression { flex: 1; }

/* ---------- Page leçon : étapes ---------- */
.etapes { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 24px; padding: 0; list-style: none; counter-reset: etape; }
.etapes button {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 16px; cursor: pointer;
  font: 600 .95rem var(--htv-texte); color: var(--htv-encre);
  background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon);
}
.etapes button::before {
  counter-increment: etape; content: counter(etape);
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  border: 1.5px solid currentColor; border-radius: 50%; font: 700 .8rem var(--htv-titre);
}
.etapes button:hover { background: var(--htv-papier-fonce); }
.etapes button[data-faite] { color: var(--htv-olive-fonce); border-color: var(--htv-olive); }
.etapes button[aria-current="step"] { background: var(--htv-olive); color: var(--htv-craie); border-color: var(--htv-olive-fonce); box-shadow: 3px 3px 0 var(--htv-encre); }

.panneau { min-height: 280px; }
.panneau > h2 { margin-bottom: 6px; }
.panneau__intro { margin: 0 0 24px; color: var(--htv-texte-2); }
.navigation-etapes { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 24px 0 56px; }

/* ---------- Vocabulaire ---------- */
.vocab { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin: 0; padding: 0; list-style: none; }
.vocab__item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--htv-papier); border: var(--htv-trait); border-radius: var(--htv-rayon); }
.vocab__texte { min-width: 0; }
.vocab__vi { margin: 0; font: 700 1.5rem/1.2 var(--htv-titre); }
.vocab__fr { margin: 0; }
.vocab__note { margin: 2px 0 0; font-family: var(--htv-main); font-size: 1.1rem; color: var(--htv-rouge); }

/* ---------- Prononciation ---------- */
.legende-tons { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 24px; padding: 12px 16px; list-style: none; border: 1.5px dashed var(--htv-pointille); border-radius: var(--htv-rayon); font-size: .9rem; }
.legende-tons li { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.legende-tons li::before { content: ""; width: 14px; height: 14px; border-radius: 2px; background: currentColor; border: 1px solid var(--htv-encre); }
.pron { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; }
.pron__ligne { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1.5px dashed var(--htv-pointille); }
.pron__ligne:last-child { border-bottom: 0; }
.pron__fr { flex: 1; min-width: 120px; color: var(--htv-texte-2); }
.syllabes { display: flex; gap: 8px; flex-wrap: wrap; }
.syllabe {
  display: inline-flex; flex-direction: column; align-items: center; min-width: 64px; padding: 6px 10px; cursor: pointer;
  background: var(--htv-papier-clair); color: inherit; font: inherit;
  border: 2px solid currentColor; border-radius: var(--htv-rayon);
}
.syllabe:hover { background: var(--htv-papier-fonce); }
.syllabe__mot { font: 700 1.5rem/1.1 var(--htv-titre); }
.syllabe__ton { font-size: .75rem; font-weight: 600; letter-spacing: .04em; }

/* ---------- Dialogue ---------- */
.dialogue { display: flex; flex-direction: column; gap: 18px; margin: 0 0 24px; padding: 0; list-style: none; }
.replique__bulle { flex: 1; min-width: 0; }
.replique__nom { margin: 0 0 2px; font-size: .8rem; font-weight: 600; letter-spacing: .06em; color: var(--htv-texte-3); text-transform: uppercase; }
.replique--moi { flex-direction: row-reverse; text-align: right; }
.dialogue[data-traduction="cachee"] .replique__fr { visibility: hidden; }
.astuces { display: flex; flex-direction: column; gap: 10px; margin: 24px 0 0; padding: 16px 20px; list-style: none; border-left: 4px solid var(--htv-rouge); background: var(--htv-papier); }
.astuces li { font-family: var(--htv-main); font-size: 1.25rem; line-height: 1.35; }
.astuces li::before { content: "Astuce — "; color: var(--htv-rouge); }

/* ---------- Écoute et quiz ---------- */
.exercice { display: flex; flex-direction: column; gap: 18px; align-items: flex-start; }
.exercice__compteur { margin: 0; }
.exercice__question { margin: 0; font-size: 1.2rem; font-weight: 500; }
.ecoute__outils { display: flex; gap: 12px; flex-wrap: wrap; }
.ecoute__bouton { gap: 12px; }
.ecoute__bouton svg { width: 24px; height: 24px; }
.choix button[data-etat] [class^="ton-"] { color: inherit; }
.choix button:disabled { cursor: default; }
.choix button:not(:disabled):hover { background: var(--htv-papier-fonce); }
.indice { margin: 0; font-family: var(--htv-main); font-size: 1.25rem; color: var(--htv-rouge); }

/* ---------- Fin de leçon ---------- */
.fin { position: relative; text-align: center; padding: 40px 24px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.fin__ticket { width: min(300px, 100%); text-align: left; box-shadow: var(--htv-ombre); }
.fin__ticket:hover { transform: none; box-shadow: var(--htv-ombre); }
.fin__ticket .tampon, .fin__ticket .tampon-onde { width: 92px; height: 92px; top: 96px; }
.fin__ticket .tampon { font-size: 1.05rem; }
.fin__actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ---------- Téléphone ---------- */
@media (max-width: 860px) {
  .une .conteneur, .duo, .lecon-tete__grille { grid-template-columns: 1fr; }
  .lecon-tete__image { max-width: 340px; }
}
@media (max-width: 600px) {
  .conteneur { padding: 0 16px; }
  .carte { padding: 18px 16px; }
  .tableau { padding: 20px 18px; border-width: 8px; }
  .nav a { padding: 8px 10px; }
  .replique--moi { flex-direction: row; text-align: left; }
  .calendrier__chiffre { font-size: 5rem; }
}

/* ---------- Pages tons et vocabulaire : en-tête court ---------- */
.une--courte { padding: 36px 0 32px; }
.une--courte .une__simple { display: block; }
.une--courte .une__intro { margin-bottom: 0; }
.une--courte h1 { margin: 4px 0 12px; }

/* ---------- Fiches des tons ---------- */
.fiches-tons { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.fiche-ton {
  display: flex; flex-direction: column; gap: 8px; padding: 0 20px 18px;
  background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon); overflow: hidden;
}
.fiche-ton::before { content: ""; display: block; height: 8px; margin: 0 -20px 6px; background: currentColor; }
.fiche-ton__tete { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.fiche-ton__tete h3 { font-size: 1.3rem; }
.fiche-ton__tete .bouton-audio { color: var(--htv-encre); }
.fiche-ton__corps { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fiche-ton__mot { margin: 0; font: 700 3.5rem/1 var(--htv-titre); }
.fiche-ton__sens { margin: 0; font-family: var(--htv-main); font-size: 1.3rem; color: var(--htv-rouge); }
.fiche-ton__desc { margin: 0; color: var(--htv-encre); }
.fiche-ton__marque { margin: 0; font-size: .9rem; }
.contour { width: 120px; height: 70px; flex-shrink: 0; }
.contour__grille { stroke: var(--htv-pointille); stroke-width: 1; stroke-dasharray: 2 3; }
.contour__ligne { fill: none; stroke: currentColor; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.contour__coupure { stroke: var(--htv-encre); stroke-width: 3; stroke-linecap: round; }

/* ---------- Exercice des tons ---------- */
.choix-tons { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; width: 100%; }
.choix-ton {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 64px; padding: 10px; cursor: pointer;
  background: var(--htv-papier-clair); color: inherit; font: inherit;
  border: 2px solid currentColor; border-radius: var(--htv-rayon); box-shadow: 3px 3px 0 currentColor;
}
.choix-ton:not(:disabled):hover { background: var(--htv-papier-fonce); }
.choix-ton:disabled { cursor: default; }
.choix-ton__nom { font: 700 1.15rem var(--htv-titre); }
.choix-ton__ex { font-size: .95rem; }
.choix-ton[data-etat="bon"] { background: var(--htv-succes-fond); outline: 3px solid var(--ton-nga); outline-offset: 2px; }
.choix-ton[data-etat="faux"] { background: var(--htv-erreur-fond); outline: 3px solid var(--htv-rouge); outline-offset: 2px; }

/* ---------- Réglages (pastilles à bascule) ---------- */
.reglages { display: flex; flex-direction: column; gap: 16px; margin-bottom: 28px; }
.reglages__groupe { display: flex; flex-direction: column; gap: 8px; }
.pastilles { display: flex; gap: 8px; flex-wrap: wrap; }
.pastilles button {
  min-height: 44px; padding: 8px 16px; cursor: pointer;
  font: 600 .95rem var(--htv-texte); color: var(--htv-encre);
  background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: 999px;
}
.pastilles button:hover { background: var(--htv-papier-fonce); }
.pastilles button[aria-pressed="true"] { background: var(--htv-encre); color: var(--htv-papier-clair); }
.pastilles button[aria-pressed="true"] [class^="ton-"] { color: inherit; }

/* ---------- Flashcards ---------- */
.zone-cartes { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.flashcard {
  position: relative; width: 100%; min-height: 260px; padding: 14px;
  background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon); box-shadow: var(--htv-ombre-olive);
}
.flashcard::after { content: ""; position: absolute; inset: 10px; border: 1.5px dashed var(--htv-pointille); pointer-events: none; }
.flashcard__coin { position: absolute; top: 18px; right: 22px; }
.flashcard__face { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 110px; padding: 28px 16px 8px; text-align: center; position: relative; z-index: 1; }
.flashcard__verso { border-top: 1.5px dashed var(--htv-pointille); margin: 8px 16px 0; position: relative; z-index: 1; text-align: center; }
.flashcard__vi { margin: 0; font: 700 clamp(2.2rem, 7vw, 3.5rem)/1.1 var(--htv-titre); }
.flashcard__fr { margin: 0; font-size: 1.5rem; font-weight: 500; }
.flashcard__note { margin: 0 0 12px; font-family: var(--htv-main); font-size: 1.2rem; color: var(--htv-rouge); }
.flashcard__actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.flashcard__stats { margin: 0; font-size: .9rem; }
.bilan { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.bilan p { margin: 0; }
.bilan__liste { margin: 0; padding-left: 20px; }
.bilan__liste span { font-weight: 600; }

/* =========================================================
   Accueil « rétro moderne » : grille bento + typographie expressive
   ========================================================= */
.bento {
  display: grid; gap: clamp(16px, 2.2vw, 28px);
  padding-block: clamp(28px, 5vw, 64px) 72px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-areas:
    "titre   titre   titre   titre   cafe  cafe"
    "reprise reprise reprise mot     mot   serie"
    "reprise reprise reprise tons    tons  tons"
    "lecons  lecons  lecons  lecons  lecons lecons";
}
.tuile--titre   { grid-area: titre; }
.tuile--reprise { grid-area: reprise; }
.tuile--cafe    { grid-area: cafe; }
.tuile--mot     { grid-area: mot; }
.tuile--serie   { grid-area: serie; }
.tuile--tons    { grid-area: tons; }
.tuile--lecons  { grid-area: lecons; margin-top: clamp(16px, 4vw, 48px); }
.bento > * { min-width: 0; }

.tuile {
  background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon-tuile);
  padding: clamp(20px, 2.5vw, 32px);
}
.bento .tableau, .bento .calendrier { border-radius: var(--htv-rayon-tuile); }
.tuile__tete { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 16px; flex-wrap: wrap; }
.tuile__intro { margin: 6px 0 18px; color: var(--htv-texte-2); max-width: 36em; }

/* Titre géant */
.tuile--titre { align-self: end; padding-top: 4px; }
.surtitre {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin: 0 0 clamp(12px, 2vw, 24px); padding-top: 10px; border-top: var(--htv-trait);
  font: 700 .8rem var(--htv-titre); letter-spacing: .14em; text-transform: uppercase; color: var(--htv-texte-3);
}
.surtitre__main { font: 400 1.3rem var(--htv-main); letter-spacing: 0; text-transform: none; }
.titre-geant {
  margin: 0; font-family: var(--htv-titre); font-weight: 800;
  font-size: clamp(3rem, 8vw, 7rem); line-height: .95; letter-spacing: -.03em;
}
.titre-geant__ligne { display: block; }
.titre-geant__ligne + .titre-geant__ligne { padding-left: .55em; } /* décalage façon affiche */
.tuile--titre__intro { margin: clamp(16px, 2.5vw, 28px) 0 0; max-width: 32em; font-size: 1.15rem; color: var(--htv-texte-2); }
.tuile--titre__intro .manuscrit { display: block; margin-bottom: 2px; }

/* Reprise : la tuile vedette */
.tuile--reprise {
  display: flex; flex-direction: column; justify-content: flex-end; gap: 14px;
  box-shadow: var(--htv-ombre-olive); position: relative; overflow: hidden;
}
.reprise__numero {
  font: 800 clamp(6rem, 13vw, 11rem)/.8 var(--htv-titre); letter-spacing: -.04em;
  color: transparent; -webkit-text-stroke: 2px var(--htv-rouge);
  padding-bottom: 12px;
}
/* En-tête de la reprise : grand numéro + illustration de la leçon, posée comme une photo */
.reprise__tete { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: auto; }
.reprise__image { width: min(48%, 260px); flex-shrink: 0; transform: rotate(2deg); box-shadow: 4px 4px 0 var(--htv-encre); }
/* Les étapes de la leçon, cochées au fil de l'avancement */
.reprise__etapes { display: grid; gap: 6px; margin: 4px 0; padding: 0; list-style: none; counter-reset: etape; }
.reprise__etapes li {
  display: flex; align-items: center; gap: 12px; padding: 7px 12px;
  border: 1.5px dashed var(--htv-pointille); border-radius: var(--htv-rayon); counter-increment: etape;
}
.reprise__etapes li::before {
  content: counter(etape); flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font: 700 .8rem var(--htv-titre); border: 1.5px solid var(--htv-encre);
}
.reprise__etape { flex: 1; font-weight: 600; }
.reprise__etat { font: 700 .72rem var(--htv-titre); letter-spacing: .1em; text-transform: uppercase; color: var(--htv-texte-3); }
.reprise__etapes li[data-etat="faite"] { border-style: solid; border-color: var(--htv-olive); }
.reprise__etapes li[data-etat="faite"]::before { background: var(--htv-olive); border-color: var(--htv-olive-fonce); color: var(--htv-craie); }
.reprise__etapes li[data-etat="faite"] .reprise__etat { color: var(--htv-olive-fonce); }
.reprise__etapes li[data-etat="en cours"] { border: 2px solid var(--htv-rouge); box-shadow: 3px 3px 0 var(--htv-encre); }
.reprise__etapes li[data-etat="en cours"]::before { background: var(--htv-rouge); border-color: var(--htv-rouge-fonce); color: var(--htv-papier-clair); }
.reprise__etapes li[data-etat="en cours"] .reprise__etat { color: var(--htv-rouge); }
.tuile--reprise .reprise__titre { font: 800 clamp(2rem, 4vw, 3.25rem)/1 var(--htv-titre); letter-spacing: -.02em; }
.tuile--reprise .reprise__fr { font-size: 1.1rem; }

/* Illustration */
/* Illustration du café : jamais rognée (contain), calée en bas ; la place en trop au-dessus
   prolonge le mur de l'image. */
.illustration--mur { background: var(--htv-illu-mur); }
.illustration--mur img { object-fit: contain; object-position: center bottom; }
.tuile--cafe { margin: 0; padding: 0; overflow: hidden; display: flex; }
.tuile--cafe img { display: block; width: 100%; height: 100%; }

/* Mot du jour et série dans la grille */
.tuile--mot { display: flex; flex-direction: column; justify-content: center; }
.tuile--serie { display: flex; flex-direction: column; }
.tuile--serie .calendrier__corps { flex: 1; justify-content: center; padding-inline: 12px; }
.tuile--serie .calendrier__chiffre { font-size: clamp(4.5rem, 7vw, 6.5rem); }

/* Tons */
.titre-tuile { font: 800 clamp(1.6rem, 2.5vw, 2.25rem)/1 var(--htv-titre); letter-spacing: -.01em; }
.tons--bento { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tons--bento .carte-ton__mot { font-size: clamp(2rem, 3vw, 2.6rem); }

/* Leçons : grand titre de section */
.tuile__tete--section { align-items: flex-end; padding-top: 12px; border-top: var(--htv-trait); margin-bottom: 24px; }
.titre-section { font: 800 clamp(2.5rem, 6vw, 5rem)/.9 var(--htv-titre); letter-spacing: -.03em; }
.tuile__tete--section .tuile__intro { margin: 0; }

/* Tablette : deux colonnes */
@media (max-width: 1000px) {
  .bento {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "titre   titre"
      "reprise cafe"
      "mot     serie"
      "tons    tons"
      "lecons  lecons";
  }
}
/* Téléphone : une colonne, dans l'ordre de lecture */
@media (max-width: 640px) {
  .bento {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "titre" "reprise" "mot" "serie" "tons" "cafe" "lecons";
  }
  .titre-geant__ligne + .titre-geant__ligne { padding-left: 0; }
  .tuile--cafe img { height: auto; }
}
@media (max-width: 380px) {
  .tons--bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* =========================================================
   Tableau de bord (index.html) : toutes les langues
   ========================================================= */

/* Couleur d'accent d'une langue (champ « couleur » de data/langues.json), prise dans la palette */
.accent-rouge { --accent: var(--htv-rouge); }
.accent-olive { --accent: var(--htv-olive); }
.accent-bois  { --accent: var(--htv-bois); }
.accent-bleu  { --accent: var(--ton-huyen); }
.accent-prune { --accent: var(--ton-nang); }
.accent-ocre  { --accent: var(--ton-hoi); }

.bento--tableau {
  grid-template-areas:
    "titre   titre   titre   titre   serie    serie"
    "langues langues langues langues revision revision"
    "langues langues langues langues semaine  semaine";
  grid-template-rows: auto auto 1fr;
}
.tuile--langues  { grid-area: langues; }
.tuile--revision { grid-area: revision; }
.tuile--semaine  { grid-area: semaine; }
.bento--tableau .tuile--serie { align-self: end; }

/* Cartes des langues */
.langues { display: grid; gap: clamp(16px, 2vw, 24px); }
.carte-langue {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  background: var(--htv-papier-clair); border: var(--htv-trait); border-radius: var(--htv-rayon-tuile);
  box-shadow: 6px 6px 0 var(--accent, var(--htv-olive)); overflow: hidden;
}
.carte-langue__image { border-right: var(--htv-trait); }
.carte-langue__image img { display: block; width: 100%; height: 100%; }
.carte-langue__corps { display: flex; flex-direction: column; gap: 14px; padding: clamp(20px, 2.5vw, 32px); min-width: 0; }
.carte-langue__surtitre { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 12px; flex-wrap: wrap; margin: 0; }
.carte-langue__surtitre .manuscrit { font-size: 1.25rem; letter-spacing: 0; text-transform: none; }
.carte-langue__nom { margin: 0; font: 800 clamp(2.4rem, 5vw, 4rem)/.95 var(--htv-titre); letter-spacing: -.03em; }
.carte-langue__accroche { margin: 0; color: var(--htv-texte-2); }
.carte-langue__lecon {
  display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 12px 14px;
  border: 1.5px dashed var(--htv-pointille); border-radius: var(--htv-rayon);
}
.carte-langue__titre-lecon { font: 700 1.5rem/1.15 var(--htv-titre); }
.carte-langue__actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: auto; }
.progression--accent > span { background: var(--accent, var(--htv-olive)); }

.carte-langue--bientot {
  grid-template-columns: minmax(0, 1fr); background: var(--htv-papier-eteint);
  border: 2px dashed var(--htv-pointille); box-shadow: none; color: var(--htv-texte-3);
}
.carte-langue--bientot .carte-langue__nom { color: var(--htv-texte-3); font-size: clamp(1.8rem, 3vw, 2.4rem); }
.carte-langue--ajout .carte-langue__corps { gap: 4px; padding-block: 16px; }
.carte-langue--ajout p { margin: 0; }

/* À réviser aujourd'hui (tableau noir) */
.tuile--revision { display: flex; flex-direction: column; gap: 10px; border-radius: var(--htv-rayon-tuile); }
.revision__titre { margin: 0; font: 400 1.35rem var(--htv-main); color: var(--htv-craie-2); }
.revision__chiffre { display: flex; align-items: baseline; gap: 12px; margin: 0; }
.revision__chiffre .grand { font-size: clamp(3.5rem, 7vw, 5.5rem); }
.revision__unite { font-size: 1.6rem; }
.revision__liste { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 0; padding: 10px 0 0; list-style: none; border-top: 1.5px dashed var(--htv-craie-2); }
.revision__liste li { display: flex; align-items: baseline; gap: 6px 14px; flex-wrap: wrap; font-size: 1.25rem; }
.revision__langue { font: 700 1.3rem var(--htv-titre); }
.revision__nombre { color: var(--htv-craie-2); }
.lien-craie { margin-left: auto; color: var(--htv-craie); font-weight: 400; }
.lien-craie:hover { color: var(--htv-papier-clair); }
.tableau :focus-visible { outline-color: var(--htv-craie); }

/* Activité de la semaine : sept colonnes empilées par langue */
.tuile--semaine { display: flex; flex-direction: column; }
.tuile--semaine .tuile__intro { margin-bottom: 14px; }
.semaine { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin: auto 0 0; padding: 0; list-style: none; }
.semaine__jour { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.semaine__colonne {
  display: flex; flex-direction: column-reverse; width: 100%; height: 96px; margin-bottom: 4px;
  border: 1.5px solid var(--htv-encre); border-radius: 2px; background: var(--htv-papier); overflow: hidden;
}
.semaine__part { display: block; width: 100%; background: var(--accent, var(--htv-olive)); }
.semaine__part + .semaine__part { border-bottom: 1.5px solid var(--htv-papier-clair); }
.semaine__jour--vide .semaine__colonne { border-style: dashed; border-color: var(--htv-pointille); }
.semaine__nombre { font: 700 .95rem var(--htv-titre); }
.semaine__nom { font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--htv-texte-3); }
.semaine__date { font-family: var(--htv-main); font-size: 1.1rem; color: var(--htv-texte-3); }
.semaine__jour--auj .semaine__colonne { border: 2px solid var(--htv-rouge); box-shadow: 3px 3px 0 var(--htv-encre); }
.semaine__jour--auj .semaine__nom, .semaine__jour--auj .semaine__date { color: var(--htv-rouge); }
.semaine__legende { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 14px 0 0; padding: 0; list-style: none; font-size: .9rem; font-weight: 600; }
.semaine__legende li { display: flex; align-items: center; gap: 6px; }
.semaine__legende li::before { content: ""; width: 14px; height: 14px; border: 1px solid var(--htv-encre); border-radius: 2px; background: var(--accent); }

@media (max-width: 1000px) {
  .bento--tableau {
    grid-template-areas:
      "titre    titre"
      "serie    revision"
      "langues  langues"
      "semaine  semaine";
    grid-template-rows: none;
  }
  .bento--tableau .tuile--serie { align-self: stretch; }
}
@media (max-width: 760px) {
  .carte-langue { grid-template-columns: minmax(0, 1fr); }
  .carte-langue__image { border-right: 0; border-bottom: var(--htv-trait); }
  .carte-langue__image img { height: auto; }
}
@media (max-width: 640px) {
  .bento--tableau { grid-template-areas: "titre" "langues" "revision" "serie" "semaine"; }
  .semaine { gap: 4px; }
  .semaine__colonne { height: 72px; }
}
