/* ══════════════════════════════════════════════════
   1. HERO SECTION ANIMÉE (BANNIÈRE)
   ══════════════════════════════════════════════════ */
.library-hero {
    position: relative;
    padding-block: clamp(4rem, 8vw, 7rem);
    padding-inline: clamp(1.25rem, 5vw, 3rem);
    background: linear-gradient(135deg, var(--navy, #1e3a5f) 0%, var(--night, #0a1424) 100%);
    color: #fff;
    overflow: hidden;
}

.library-hero__bg-animation {
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(circle at 10% 20%, rgba(201, 37, 37, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(30, 58, 95, 0.3) 0%, transparent 40%);
    animation: pulse-bg 8s ease-in-out infinite alternate;
}

@keyframes pulse-bg {
    0% { opacity: 0.5; transform: scale(1); }
    100% { opacity: 1; transform: scale(1.1); }
}

.library-hero__grid {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr;
    gap: 3rem;
    align-items: center;
    max-width: 1240px;
    margin-inline: auto;
}

.library-hero__content {
    text-align: center;
    animation: fadeInUp 0.8s ease-out;
}

.library-hero__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    background: rgba(201, 37, 37, 0.15);
    border: 1px solid rgba(201, 37, 37, 0.3);
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(4px);
}

.library-hero__badge-dot {
    width: 8px;
    height: 8px;
    background: var(--red, #c92525);
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(201, 37, 37, 0.2);
}

.library-hero__title {
    font-family: var(--font-heading, 'Playfair Display', serif);
    font-size: clamp(2.2rem, 5vw, 3.5rem);
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: 1.25rem;
}

.library-hero__title span {
    color: var(--red, #c92525);
}

.library-hero__subtitle {
    font-size: clamp(1rem, 2vw, 1.15rem);
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.7;
    max-width: 600px;
    margin: 0 auto 2rem;
}

.library-hero__actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ── Illustration SVG Animée ── */
.library-hero__visual {
    display: flex;
    justify-content: center;
    animation: fadeInRight 1s ease-out 0.3s backwards;
    /* 🎯 MOBILE : Force l'animation EN PREMIER (au-dessus du texte) */
    order: -1 !important; 
}

.library-illustration {
    width: 100%;
    max-width: 380px;
    height: auto;
    filter: drop-shadow(0 20px 40px rgba(0,0,0,0.3));
}

/* Animations des éléments SVG */
.lib-ill__bg-circle {
    fill: rgba(255, 255, 255, 0.03);
    animation: pulse 4s ease-in-out infinite;
}

.lib-ill__books {
    animation: float 6s ease-in-out infinite;
}

.lib-ill__sparkle {
    animation: twinkle 3s ease-in-out infinite;
}
.lib-ill__sparkle--1 { animation-delay: 0s; }
.lib-ill__sparkle--2 { animation-delay: 1.5s; }

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ══════════════════════════════════════════════════
   2. CATALOGUE SECTION
   ══════════════════════════════════════════════════ */
.library-catalog {
    padding-block: clamp(3rem, 6vw, 5rem);
    padding-inline: clamp(1.25rem, 5vw, 3rem);
    background: var(--bg-secondary, #f3f5f8);
}

.section-header {
    text-align: center;
    margin-bottom: 3rem;
    max-width: 1240px;
    margin-inline: auto;
}

.section-title {
    font-family: var(--font-heading, 'Playfair Display', serif);
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    color: var(--text-primary, #111827);
    margin-bottom: 0.5rem;
}

.section-subtitle {
    color: var(--text-secondary, #526071);
    font-size: 1.05rem;
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    max-width: 1240px;
    margin-inline: auto;
}

.book-card {
    background: var(--bg-primary, #ffffff);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-color, #e2e6ec);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease, border-color 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.book-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    border-color: rgba(201, 37, 37, 0.3);
}

.book-card__image {
    position: relative;
    height: 280px;
    overflow: hidden;
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
}

.book-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.book-card:hover .book-card__image img {
    transform: scale(1.05);
}

.book-card__price,
.book-card__badge-free {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.4rem 0.9rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.book-card__price {
    background: var(--red, #c92525);
    color: white;
}

.book-card__badge-free {
    background: #10b981;
    color: white;
}

.book-card__overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.book-card:hover .book-card__overlay {
    opacity: 1;
}

.book-card__content {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.book-card__title {
    font-family: var(--font-heading, 'Playfair Display', serif);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary, #111827);
    margin: 0 0 0.4rem 0;
    line-height: 1.3;
}

.book-card__author {
    color: var(--red, #c92525);
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
}

.book-card__excerpt {
    color: var(--text-secondary, #526071);
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
    flex: 1;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-primary, #ffffff);
    border-radius: 16px;
    border: 2px dashed var(--border-color, #e2e6ec);
}

.empty-state__icon {
    color: var(--text-muted, #94a3b8);
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.25rem;
    color: var(--text-primary, #111827);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary, #526071);
}

/* ══════════════════════════════════════════════════
   3. INFO SECTION
   ══════════════════════════════════════════════════ */
.library-info {
    padding-block: clamp(3rem, 6vw, 5rem);
    padding-inline: clamp(1.25rem, 5vw, 3rem);
    background: var(--bg-primary, #ffffff);
    border-top: 1px solid var(--border-color, #e2e6ec);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    max-width: 1240px;
    margin-inline: auto;
}

.info-card {
    background: var(--bg-secondary, #f3f5f8);
    padding: 2.5rem 2rem;
    border-radius: 16px;
    border: 1px solid transparent;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.info-card:hover {
    transform: translateY(-8px);
    background: var(--bg-primary, #ffffff);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
    border-color: rgba(201, 37, 37, 0.2);
}

.info-card__icon {
    width: 64px;
    height: 64px;
    background: rgba(201, 37, 37, 0.08);
    color: var(--red, #c92525);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    transition: all 0.3s ease;
}

.info-card:hover .info-card__icon {
    background: var(--red, #c92525);
    color: white;
    transform: scale(1.1) rotate(-5deg);
}

.info-card h3 {
    font-family: var(--font-heading, 'Playfair Display', serif);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary, #111827);
    margin: 0 0 0.75rem 0;
}

.info-card p {
    font-size: 0.95rem;
    color: var(--text-secondary, #526071);
    line-height: 1.6;
    margin: 0;
}

/* ══════════════════════════════════════════════════
   4. DARK MODE SUPPORT
   ══════════════════════════════════════════════════ */
[data-theme="dark"] .library-catalog {
    background: var(--night, #0a1424);
}

[data-theme="dark"] .section-title {
    color: #f2f4f7;
}

[data-theme="dark"] .section-subtitle,
[data-theme="dark"] .book-card__excerpt,
[data-theme="dark"] .empty-state p {
    color: #b3bcc9;
}

[data-theme="dark"] .book-card {
    background: var(--bg-secondary, #151a24);
    border-color: #262d3a;
}

[data-theme="dark"] .book-card__title,
[data-theme="dark"] .empty-state h3 {
    color: #f2f4f7;
}

[data-theme="dark"] .info-card {
    background: var(--bg-secondary, #151a24);
}

[data-theme="dark"] .info-card:hover {
    background: #1e2532;
    border-color: rgba(201, 37, 37, 0.3);
}

[data-theme="dark"] .info-card h3 {
    color: #f2f4f7;
}

/* ══════════════════════════════════════════════════
   5. RESPONSIVE (Mobile & Tablette & Ordi)
   ══════════════════════════════════════════════════ */

/* 🎯 MOBILE : Flexbox inversé pour forcer l'animation en premier */
.library-hero__grid {
    display: flex;
    flex-direction: column-reverse; /* Inverse l'ordre : le visuel (2ème dans le HTML) passe en 1er */
    gap: 3rem;
    align-items: center;
    max-width: 1240px;
    margin-inline: auto;
}

/* 🎯 ORDINATEUR (≥ 900px) : Grille avec texte à gauche, animation à droite */
@media (min-width: 900px) {
    .library-hero__grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        text-align: left;
    }
    
    .library-hero__content {
        order: 1 !important; /* Texte à gauche */
        text-align: left;
    }
    
    .library-hero__visual {
        order: 2 !important; /* Animation à droite */
        justify-content: flex-end;
    }
    
    .library-hero__subtitle {
        margin: 0 0 2rem 0;
    }
    
    .library-hero__actions {
        justify-content: flex-start;
    }
}

@media (max-width: 640px) {
    .books-grid {
        grid-template-columns: 1fr;
    }
    
    .book-card__image {
        height: 240px;
    }
}
/* ==========================================================
   Détail d'un livre : à ajouter dans public/css/pages/library.css
   Charte Juridex : bleu marine #1e3a5f, rouge #c92525, Playfair / Inter
   ========================================================== */

.book-detail {
    --bd-navy: #1e3a5f;
    --bd-red: #c92525;
    --bd-bg: #f4f6f9;
    --bd-surface: #ffffff;
    --bd-line: #dfe5ec;
    --bd-text: #14283f;
    --bd-muted: #5b6b7e;
    --bd-gutter: clamp(1rem, 4vw, 2rem);

    background: var(--bd-bg);
    color: var(--bd-text);
    padding-block: clamp(1.5rem, 4vw, 3.5rem) clamp(3rem, 6vw, 5rem);
    min-height: 60vh;
}

[data-theme="dark"] .book-detail {
    --bd-navy: #6f9bd1;
    --bd-bg: #0e1824;
    --bd-surface: #14222f;
    --bd-line: #263a4d;
    --bd-text: #e8eef5;
    --bd-muted: #9fb0c2;
}

.book-detail *,
.book-detail *::before,
.book-detail *::after { box-sizing: border-box; }

.book-detail .container {
    width: 100%;
    max-width: 1160px;
    margin-inline: auto;
    padding-inline: var(--bd-gutter);
}

/* ----- Lien de retour ----- */
.book-detail .back-link {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: clamp(1.25rem, 3vw, 2rem);
    padding: .5rem .85rem .5rem .65rem;
    border-radius: 999px;
    color: var(--bd-muted);
    font-size: .92rem;
    font-weight: 600;
    text-decoration: none;
    transition: color .15s, background .15s;
}
.book-detail .back-link svg { width: 18px; height: 18px; transition: transform .15s; }
.book-detail .back-link:hover { color: var(--bd-text); background: var(--bd-surface); }
.book-detail .back-link:hover svg { transform: translateX(-3px); }

/* ----- Mise en page ----- */
.book-detail__grid {
    display: grid;
    grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
    gap: clamp(1.5rem, 5vw, 4rem);
    align-items: start;
}

/* ----- Couverture ----- */
.book-detail__image {
    position: sticky;
    top: 6.5rem; /* sous le header fixe */
    background: var(--bd-surface);
    border: 1px solid var(--bd-line);
    border-radius: 14px;
    padding: clamp(.75rem, 2vw, 1.25rem);
}
.book-detail__image img {
    display: block;
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    border-radius: 8px;
    background: var(--bd-line);
    box-shadow: 0 12px 28px rgba(20, 40, 63, .18);
}

/* ----- Informations ----- */
.book-detail__info { min-width: 0; }

.book-detail__title {
    margin: 0 0 .6rem;
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.75rem, 4vw, 2.75rem);
    font-weight: 700;
    line-height: 1.15;
    color: var(--bd-text);
    overflow-wrap: anywhere;
}

.book-detail__author {
    margin: 0 0 1.5rem;
    font-size: 1.05rem;
    color: var(--bd-muted);
}
.book-detail__author strong { color: var(--bd-text); font-weight: 600; }

.book-detail__price {
    display: inline-block;
    margin-bottom: 1.75rem;
    padding: .5rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--bd-line);
    background: var(--bd-surface);
    color: var(--bd-red);
    font-size: 1.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

/* ----- Description ----- */
.book-detail__description {
    margin-bottom: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--bd-line);
}
.book-detail__description h3 {
    margin: 0 0 .75rem;
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--bd-text);
}
.book-detail__description p {
    margin: 0;
    max-width: 68ch;
    color: var(--bd-muted);
    font-size: 1rem;
    line-height: 1.75;
    white-space: pre-line; /* respecte les retours à la ligne saisis */
}

/* ----- Actions ----- */
.book-detail__actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
}
.book-detail__actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    flex: 0 1 auto;
    min-height: 50px;
    padding-inline: 1.5rem;
    border-radius: 10px;
    font-weight: 600;
    text-decoration: none;
}
.book-detail__actions .btn svg { flex: none; width: 20px; height: 20px; }

.book-detail .back-link:focus-visible,
.book-detail__actions .btn:focus-visible {
    outline: 3px solid rgba(201, 37, 37, .45);
    outline-offset: 2px;
}

/* ----- Tablette ----- */
@media (max-width: 860px) {
    .book-detail__grid {
        grid-template-columns: 1fr;
        gap: 1.75rem;
    }
    .book-detail__image {
        position: static;
        width: min(100%, 340px);
        margin-inline: auto;
    }
}

/* ----- Mobile ----- */
@media (max-width: 480px) {
    .book-detail__title { text-align: left; }
    .book-detail__actions { flex-direction: column; }
    .book-detail__actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .book-detail .back-link,
    .book-detail .back-link svg { transition: none; }
}