/* Book Catalog Pro – Public Styles */

/* ---------------------------------------------------------------
   Wrapper
--------------------------------------------------------------- */
.bcp-archive-wrap,
.bcp-single-wrap {
        max-width: 1200px;
        margin: 0 auto;
        padding: 24px 16px 48px;
}

/* ---------------------------------------------------------------
   Archive header
--------------------------------------------------------------- */
.bcp-archive-title {
        margin-bottom: 24px;
}

/* ---------------------------------------------------------------
   Filter bar
--------------------------------------------------------------- */
.bcp-filter-form {
        margin-bottom: 24px;
}
.bcp-filter-row {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        align-items: center;
}
.bcp-search-wrap {
        display: flex;
        flex: 1 1 220px;
        min-width: 200px;
}
.bcp-search-input {
        flex: 1;
        padding: 8px 12px;
        border: 1px solid #ccc;
        border-right: none;
        border-radius: 4px 0 0 4px;
        font-size: 14px;
}
.bcp-search-btn {
        padding: 8px 12px;
        background: #0073aa;
        color: #fff;
        border: 1px solid #0073aa;
        border-radius: 0 4px 4px 0;
        cursor: pointer;
        font-size: 14px;
        line-height: 1;
}
.bcp-search-btn:hover { background: #005f8d; }

.bcp-filter-select {
        padding: 8px 10px;
        border: 1px solid #ccc;
        border-radius: 4px;
        font-size: 14px;
        background: #fff;
}

.bcp-display-toggle {
        display: flex;
        gap: 4px;
        margin-left: auto;
}
.bcp-display-btn {
        display: inline-block;
        padding: 7px 10px;
        border: 1px solid #ccc;
        border-radius: 4px;
        color: #555;
        text-decoration: none;
        font-size: 13px;
        line-height: 1;
}
.bcp-display-btn.active,
.bcp-display-btn:hover {
        background: #0073aa;
        color: #fff;
        border-color: #0073aa;
}

.bcp-active-filter { margin: 8px 0 0; }
.bcp-clear-filter {
        color: #a00;
        text-decoration: none;
        font-size: 13px;
}
.bcp-clear-filter:hover { text-decoration: underline; }

.bcp-result-count {
        color: #666;
        font-size: 13px;
        margin-bottom: 16px;
}

/* ---------------------------------------------------------------
   Book grid
--------------------------------------------------------------- */
.bcp-book-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 24px;
        margin-bottom: 32px;
}

.bcp-book-card--grid {
        background: #fff;
        border: none;
        border-radius: 6px;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        box-shadow: 0 2px 8px rgba(0,0,0,.08);  /* resting — card boundary always visible */
        transition: box-shadow .2s, transform .2s;
}
.bcp-book-card--grid:hover {
        box-shadow: 0 6px 20px rgba(0,0,0,.18);
        transform: translateY(-2px);
}

.bcp-card-cover-link {
        display: block;
        background: transparent;
}
.bcp-card-cover {
        position: relative;
        width: 100%;
        padding-bottom: 150%;   /* 2:3 portrait — height = 1.5× width */
        overflow: hidden;
        display: block;
}
/* Use !important so WordPress theme resets (img { height:auto }) cannot
   undo the fill.  Without these the image shrinks to its intrinsic size
   and gray bleeds in around it. */
.bcp-card-cover img {
        position: absolute !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        object-position: center top !important;
        display: block !important;
}

