:root {
    --p-width: 210mm;
    --p-height: 297mm;
}

body {
    background: #333; /* Fond gris pour contraster avec le papier */
    margin: 0;
    padding: 0;
}

#master-flow {
    width: var(--p-width);
    margin: 20px auto; /* Centre les pages à l'écran */
}

.page-section {
    width: var(--p-width);
    height: var(--p-height); /* ON FORCE LA HAUTEUR A4 ICI */
    background-color: #f4e4bc !important;
    background-image: url('https://www.transparenttextures.com/patterns/paper-fibers.png');
    border: 2px solid #8b7355;
    outline: 5px double #8b7355;
    outline-offset: -10px;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
    margin-bottom: 20px; /* Espace entre les pages à l'écran */
    display: flex;
    flex-direction: column;
}

/* Impression parfaite */
@media print {
    @page {
        size: A4 portrait;
        margin: 0;
    }
    body { background: white; }
    #master-flow { margin: 0; }
    .page-section {
        margin: 0 !important;
        page-break-after: always;
        box-shadow: none !important;
    }
    .no-print { display: none !important; } /* Masque le bouton imprimer */
}

@media print {
    .no-print { display: none !important; }
}

.no-print { 
    display: block !important; 
    position: fixed !important; 
    top: 20px !important; 
    right: 20px !important; 
    z-index: 99999 !important; 
}



/* Titres */
h1 {
    width: 100%;
    text-align: center;
    padding: 3mm 0;
    margin: 0;
    box-sizing: border-box;
}

/* ============================================================
   STYLE SPÉCIFIQUE —  
   ============================================================ */

.contenu-fiche {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    box-sizing: border-box;
    position: relative;
    padding: 14mm 18mm 12mm 18mm;
}

.corps-fiche {
    flex: 1;
    overflow: hidden;
}

/* FOOTER STABLE */
.footer-fiche {
    margin-top: auto;

    display: flex;
    flex-direction: column;
    gap: 6px;

    padding-top: 10mm; /* espace propre sans ligne */
}

/* RENVOI PRINCIPAL */
.renvoi {
    text-align: right;
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    color: #5d4037;
    font-weight: bold;

    margin-top: 0;
}

/* RENVOIS SECONDAIRES */
.renvoi1 {
    text-align: left;
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    color: #5d4037;
}

/* Titre de l'acte */
.acte {
    text-align: center;
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #c5a059;
    margin-top: 8px;
    margin-bottom: 10px;
}

/* Lignes d'écriture */
.ligne {
    border-bottom: 1px solid #c5a059;
    height: 24px;
    margin-bottom: 6px;
}

.lignes {
    margin-top: 8px;
}

/* Titre principal de la fiche */
.contenu-fiche h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    color: #3e2723;
    margin: 0 0 4px 0;
    text-align: center;
    margin-top: 0.2rem;
    margin-bottom: 0.2rem;
    line-height: 1;
}

/* Sous-titre */
.contenu-fiche h2 {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    text-align: center;
    color: #b08968;
    margin-top: 0;
    margin-bottom: 10px;
    text-transform: uppercase;
}

/* La note d'introduction */
.note {
    border-left: 3px solid #c5a059;
    padding-left: 15px;
    font-style: italic;
    background: rgba(197, 160, 89, 0.05);
    padding: 10px 15px;
    font-size: 1.05rem;
    margin-bottom: 12px;
}

/* Zone des savoirs-faire */
.encart {
    border: 1px solid #e6ccb2;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.5);
    margin: 10px 0;
    text-align: center;
    font-size: 1rem;
}

.encart-titre {
    font-weight: bold;
    color: #5d4037;
        text-transform: uppercase;
    font-size: 1rem;
}

.savoir {
    display: inline-block;
    padding: 3px 30px;
    border: 1px solid #c5a059;
    border-radius: 4px;
    font-size: 1.2rem;
    background: #fdfaf7;
    white-space: nowrap;
    flex-shrink: 0;
}
/* ============================================================
   SOMMAIRE
   ============================================================ */

#sommaire {
    columns: 3;
    column-gap: 8mm;
    padding: 6mm;
    font-family: 'Libre Baskerville', serif;
}

.bloc-acte {
    margin-bottom: 6mm;
    color: #916309;
}

.acte-titre {
    display: block;
    width: 100%;
    border-bottom: 1px solid #916309;
    margin-bottom: 4px;
    padding-bottom: 2px;
}

.acte-label {
    display: block;
    font-family: 'Cinzel', serif;
    font-size: 0.65rem;
    color: #916309;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.acte-nom {
    display: block;
    font-family: 'Cinzel', serif;
    font-size: 0.78rem;
    color: #916309;
    text-transform: uppercase;
    font-weight: bold;
}

.fiche-item {
    font-size: 0.75rem;
    color: #3e2723;
    line-height: 1.35;
    margin-bottom: 1px;
    display: flex;
    gap: 5px;
}

.fiche-num {
    color: #b08968;
    font-weight: bold;
    min-width: 6mm;
    text-align: right;
    flex-shrink: 0;
}

.chargement {
    text-align: center;
    font-style: italic;
    color: #8b5e2a;
    margin-top: 20mm;
}
/* ============================================================
   CHOIX ET GRILLE
   ============================================================ */

.choix-titre {
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    text-transform: uppercase;
    color: #5d4037;
    font-weight: bold;
    margin: 12px 0 6px 0;
    letter-spacing: 1px;
}

.choix-item {
    font-size: 1rem;
    color: #3e2723;
    line-height: 1.4;
    margin-bottom: 4px;
    padding-left: 4px;
}

