/* ===================================
   MON HISTOIRE D'HIVER/NOËL - STYLES
   Fichier CSS principal
   =================================== */

/* ===================================
   1. IMPORTS ET POLICES
   =================================== */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;700&family=Merriweather:ital,wght@1,700&family=Bubblegum+Sans&display=swap');

.font-fredoka { 
    font-family: 'Fredoka', cursive; 
    font-weight: 700; 
}

.font-serif-book { 
    font-family: 'Merriweather', serif; 
}

.font-bubblegum { 
    font-family: 'Bubblegum Sans', cursive; 
}

/* ===================================
   2. UTILITAIRES GÉNÉRAUX
   =================================== */
.hidden { 
    display: none !important; 
}

/* ===================================
   3. ARRIÈRE-PLAN ET ANIMATIONS
   =================================== */
.page-bg {
    background: linear-gradient(135deg, #e6f7ff 0%, #f0f9ff 50%, #ffebf0 100%);
    position: relative;
    overflow-x: hidden;
}

.snowflake {
    position: absolute;
    top: -10px;
    color: rgba(255, 255, 255, 0.8);
    user-select: none;
    cursor: default;
    animation: fall linear infinite;
    z-index: 1;
}

@keyframes fall {
    from { transform: translateY(-100px); }
    to   { transform: translateY(calc(100vh + 100px)); }
}

/* ===================================
   4. LIVRE - STRUCTURE 3D
   =================================== */
.book-container {
    perspective: 2000px;
    width: 100%;
    max-width: 650px;
    margin: 0 auto;
    position: relative;
    aspect-ratio: 3 / 4;
    height: auto;
}

.book {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.645, 0.045, 0.355, 1);
}

/* ===================================
   5. PAGES DU LIVRE
   =================================== */
