/* Yeees! Code — charte « Sunset » (docs/charte-graphique.md) : crème, charcoal, orange corail, coins très arrondis. */

@font-face { font-family: 'Chewy'; src: url('/assets/fonts/chewy.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Urbanist'; src: url('/assets/fonts/urbanist.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Figtree'; src: url('/assets/fonts/figtree-latin.woff2') format('woff2'); font-weight: 300 700; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Figtree'; src: url('/assets/fonts/figtree-latin-ext.woff2') format('woff2'); font-weight: 300 700; font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --creme: #FFFAF5;
  --charcoal: #1F1B16;
  --stone: #6B6B6B;
  --stone-soft: #A8A29E;
  --orange: #FF6B35;
  --orange-fonce: #E64A19;
  --orange-clair: #FFA07A;
  --rose: #FF8B7E;
  --rose-doux: #FFE0DA;
  --menthe: #59CD90;
  --marine: #2E4057;
  --marine-doux: #4A6582;
  --or: #D4A574;
  /* Contrastes AA mesurés (relecture du 01/12/2026) : le texte blanc va sur l'orange FONCÉ (4,7:1, l'orange vif
     ne donne que 2,8:1), les petites étoiles en or foncé, les numéros de ligne en gris moyen. */
  --or-fonce: #8A5A1F;
  --menthe-fonce: #22764a;
  --bord: rgba(107, 107, 107, 0.15);
  --bord-fort: rgba(107, 107, 107, 0.25);
  --duree: 380ms;
  --police-titre: 'Urbanist', system-ui, sans-serif;
  --police-texte: 'Figtree', system-ui, sans-serif;
  --police-code: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--creme);
  color: var(--charcoal);
  font-family: var(--police-texte);
  font-size: 17px;
  line-height: 1.5;
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--police-titre); font-weight: 900; letter-spacing: -0.02em; line-height: 1.15; margin: 0 0 0.5em; }
p { margin: 0 0 0.8em; }
button { font: inherit; color: inherit; cursor: pointer; }
/* Pas de zoom au double toucher (Safari zoomait quand on touchait deux fois « avancer() » de suite). */
button, a, .plateau, .extrait { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--orange-fonce); outline-offset: 2px; }
code, kbd, pre { font-family: var(--police-code); }
kbd { background: #fff; border: 2px solid var(--bord-fort); border-radius: 8px; padding: 0 6px; font-size: 0.85em; }

.evitement { position: absolute; left: -999px; top: 0; background: var(--charcoal); color: #fff; padding: 8px 14px; border-radius: 999px; z-index: 50; }
.evitement:focus { left: 12px; top: 12px; }

.logo-yeees { font-family: 'Chewy', var(--police-titre); font-weight: 400; text-transform: uppercase; letter-spacing: 0.01em; }
.logo-yeees.petit { font-size: 1.05em; }

/* ---------- en-tête ---------- */
.entete {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left));
  background: rgba(255, 250, 245, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--bord);
}
.logo { display: flex; align-items: baseline; gap: 6px; background: none; border: 0; padding: 4px 8px; border-radius: 999px; }
.logo .logo-yeees { font-size: 30px; color: var(--charcoal); }
.logo-code { font-family: var(--police-titre); font-weight: 900; font-size: 22px; color: var(--orange); letter-spacing: -0.02em; }
.entete-droite { display: flex; align-items: center; gap: 8px; }
.compteur { white-space: nowrap; font-family: var(--police-titre); font-weight: 800; color: var(--orange-fonce); background: #fff; border: 2px solid var(--bord); border-radius: 999px; padding: 4px 14px; }
.rond { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--bord-fort); background: #fff; font-weight: 800; font-size: 18px; }
.rond:hover { border-color: var(--orange); }

.vue { max-width: 1240px; margin: 0 auto; padding: 24px max(16px, env(safe-area-inset-left)) 48px; }

/* ---------- boutons ---------- */
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 10px 22px;
  border-radius: 999px; border: 2px solid var(--bord-fort); background: #fff;
  font-weight: 700; transition: border-color .15s, transform .1s, background .15s;
}
.bouton:hover { border-color: var(--orange); }
.bouton:active { transform: scale(0.97); }
.bouton:disabled { opacity: .45; cursor: not-allowed; }
.bouton.principal { background: var(--orange-fonce); border-color: var(--orange-fonce); color: #fff; }
.bouton.principal:hover { background: #C73E12; border-color: #C73E12; }
.bouton.discret { background: transparent; }
.bouton.grand { font-size: 20px; min-height: 60px; padding: 14px 36px; }
.lien { background: none; border: 0; text-decoration: underline; color: var(--stone); padding: 12px 8px; min-height: 48px; }

.surtitre { font-size: 11px; text-transform: uppercase; letter-spacing: 0.2em; font-weight: 800; color: var(--marine); margin-bottom: 6px; }
.carte { background: #fff; border: 2px solid var(--bord); border-radius: 24px; padding: 18px 20px; }

/* ---------- accueil ---------- */
.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 32px; align-items: center; margin: 12px 0 28px; }
.hero h1 { font-size: clamp(32px, 5vw, 54px); }
.chapeau { font-size: 19px; color: rgba(31, 27, 22, 0.75); max-width: 36em; }
.devise { margin-top: 14px; color: var(--marine-doux); font-weight: 600; }
.hero-image { aspect-ratio: 1; max-width: 340px; justify-self: center; width: 100%; background: #fff; border: 2px solid var(--bord); border-radius: 40px; display: grid; place-items: center; padding: 18%; }
.hero-image svg { width: 100%; height: auto; animation: flotter 3.2s ease-in-out infinite; }
@keyframes flotter { 50% { transform: translateY(-8px) rotate(-3deg); } }

.aide-repliable, .concept { background: rgba(89, 205, 144, 0.1); border: 2px solid rgba(89, 205, 144, 0.4); border-radius: 18px; padding: 12px 18px; margin-bottom: 28px; }
.aide-repliable summary, .concept summary { cursor: pointer; font-weight: 800; font-family: var(--police-titre); font-size: 18px; }
.etapes { padding-left: 22px; }
.etapes li { margin-bottom: 6px; }

.titre-section { font-size: 28px; }
.chapitres { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(270px, 100%), 1fr)); gap: 16px; }
.chapitre { background: #fff; border: 2px solid var(--bord); border-radius: 24px; padding: 18px; }
.chapitre.ferme { opacity: 0.6; }
.chapitre-tete { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.chapitre-emoji { font-size: 30px; width: 54px; height: 54px; display: grid; place-items: center; background: var(--rose-doux); border-radius: 18px; flex: none; }
.chapitre h3 { margin: 0; font-size: 20px; }
.chapitre p { color: var(--stone); font-size: 15px; margin: 0; }
.pastilles { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pastille {
  min-width: 64px; min-height: 56px; border-radius: 18px; border: 2px solid var(--bord-fort); background: var(--creme);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px 8px; font-weight: 800;
}
.pastille:hover:not(:disabled) { border-color: var(--orange); }
.pastille .p-etoiles { font-size: 12px; color: var(--or-fonce); letter-spacing: 1px; }
.pastille.faite { background: rgba(89, 205, 144, 0.12); border-color: rgba(89, 205, 144, 0.5); }
.pastille.actuelle { background: var(--orange-fonce); color: #fff; border-color: var(--orange-fonce); }
.pastille.actuelle .p-etoiles { color: #fff; }
.pastille:disabled { cursor: not-allowed; opacity: .5; }

.faq { margin-top: 40px; }
.faq details { background: #fff; border: 2px solid var(--bord); border-radius: 18px; padding: 12px 18px; margin-bottom: 10px; }
.faq summary { cursor: pointer; font-weight: 800; font-family: var(--police-titre); font-size: 18px; min-height: 32px; }
.faq details p { margin: 10px 0 0; color: rgba(31, 27, 22, 0.8); }
.chapitre .niveaux-texte { margin: 10px 0 0; padding-left: 20px; font-size: 14px; color: var(--stone); }
.diplome-appel { display: flex; gap: 18px; align-items: center; margin-top: 28px; background: rgba(212, 165, 116, 0.15); border: 2px solid rgba(212, 165, 116, 0.5); border-radius: 24px; padding: 20px; }
.grand-emoji { font-size: 60px; margin: 0; }

.pied { margin-top: 48px; padding-top: 18px; border-top: 2px solid var(--bord); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; color: var(--stone); font-size: 14px; }
.pied p { margin: 0; }

/* ---------- niveau ---------- */
.barre-niveau { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.titre-niveau { font-size: clamp(22px, 3vw, 30px); margin: 0; flex: 1; }
.etoiles-niveau { font-size: 22px; color: var(--or-fonce); letter-spacing: 2px; }
.etoiles-niveau .vide { color: var(--bord-fort); }

.disposition { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.colonne-plateau { position: sticky; top: 84px; }

.onglets { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.onglet { border-radius: 999px; border: 2px solid var(--bord-fort); background: #fff; padding: 8px 16px; font-weight: 700; min-height: 48px; }
.onglet[aria-pressed="true"] { background: var(--marine); color: #fff; border-color: var(--marine); }
.onglet.ok::after { content: ' ✓'; color: var(--menthe); }
.onglet[aria-pressed="true"].ok::after { color: #fff; }
.onglet.ko::after { content: ' ✗'; color: var(--orange-fonce); }
.note-cartes { font-size: 14px; color: var(--stone); margin-bottom: 10px; }

.cadre-plateau { scroll-margin-top: 76px; background: #fff; border: 2px solid var(--bord); border-radius: 28px; padding: 14px; }
.plateau { position: relative; display: grid; width: 100%; max-width: 640px; margin: 0 auto; gap: 3px; }
.case { aspect-ratio: 1; border-radius: 22%; background: var(--creme); border: 2px solid rgba(107, 107, 107, 0.1); position: relative; display: grid; place-items: center; transition: background .25s; }
.case.mur { background: var(--marine-doux); border-color: var(--marine); }
.case.mur.cache { background: transparent; border-color: transparent; }
.case.cible { border: 3px dashed var(--orange-clair); }
.case.peinte { border-style: solid; }
.case svg { width: 74%; height: 74%; }
.case .gemme-svg { animation: briller 2.4s ease-in-out infinite; }
@keyframes briller { 50% { transform: scale(1.08) rotate(6deg); } }
.case .gemme-svg.partie { animation: ramassee .45s ease-in forwards; }
@keyframes ramassee { to { transform: translateY(-60%) scale(0.2); opacity: 0; } }

.robot {
  position: absolute; top: 0; left: 0; z-index: 2; pointer-events: none;
  transition: transform var(--duree) cubic-bezier(.4, 0, .2, 1);
}
.robot-corps { position: relative; width: 100%; height: 100%; transition: transform var(--duree) cubic-bezier(.4, 0, .2, 1); }
.robot-corps svg { width: 100%; height: 100%; display: block; }
/* Une flèche devant le robot : on voit d'un coup d'œil où il regarde (le visage seul était ambigu). */
.robot-corps::before { content: ''; position: absolute; left: 40%; top: -14%; width: 20%; height: 14%; background: var(--orange-fonce); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.robot.choc .robot-corps svg { animation: choc .35s ease-out; }
@keyframes choc { 30% { transform: translateY(-14%); } 60% { transform: translateY(4%); } }
.robot.triste .robot-corps svg { filter: grayscale(0.6); }
.robot.content .robot-corps svg { animation: sauter .5s ease-out 2; }
@keyframes sauter { 40% { transform: translateY(-18%) scale(1.06); } }

.bulle {
  position: absolute; z-index: 3; transform: translate(-50%, -100%);
  background: #fff; border: 2px solid var(--charcoal); border-radius: 16px; padding: 4px 12px;
  font-weight: 800; font-family: var(--police-titre); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none; animation: apparaitre .2s ease-out;
  transition: left var(--duree) cubic-bezier(.4, 0, .2, 1), top var(--duree) cubic-bezier(.4, 0, .2, 1);
}
.bulle::after { content: ''; position: absolute; left: 50%; bottom: -8px; width: 12px; height: 12px; background: #fff; border-right: 2px solid var(--charcoal); border-bottom: 2px solid var(--charcoal); transform: translateX(-50%) rotate(45deg); }
@keyframes apparaitre { from { opacity: 0; transform: translate(-50%, -80%); } }

.reglage-vitesse { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 15px; color: var(--stone); flex-wrap: wrap; }
.reglage-vitesse label { font-weight: 700; color: var(--charcoal); }
.reglage-vitesse input { accent-color: var(--orange); width: 140px; }
.legende { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; color: var(--stone); }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.mini { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.mini.gemme { background: var(--menthe); transform: rotate(45deg) scale(.8); }
.mini.drapeau { background: var(--orange); }
.mini.cible { border: 2px dashed var(--orange-clair); }

.mission { margin-bottom: 14px; }
.texte-mission { font-size: 18px; font-weight: 600; margin: 0; }
.concept { margin-bottom: 14px; }
.concept[open] summary { margin-bottom: 8px; }
.exemple { background: var(--charcoal); color: #FFE9DC; border-radius: 14px; padding: 12px 16px; margin: 0; font-size: 15px; overflow-x: auto; }

/* ---------- éditeur ---------- */
.editeur { background: #fff; border: 2px solid var(--bord-fort); border-radius: 22px; overflow: hidden; }
.editeur:focus-within { border-color: var(--orange); }
.editeur-entete { display: flex; justify-content: space-between; gap: 8px; padding: 8px 14px; background: var(--creme); border-bottom: 2px solid var(--bord); font-size: 13px; font-weight: 800; color: var(--marine); text-transform: uppercase; letter-spacing: 0.1em; }
.lien-editeur { background: none; border: 0; padding: 0 0 0 10px; font-size: 13px; font-weight: 700; text-transform: none; letter-spacing: 0; color: var(--stone); text-decoration: underline; min-height: 24px; }
.lien-editeur:hover { color: var(--orange-fonce); }
.editeur-entete { align-items: center; flex-wrap: wrap; }
.compte-lignes { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 700; color: var(--stone); }
.compte-lignes.ok { color: var(--menthe-fonce); }
.editeur-corps { display: flex; font-family: var(--police-code); font-size: var(--taille-code, 16px); line-height: 1.625; }
.gouttiere { flex: none; width: 2.8em; padding: 12px 0; text-align: right; color: var(--stone); background: var(--creme); user-select: none; overflow: hidden; height: 340px; }
.gouttiere div { padding-right: 10px; height: 1.625em; }
.gouttiere .active { color: var(--orange-fonce); font-weight: 800; }
.gouttiere .fautive { color: #fff; background: var(--orange-fonce); }
.zone-texte { position: relative; flex: 1; min-width: 0; }
.surlignage { position: absolute; left: 0; right: 0; height: 1.625em; background: rgba(255, 107, 53, 0.16); border-left: 4px solid var(--orange); pointer-events: none; display: none; transition: top .12s; }
.surlignage.fautive { background: rgba(230, 74, 25, 0.14); border-left-color: var(--orange-fonce); }
textarea#code {
  position: relative; display: block; width: 100%; height: 340px; resize: vertical; border: 0; outline: none;
  padding: 12px 14px; background: transparent; color: var(--charcoal);
  font: inherit; line-height: 1.625; tab-size: 2; white-space: pre; overflow-wrap: normal; overflow: auto;
}

.palette { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.extrait { font-family: var(--police-code); font-size: 15px; font-weight: 600; min-height: 48px; padding: 6px 14px; border-radius: 14px; border: 2px solid var(--bord-fort); background: #F4F1EE; }
.extrait:hover { border-color: var(--orange); background: #fff; }
.extrait.question { background: rgba(89, 205, 144, 0.14); border-color: rgba(89, 205, 144, 0.5); }
.extrait.structure { background: rgba(46, 64, 87, 0.07); border-color: rgba(46, 64, 87, 0.25); }
.aide-palette { font-size: 13px; color: var(--stone); margin: 8px 0 0; }
.aide-bouton { margin: 10px 0 0; padding: 8px 12px; border-radius: 12px; background: rgba(46, 64, 87, 0.06); color: var(--marine); font-size: 15px; font-weight: 600; min-height: 2.6em; }
.question-exemple { background: rgba(89, 205, 144, 0.2); border-radius: 6px; padding: 0 5px; }

.commandes { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; align-items: center; }
.commandes .espace { flex: 1; }

.message { margin-top: 16px; scroll-margin-top: 76px; border-radius: 18px; padding: 14px 18px; border: 2px solid; font-weight: 600; }
.message.erreur { background: var(--rose-doux); border-color: var(--rose); }
.message.info { background: rgba(46, 64, 87, 0.06); border-color: rgba(46, 64, 87, 0.2); }
.message.succes { background: rgba(89, 205, 144, 0.15); border-color: rgba(89, 205, 144, 0.5); }
.message ul { margin: 6px 0 0; padding-left: 20px; font-weight: 500; }
.message .conseil { font-weight: 500; color: var(--marine); margin: 8px 0 0; }

/* ---------- fenêtres ---------- */
.fenetre { border: 0; border-radius: 28px; padding: 0; max-width: min(480px, 94vw); width: 100%; background: var(--creme); color: var(--charcoal); box-shadow: 0 20px 60px rgba(31, 27, 22, 0.25); }
.fenetre.large { max-width: min(760px, 94vw); }
.fenetre::backdrop { background: rgba(31, 27, 22, 0.45); }
.fenetre-corps { padding: 26px; max-height: 86vh; overflow: auto; }
.fenetre-corps.centre { text-align: center; }
.fenetre-boutons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.centre .fenetre-boutons { justify-content: center; }
.grosses-etoiles { font-size: 54px; letter-spacing: 6px; margin: 0; color: var(--or); }
.grosses-etoiles .vide { color: var(--bord-fort); }
.grosses-etoiles span { display: inline-block; animation: etoile .5s cubic-bezier(.3, 1.6, .5, 1) both; }
.grosses-etoiles span:nth-child(2) { animation-delay: .15s; }
.grosses-etoiles span:nth-child(3) { animation-delay: .3s; }
@keyframes etoile { from { transform: scale(0) rotate(-90deg); } }
.liste-etoiles { list-style: none; padding: 0; text-align: left; display: inline-block; }
.liste-etoiles li { margin: 4px 0; }

.aide-famille { margin: 16px 0 6px; font-size: 17px; }
.aide-ligne { display: grid; grid-template-columns: minmax(150px, 210px) 1fr; gap: 12px; padding: 8px 0; border-bottom: 2px solid var(--bord); }
.aide-ligne code { font-weight: 700; }

.champ { display: grid; gap: 6px; font-weight: 700; margin-bottom: 16px; }
.champ input { font: inherit; padding: 12px 16px; border-radius: 16px; border: 2px solid var(--bord-fort); background: #fff; }
.diplome { text-align: center; background: #fff; border: 6px double var(--or); border-radius: 28px; padding: 32px 24px; }
.diplome-logo { font-size: 44px; margin: 0; }
.diplome h2 { font-size: 34px; color: var(--orange-fonce); }
.diplome-nom { font-family: var(--police-titre); font-size: 36px; font-weight: 900; border-bottom: 3px solid var(--orange); display: inline-block; padding: 0 20px; min-width: 50%; }
.diplome-etoiles { color: var(--or); font-weight: 800; font-size: 20px; }
.diplome-date { color: var(--stone); }

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

/* ---------- petits écrans ---------- */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .hero-image { max-width: 200px; grid-row: 1; }
  .disposition { grid-template-columns: 1fr; }
  .colonne-plateau { position: static; }
  .gouttiere, textarea#code { height: 240px; }
  .commandes .bouton.principal { flex: 1; }
  .logo .logo-yeees { font-size: 24px; }
  .logo-code { font-size: 18px; }
  .compteur { padding: 4px 10px; font-size: 14px; }
  .rond { width: 40px; height: 40px; }
  .titre-niveau { flex-basis: 100%; order: 3; }
  .cadre-plateau { padding: 8px; }
}
/* Très petits écrans (et zoom fort) : rien ne doit déborder. Le total d'étoiles se lit aussi sur le parcours. */
@media (max-width: 360px) {
  .compteur { display: none; }
  .entete { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .vue { padding-left: 10px; padding-right: 10px; }
  .hero h1 { font-size: 28px; }
  .bouton.grand { padding: 12px 24px; font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
@media print {
  body * { visibility: hidden; }
  #dlg-diplome, #dlg-diplome .diplome, #dlg-diplome .diplome * { visibility: visible; }
  #dlg-diplome { position: absolute; inset: 0; box-shadow: none; max-width: none; background: #fff; }
  #dlg-diplome .diplome { position: absolute; left: 0; right: 0; top: 0; }
}
.message p.m0 { margin: 0; }
