/**
 * NovaBook — catalogue styles.
 *
 * Mobile first: the base rules are the narrow-screen layout, widened by
 * min-width queries. No fixed margin on an optional block — spacing comes
 * from `gap` on the container, so a block that does not render leaves no
 * residual space behind it.
 *
 * Colours are inherited from the active theme. Zero !important.
 *
 * @package NovaBook
 * @since   1.0.0
 */

.novabook-archive,
.novabook-single {
    --nb-gap: 1.25rem;
    --nb-radius: 8px;
    --nb-border: rgba(128, 128, 128, 0.18);
    --nb-muted: rgba(128, 128, 128, 0.75);
    /* 5 / 8 = 0.625 → height = width x 1.6, the reference cover ratio.
       Was 2 / 3 (x1.5), which no longer matched the generated sizes. */
    --nb-cover-ratio: 5 / 8;
}


/* ============================================================
   1. GENRE FILTER
   ============================================================ */

.novabook-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0 0 1.5rem;
}

.novabook-filter-item {
    display: inline-block;
    padding: 0.35em 0.85em;
    border: 1px solid var(--nb-border);
    border-radius: 999px;
    font-size: 0.875rem;
    line-height: 1.4;
    text-decoration: none;
    color: inherit;
    opacity: 0.75;
    transition: opacity 0.15s ease, border-color 0.15s ease;
}

.novabook-filter-item:hover,
.novabook-filter-item:focus-visible {
    opacity: 1;
}

.novabook-filter-item.is-current {
    opacity: 1;
    border-color: currentColor;
    font-weight: 600;
}


/* ============================================================
   2. GRID — 2 columns from 0, then 3, then 4
   ============================================================ */

.novabook-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--nb-gap);
    margin: 0 0 2rem;
}

@media (min-width: 600px) {
    .novabook-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 900px) {
    .novabook-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.novabook-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.novabook-card-link {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-decoration: none;
    color: inherit;
}

.novabook-cover {
    aspect-ratio: var(--nb-cover-ratio);
    overflow: hidden;
    border-radius: var(--nb-radius);
    background: rgba(128, 128, 128, 0.08);
}

.novabook-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s ease;
}

.novabook-card-link:hover .novabook-cover-img {
    transform: scale(1.03);
}

.novabook-cover-placeholder {
    display: block;
    width: 100%;
    height: 100%;
}

/* Titre, auteur et formats sont centrés sous la couverture. Le centrage porte
   sur ces trois éléments et non sur .novabook-card : la couverture reste ainsi
   hors de portée de text-align, et son image comme son substitut sont de toute
   façon en display:block et width:100%, donc calés sur les bords de la carte.
   Le texte se centre sous une couverture qui, elle, ne bouge pas. */
.novabook-card-title {
    font-size: 0.9375rem;
    font-weight: 700;
    line-height: 1.3;
    margin: 0;
    text-align: center;
    word-break: break-word;
    overflow-wrap: break-word;
}

.novabook-card-author,
.novabook-card-formats {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.4;
    text-align: center;
    color: var(--nb-muted);
}

.novabook-card-formats {
    font-size: 0.75rem;
}

.novabook-empty {
    margin: 1rem 0 2rem;
    color: var(--nb-muted);
}


/* ============================================================
   3. SINGLE — stacked on mobile, two columns from 700px
   ============================================================ */

.novabook-book {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin: 0 0 2.5rem;
}

@media (min-width: 700px) {
    .novabook-book {
        flex-direction: row;
        align-items: flex-start;
        gap: 2.5rem;
    }

    .novabook-single-cover {
        flex: 0 0 280px;
        position: sticky;
        top: 100px;
    }

    .novabook-single-body {
        flex: 1;
        min-width: 0;
    }
}

.novabook-single-cover {
    max-width: 280px;
    margin-inline: auto;
    width: 100%;
}

.novabook-single-cover img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--nb-radius);
}

/* The body is a flex column: every optional block spaces itself through
   `gap`, so an absent block leaves no gap of its own. */
