/* vitrail/vitrail.css — « L'Atelier du Maître Verrier » (patron : miroirs/miroirs.css) */
:root {
  --ink: #f6efe2; --dim: #c9b9a0; --or: #ffd36a; --vert: #8dffc0; --cyan: #7fe0ff; --rouge: #ff9a8a; --violet: #c4a2ff;
  --panel: rgba(20, 14, 8, .9); --bord: rgba(255, 211, 106, .28); --sw: 1024px;
  --u: calc(var(--sw) / 1280);
  --serif: Georgia, "Times New Roman", Times, serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: #0b0710; color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-tap-highlight-color: transparent; }
body { overflow-x: hidden; }
button { touch-action: manipulation; }
.wrap { position: relative; z-index: 1; width: var(--sw); max-width: 100%; margin: 0 auto; }

/* Notation d'un angle : le chapeau au-dessus des trois lettres */
.ang { position: relative; display: inline-block; font-style: italic; font-family: var(--serif); padding: 0 1px; }
.ang::before { content: ''; position: absolute; left: 6%; right: 6%; top: -.3em; height: .34em;
  background: linear-gradient(to top left, transparent calc(50% - 1px), currentColor calc(50% - .5px), currentColor calc(50% + .5px), transparent calc(50% + 1px)) left / 50% 100% no-repeat,
              linear-gradient(to top right, transparent calc(50% - 1px), currentColor calc(50% - .5px), currentColor calc(50% + .5px), transparent calc(50% + 1px)) right / 50% 100% no-repeat; }

/* ── Bandeau ─────────────────────────────────────────────────────────────── */
.fv-header { display: flex; align-items: center; gap: 6px; padding: 6px 8px; min-height: 50px; background: linear-gradient(180deg, #2a1830, #150c18); border-bottom: 1px solid var(--bord); }
.fv-header .titre { flex: 1; min-width: 0; font-weight: 700; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fv-header .titre small { color: var(--dim); font-weight: 400; }
.pastille { flex: none; display: inline-flex; align-items: center; gap: 4px; background: rgba(255,255,255,.06); border: 1px solid var(--bord); border-radius: 99px; padding: 6px 11px; font-size: .88rem; color: var(--ink); }
.pastille.possibles { color: var(--or); letter-spacing: 1px; }
.pastille.possibles i { font-style: normal; opacity: .45; }
.btn-rond { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--bord); background: rgba(255,255,255,.06); color: var(--ink); font-size: 1.05rem; padding: 0; cursor: pointer; font-family: inherit; }
.btn-rond:active { transform: scale(.94); }
.btn-rond:disabled { opacity: .35; cursor: default; }
.btn-rond.actif { background: linear-gradient(135deg, #fff1b8, #ffc94d); border-color: transparent; }

/* ── Scène ───────────────────────────────────────────────────────────────── */
.scene { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; background: #1a0f08; touch-action: none; }
.scene canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.calque { position: absolute; pointer-events: none; }
.bulle { left: calc(40 * var(--u)); top: calc(30 * var(--u)); width: min(calc(520 * var(--u)), 92%); max-height: calc(380 * var(--u)); overflow: auto; padding: calc(12 * var(--u)) calc(16 * var(--u)); border-radius: calc(18 * var(--u));
  background: rgba(30, 16, 34, .93); border: 1px solid var(--bord); box-shadow: 0 8px 30px rgba(0,0,0,.6); font-size: max(12.5px, calc(19 * var(--u))); line-height: 1.4; opacity: 0; transform: translateY(-10px); transition: opacity .3s, transform .3s; }
.bulle.vue { opacity: 1; transform: none; }
.bulle .qui { color: var(--or); font-weight: 700; margin-bottom: 2px; }
.bulle b { color: var(--or); }

/* ── Console ─────────────────────────────────────────────────────────────── */
.console { position: relative; background: linear-gradient(180deg, #24152a, #120a14); border-top: 1px solid var(--bord); padding: 8px 10px 2px; }
.consigne { text-align: center; color: var(--ink); font-size: .98rem; line-height: 1.5; min-height: 1.5em; margin: 0 auto 8px; max-width: 920px; }
.consigne b { color: var(--or); }
.num-etape { display: inline-block; font-size: .78rem; font-weight: 800; color: #1a1006; background: var(--or); border-radius: 99px; padding: 1px 8px; margin-right: 4px; vertical-align: 1px; }
.tag5e { display: inline-block; font-size: .75rem; font-weight: 800; color: #1a0620; background: var(--violet); border-radius: 99px; padding: 1px 8px; margin-left: 4px; vertical-align: 1px; }
.commandes { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ligne { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 10px; }
.etiq { color: var(--dim); font-size: .82rem; font-weight: 700; }
.puces { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; border-radius: 99px; transition: box-shadow .3s; }
.puces.appel { box-shadow: 0 0 0 3px rgba(255, 154, 138, .8); }
.puce { font: 700 .95rem system-ui, sans-serif; padding: 9px 14px; min-height: 46px; min-width: 64px; border-radius: 99px; border: 1px solid var(--bord); background: rgba(255,255,255,.06); color: var(--ink); cursor: pointer; }
.puce.actif { background: linear-gradient(135deg, #fff1b8, #ffc94d); color: #2a1406; border-color: transparent; box-shadow: 0 0 14px rgba(255, 201, 77, .5); }
.touche:active, .puce:active { transform: scale(.94); }
.saisie { display: flex; align-items: baseline; gap: 2px; padding: 4px 14px; border-radius: 14px; background: rgba(0,0,0,.35); border: 1px solid rgba(255,211,106,.35); transition: opacity .2s; }
.champ { min-width: 2.2em; text-align: right; font: 700 1.7rem var(--serif); color: #fff; font-variant-numeric: lining-nums tabular-nums; }
.champ.vide { color: rgba(255,255,255,.3); }
.unite { font: 700 1.4rem var(--serif); color: var(--or); }
.pave { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; max-width: 640px; transition: opacity .2s; }
.pave.grise, .saisie.grise { opacity: .38; }
.touche { width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--bord); background: linear-gradient(180deg, rgba(255,255,255,.1), rgba(255,255,255,.03)); color: var(--ink); font: 700 1.2rem system-ui, sans-serif; cursor: pointer; padding: 0; }
.touche.efface { width: 54px; color: var(--rouge); }
.etat-pointe { color: var(--dim); font-size: .92rem; }
.etat-pointe b { color: var(--or); }
.pied { display: flex; align-items: center; justify-content: center; min-height: 34px; margin-top: 2px; padding: 0 130px 0 60px; }
.pied .msg { flex: 1; text-align: center; font-size: .9rem; color: var(--dim); min-height: 1.2em; }
.pied .msg.ok { color: var(--vert); } .pied .msg.ko { color: var(--rouge); }
.pied .msg b { color: inherit; }
.bouton { cursor: pointer; font: 800 1rem system-ui, sans-serif; padding: 11px 18px; border-radius: 12px; border: 0; color: #2a1406; background: linear-gradient(135deg, #fff1b8, #ffc94d); box-shadow: 0 0 20px rgba(255, 201, 77, .45); min-height: 46px; }
.bouton.tirer { min-height: 50px; padding: 10px 22px; font-size: 1.05rem; animation: appel 2.4s ease-in-out infinite; }
.bouton:disabled { opacity: .38; animation: none; cursor: default; box-shadow: none; }
@keyframes appel { 50% { box-shadow: 0 0 34px rgba(255, 210, 100, .85); } }
.bouton:active { transform: scale(.96); }
.bouton.violet { color: #fff; background: linear-gradient(135deg, #8e6bff, #5a3fd0); box-shadow: 0 0 18px rgba(142, 107, 255, .4); }
.bouton.discret { color: var(--ink); background: rgba(255,255,255,.08); box-shadow: none; border: 1px solid var(--bord); }

/* ── Dialogues ───────────────────────────────────────────────────────────── */
.voile { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center; padding: 12px; background: rgba(8, 3, 10, .62); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.voile.ouvert { display: flex; }
.voile.bas { align-items: flex-end; background: linear-gradient(180deg, transparent 35%, rgba(8, 3, 10, .72)); backdrop-filter: none; -webkit-backdrop-filter: none; }
.voile.bas .dialogue { margin-bottom: 64px; max-height: 50dvh; }
.voile.haut { align-items: flex-start; background: linear-gradient(0deg, transparent 35%, rgba(8, 3, 10, .72)); backdrop-filter: none; -webkit-backdrop-filter: none; }
.voile.haut .dialogue { margin-top: 4px; max-height: 48dvh; }
/* Explication posée à droite (sur le vitrail) : l'esquisse et le rapporteur restent visibles */
.voile.cote { justify-content: flex-end; align-items: flex-start; background: linear-gradient(270deg, rgba(8, 3, 10, .55), transparent 40%); backdrop-filter: none; -webkit-backdrop-filter: none; padding-top: 56px; }
.voile.cote .dialogue { width: min(360px, 36vw); max-height: calc(100dvh - 130px); padding: 14px 16px; }
.voile.cote .dialogue p { font-size: .98rem; line-height: 1.5; }
.dialogue { width: min(100%, 680px); max-height: calc(100dvh - 24px); overflow: auto; -webkit-overflow-scrolling: touch; background: linear-gradient(180deg, #2c1a30, #150a16); border: 1px solid var(--bord); border-radius: 20px;
  padding: 18px 20px; box-shadow: 0 20px 60px rgba(0,0,0,.75), 0 0 40px rgba(200, 140, 255, .14); animation: monte .35s ease-out; color: var(--ink); }
@keyframes monte { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }
.dialogue .qui { font-weight: 800; color: var(--or); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.dialogue .qui.ombre { color: #b9b9c8; }
.dialogue .qui span { font-size: 1.7rem; }
.dialogue p { margin: 0 0 12px; line-height: 1.6; font-size: 1.04rem; }
.dialogue p.tt { min-height: 3.2em; }
.dialogue b { color: var(--or); }
.dialogue .avertit { color: var(--rouge); font-size: .92rem; }
.dialogue .actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.grosse-etoiles { font-size: 2.6rem; text-align: center; color: var(--or); letter-spacing: 8px; text-shadow: 0 0 18px rgba(255,211,106,.7); margin: 4px 0 6px; }
.grosse-etoiles i { font-style: normal; display: inline-block; animation: etoile .6s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes etoile { from { transform: scale(0) rotate(-120deg); opacity: 0; } }

/* Carte des chapitres */
.carte h2 { margin: 0 0 4px; text-align: center; font: 700 1.6rem var(--serif); color: #fff; text-shadow: 0 0 18px rgba(255, 180, 230, .5); }
.carte .sous { text-align: center; color: var(--dim); margin: 0 0 14px; font-size: .92rem; }
.carte .legende { text-align: center; color: var(--dim); font-size: .82rem; margin: 10px 0 0; }
.chapitres { display: grid; gap: 10px; }
.chap { --c: #ffd36a; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; border: 1px solid rgba(255,255,255,.18); cursor: pointer; text-align: left; font: inherit; color: var(--ink);
  background: linear-gradient(90deg, rgba(255,255,255,.08), rgba(255,255,255,.02)); }
.chap:disabled { opacity: .45; cursor: default; }
.chap .num { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; font: 800 1.3rem var(--serif); color: #1a1006; background: radial-gradient(circle at 35% 30%, #fff, var(--c) 60%); box-shadow: 0 0 16px var(--c); }
.chap .t { flex: 1; font-weight: 700; }
.chap .t small { display: block; font-weight: 400; color: var(--dim); font-size: .8rem; }
.chap .barre { display: block; height: 5px; border-radius: 3px; background: rgba(255,255,255,.08); margin-top: 6px; overflow: hidden; }
.chap .barre i { display: block; height: 100%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.chap .et { color: var(--or); font-size: .9rem; white-space: nowrap; }
.niveaux-liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-top: 12px; }
.niveaux-liste button { font: inherit; text-align: left; cursor: pointer; padding: 9px 11px; border-radius: 12px; border: 1px solid var(--bord); background: rgba(255,255,255,.05); color: var(--ink); min-height: 44px; }
.niveaux-liste button:disabled { opacity: .4; cursor: default; }
.niveaux-liste .gestes { float: right; font-size: .9rem; }
.niveaux-liste .et { color: var(--or); font-size: .85rem; display: block; letter-spacing: 2px; }
.niveaux-liste .boss { border-color: rgba(255, 143, 176, .6); }

/* Carnet du verrier (fiche de révision) */
.grimoire { background: linear-gradient(180deg, #f1e3bf, #e2cd9d); color: #2a1406; border-radius: 14px; padding: 14px 16px; box-shadow: inset 0 0 40px rgba(120, 80, 30, .35); }
.grimoire h3 { margin: 12px 0 6px; font: 700 1.15rem var(--serif); color: #5a2a10; border-bottom: 1px solid rgba(90,42,16,.3); padding-bottom: 3px; }
.grimoire h3:first-child { margin-top: 0; }
.grimoire .regle { margin: 0 0 8px; line-height: 1.5; font-size: .98rem; }
.grimoire .regle b { color: #7a2a10; }
.grimoire .ex { display: block; font-family: var(--serif); color: #3a2a6a; margin-top: 2px; }
.grimoire .scelle { color: #8a6a40; font-style: italic; }

/* À propos (SEO) */
.seo-about { max-width: 840px; margin: 26px auto 16px; padding: 16px 22px; border-radius: 14px; background: rgba(34, 20, 36, .8); border: 1px solid var(--bord); color: var(--dim); font-size: .92rem; line-height: 1.55; }
.seo-about h2 { color: var(--or); font-size: 1.05rem; margin: 0 0 8px; }
.seo-about a { color: var(--cyan); }

@media (max-width: 820px) {
  .pied { padding: 0 96px 0 50px; }
  .touche { width: 42px; height: 44px; font-size: 1.1rem; }
  .puce { min-width: 56px; padding: 8px 11px; }
  .consigne { font-size: .93rem; }
}
@media (max-width: 600px) {
  #etoilesTotal { display: none; }
  .pastille { padding: 5px 8px; font-size: .8rem; }
  .fv-header .titre small { display: none; }
  .btn-rond { width: 36px; height: 36px; font-size: .95rem; }
  .fv-header { gap: 4px; padding: 5px 5px; }
  .etiq { display: none; }
  .pied { padding: 0 70px 0 40px; }
}
/* Garde-fous thèmes du site (le bandeau et le jeu gardent leur fond sombre : texte clair obligatoire) */
body[class*="theme-"] .fv-header, body[class*="theme-"] .fv-header * { color: #fff !important; -webkit-text-fill-color: #fff !important; text-shadow: none !important; }
body[class*="theme-"] .wrap, body[class*="theme-"] .wrap * { color: #f6efe2 !important; -webkit-text-fill-color: #f6efe2 !important; }
body[class*="theme-"] .wrap .unite, body[class*="theme-"] .wrap .consigne b { color: #ffd36a !important; -webkit-text-fill-color: #ffd36a !important; }
body[class*="theme-"] .wrap .bouton:not(.violet):not(.discret), body[class*="theme-"] .wrap .bouton:not(.violet):not(.discret) *, body[class*="theme-"] .wrap .puce.actif, body[class*="theme-"] .wrap .num-etape, body[class*="theme-"] .wrap .tag5e { color: #2a1406 !important; -webkit-text-fill-color: #2a1406 !important; }
body[class*="theme-"] .voile .dialogue, body[class*="theme-"] .voile .dialogue * { color: #f6efe2 !important; -webkit-text-fill-color: #f6efe2 !important; }
body[class*="theme-"] .voile .bouton:not(.discret):not(.violet) { color: #2a1406 !important; -webkit-text-fill-color: #2a1406 !important; }
body[class*="theme-"] .voile .grimoire, body[class*="theme-"] .voile .grimoire * { color: #2a1406 !important; -webkit-text-fill-color: #2a1406 !important; }

/* Guide des gestes du rapporteur (premiers niveaux seulement, puis il disparaît) */
.guide { right: calc(290 * var(--u)); top: calc(24 * var(--u)); width: min(calc(380 * var(--u)), 60%); padding: calc(8 * var(--u)) calc(12 * var(--u)); border-radius: calc(14 * var(--u));
  background: rgba(16, 40, 26, .9); border: 1px solid rgba(141, 255, 192, .45); font-size: max(11.5px, calc(16 * var(--u))); line-height: 1.35; opacity: 0; transition: opacity .3s; }
.guide.vu { opacity: 1; }
.guide b { color: var(--vert); }
.guide ol { list-style: none; margin: 4px 0 0; padding: 0; }
.guide li { color: rgba(246, 239, 226, .55); margin: 2px 0; }
.guide li.actif { color: #fff; font-weight: 700; }
.guide li.fait { color: var(--vert); }
.puce.nom { font: italic 700 1.15rem var(--serif); padding-top: 12px; }

/* Diplôme */
.note-diplome { font-size: .92rem !important; color: var(--dim); }
.champ-nom { display: flex; flex-direction: column; gap: 4px; margin: 0 0 10px; font-weight: 700; color: var(--or); }
.champ-nom input { font: 700 1.2rem var(--serif); padding: 10px 12px; border-radius: 12px; border: 2px solid var(--bord); background: #fff8ea; color: #1d2c5a; -webkit-text-fill-color: #1d2c5a; min-height: 48px; }
.champ-nom input.vide { border-color: var(--rouge); box-shadow: 0 0 0 3px rgba(255, 154, 138, .5); }
.apercu-diplome canvas { width: 100%; height: auto; display: block; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
.aide-ios { font-size: .92rem; color: var(--ink); }
.aide-ios img { width: 100%; margin-top: 8px; border-radius: 8px; }
body[class*="theme-"] .voile .champ-nom input { color: #1d2c5a !important; -webkit-text-fill-color: #1d2c5a !important; }
body[class*="theme-"] .wrap .guide li.fait { color: #8dffc0 !important; -webkit-text-fill-color: #8dffc0 !important; }
@media (max-width: 600px) { .guide { display: none; } }

/* Bouton de la loupe de lecture (bien visible pendant toute mesure / construction) */
.bouton.loupe { color: #06213a; background: linear-gradient(135deg, #d8f1ff, #7cc8ff); box-shadow: 0 0 16px rgba(124, 200, 255, .45); min-width: 120px; }
.bouton.loupe.actif { color: #fff; background: linear-gradient(135deg, #2f6fb0, #1c4677); }
.bouton.loupe.appel { animation: appelLoupe 1.4s ease-in-out infinite; }
@keyframes appelLoupe { 50% { box-shadow: 0 0 0 6px rgba(124, 200, 255, .55), 0 0 30px rgba(124, 200, 255, .8); } }
body[class*="theme-"] .wrap .bouton.loupe:not(.actif) { color: #06213a !important; -webkit-text-fill-color: #06213a !important; }

/* Guidage de la 1re construction : flèche au-dessus du bouton à toucher */
.bouton.montre { position: relative; outline: 3px solid #fff1b8; outline-offset: 3px; }
.bouton.montre::before { content: '⬇'; position: absolute; left: 50%; top: -40px; transform: translateX(-50%); font-size: 30px; line-height: 1; color: #ffc23a; -webkit-text-fill-color: #ffc23a; text-shadow: 0 0 6px #000, 0 0 2px #fff; animation: rebond .8s ease-in-out infinite; pointer-events: none; }
@keyframes rebond { 50% { transform: translate(-50%, -8px); } }
/* Guide des gestes (ch. 6) : le bouton à utiliser maintenant bat doucement */
.bouton.appel-geste { animation: appelGeste 1.1s ease-in-out infinite; box-shadow: 0 0 0 3px #ffc23a, 0 0 18px rgba(255, 194, 58, .7); }
@keyframes appelGeste { 50% { transform: scale(1.06); } }