.page {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: linear-gradient(to right, #f9f7f2 0%, #ffffff 5%, #ffffff 95%, #f9f7f2 100%);
    border: 1px solid #d9d9d9;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    padding: 30px;
    box-sizing: border-box;
    transform-origin: left center;
    backface-visibility: hidden;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.8s cubic-bezier(0.645, 0.045, 0.355, 1);
}

.page.active { 
    opacity: 1; 
    transform: rotateY(0deg); 
}

.page.prev { 
    transform: rotateY(-180deg); 
}

.page.next { 
    transform: rotateY(180deg); 
}

/* ===================================
   6. COUVERTURES (AVANT/ARRIÈRE)
   =================================== */
.page-cover,
.page-back {
    padding: 0;
    border: none;
    box-shadow: none;
    background: transparent;
}

.page-cover {
    background: linear-gradient(135deg, #4FC3F7 0%, #29B6F6 100%);
    color: white;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 12px solid #0288D1;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.page-back {
    background: linear-gradient(135deg, #29B6F6 0%, #4FC3F7 100%);
    color: white;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 12px solid #0288D1;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.page-cover .cover-content,
.page-back .cover-content {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 0;
}

.cover-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
}

/* ===================================
   7. ILLUSTRATIONS
   =================================== */
.cover-illustration-area {
    width: 100%;
    height: 100%;
    border-radius: 0;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0;
    overflow: hidden;
}

.page-cover .cover-illustration-area .page-illustration {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.illustration-area {
    flex: 2;
    border: none;
    background: transparent;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.illustration-placeholder {
    font-family: 'Fredoka', cursive;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #c0b090;
    opacity: 0.9;
}

.page-illustration {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* ===================================
   8. TITRE ET TEXTE
   =================================== */
.cover-title-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    text-align: center;
    padding: 0.5rem 1rem;
    border-radius: 0 0 24px 24px;
    background: linear-gradient(
        to bottom,
        rgba(255,255,255,0.80),
        rgba(255,255,255,0.55)
    );
    font-size: 1.6rem;
    color: #333;
    letter-spacing: 0.06em;
    font-family: 'Fredoka', cursive;
    font-weight: 700;
    text-transform: uppercase;
    text-shadow: 0 0 4px rgba(255,255,255,0.7);
    box-shadow: 0 3px 12px rgba(0,0,0,0.25);
    max-width: 100%;
    box-sizing: border-box;
}

.page-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.text-area {
    flex: 1.4;
    display: flex;
    align-items: center;
    justify-content: center;
}

.child-text {
    font-family: 'Fredoka', cursive;
    font-size: 2.1rem;
    line-height: 1.4;
    font-weight: 700;
    color: #333;
    margin: 20px 0;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: center;
}

/* ===================================
   9. NUMÉROS DE PAGE ET FOOTER
   =================================== */
.page-number {
    position: absolute;
    bottom: 15px;
    font-size: 14px;
    color: #888;
}

.page-number.left { 
    left: 20px; 
}

.page-number.right { 
    right: 20px; 
}

.page-footer {
    position: absolute;
    bottom: 8px;
    left: 10px;
    font-size: 8px;
    color: #999;
    font-family: 'Fredoka', cursive;
    opacity: 0.7;
}

.coloring-hint {
    position: absolute;
    bottom: 8px;
    right: 10px;
    font-size: 8px;
    color: #999;
    font-family: 'Fredoka', cursive;
    opacity: 0.7;
}

/* ===================================
   10. NAVIGATION
   =================================== */
.book-navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 30px;
    gap: 20px;
}

.nav-button {
    background: white;
    border: 2px solid #d32f2f;
    color: #d32f2f;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.nav-button:hover {
    background: #d32f2f;
    color: white;
    transform: scale(1.1);
}

.nav-button:active { 
    transform: scale(0.95); 
}

.nav-button:disabled { 
    opacity: .5; 
    cursor: not-allowed; 
}

/* ===================================
   11. BOUTONS ET CONTRÔLES
   =================================== */
.mode-toggle-btn {
    background: white;
    border: 2px solid #0288D1;
    color: #0288D1;
    border-radius: 9999px;
    padding: 8px 16px;
    font-weight: 700;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 3px 8px rgba(0,0,0,0.12);
}

.mode-toggle-btn:hover {
    background: #0288D1;
    color: white;
    transform: translateY(-1px);
}

.mode-toggle-btn.active {
    background: #0288D1;
    color: white;
    border-color: #01579B;
}

.btn-christmas {
    background: linear-gradient(45deg, #d32f2f, #f44336);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 24px;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(211,47,47,0.3);
    position: relative;
    overflow: hidden;
}

.btn-christmas:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(211,47,47,0.4);
}

.btn-christmas:active {
    transform: translateY(0);
}

.btn-christmas::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-christmas:hover::before {
    width: 300px;
    height: 300px;
}

/* ===================================
   12. INDICATEURS DE PAGE
   =================================== */
.page-indicator { 
    display: flex; 
    gap: 8px; 
}

.page-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ccc;
    cursor: pointer;
    transition: all 0.3s ease;
}

.page-dot.active {
    background: #d32f2f;
    transform: scale(1.2);
}

/* ===================================
   13. FORMULAIRES
   =================================== */
.form-christmas {
    background: white;
    border-radius: 20px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    padding: 40px;
}

.input-christmas {
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 1rem;
    transition: all 0.3s ease;
    outline: none;
}

.input-christmas:focus {
    border-color: #d32f2f;
    box-shadow: 0 0 0 3px rgba(211,47,47,0.1);
}

.choice-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.choice-option {
    cursor: pointer;
}

.choice-option input[type="radio"] {
    display: none;
}

.choice-pill {
    display: inline-block;
    padding: 10px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    background: white;
    transition: all 0.3s ease;
    font-weight: 600;
}

.choice-option input[type="radio"]:checked + .choice-pill {
    background: #d32f2f;
    color: white;
    border-color: #d32f2f;
}

.choice-pill:hover {
    border-color: #d32f2f;
    transform: translateY(-2px);
}

.conte-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.conte-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.conte-card.selected {
    border-color: #d32f2f;
    background: linear-gradient(135deg, #fff5f5 0%, #ffffff 100%);
}

/* ===================================
   14. LOADER / INDICATEUR DE CHARGEMENT
   =================================== */
.loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    color: white;
}

.spinner {
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===================================
   15. COLORISATION DES MOTS
   =================================== */
.mot { 
    display: inline-block; 
    white-space: pre-wrap; 
}

.c-vert { 
    color: #2e7d32; 
}

.c-vert-sapin { 
    color: #1b5e20; 
}

.c-gris { 
    color: #9e9e9e; /* gris plus foncé pour l'impression */
}

.c-rouge { 
    color: #c62828; 
}

.c-bleu { 
    color: #1565c0; 
}

.c-noir { 
    color: #000000; 
}

body.mode-digrammes .c-rouge,
body.mode-digrammes .c-bleu,
body.mode-digrammes .c-noir {
    color: #000000;
}

.rainbow-text {
    font-weight: 700;
    text-transform: uppercase;
}

/* ===================================
   16. IMPRESSION
   =================================== */
@media print {
    body > * { 
        display: none !important; 
    }
    
    #print-area {
        display: block !important;
        position: absolute;
        top: 0;
        left: 0;
        width: 210mm;
        height: 297mm;
        margin: 0;
        padding: 2cm;
        box-shadow: none;
        background-color: white;
        color: #000;
        page-break-after: always;
    }
    
    #print-area h2 {
        font-family: 'Merriweather', serif;
        font-size: 24pt;
        text-align: center;
        margin-bottom: 1cm;
        page-break-after: avoid;
    }
    
    #print-area p {
        font-family: 'Fredoka', cursive;
        font-size: 12pt;
        line-height: 1.5;
        text-indent: 1em;
        text-transform: uppercase;
    }
    
    #print-area > div {
        height: 100%;
        overflow: hidden;
    }
    
    .print-footer {
        position: absolute;
        bottom: 10px;
        left: 10px;
        font-size: 8pt;
        color: #999;
    }
    
    .print-coloring {
        position: absolute;
        bottom: 10px;
        right: 10px;
        font-size: 8pt;
        color: #999;
    }
}