.novabook-single-body {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.novabook-title {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
    word-break: break-word;
    overflow-wrap: break-word;
}

@media (min-width: 700px) {
    .novabook-title {
        font-size: 2rem;
    }
}

.novabook-author {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    opacity: 0.85;
}

.novabook-genres {
    margin: 0;
    font-size: 0.875rem;
}

.novabook-genres a {
    color: inherit;
    opacity: 0.75;
}

.novabook-genres a:hover {
    opacity: 1;
}

/* Ligne des données objectives : longueur et langue. Même grammaire que la
   ligne d'identité — le séparateur est porté par ::before de l'élément qui
   suit, si bien qu'il voyage avec son item au passage à la ligne au lieu de
   rester orphelin en bout de rangée. */
/* Encadrement repris des blocs du bas, .novabook-buy et .novabook-bookshop :
   mêmes bordure, rayon et padding, pris sur les mêmes variables. Pas de fond —
   ces deux blocs n'en ont pas, et en ajouter un ici les ferait diverger. */
.novabook-details {
    margin: 0;
    padding: 1.25rem;
    border: 1px solid var(--nb-border);
    border-radius: var(--nb-radius);
}

/* L'icône prend la taille et la couleur du texte : 1em, currentColor, aucune
   dimension en dur. Décorative — le libellé dit déjà « 320 pages » et
   « en français » —, donc retirée de l'arbre d'accessibilité. */
.novabook-detail-icon {
    width: 1em;
    height: 1em;
    margin-right: 0.4em;
    flex-shrink: 0;
    opacity: 0.6;
}

.novabook-pitch {
    font-size: 1rem;
    line-height: 1.65;
}

.novabook-pitch p {
    margin: 0 0 0.75rem;
}

.novabook-pitch p:last-child {
    margin-bottom: 0;
}


/* ============================================================
   4. BUY — full-width buttons on mobile, inline from 480px
   ============================================================ */

.novabook-buy,
.novabook-bookshop {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.25rem;
    border: 1px solid var(--nb-border);
    border-radius: var(--nb-radius);
}

/* Air between the heading row and the buttons. Carried by the container gap
   rather than a margin on the header: with no button row — a book on Kindle
   Unlimited and nothing else — a margin would leave a dangling space before
   the block's padding, while a gap simply does not apply. */
.novabook-buy {
    gap: 1.35rem;
}

.novabook-buy-title,
.novabook-bookshop-title {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0;
    opacity: 0.6;
}

.novabook-bookshop-title {
    font-size: 0.8125rem;
}

/* The heading has to win the row outright: bigger type AND less veiling than
   the 0.6 opacity shared with the bookshop title. The eye lands here, then on
   the buttons; the badge is noticed second. */
.novabook-buy-title {
    font-size: 1.125rem;
    opacity: 0.85;
}

.novabook-buy-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

@media (min-width: 480px) {
    .novabook-buy-list {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

.novabook-btn {
    display: block;
    padding: 0.8em 1.4em;
    border: 1px solid currentColor;
    border-radius: var(--nb-radius);
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.15s ease;
}

@media (min-width: 480px) {
    .novabook-btn {
        display: inline-block;
    }
}

.novabook-btn:hover,
.novabook-btn:focus-visible {
    opacity: 0.75;
}

/* Kindle Unlimited stated as text, when there is no ebook link to point at.
   Deliberately not a button: nothing to click. */
.novabook-note {
    margin: 0;
    font-size: 0.875rem;
    color: var(--nb-muted);
}

.novabook-bookshop-text {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.novabook-isbn {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
    margin: 0;
}

.novabook-isbn-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.6;
}

.novabook-isbn-value {
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 1.0625rem;
    letter-spacing: 0.04em;
    word-break: break-all;
}

.novabook-soon {
    margin: 0;
    font-size: 0.9375rem;
    color: var(--nb-muted);
}

.novabook-term-desc {
    margin: 0 0 1.25rem;
    font-size: 0.9375rem;
    line-height: 1.6;
}


/* ============================================================
   3b. META LINE — author · genres · Kindle Unlimited, one row
   The separator is a ::before on every item but the first, so it is
   part of the item box: when the line wraps, the separator goes with
   its item to the next row and is never stranded at the end of one.
   ============================================================ */

/* UNE seule grammaire pour les deux lignes de la fiche — identité
   (auteur · genre) et détails (pages · langue). Les deux classes partagent
   les mêmes règles plutôt que de les recopier : elles ne peuvent pas diverger
   au prochain ajustement. */
.novabook-meta-line,
.novabook-details {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.6rem;
    font-size: 0.875rem;
    min-width: 0;
}

.novabook-meta-line {
    margin: 0;
}

.novabook-meta-item,
.novabook-detail {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    word-break: break-word;
    overflow-wrap: break-word;
}

.novabook-meta-item + .novabook-meta-item::before,
.novabook-meta-item:not(:first-child)::before,
.novabook-detail + .novabook-detail::before,
.novabook-detail:not(:first-child)::before {
    content: "·";
    margin-right: 0.6rem;
    opacity: 0.45;
    flex-shrink: 0;
}

.novabook-meta-line .novabook-author {
    font-weight: 600;
    opacity: 0.85;
}

/* Le lien auteur prenait le bleu par défaut du navigateur : la règle de lien
   du thème est limitée aux conteneurs de contenu (.entry-content et consorts),
   dont la fiche livre ne fait pas partie. On applique donc la variable de lien
   du thème, avec le vert NovaFuture en repli si NovaBook tourne sans lui. */
.novabook-meta-line .novabook-author a {
    color: var(--nt-link, #096e09);
    text-decoration: none;
    transition: color var(--nt-transition, 0.2s ease-in-out);
}

.novabook-meta-line .novabook-author a:hover,
.novabook-meta-line .novabook-author a:focus {
    color: var(--nt-link-hover, #075207);
    text-decoration: underline;
}

.novabook-meta-line .novabook-genres a {
    color: inherit;
    opacity: 0.75;
    text-decoration: none;
}

.novabook-meta-line .novabook-genres a:hover {
    opacity: 1;
    text-decoration: underline;
}
