/* ====================================== */
/* STYLES POUR LE COMPOSANT BOOK-DETAIL */
/* Design Iktisar — L'Encre et l'Écran   */
/* ====================================== */

/* ---  Container principal --- */
.book-detail {
    position: relative;
    display: none;
    padding: 10px 36px;
    min-height: 500px;
    opacity: 0;
    transition: background 0.3s ease;
    z-index: 5;
}

.book-detail-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.book-detail .actions {
    width: 100%;
    display: flex;
    justify-content: center;
}

.book-detail .icon-group {
    margin-left: 0;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

/* Label sous les icônes : visible uniquement sur mobile */
.bd-icon-label {
    display: none;
}

/* Onglets mobiles : cachés sur desktop */
.bd-mobile-tabs {
    display: none;
}

/* Panneaux onglets desktop : wrappers transparents dans la grille */
.book-detail-main .bd-tab-panel {
    display: contents;
}

/* Panneau Contenu (hors grille) : toujours visible */
.bd-tab-panel[data-panel="contenu"] {
    display: block;
}

/* --- Icônes rondes (favoris, partager, télécharger) --- */
.book-detail .icon-alone {
    font-size: 18px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--panel-light);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
    transition: var(--transition-normal);
    color: var(--muted);
    position: relative;
    overflow: visible;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.book-detail .icon-alone svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    transition: var(--transition-normal);
}

.book-detail .icon-alone:hover {
    background: var(--panel);
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-hover);
    color: var(--accent);
    border-color: var(--accent);
}