.grille-savoirs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    justify-content: center;
}

p {
    text-align: justify;
    font-size: 1rem;
}

.badge {
    
    border: 1px solid #c5a059;
    background: transparent;
    font-size: 1.1rem;
    border-radius: 20px;
    color: #5d4037;
    margin: 4px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    box-sizing: border-box;
}


.badge-module {
    position: absolute;
    top: 15px;
    right: 20px;
    font-family: 'Cinzel', serif;
    font-size: 0.75rem;
    margin:15px 0 25px;
    border: 1px solid #8b7355;
    background: rgba(255, 255, 255, 0.6);
    color: #3e2723;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 3px;
    backdrop-filter: blur(3px);
}

.badge-flux {
    border-color: #6d4c41;
    color: #3e2723;
}

.badge-courant {
    border-color: #5d4037;
    background: rgba(240, 230, 220, 0.7);
    color: #4e342e;
}

.choix-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 par ligne */
    gap: 5px 20px; /* espace vertical + horizontal */
}

.choix-item {
    display: flex;
    align-items: center;
}
/* ============================================================
   CLASSES MANQUANTES — FICHES CAP & ACTE IV/V
   ============================================================ */

/* Footer unifié (les fiches utilisent .footer, le CSS définissait .footer-fiche) */
.footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 6mm;
}

/* Header de fiche */
.header-fiche {
    margin-bottom: 8px;
}

/* Scène narrative (ex: "Lisbonne, hiver 1777…") */
.scene {
    display: block;
    font-family: 'Libre Baskerville', serif;
    font-size: 0.78rem;
    font-style: italic;
    color: #8b7355;
    text-align: center;
    margin-bottom: 4px;
}

/* Bloc de narration / intro */
.narration {
    font-family: 'Libre Baskerville', serif;
    font-size: 1rem;
    color: #3e2723;
    text-align: justify;
    margin-bottom: 10px;
    line-height: 1.35;
}

/* Trace / citation cartographe */
.trace {
    border-left: 3px solid #c5a059;
    padding: 8px 14px;
    font-style: italic;
    font-size: 0.95rem;
    color: #5d4037;
    background: rgba(197, 160, 89, 0.07);
    margin: 10px 0;
}

/* Passage / titre de vent dans les encarts "depuis le Sud" */
.passage {
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    font-weight: bold;
    color: #b08968;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

/* ---- Variantes directionnelles de .contenu-fiche ---- */

/* Nord — tons bleu nuit / marine */
.contenu-fiche.nord {
    --accent: #1a3a5c;
    --accent-light: rgba(26, 58, 92, 0.08);
}
.contenu-fiche.nord .acte,
.contenu-fiche.nord .renvoi,
.contenu-fiche.nord .passage {
    color: #1a3a5c;
}
.contenu-fiche.nord .encart {
    border-color: #1a3a5c;
}

/* Sud — tons terre / ocre chaud */
.contenu-fiche.sud {
    --accent: #8b4513;
    --accent-light: rgba(139, 69, 19, 0.07);
}
.contenu-fiche.sud .acte,
.contenu-fiche.sud .renvoi,
.contenu-fiche.sud .passage {
    color: #8b4513;
}
.contenu-fiche.sud .encart {
    border-color: #c07a40;
}

/* Ouest — tons violet / ardoise */
.contenu-fiche.ouest {
    --accent: #4a3560;
    --accent-light: rgba(74, 53, 96, 0.07);
}
.contenu-fiche.ouest .acte,
.contenu-fiche.ouest .renvoi,
.contenu-fiche.ouest .passage {
    color: #4a3560;
}
.contenu-fiche.ouest .encart {
    border-color: #7b5ea7;
}

/* ---- Modificateurs d'encart pour les vents ---- */

.encart.vent {
    padding: 8px 12px;
    margin: 8px 0;
}

.encart.vent.est {
    border-left: 4px solid #c5a059;
    background: rgba(197, 160, 89, 0.06);
}

.encart.vent.nord {
    border-left: 4px solid #1a3a5c;
    background: rgba(26, 58, 92, 0.06);
}

.encart.vent.ouest {
    border-left: 4px solid #7b5ea7;
    background: rgba(123, 94, 167, 0.06);
}

/* Ancre Sud — encart de conclusion */
.encart.sud-ancre {
    border: 1px dashed #c07a40;
    background: rgba(139, 69, 19, 0.05);
    padding: 10px;
    text-align: center;
    font-style: italic;
    color: #8b4513;
    margin-top: 12px;
}
/* ============================================================
   VARIANTE COMPACTE — fiches avec beaucoup de contenu
   ============================================================ */

.contenu-fiche.compact {
    padding: 12mm 20mm 10mm 20mm;
}

.contenu-fiche.compact .encart {
    margin: 8px 0;
    padding: 6px 8px;
}

.contenu-fiche.compact .encart-titre {
    font-size: 0.9rem;
}

.contenu-fiche.compact .encart p {
    font-size: 0.95rem;
    margin: 4px 0 0 0;
}

.contenu-fiche.compact .note {
    padding: 8px 12px;
    font-size: 0.95rem;
    margin-bottom: 10px;
}

.contenu-fiche.compact h1 {
    font-size: 1.8rem;
}

.contenu-fiche.compact h2 {
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.contenu-fiche.compact .header-fiche {
    margin-bottom: 4px;
}

.contenu-fiche.compact p {
    font-size: 1rem;
}

.contenu-fiche.compact .footer {
    padding-top: 6mm;
}

.contenu-fiche.compact .choix-titre {
    margin: 6px 0 4px 0;
}