/* ===================================
   17. RESPONSIVE - MOBILE
   =================================== */
@media (max-width: 768px) {
    .conte-card { 
        margin-bottom: 16px; 
    }
    
    .form-christmas { 
        padding: 20px !important; 
    }
    
    .nav-button { 
        width: 45px; 
        height: 45px; 
    }
    
    .book-container { 
        height: 500px; 
    }
    
    .page { 
        padding: 20px; 
    }
    
    .page-cover h2 { 
        font-size: 2rem; 
    }
    
    .child-text { 
        font-size: 1.5rem; 
    }
    
    .cover-title-overlay {
        font-size: 0.75rem;
        padding: 0.30rem 0.7rem;
        border-radius: 0 0 16px 16px;
        line-height: 1.2;
        letter-spacing: 0.04em;
        background: linear-gradient(
            to bottom,
            rgba(255,255,255,0.75),
            rgba(255,255,255,0.45)
        );
    }
}


/* Ajustements responsifs pour le titre de couverture */
@media (min-width: 1024px) {
    .cover-title-overlay {
        font-size: 2rem;
        padding: 0.75rem 2rem;
    }
}

@media (max-width: 640px) {
    .cover-title-overlay {
        font-size: 1rem;
        padding: 0.35rem 0.75rem;
        background: linear-gradient(
            to bottom,
            rgba(255,255,255,0.70),
            rgba(255,255,255,0.35)
        );
        text-shadow: 0 0 3px rgba(255,255,255,0.5);
    }
}


/* ===============================
   Modes d'affichage lecture
   =============================== */

/* Police d'écriture "script" : toujours Fredoka, en gras */
body.script-font-mode .child-text {
    text-transform: none;
    font-weight: 700;
    letter-spacing: 0.03em;
}

/* Mode sans images pour la lecture */
body.hide-images-mode .illustration-area,
body.hide-images-mode .cover-illustration-area,
body.hide-images-mode .page-illustration,
body.hide-images-mode .illustration-placeholder {
    display: none !important;
}

body.hide-images-mode .page-content {
    justify-content: center;
}

body.hide-images-mode .text-area {
    flex: 1;
}