/* --- Couverture --- */
.book-cover {
    /* 360px = 240 * 3/2, ratio 2:3 exact des couvertures (COVER_LARGE, voir
       lib/imgTransform.js) — sans object-fit, un ratio de boîte différent
       étirait/déformait l'image plutôt que la recadrer. */
    height: 360px;
    width: 240px;
    object-fit: cover;
    flex-shrink: 0;
    display: block;
    border-radius: var(--cover-radius, 4px);
    opacity: 0;
    transition: transform 300ms ease, box-shadow 300ms ease;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
    border: none;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* --- Flèches de navigation --- */
.book-detail .arrow,
#prevBtnDetail,
#nextBtnDetail {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--panel-light);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition-normal);
    color: var(--muted);
    position: absolute;
    top: 180px;
    transform: translateY(-50%);
    z-index: 10;
    font-size: 14px;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

/* [id^="...--"] en plus de l'ID exact : le slot secondaire (comparaison de
   2 livres) suffixe tous les IDs avec "--book-detail-2" via _suffixIds()
   dans book-detail.js — un #id exact ne matche donc que le slot primaire et
   laisse les flèches du 2e livre sans left/right (mauvaise position). */
#prevBtnDetail, [id^="prevBtnDetail--"] { left: -20px; }
#nextBtnDetail, [id^="nextBtnDetail--"] { right: -20px; }

.book-detail .arrow:hover,
#prevBtnDetail:hover:not(.disabled),
[id^="prevBtnDetail--"]:hover:not(.disabled),
#nextBtnDetail:hover:not(.disabled),
[id^="nextBtnDetail--"]:hover:not(.disabled) {
    background: var(--panel);
    transform: translateY(-50%) translateY(-4px) scale(1.08);
    box-shadow: var(--shadow-hover);
    color: var(--accent);
    border-color: var(--accent);
}

#prevBtnDetail.disabled,
[id^="prevBtnDetail--"].disabled,
#nextBtnDetail.disabled,
[id^="nextBtnDetail--"].disabled {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

.animated-clone {
    aspect-ratio: 210 / 297;
    border-radius: 6px;
    transition: transform 300ms, box-shadow 300ms;
    z-index: 5;
}

/* --- Section haute : couverture + infos --- */
.book-detail-top {
    display: flex;
    align-items: flex-start;
    gap: 48px;
    width: 100%;
    position: relative;
    overflow: visible;
}

.book-detail-right {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 20px;
    overflow: visible;
}

.book-detail-right .title {
    font-family: var(--font-serif);
    font-size: 1.85rem;
    font-weight: 600;
    margin-bottom: 0;
    line-height: 1.3;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* --- Auteur --- */
.author-container {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.author-label { display: none !important; }

.author-container .author-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 150ms ease, transform 120ms ease, font-weight 120ms ease;
}

.author-container .author-name:hover {
    color: var(--accent);
    font-weight: 700;
    transform: translateY(-1px);
}

/* Dark mode: author links use gold */
body.theme-noir .author-container .author-name {
    color: var(--accent-gold);
}
body.theme-noir .author-container .author-name:hover {
    color: var(--accent-gold-light, #d4af5f);
}

/* --- Tooltip --- */
.icon-tooltip {
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(40, 40, 40, 0.92);
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.icon-alone:hover .icon-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(-2px);
}

#favoriteBtn:hover .icon-tooltip {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Tactile (mobile et tablette) : le tooltip hover est inaccessible au tap,
   on s'aligne sur le choix déjà fait pour mobile (icônes seules, sans texte). */
@media (hover: none) {
    .icon-tooltip {
        display: none !important;
    }
}

/* --- Section infos (résumé, catégorie, etc.) --- */
.book-detail .lead {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-family: var(--font-sans);
}

/* --- Info heading (Résumé / Détails) --- */
.info-heading {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 14px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent);
}

/* --- YouTube links --- */
.detail-col .youtube-links-container {
    justify-content: center;
}

/* Liens YouTube mobiles : cachés sur desktop (spécificité supérieure à .btn-card) */
.book-detail .bd-yt-mobile {
    display: none;
}

/* Sous-titre des liens YouTube : visible uniquement sur mobile */
.youtube-link-desc {
    display: none;
}

.book-detail-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    width: 100%;
    margin-top: 28px;
    margin-bottom: 16px;
}

.detail-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.book-detail .info {
    background: var(--panel-light);
    padding: 20px 24px;
    border-radius: var(--card-radius);
    border: 1px solid rgba(0, 0, 0, 0.04);
    box-shadow: var(--shadow-sm);
}

.book-detail .info p {
    margin: 6px 0;
    color: var(--text-secondary);
    font-size: 0.925rem;
    font-family: var(--font-sans);
    line-height: 1.6;
}

.book-detail .info p strong {
    color: var(--text-primary);
}

/* --- Boutons card --- */
.buttons-grid-new {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0;
    padding: 5px;
}

.btn-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--panel-light);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    padding: 10px 18px;
    cursor: pointer;
    transition: var(--transition-normal);
    box-shadow: var(--shadow-sm);
    min-width: 160px;
    font-family: var(--font-sans);
    text-decoration: none;
}

.btn-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    border-color: var(--accent);
}

/* Halo "nouveauté" (cf. js/novelty.js) — uniquement l'anneau animé, pas de
   bordure pleine permanente : même principe que la carte Bibliothèque
   (Bibliotheque-style.css) pour le sens de l'animation (anneau qui part
   TOUJOURS de l'intérieur vers l'extérieur en boucle, 0%→100% ease-out,
   jamais de retour vers l'intérieur), mais sans garder la bordure statique
   colorée ici. Amplitude réduite (offset max 2px, opacité de départ plus
   faible) — un anneau plus large/opaque répété sur 5 boutons dans une même
   rangée devenait visuellement surchargé (cf. historique). Vert du site
   (--accent, cf. common-styles.css), donc varie selon le thème actif —
   distinct du vert vif de la sélection des modes de jeu du hub quiz. */
.btn-card-novelty {
    --novelty-color: var(--accent);
    animation: noveltyBtnPulse 1.4s ease-out infinite;
}
/* Livre entièrement nouveau (kind book_added, cf. js/novelty.js) : doré au
   lieu du vert vif, appliqué à tous les boutons disponibles de la fiche
   (pas seulement Lire), dans tous les thèmes. */