.bcp-card-body {
        padding: 10px 12px 6px;
        flex: 1;
}
.bcp-card-title {
        font-size: 14px;
        margin: 0 0 4px;
        line-height: 1.3;
}
.bcp-card-title a {
        color: inherit;
        text-decoration: none;
}
.bcp-card-title a:hover { color: #0073aa; }
.bcp-card-authors {
        font-size: 12px;
        color: #666;
        margin: 0 0 2px;
}
.bcp-card-series {
        font-size: 11px;
        color: #888;
        margin: 0;
}

.bcp-card-footer {
        padding: 8px 12px;
        border-top: none;
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
}
.bcp-card-detail-link,
.bcp-card-buy-link {
        font-size: 12px;
        padding: 4px 10px;
        border-radius: 3px;
        text-decoration: none;
        display: inline-block;
}
.bcp-card-detail-link {
        background: #ff9900;
        color: #fff !important;
        font-weight: 600;
}
.bcp-card-detail-link:hover { background: #e68900; color: #fff; }
.bcp-card-buy-link {
        background: #ff9900;
        color: #fff;
}
.bcp-card-buy-link:hover { background: #e68900; }

/* ---------------------------------------------------------------
   Mosaic display (shortcode display="mosaic")
   - PHP pre-calculates N columns and outputs N .bcp-mosaic-col divs
     inside .bcp-mosaic-wrap (flexbox row).
   - Books are distributed in row-major order (same as grid) so
     positions match: Col 0 = books 0,N,2N…; Col 1 = books 1,N+1…
   - Cards within a column stack flush (no row-height alignment),
     which eliminates the white-space gaps of a grid row approach.
--------------------------------------------------------------- */
.bcp-mosaic-wrap {
        display: flex;
        flex-direction: row;
        gap: 24px;          /* same column gap as .bcp-book-grid */
        margin-bottom: 32px;
        align-items: flex-start;
}
.bcp-mosaic-col {
        flex: 1;
        min-width: 0;       /* prevent flex blowout */
        display: flex;
        flex-direction: column;
        gap: 24px;          /* vertical card separation — same as grid row gap */
}

.bcp-book-card--mosaic {
        background: transparent;
        border: none;
        border-radius: 4px;
        display: block;
        width: 100%;
        margin: 0;
        box-shadow: 0 2px 8px rgba(0,0,0,.08);   /* resting — same as grid/list */
        transition: box-shadow .2s, transform .2s;
}
.bcp-book-card--mosaic:hover {
        box-shadow: 0 6px 20px rgba(0,0,0,.18);
        transform: translateY(-2px);
}
.bcp-mosaic-cover-link {
        display: block;
        line-height: 0;
        background: transparent;
}
.bcp-mosaic-cover-img {
        display: block;
        width: 100%;
        height: auto;
        border-radius: 4px 4px 0 0;
        box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.bcp-mosaic-body {
        padding: 10px 12px 12px;   /* match .bcp-card-body; cover image stays edge-to-edge */
}
.bcp-mosaic-body .bcp-card-title {
        font-size: 14px;
        margin: 0 0 4px;
        line-height: 1.3;
}
.bcp-mosaic-body .bcp-card-title a { color: inherit; text-decoration: none; }
.bcp-mosaic-body .bcp-card-title a:hover { color: #0073aa; }
.bcp-mosaic-body .bcp-card-authors {
        font-size: 12px;
        color: #666;
        margin: 0 0 4px;
}
.bcp-mosaic-body .bcp-card-series {
        font-size: 11px;
        color: #888;
        margin: 0 0 6px;
}
.bcp-mosaic-actions { margin: 6px 0 0; }

/* ---------------------------------------------------------------
   Book list
--------------------------------------------------------------- */
.bcp-book-list {
        display: flex;
        flex-direction: column;
        gap: 16px;
        margin-bottom: 32px;
        container-type: inline-size; /* enables @container queries on child cards */
}
.bcp-book-card--list {
        display: flex;
        gap: 20px;
        background: #fff;
        border: none;
        border-radius: 6px;
        padding: 16px;
        align-items: stretch;
        min-height: 200px;
        box-shadow: 0 2px 8px rgba(0,0,0,.08);  /* resting shadow — replaces border */
        transition: box-shadow .2s, transform .2s;
}
.bcp-book-card--list:hover {
        box-shadow: 0 6px 20px rgba(0,0,0,.18);
        transform: translateY(-2px);
}
.bcp-list-cover {
        flex: 0 0 140px;
        display: flex;
        align-items: stretch;
}
.bcp-list-cover img {
        width: 140px;
        height: 100%;
        max-height: 220px;
        object-fit: cover;
        border-radius: 4px;
        box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.bcp-list-info {
        flex: 1 1 auto;
        min-width: 0;
        max-width: 640px;
        display: flex;
        flex-direction: column;
        justify-content: center;
}
.bcp-list-info .bcp-card-title {
        font-size: 17px;
}
.bcp-list-info .bcp-card-authors { font-size: 14px; }
.bcp-card-cats, .bcp-card-tags {
        font-size: 13px;
        color: #555;
        margin: 3px 0;
}
.bcp-card-excerpt {
        font-size: 13px;
        color: #666;
        margin-top: 6px;
}
.bcp-list-actions {
        flex: 0 0 auto;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: stretch;
        gap: 8px;
        padding: 0 8px;
        margin-left: auto;
}
.bcp-list-actions .bcp-card-detail-link {
        font-size: 14px;
        padding: 10px 22px;
        text-align: center;
        min-width: 110px;
}

/* ---------------------------------------------------------------
   Single book
--------------------------------------------------------------- */
.bcp-breadcrumb {
        font-size: 13px;
        color: #888;
        margin-bottom: 24px;
}
.bcp-breadcrumb a { color: #0073aa; text-decoration: none; }
.bcp-breadcrumb a:hover { text-decoration: underline; }

.bcp-book-single {
        display: flex;
        gap: 40px;
        align-items: flex-start;
        flex-wrap: wrap;
}
.bcp-book-single-cover {
        flex: 0 0 220px;
        text-align: center;
}
.bcp-cover-img {
        max-width: 100%;
        border-radius: 4px;
        box-shadow: 0 4px 16px rgba(0,0,0,.18);
        margin-bottom: 16px;
}
.bcp-buy-btn {
        display: block;
        background: #ff9900;
        color: #fff !important;
        text-decoration: none;
        padding: 12px 16px;
        border-radius: 4px;
        font-weight: bold;
        font-size: 15px;
        text-align: center;
        transition: background .2s;
}
.bcp-buy-btn:hover { background: #e68900; }
.bcp-buy-btn--bottom { margin-top: 20px; display: inline-block; }

.bcp-book-single-info { flex: 1; min-width: 260px; }
.bcp-book-title { font-size: 28px; margin: 0 0 12px; }
.bcp-book-authors { font-size: 16px; margin: 0 0 8px; }
.bcp-book-series  { font-size: 14px; color: #555; margin: 0 0 8px; }
.bcp-book-series a { color: #0073aa; text-decoration: none; }
.bcp-book-publisher { font-size: 13px; color: #666; margin: 0 0 8px; }
.bcp-book-isbn { font-size: 13px; color: #666; margin: 0 0 8px; }
.bcp-book-categories,
.bcp-book-tags { font-size: 14px; margin: 0 0 8px; }
.bcp-book-categories a,
.bcp-book-tags a { color: #0073aa; text-decoration: none; }
.bcp-book-categories a:hover,
.bcp-book-tags a:hover { text-decoration: underline; }
.bcp-tag-link {
        background: #f0f0f0;
        border-radius: 3px;
        padding: 1px 6px;
        font-size: 12px;
}
.bcp-book-description { margin-top: 20px; line-height: 1.7; }
.bcp-book-description h2 { font-size: 18px; margin-bottom: 10px; }
.bcp-book-description p { margin: 0 0 1em; }
.bcp-book-description p:last-child { margin-bottom: 0; }

.bcp-filter-heading { margin: 0 0 6px; font-size: 22px; }
.bcp-filter-back { margin: 0 0 16px; font-size: 13px; }
.bcp-filter-back a { color: #0073aa; text-decoration: none; }
.bcp-filter-back a:hover { text-decoration: underline; }

.bcp-single-footer { margin-top: 40px; }
.bcp-back-link { color: #0073aa; text-decoration: none; }
.bcp-back-link:hover { text-decoration: underline; }

/* ---------------------------------------------------------------
   Pagination
--------------------------------------------------------------- */
.bcp-pagination {
        display: flex;
        gap: 6px;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        margin: 32px 0;
}
.bcp-page-link {
        padding: 7px 12px;
        border: 1px solid #ccc;
        border-radius: 4px;
        text-decoration: none;
        color: #333;
        font-size: 14px;
        background: #fff;
        transition: background .15s;
}
.bcp-page-link:hover { background: #f0f0f0; }
.bcp-page-link.current {
        background: #0073aa;
        color: #fff;
        border-color: #0073aa;
}
.bcp-page-ellipsis { padding: 7px 4px; color: #888; }

/* ---------------------------------------------------------------
   No results
--------------------------------------------------------------- */
.bcp-no-results {
        text-align: center;
        padding: 48px 16px;
        color: #666;
}

/* ---------------------------------------------------------------
   Widget
--------------------------------------------------------------- */
.bcp-widget-list {
        list-style: none;
        margin: 0;
        padding: 0;
}
.bcp-widget-list li {
        border-bottom: 1px solid rgba(0,0,0,.07);
}
.bcp-widget-list li:last-child { border-bottom: none; }
.bcp-widget-list a {
        display: block;
        padding: 6px 0;
        text-decoration: none;
        color: inherit;
}
.bcp-widget-list a:hover { color: #0073aa; }
.bcp-count { color: #888; font-size: 12px; }

/* ---------------------------------------------------------------
   Inline single book shortcode
--------------------------------------------------------------- */
.bcp-single-book-inline {
        display: inline-block;
        max-width: 180px;
        vertical-align: top;
        margin: 0 12px 12px 0;
}

/* ---------------------------------------------------------------
   Responsive — viewport fallback (for browsers without container query support)
   These @media rules fire on window width and serve as a safety net.
   Modern browsers use the @container rules below, which fire on the
   actual painted container width regardless of window size.
--------------------------------------------------------------- */
@media (max-width: 900px) {
        /* Mosaic fallback: collapse PHP columns → auto-fill CSS grid */
        .bcp-mosaic-wrap {
                display: grid;
                grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
                gap: 16px;
        }
        .bcp-mosaic-col { display: contents; }

        /* List fallback: stack when viewport is narrow */
        .bcp-book-card--list { flex-direction: column; min-height: 0; }
        .bcp-list-cover { flex: none; width: 100%; justify-content: center; }
        .bcp-list-cover img {
                width: auto; max-width: 180px; height: auto; max-height: 260px;
                object-fit: contain;
                border-radius: 6px;
        }
        .bcp-list-actions { flex-direction: row; width: 100%; margin-left: 0; padding: 0; justify-content: flex-start; }
}

@media (max-width: 599px) {
        .bcp-book-grid {
                grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
                gap: 14px;
        }
        .bcp-mosaic-wrap {
                grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
                gap: 12px;
        }
        .bcp-book-single { flex-direction: column; }
        .bcp-book-single-cover { flex: none; width: 100%; max-width: 220px; }
        .bcp-filter-row { flex-direction: column; align-items: stretch; }
        /* When the row stacks vertically the flex-basis of .bcp-search-wrap
           becomes a height basis (~220 px), making the search bar very tall.
           Override to a fixed single-line height and full width instead. */
        .bcp-search-wrap  { flex: none; width: 100%; min-width: 0; }
        .bcp-search-input { height: 38px; box-sizing: border-box; }
        .bcp-display-toggle { margin-left: 0; justify-content: flex-end; }
}

/* ---------------------------------------------------------------
   Container queries — fire on actual painted container width, not
   viewport width. Fixes the sidebar scenario: window > 900px but
   content container is only ~747px, so the @media rules above
   never fire even though the layout is too narrow.

   Browser support: Chrome 105+, Firefox 110+, Safari 16+ (2022-23).
   The @media rules above remain as fallback for older browsers.
--------------------------------------------------------------- */

/* List: .bcp-book-list has container-type: inline-size (set above),
   so these rules fire when that element itself is ≤ 760px wide. */
@container (max-width: 760px) {
        .bcp-book-card--list { flex-direction: column; min-height: 0; }
        /* Show the cover as a centred portrait — not a wide landscape crop.
           width:auto + max-width keeps the natural book-cover proportions;
           object-fit:contain shows the whole cover without cropping. */
        .bcp-list-cover { flex: none; width: 100%; justify-content: center; }
        .bcp-list-cover img {
                width: auto; max-width: 180px; height: auto; max-height: 260px;
                object-fit: contain;
                border-radius: 6px;
        }
        .bcp-list-actions { flex-direction: row; width: 100%; margin-left: 0; padding: 0; justify-content: flex-start; }
}

/* Mosaic: .bcp-mosaic-container (the thin wrapper div added in PHP) has
   container-type: inline-size, so these rules fire on its painted width. */
.bcp-mosaic-container {
        container-type: inline-size;
}
@container (max-width: 760px) {
        .bcp-mosaic-wrap {
                display: grid;
                grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
                gap: 16px;
        }
        .bcp-mosaic-col { display: contents; }
}
@container (max-width: 480px) {
        .bcp-mosaic-wrap {
                grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
                gap: 12px;
        }
}
