/* ═══════════════════════════════════════════════════════════════
   LECTEUR DE LIVRE — Flipbook réaliste INLINE
   Le livre est directement visible dans la page, sans overlay
   ═══════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════
   SECTION LIVRE — conteneur inline
   ═══════════════════════════════════════════════════════════════ */
#livre-inline-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px 60px;
    position: relative;
}

/* ── Barre de progression ── */
.livre-progress-bar {
    width: 100%;
    max-width: 900px;
    height: 2px;
    background: rgba(5, 13, 24, 0.5);
    margin-bottom: 20px;
    border-radius: 1px;
}
.livre-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--led-blue, #4a90e2), var(--sun, #ffd700));
    transition: width 0.3s ease;
    border-radius: 1px;
}

/* ═══════════════════════════════════════════════════════════════
   SCÈNE 3D DU LIVRE
   ═══════════════════════════════════════════════════════════════ */
.livre-scene {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 2500px;
    perspective-origin: center 40%;
    padding: 20px 0;
    min-height: 660px;
}

/* ── Le livre ── */
.livre-book {
    position: relative;
    width: 900px;
    height: 600px;
    transform-style: preserve-3d;
    transform: rotateX(2deg);
    transition: transform 0.5s ease;
}
@media (max-width: 950px) {
    .livre-book { transform: scale(0.7) rotateX(2deg); }
}
@media (max-width: 720px) {
    .livre-book { transform: scale(0.5) rotateX(2deg); }
}

/* ── Page individuelle ── */
.livre-page {
    position: absolute;
    top: 0;
    width: 450px;
    height: 600px;
    background: #f5f0e4;
    color: #1c1814;
    padding: 32px 30px 32px 30px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.42, 0, 0.58, 1);
    backface-visibility: hidden;
}

.livre-page.right {
    left: 450px;
    border-radius: 0 4px 4px 0;
    box-shadow: inset 8px 0 16px -8px rgba(0,0,0,0.4), 0 0 20px rgba(0,0,0,0.3);
}
.livre-page.left {
    left: 0;
    border-radius: 4px 0 0 4px;
    box-shadow: inset -8px 0 16px -8px rgba(0,0,0,0.4), 0 0 20px rgba(0,0,0,0.3);
}
.livre-page.flipping {
    z-index: 20;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
}

/* Ombre de la reliure */
.livre-book::before {
    content: '';
    position: absolute;
    left: 448px; top: 0;
    width: 4px; height: 100%;
    background: linear-gradient(90deg, rgba(0,0,0,0.3), rgba(0,0,0,0.05), rgba(0,0,0,0.3));
    z-index: 5;
    pointer-events: none;
}

/* Tranche du livre */
.livre-book::after {
    content: '';
    position: absolute;
    right: -3px; top: 2px;
    width: 6px; height: 596px;
    background: linear-gradient(180deg, #c4362b 0%, #ffd700 15%, #4a90e2 30%, #88ff99 45%, #c4362b 60%, #ffd700 75%, #4a90e2 90%, #88ff99 100%);
    border-radius: 0 3px 3px 0;
    opacity: 0.4;
    z-index: 1;
}

/* ═══════════════════════════════════════════════════════════════
   COUVERTURE
   ═══════════════════════════════════════════════════════════════ */
.livre-cover {
    position: absolute;
    top: 0; left: 450px;
    width: 450px; height: 600px;
    background: linear-gradient(135deg, #0a1a2a 0%, #15315a 50%, #0a1a2a 100%);
    border-radius: 0 6px 6px 0;
    box-shadow: 5px 5px 20px rgba(0,0,0,0.5), inset 0 0 40px rgba(0,0,0,0.3);
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: transform 1.2s cubic-bezier(0.42, 0, 0.58, 1);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
}
.livre-cover::before {
    content: '';
    position: absolute;
    inset: 20px;
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 2px;
    pointer-events: none;
}
.livre-cover::after {
    content: '';
    position: absolute;
    top: 30px; left: 30px; right: 30px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.5), transparent);
    box-shadow: 0 540px 0 rgba(255, 215, 0, 0.5);
}
.livre-cover.open {
    transform: rotateY(-170deg);
}
.livre-cover-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 2.8em; font-weight: 700;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
    margin-bottom: 12px; line-height: 1.1;
}
.livre-cover-subtitle {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 1.1em; font-style: italic;
    color: #d4dce8;
    margin-bottom: 40px; max-width: 300px; line-height: 1.4;
}
.livre-cover-author {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 1.3em; color: #8ba3bd;
    margin-top: 40px; letter-spacing: 2px;
}
.livre-cover-ornament {
    color: rgba(255, 215, 0, 0.5);
    font-size: 1.5em; margin: 20px 0; letter-spacing: 8px;
}
.livre-cover-footer {
    position: absolute; bottom: 35px; left: 0; right: 0;
    text-align: center; font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7em; color: rgba(139, 163, 189, 0.5); letter-spacing: 1px;
}
.livre-cover-hint {
    position: absolute; bottom: 55px; left: 0; right: 0;
    text-align: center; font-family: 'EB Garamond', serif;
    font-size: 0.75em; font-style: italic; color: rgba(255, 215, 0, 0.4);
    letter-spacing: 1px;
    animation: livreHintPulse 3s ease-in-out infinite;
}
@keyframes livreHintPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.7; }
}
.livre-cover.open .livre-cover-hint { display: none; }

