/* La botanique des fleuristes — schémas à légender */

@font-face { font-family: "Manrope"; src: url(polices/manrope-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Manrope"; src: url(polices/manrope-600.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Manrope"; src: url(polices/manrope-800.woff2) format("woff2"); font-weight: 800; font-display: swap; }

:root {
    --bordeaux: #973c3e;
    --bordeaux-fonce: #7a2f31;
    --papier: #f7f3ec;
    --carte: #ffffff;
    --texte: #232323;
    --discret: #6b6560;
    --trait: #e3dcd1;
    --case: #f1ece3;
    --vert: #2e7d32;
    --vert-clair: #e7f3e8;
    --rouge: #c62828;
    --rouge-clair: #fbe9e9;
    --bleu-sol: #1f5aa6;
    --bleu-sol-clair: #e8f0fb;
    --selection: #f0b429;
    --ombre: 0 1px 2px rgba(60, 40, 30, .06), 0 4px 16px rgba(60, 40, 30, .07);
    --rayon: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--papier);
    color: var(--texte);
    font: 16px/1.45 "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button { font: inherit; color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--selection); outline-offset: 2px; }

/* ---------- Bandeau ---------- */
.bandeau {
    position: sticky; top: 0; z-index: 20;
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
    padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
    background: var(--bordeaux); color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
}
.bandeau-papier {
    justify-self: start;
    color: #fff; text-decoration: none; font-weight: 600; font-size: 14px;
    padding: 7px 12px; border: 1px solid rgba(255, 255, 255, .55); border-radius: 999px;
}
.bandeau-papier:hover { background: rgba(255, 255, 255, .12); }
.bandeau-titre { display: flex; flex-direction: column; align-items: center; text-align: center; line-height: 1.2; }
.bandeau-livre { font-weight: 800; font-size: 18px; letter-spacing: .01em; }
.bandeau-auteur { font-size: 13px; opacity: .85; }
.bandeau-sommaire {
    justify-self: end;
    display: inline-flex; align-items: center; gap: 8px;
    background: #fff; color: var(--bordeaux); border: 0; border-radius: 999px;
    padding: 8px 14px; font-weight: 800; font-size: 14px; cursor: pointer;
}
.bandeau-sommaire svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.bandeau-sommaire:hover { background: #fbeeee; }

/* ---------- Mise en page ---------- */
main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 18px 16px 28px; }
.pied { text-align: center; font-size: 13px; color: var(--discret); padding: 16px; border-top: 1px solid var(--trait); }

.entete-schema {
    display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
    margin-bottom: 16px;
}
.entete-infos { text-align: center; }
.entete-meta { margin: 0 0 2px; font-size: 13px; font-weight: 600; color: var(--bordeaux); text-transform: uppercase; letter-spacing: .06em; }
.entete-titre { margin: 0; font-size: clamp(20px, 3vw, 28px); font-weight: 800; line-height: 1.2; }
.nav {
    width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--trait);
    background: var(--carte); box-shadow: var(--ombre); cursor: pointer;
    font-size: 28px; line-height: 1; color: var(--bordeaux); display: grid; place-items: center;
}
.nav:hover:not(:disabled) { background: #fbeeee; }
.nav:disabled { opacity: .35; cursor: default; box-shadow: none; }

.espace { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.carte { background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre); }

/* ---------- Schéma ---------- */
.figure { margin: 0; padding: 14px; position: sticky; top: 84px; }
.figure-bouton { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.figure-bouton img { display: block; margin: 0 auto; max-height: min(70vh, 620px); width: auto; border-radius: 6px; }
.figure-aide { margin: 8px 0 0; text-align: center; font-size: 13px; color: var(--discret); }

/* ---------- Exercice ---------- */
.exercice { padding: 16px; }
.consigne { margin: 0 0 12px; font-size: 14px; color: var(--discret); }
.lignes { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.ligne { display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 10px; }
.repere {
    width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
    border: 2.5px solid currentColor; background: #fff; font-weight: 800; font-size: 15px; justify-self: center;
}
.repere-image { width: 40px; height: 40px; border: 0; border-radius: 6px; overflow: hidden; }
.repere-image img { width: 40px; height: 40px; object-fit: contain; }

.case {
    min-height: 44px; width: 100%; padding: 4px; text-align: left;
    border: 2px dashed #cfc6b8; border-radius: 10px; background: var(--case); cursor: pointer;
    display: flex; align-items: center;
}
.case:empty::before { content: attr(data-vide); color: #a39a8d; font-size: 14px; padding-left: 8px; }
.case:not(:empty) { border-color: transparent; background: none; padding: 0; }
.case:not(:empty).survol { border-color: var(--bordeaux); background: #fbeeee; padding: 2px; }
.case.survol, .banque.survol { border-color: var(--bordeaux); background: #fbeeee; }
.case.cible { border-style: solid; border-color: var(--selection); background: #fff8e6; }

.banque {
    display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start;
    min-height: 56px; padding: 10px; border: 2px dashed transparent; border-radius: 12px; background: #faf8f4;
}
.banque-titre { margin: 4px 0 6px; font-size: 13px; font-weight: 600; color: var(--discret); }
.banque-vide { color: var(--discret); font-size: 14px; padding: 6px; }

.etiquette {
    touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
    border: 1.5px solid #d6cdbf; background: #fff; border-radius: 9px;
    padding: 8px 12px; font-size: 15px; font-weight: 600; line-height: 1.25; text-align: left;
    cursor: grab; box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
.case .etiquette { width: 100%; }
.etiquette:hover { border-color: var(--bordeaux); }
.etiquette.choisie { border-color: var(--selection); background: #fff8e6; box-shadow: 0 0 0 3px rgba(240, 180, 41, .35); }
.etiquette.fantome { position: fixed; z-index: 100; pointer-events: none; cursor: grabbing; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); transform: rotate(-1.5deg); }
.etiquette.en-vol { opacity: .35; }
.etiquette.juste { border-color: var(--vert); background: var(--vert-clair); color: #1b4d1e; cursor: default; }
.etiquette.fausse { border-color: var(--rouge); background: var(--rouge-clair); color: #7f1d1d; cursor: default; }
.etiquette.solution { border-color: var(--bleu-sol); background: var(--bleu-sol-clair); color: #173f75; cursor: default; }
.etiquette.juste::before { content: "✓ "; font-weight: 800; }
.etiquette.fausse::before { content: "✗ "; font-weight: 800; }
.verrou .etiquette { cursor: default; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.bouton {
    border: 1.5px solid var(--bordeaux); background: #fff; color: var(--bordeaux);
    border-radius: 999px; padding: 10px 18px; font-weight: 800; font-size: 15px; cursor: pointer;
}
.bouton:hover:not(:disabled) { background: #fbeeee; }
.bouton-principal { background: var(--bordeaux); color: #fff; }
.bouton-principal:hover:not(:disabled) { background: var(--bordeaux-fonce); }
.bouton:disabled { opacity: .45; cursor: default; }

.resultat { margin: 14px 0 0; padding: 12px 14px; border-radius: 10px; font-weight: 600; }
.resultat:empty { display: none; }
.resultat.bravo { background: var(--vert-clair); color: #1b4d1e; }
.resultat.presque { background: #fff4dc; color: #6b4a00; }
.resultat.revoir { background: var(--rouge-clair); color: #7f1d1d; }
.resultat .score { font-size: 22px; font-weight: 800; margin-right: 6px; }

/* ---------- Choix (7a/7b, 33a/33b) ---------- */
.choix-intro { text-align: center; font-size: 17px; margin: 4px 0 18px; }
.choix { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.choix-carte { display: block; width: 100%; padding: 14px; border: 2px solid transparent; text-align: left; cursor: pointer; }
.choix-carte:hover { border-color: var(--bordeaux); }
.choix-carte img { display: block; margin: 10px auto 0; max-height: 360px; width: auto; }
.choix-carte .entete-meta { text-align: left; }
.choix-carte strong { display: block; font-size: 18px; }

/* ---------- Fenêtres ---------- */
.fenetre { border: 0; border-radius: 16px; padding: 0; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); color: var(--texte); }
.fenetre::backdrop { background: rgba(35, 20, 20, .55); }
.fenetre-sommaire { width: min(720px, 94vw); max-height: 86vh; }
.fenetre-entete { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; background: #fff; border-bottom: 1px solid var(--trait); z-index: 1; }
.fenetre-entete h2 { margin: 0; font-size: 20px; }
.fermer { border: 0; background: var(--case); width: 40px; height: 40px; border-radius: 50%; font-size: 24px; cursor: pointer; line-height: 1; }
.sommaire-progression { margin: 12px 18px 0; color: var(--discret); font-size: 14px; }
.chapitre { padding: 6px 18px 12px; }
.chapitre h3 { margin: 12px 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--bordeaux); }
.chapitre ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.lien-schema {
    width: 100%; display: grid; grid-template-columns: 46px 1fr auto; align-items: center; gap: 10px;
    padding: 9px 10px; border: 0; border-radius: 10px; background: none; text-align: left; cursor: pointer;
}
.lien-schema:hover { background: var(--case); }
.lien-schema.actuel { background: #fbeeee; }
.lien-numero { font-weight: 800; color: var(--bordeaux); }
.lien-page { font-size: 13px; color: var(--discret); white-space: nowrap; }
.lien-etat { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 999px; margin-left: 6px; }
.lien-etat.reussi { background: var(--vert-clair); color: var(--vert); }
.lien-etat.essaye { background: #fff4dc; color: #8a5d00; }

.fenetre-loupe { width: 96vw; height: 92vh; max-width: none; max-height: none; background: #fff; overflow: hidden; }
.loupe-defilement { position: relative; width: 100%; height: 100%; overflow: hidden; touch-action: none; cursor: zoom-in; user-select: none; -webkit-user-select: none; }
.loupe-defilement.zoome { cursor: grab; }
.loupe-defilement img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; will-change: transform; -webkit-user-drag: none; pointer-events: none; }
.manipule .loupe-aide { opacity: 0; }
.loupe-aide { transition: opacity .4s; position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); margin: 0; padding: 6px 12px; border-radius: 999px; background: rgba(35, 35, 35, .72); color: #fff; font-size: 13px; pointer-events: none; white-space: nowrap; }
/* Bouton fixe à l'écran (le dialogue n'est pas transformé : fixed = par rapport à la fenêtre) */
.fenetre-loupe .fermer { position: fixed; top: calc(4vh + 10px); right: calc(2vw + 10px); z-index: 2; box-shadow: 0 2px 10px rgba(0, 0, 0, .25); background: #fff; }

.avertissement { background: var(--rouge-clair); padding: 14px; border-radius: 10px; }

/* ---------- Couleurs des repères (celles des schémas du livre) ---------- */
.couleur-B { color: #1f4fc4; }
.couleur-V { color: #2e7d32; }
.couleur-M { color: #c2187f; }
.couleur-R { color: #d32f2f; }
.couleur-N { color: #222; }
.couleur-LB { color: #0089a8; }
.couleur-O { color: #e66a00; }
.couleur-J { color: #8a6d00; background: #fff6c2; }
.couleur-MAR { color: #7b3f12; }

/* ---------- Petits écrans ---------- */
@media (max-width: 860px) {
    .espace { grid-template-columns: minmax(0, 1fr); }
    .figure { position: static; }
    .figure-bouton img { max-height: 48vh; }
    /* Réserve d'étiquettes fixée en bas de l'écran, défilant horizontalement */
    .banque-titre { display: none; }
    .banque {
        position: sticky; bottom: 0; z-index: 10;
        flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
        margin: 10px -12px -12px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
        border: 0; border-top: 1px solid var(--trait); border-radius: 0 0 var(--rayon) var(--rayon);
        background: rgba(255, 255, 255, .97); box-shadow: 0 -6px 18px rgba(60, 40, 30, .12);
        scrollbar-width: thin;
    }
    .banque .etiquette { flex: 0 0 auto; white-space: nowrap; touch-action: pan-x; }
    .banque.survol { background: #fbeeee; }
    .actions { margin-top: 16px; }
}
@media (max-width: 560px) {
    main { padding: 12px 10px 20px; }
    .bandeau { grid-template-columns: auto 1fr auto; gap: 8px; padding-top: 8px; padding-bottom: 8px; }
    .bandeau-livre { font-size: 15px; }
    .bandeau-auteur { font-size: 11px; }
    .bandeau-papier { padding: 6px 10px; font-size: 13px; }
    .bandeau-sommaire span { display: none; }
    .bandeau-sommaire { padding: 9px; }
    .entete-schema { gap: 8px; }
    .nav { width: 42px; height: 42px; font-size: 24px; }
    .exercice, .figure { padding: 12px; }
    .etiquette { font-size: 15px; padding: 9px 11px; }
    .actions .bouton { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: no-preference) {
    .etiquette, .case, .bouton, .nav { transition: background-color .15s, border-color .15s, box-shadow .15s; }
}
[hidden] { display: none !important; }
