/* ── Ebook Library ──────────────────────────────────────────────────────── */

.ebook-library { font-family: inherit; }

/* Filter bar */
.ebook-filters {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 28px;
    padding: 16px 20px;
    background: #f8f7f4;
    border-radius: 8px;
    border: 1px solid #e8e6e1;
}

/* Row 1 – search */
.ebook-filters__search-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.ebook-filters__search {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 15px;
    background: #fff;
}
.ebook-filters__search:focus {
    outline: none;
    border-color: #721628;
    box-shadow: 0 0 0 2px rgba(44,62,80,.15);
}

/* Row 2 – dropdowns */
.ebook-filters__dropdown-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.ebook-filters__dropdown-row select {
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 14px;
    background: #fff;
    min-width: 140px;
}
.ebook-filters__sort {
    margin-left: auto; /* push sort to the right */
}

.ebook-filter-btn {
    padding: 9px 20px;
    background: #721628;
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.ebook-filter-btn:hover { background: #4a0f1a; }
.ebook-filter-clear {
    font-size: 13px;
    color: #888;
    text-decoration: none;
    padding: 4px;
    white-space: nowrap;
}
.ebook-filter-clear:hover { color: #c00; text-decoration: underline; }
.ebook-results-bar {
    font-size: 13px;
    color: #666;
    margin-bottom: 16px;
}

/* Grid */
.ebook-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 24px;
    margin-bottom: 36px;
}

/* Card */
.ebook-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    overflow: hidden;
    transition: box-shadow .2s, transform .2s;
}
.ebook-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,.14);
    transform: translateY(-3px);
}
.ebook-card__cover-link { display: block; text-decoration: none; }
.ebook-card__cover {
    width: 100%;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    background: #dde4ec;
    position: relative;
}
.ebook-card__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.ebook-card__cover--placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 52px;
    color: rgba(0,0,0,.2);
    background: linear-gradient(135deg, #F3E5DB 0%, #E0A382 100%);
}

.ebook-card__body {
    padding: 12px 14px 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ebook-card__title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    color: #1a1a1a;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-decoration: none;
}
.ebook-card__title a { color: inherit; text-decoration: none; }
.ebook-card__title a:hover { color: #721628; }
.ebook-card__author {
    font-size: 12px;
    color: #666;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ebook-card__genres {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}
.ebook-card__genre-badge {
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 20px;
    background: #F3E5DB;
    color: #721628;
    text-decoration: none;
    white-space: nowrap;
}
.ebook-card__genre-badge:hover { background: #721628; color: #fff; }

.ebook-card__footer { padding: 10px 14px 14px; }
.ebook-card__btn {
    display: block;
    text-align: center;
    padding: 8px;
    background: #721628;
    color: #fff;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}
.ebook-card__btn:hover { background: #4a0f1a; color: #fff; }

/* No results */
.ebook-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #888;
    font-size: 16px;
}

/* Pagination */
.ebook-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-top: 12px;
}
.ebook-pagination a,
.ebook-pagination span {
    display: inline-block;
    padding: 6px 13px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    text-decoration: none;
    color: #721628;
    background: #fff;
}
.ebook-pagination span.current {
    background: #721628;
    color: #fff;
    border-color: #721628;
}
.ebook-pagination a:hover { background: #f0f0f0; }

/* ── Locked card button (non-members) ────────────────────────────────────── */
.ebook-card__btn--locked {
    background: #7f8c8d;
    cursor: default;
}
.ebook-card__btn--locked:hover { background: #6c7a7b; }

/* ── Membership CTA (single ebook + library) ─────────────────────────────── */
.ebook-members-only {
    margin: 2em 0;
    padding: 2.5em 1.5em;
    background: #faf4f0;
    border: 1px solid #ddc9bc;
    border-radius: 10px;
    text-align: center;
}
.ebook-members-only__icon { font-size: 3rem; margin-bottom: .5em; display: block; }
.ebook-members-only h3    { margin: 0 0 .5em; font-size: 1.4rem; }
.ebook-members-only p     { color: #555; margin: 0 0 1.5em; }

.ebook-cta-btn {
    display: inline-block;
    padding: 10px 24px;
    margin: 0 6px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    background: #F3E5DB;
    color: #721628;
}
.ebook-cta-btn--primary    { background: #721628; color: #fff; }
.ebook-cta-btn:hover       { opacity: .85; }

/* ── Print protection ────────────────────────────────────────────────────── */
@media print {
    .ebook-reader-frame { display: none !important; }
    .ebook-library      { display: none !important; }
}

/* ── Read Now button ([ebook_read_button] shortcode) ─────────────────────── */
.ebook-read-btn {
    display: inline-block;
    padding: 0.75rem 2rem;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none !important;
    /* !important prevents theme cascade from dark/coloured parent sections
       overriding these values (Ollie sets color:base on .has-primary-background-color) */
    background: var(--wp--preset--color--base, #F3E5DB) !important;
    color: var(--wp--preset--color--primary, #721628) !important;
    transition: opacity 0.2s;
    margin-top: var(--wp--preset--spacing--small, 0.75rem);
}
.ebook-read-btn:hover { opacity: 0.88; }

.ebook-read-btn--outline {
    background: transparent !important;
    color: var(--wp--preset--color--base, #F3E5DB) !important;
    border: 2px solid var(--wp--preset--color--base, #F3E5DB);
}
.ebook-read-btn--ghost {
    background: transparent !important;
    color: var(--wp--preset--color--base, #F3E5DB) !important;
    opacity: 0.7;
    padding-left: 1rem;
    padding-right: 1rem;
}
.ebook-read-cta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-top: var(--wp--preset--spacing--small, 0.75rem);
}

/* ── Single ebook page (single-ebook.html template) ─────────────────────── */
.ebook-single-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 1rem;
    color: var(--wp--preset--color--base, #F3E5DB);
    opacity: 0.85;
    margin: 0;
}
.ebook-single-meta__author    { font-style: italic; }
.ebook-single-meta__sep       { opacity: 0.5; }
.ebook-single-meta__published { font-size: 0.9rem; }

/* Reader frame — constrained width on single page */
.single-ebook .ebook-reader-frame {
    margin-top: var(--wp--preset--spacing--large, 2rem);
}
.single-ebook .ebook-reader-frame iframe {
    border-radius: 6px;
    border: 1px solid var(--wp--preset--color--primary-accent, #F3E5DB) !important;
}