/* ═══════════════════════════════════════════════════════════════
   TYPOGRAPHIE DES PAGES
   ═══════════════════════════════════════════════════════════════ */
.livre-page h2 {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 1.3em; color: #5b1a1a;
    margin-bottom: 12px; font-weight: 600;
    border-bottom: 1px solid #c9bea6; padding-bottom: 6px;
}
.livre-page h3 {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 1.1em; color: #3e372e;
    margin-top: 1.2em; margin-bottom: 0.4em; font-weight: 500;
}
.livre-page p {
    font-family: 'Spectral', 'EB Garamond', Georgia, serif;
    font-size: 0.75em; line-height: 1.55;
    color: #1c1814; margin-bottom: 0.7em;
    text-align: justify; text-indent: 1.5em;
}
.livre-page p:first-child { text-indent: 0; }
.livre-page ul, .livre-page ol {
    font-family: 'Spectral', Georgia, serif;
    font-size: 0.72em; line-height: 1.5; color: #1c1814;
    margin: 0.3em 0 0.6em 1.5em;
}
.livre-page li { margin-bottom: 0.2em; }
.livre-page strong { color: #5b1a1a; font-weight: 600; }
.livre-page em { color: #3e372e; font-style: italic; }
.livre-page code {
    background: rgba(91, 26, 26, 0.06); color: #5b1a1a;
    padding: 1px 4px; border-radius: 2px;
    font-family: 'IBM Plex Mono', monospace; font-size: 0.85em;
}
.livre-page pre {
    background: #f0ece4; border: 1px solid #d9cfb8;
    border-left: 3px solid #5b1a1a;
    padding: 8px 10px; overflow: hidden;
    margin: 0.6em 0; border-radius: 2px;
    /* Plus de max-height : la pagination splitte correctement les <pre> longs
       en plusieurs pages. L'overflow:hidden évite juste qu'un <pre> très large
       déborde horizontalement. */
}
.livre-page pre code {
    background: transparent; color: #1c1814; padding: 0;
    font-size: 0.68em; line-height: 1.35;
    display: block; white-space: pre-wrap; word-break: break-word;
}
.livre-page-num {
    position: absolute; bottom: 16px;
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 0.75em; color: #8ba3bd;
}
.livre-page.right .livre-page-num { right: 36px; }
.livre-page.left .livre-page-num { left: 36px; }
.livre-page-header {
    position: absolute; top: 16px;
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 0.7em; color: #8ba3bd; font-style: italic;
}
.livre-page.right .livre-page-header { right: 36px; }
.livre-page.left .livre-page-header { left: 36px; }

/* ═══════════════════════════════════════════════════════════════
   NAVIGATION INLINE
   ═══════════════════════════════════════════════════════════════ */
.livre-nav-area {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
}
.livre-nav-btn {
    background: var(--bg-card, rgba(10, 26, 42, 0.8));
    border: 1px solid var(--border, #1e3a5f);
    color: var(--text-dim, #8ba3bd);
    width: 44px; height: 44px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s; font-size: 1.1em;
}
.livre-nav-btn:hover:not(:disabled) {
    border-color: var(--led-blue, #4a90e2);
    color: var(--text, #e0e8f0);
    background: var(--led-soft, rgba(74, 144, 226, 0.15));
}
.livre-nav-btn:disabled { opacity: 0.2; cursor: not-allowed; }
.livre-page-counter {
    color: var(--text-dim, #8ba3bd);
    font-family: var(--font-mono, monospace);
    font-size: 0.85em;
    min-width: 180px;
    text-align: center;
    line-height: 1.4;
}

/* ── Table des matières (overlay) ── */
.livre-toc-overlay {
    position: fixed; inset: 0;
    background: var(--bg-deep, rgba(5, 13, 24, 0.95));
    border-left: 1px solid var(--led-blue, #4a90e2);
    z-index: 10001;
    display: none;
    padding: 60px 40px;
    overflow-y: auto;
}
.livre-toc-overlay.active { display: block; }
.livre-toc-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 2em; color: var(--sun, #ffd700);
    margin-bottom: 30px; text-align: center;
}
.livre-toc-list { max-width: 600px; margin: 0 auto; }
.livre-toc-partie-title {
    color: var(--sun, #ffd700); font-size: 0.9em;
    text-transform: uppercase; letter-spacing: 1.5px;
    margin-top: 20px; margin-bottom: 8px;
}
.livre-toc-chapter {
    color: var(--text-dim, #8ba3bd); font-size: 0.95em;
    padding: 6px 0 6px 20px; cursor: pointer;
    transition: color 0.15s; border-left: 2px solid transparent;
}
.livre-toc-chapter:hover { color: var(--text, #e0e8f0); border-left-color: var(--led-blue, #4a90e2); }
.livre-toc-chapter .num { color: var(--text-muted, #6a829c); font-family: monospace; margin-right: 8px; }
.livre-toc-close {
    position: fixed; top: 20px; right: 20px;
    background: none; border: 1px solid var(--border);
    color: var(--text-dim); padding: 6px 14px; border-radius: 4px;
    cursor: pointer; font-size: 0.9em;
}

/* ═══════════════════════════════════════════════════════════════
   AMÉLIORATION 1 — RECHERCHE PLEIN TEXTE
   ═══════════════════════════════════════════════════════════════ */
.livre-search-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 12px;
}
.livre-search-input {
    background: var(--bg-card, #102540);
    border: 1px solid var(--border, #1e3a5f);
    border-radius: 4px;
    padding: 5px 12px;
    color: var(--text, #e0e8f0);
    font-family: var(--font-mono, monospace);
    font-size: 0.8em;
    width: 200px;
    outline: none;
    transition: border-color 0.2s;
}
.livre-search-input:focus { border-color: var(--led-blue, #4a90e2); }
.livre-search-input::placeholder { color: var(--text-muted, #6a829c); }

.livre-search-results {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg-deep, #050d18);
    border: 1px solid var(--border, #1e3a5f);
    border-radius: 6px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    z-index: 10002;
    display: none;
    padding: 8px;
}
.livre-search-results.active { display: block; }
.livre-search-result {
    padding: 10px 14px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}
.livre-search-result:hover { background: var(--led-soft, rgba(74, 144, 226, 0.1)); }
.livre-search-result-chapter {
    color: var(--led-blue, #4a90e2);
    font-size: 0.8em;
    font-family: var(--font-mono, monospace);
    margin-bottom: 2px;
}
.livre-search-result-snippet {
    color: var(--text-dim, #8ba3bd);
    font-size: 0.85em;
    line-height: 1.4;
}
.livre-search-highlight {
    background: rgba(255, 215, 0, 0.25);
    border-radius: 2px;
    padding: 1px 2px;
    color: var(--sun, #ffd700);
}
.livre-search-result-count {
    color: var(--text-muted, #6a829c);
    font-size: 0.75em;
    text-align: center;
    padding: 6px;
    border-bottom: 1px solid var(--border, #1e3a5f);
    margin-bottom: 4px;
}

/* ═══════════════════════════════════════════════════════════════
   AMÉLIORATION 2 — COLORATION SYNTAXIQUE
   ═══════════════════════════════════════════════════════════════ */
.livre-page pre code .hljs-keyword { color: #5b1a1a; font-weight: 600; }
.livre-page pre code .hljs-string { color: #4a5a2b; }
.livre-page pre code .hljs-comment { color: #8a8070; font-style: italic; }
.livre-page pre code .hljs-number { color: #8b6914; }
.livre-page pre code .hljs-title { color: #2d3b45; }
.livre-page pre code .hljs-type { color: #5b1a1a; }
.livre-page pre code .hljs-built_in { color: #8b6914; }
.livre-page pre code .hljs-meta { color: #8a8070; }
.livre-page pre code .hljs-attr { color: #2d3b45; }
.livre-page pre code .hljs-section { color: #5b1a1a; font-weight: 600; }

/* ═══════════════════════════════════════════════════════════════
   AMÉLIORATION 3 — SAUVEGARDE DE POSITION (visuel)
   ═══════════════════════════════════════════════════════════════ */
.livre-bookmark-btn {
    background: none;
    border: 1px solid var(--border, #1e3a5f);
    color: var(--text-dim, #8ba3bd);
    width: 36px; height: 36px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9em;
}
.livre-bookmark-btn:hover { border-color: var(--sun, #ffd700); color: var(--sun, #ffd700); }
.livre-bookmark-btn.saved { color: var(--sun, #ffd700); border-color: var(--sun, #ffd700); }
.livre-resume-hint {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card, #102540);
    border: 1px solid var(--led-blue, #4a90e2);
    border-radius: 4px;
    padding: 4px 14px;
    font-size: 0.75em;
    color: var(--led-blue, #4a90e2);
    cursor: pointer;
    white-space: nowrap;
    display: none;
    z-index: 10;
}
.livre-resume-hint.active { display: block; }
.livre-resume-hint:hover { background: var(--led-soft, rgba(74, 144, 226, 0.15)); }

/* ═══════════════════════════════════════════════════════════════
   AMÉLIORATION 4 — LIENS CROISÉS
   ═══════════════════════════════════════════════════════════════ */
.livre-cross-link {
    color: #5b1a1a;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
    cursor: pointer;
    font-weight: 500;
}
.livre-cross-link:hover {
    color: #8b6914;
    text-decoration-style: solid;
}

/* ═══════════════════════════════════════════════════════════════
   AMÉLIORATION 5 — LETTRINES
   ═══════════════════════════════════════════════════════════════ */
.livre-page h2 + p::first-letter {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 3.2em;
    font-weight: 700;
    float: left;
    line-height: 0.85;
    padding: 4px 8px 0 0;
    color: #5b1a1a;
}