.btn-card-novelty-gold {
    --novelty-color: var(--accent-gold, #b89e14);
    animation: noveltyBtnPulse 1.4s ease-out infinite;
}
@keyframes noveltyBtnPulse {
    0% {
        outline: 1px solid color-mix(in srgb, var(--novelty-color) 55%, transparent);
        outline-offset: 0;
    }
    100% {
        outline: 1px solid color-mix(in srgb, var(--novelty-color) 0%, transparent);
        outline-offset: 3px;
    }
}

.btn-card .icon-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-card .icon-circle svg {
    width: 18px;
    height: 18px;
}

.btn-card .icon-circle { background: rgba(0, 0, 0, 0.04); color: var(--text-secondary); }

.btn-card span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    /* Toujours tronquer le texte quand le bouton est contraint en largeur
       (sidebar, grille mobile, popup auteur). flex:1 + min-width:0 permettent
       à overflow:hidden de s'activer dans un conteneur flex. */
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Grille d'actions images --- */
.action-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start;
}

.action-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 200px;
    height: 200px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: var(--transition-normal);
    border: 2px solid transparent;
}

.action-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

.action-item:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

#biographieBtn {
    position: relative;
    transition: var(--transition-normal);
}

#biographieBtn:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 6px 16px rgba(60, 140, 108, 0.2);
}

/* --- Bouton retour — visuel partagé via .btn-back-icon (common-styles.css) --- */
.book-detail .back-button {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 20;
}

.book-detail .back-button:hover {
    transform: translateX(-2px);
}

/* --- Bouton Aide / Tuto --- */
.help-button-circle {
    position: absolute;
    top: 0;
    right: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--panel-light);
    border: 1px solid rgba(26, 82, 56, 0.15);
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 20;
    box-shadow: var(--shadow-sm);
}

.help-button-circle:hover {
    background: var(--accent-gold);
    color: white;
    border-color: var(--accent-gold);
    transform: scale(1.1);
    box-shadow: var(--shadow-hover);
}

/* --- YouTube --- */
.youtube-links-container {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 0;
    padding: 0;
    border-top: none;
}

.youtube-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font-sans);
    text-decoration: none;
    transition: var(--transition-normal);
    background: var(--panel-light);
    border: 1px solid rgba(0, 0, 0, 0.06);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.youtube-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.youtube-link .youtube-icon {
    width: 26px;
    height: 26px;
    min-width: 26px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.youtube-link.source .youtube-icon svg,
.youtube-link.video-book .youtube-icon svg {
    fill: var(--text-secondary);
}

.youtube-link.source { border-color: rgba(0, 0, 0, 0.06); }
.youtube-link.video-book { border-color: rgba(0, 0, 0, 0.04); }

.youtube-link span { line-height: 1; }

/* ====================================== */
/* RESPONSIVE BOOK DETAIL (in-file)       */
/* ====================================== */
@media (max-width: 900px) and (pointer: coarse) {
    .book-detail {
        flex-direction: column;
        align-items: center;
        padding: 24px 12px;
        min-height: 320px;
    }

    .book-detail-left {
        max-width: 100%;
        min-width: 0;
        width: 100%;
        margin-bottom: 16px;
    }

    .book-cover { max-width: 180px; height: auto; }

    .action-item { width: 70px; height: 70px; }

    .book-detail-main {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

@media (max-width: 600px) and (pointer: coarse) {
    .book-detail {
        padding: 12px 4px;
        min-height: 180px;
    }

    .book-detail-left { gap: 10px; }
    .book-cover { max-width: 120px; }
    .action-item { width: 48px; height: 48px; }

    .book-detail .btn {
        font-size: 0.9rem;
        padding: 8px 10px;
    }
}

@media (max-width: 500px) and (pointer: coarse),
       (pointer: coarse) and (max-height: 600px) and (orientation: landscape) {
    .book-detail {
        flex-direction: column;
        text-align: center;
        margin: 16px 0;
        padding: 16px;
    }

    .book-detail img {
        width: 120px;
        margin: 0 auto 16px auto;
    }

    .book-detail .buttons {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .book-detail .btn {
        flex: 1;
        min-width: 120px;
        margin: 4px;
    }
}

