/**
 * Palavi Library - Public Book Catalog
 * ------------------------------------------------------------------
 * Page-specific styles for books.php (the public, no-login catalog).
 * Reuses glass.css tokens (--brand-*, .glass-card, .btn-brand,
 * .badge-soft, .modal-scale-fade) and user.css's .book-card/
 * .book-cover-wrapper/.book-access-badge directly - only new rules
 * live here: the top nav, hero banner, results/sidebar layout, rating
 * filter, category list, top-rated widget, card badges/heart icon,
 * and the login/register modal tabs.
 */

body {
    background: var(--bg-body);
}

/* ---------------------------------------------------------------
   TOP NAV
   --------------------------------------------------------------- */
.catalog-topnav {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-glass);
    position: sticky;
    top: 0;
    z-index: 30;
}

.catalog-topnav-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.catalog-cat-dropdown-btn {
    background: var(--brand-gradient);
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    border: none;
    border-radius: var(--radius-md);
    padding: 10px 16px;
}

.catalog-cat-dropdown-btn:hover,
.catalog-cat-dropdown-btn:focus {
    color: #fff;
}

.catalog-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 800;
    font-size: 1.1rem;
}

.catalog-brand img {
    height: 32px;
    width: auto;
}

.catalog-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ---------------------------------------------------------------
   HERO BANNER
   --------------------------------------------------------------- */
.catalog-hero {
    position: relative;
    overflow: hidden;
    background: var(--brand-gradient);
    animation: catalogFadeUp 0.5s var(--ease-standard) both;
}

.catalog-hero-blob-1,
.catalog-hero-blob-2 {
    position: absolute;
    border-radius: 50%;
    filter: blur(50px);
    opacity: 0.35;
    background: #fff;
}

.catalog-hero-blob-1 { width: 220px; height: 220px; top: -80px; left: -60px; }
.catalog-hero-blob-2 { width: 260px; height: 260px; bottom: -100px; right: -60px; }

.catalog-hero-inner {
    position: relative;
    max-width: 1240px;
    margin: 0 auto;
    padding: 56px 20px;
    display: flex;
    align-items: center;
    gap: 40px;
}

.catalog-hero-content {
	flex: 1 1 auto;
	min-width: 0;
}

.catalog-hero-photo {
    min-width: 0;
}

.catalog-hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(6px);
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.catalog-hero h1 {
    font-size: clamp(2rem, 4.2vw, 2.75rem);
    font-weight: 800;
    color: #fff;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.catalog-hero-tagline {
    color: rgba(255, 255, 255, 0.9);
    font-size: clamp(0.95rem, 1.6vw, 1.1rem);
    max-width: 440px;
    margin-bottom: 22px;
}

.catalog-hero-cta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 22px;
}

.catalog-hero-cta .btn-outline-light {
    font-weight: 600;
}

.catalog-breadcrumb {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    margin: 0;
}

.catalog-breadcrumb a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
}

.catalog-breadcrumb span:last-child {
    color: #fff;
    font-weight: 600;
}

.catalog-hero-photo {
    flex: 1 1 380px;
    max-width: 460px;
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
    border: 4px solid rgba(255, 255, 255, 0.25);
}

.catalog-hero-photo img {
    display: block;
    width: 100%;
    height: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

@media (max-width: 900px) {
    .catalog-hero-inner {
        flex-direction: column;
        text-align: center;
        padding: 40px 20px;
    }
    .catalog-hero-tagline { max-width: none; margin-left: auto; margin-right: auto; }
    .catalog-hero-cta { justify-content: center; }
    .catalog-hero-photo { max-width: 420px; width: 100%; }
}

@media (max-width: 420px) {
    .catalog-hero-cta {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .catalog-hero-cta .btn {
        width: 100%;
    }
}

/* ---------------------------------------------------------------
   FULL-WIDTH IMAGE BANNER
   --------------------------------------------------------------- */
.catalog-wide-banner {
    position: relative;
    overflow: hidden;
    min-height: 340px;
    display: flex;
    align-items: center;
    margin: 8px 0;
}

.catalog-wide-banner img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.catalog-wide-banner-scrim {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(20, 18, 50, 0.85) 0%, rgba(20, 18, 50, 0.55) 45%, rgba(20, 18, 50, 0.15) 80%);
}

.catalog-wide-banner-content {
    position: relative;
    max-width: 1240px;
    margin: 0 auto;
    padding: 48px 20px;
    width: 100%;
}

.catalog-wide-banner-content h2 {
    font-size: clamp(1.6rem, 3.4vw, 2.3rem);
    font-weight: 800;
    color: #fff;
    margin-bottom: 10px;
    letter-spacing: -0.02em;
    max-width: 520px;
}

.catalog-wide-banner-content p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    max-width: 460px;
    margin-bottom: 20px;
}

@media (max-width: 767px) {
    .catalog-wide-banner { min-height: 300px; }
    .catalog-wide-banner img { object-position: 75% center; }
    .catalog-wide-banner-scrim {
        background: linear-gradient(180deg, rgba(20, 18, 50, 0.45) 0%, rgba(20, 18, 50, 0.88) 70%, rgba(20, 18, 50, 0.94) 100%);
    }
}

/* ---------------------------------------------------------------
   STORY ROWS (alternating image / text)
   --------------------------------------------------------------- */
.catalog-story-row {
    display: flex;
    align-items: center;
    gap: 48px;
}

.catalog-story-row-reverse {
    flex-direction: row-reverse;
}

.catalog-story-media {
	flex: 1 1 auto;
	min-width: 0;
}

.catalog-story-media img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.catalog-story-text {
    flex: 1 1 380px;
    min-width: 0;
}

.catalog-story-eyebrow {
    color: var(--brand-primary);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.catalog-story-text h2 {
    font-size: clamp(1.4rem, 2.6vw, 1.9rem);
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -0.01em;
}

.catalog-story-text p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.65;
}

@media (max-width: 767px) {
    .catalog-story-row,
    .catalog-story-row-reverse {
        flex-direction: column;
        text-align: center;
    }
    .catalog-story-text p { margin-left: auto; margin-right: auto; }
}

/* ---------------------------------------------------------------
   GALLERY
   --------------------------------------------------------------- */
.catalog-section-sub {
    color: var(--text-secondary);
    font-size: 0.92rem;
    margin: -6px 0 18px;
}

.catalog-gallery {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 140px;
    gap: 14px;
}

.catalog-gallery-item {
    position: relative;
    grid-row: span 1;
    border: none;
    padding: 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform var(--duration-base) var(--ease-standard), box-shadow var(--duration-base) var(--ease-standard);
}

.catalog-gallery-item-tall {
    grid-row: span 2;
}

.catalog-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--duration-slow) var(--ease-standard);
}

.catalog-gallery-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.catalog-gallery-item:hover img {
    transform: scale(1.06);
}

#catalogGalleryModalImg {
    max-height: 80vh;
    object-fit: contain;
}

@media (max-width: 767px) {
    .catalog-gallery {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 160px;
    }
}

/* ---------------------------------------------------------------
   LAYOUT
   --------------------------------------------------------------- */
.catalog-container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 32px 20px 64px;
}

.catalog-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 28px;
    align-items: start;
}

@media (max-width: 900px) {
    .catalog-layout {
        grid-template-columns: 1fr;
    }
}

.catalog-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

#catalogResultsInfo {
    color: var(--text-secondary);
    font-size: 0.88rem;
}

#catalogSort {
    max-width: 200px;
}

.catalog-empty {
    text-align: center;
    padding: 64px 20px;
    color: var(--text-muted);
}

.catalog-empty i {
    font-size: 2.4rem;
    display: block;
    margin-bottom: 12px;
    opacity: 0.6;
}

/* ---------------------------------------------------------------
   SIDEBAR
   --------------------------------------------------------------- */
.catalog-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: sticky;
    top: 84px;
}

@media (max-width: 900px) {
    .catalog-sidebar {
        position: static;
    }
}

.catalog-widget {
    padding: 20px;
}

.catalog-widget-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 14px;
    position: relative;
    padding-bottom: 8px;
}

.catalog-widget-title::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 32px;
    height: 3px;
    border-radius: var(--radius-pill);
    background: var(--brand-gradient);
}

.catalog-search-wrap {
    position: relative;
}

.catalog-search-wrap input {
    padding-right: 42px;
}

.catalog-search-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--brand-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.catalog-rating-filters {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.catalog-rating-btn {
    text-align: left;
    background: var(--bg-glass);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 9px 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--duration-fast) ease, color var(--duration-fast) ease, border-color var(--duration-fast) ease;
}

.catalog-rating-btn:hover {
    border-color: var(--brand-primary);
}

.catalog-rating-btn.active {
    background: var(--brand-gradient);
    color: #fff;
    font-weight: 600;
}

.catalog-cat-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.catalog-cat-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: background var(--duration-fast) ease, color var(--duration-fast) ease;
}

.catalog-cat-link i {
    margin-right: 0%;
}

.catalog-cat-link:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.catalog-cat-link.active {
    background: var(--brand-gradient);
    color: #fff;
}

.catalog-cat-link.active i {
    color: #fff !important;
}

.catalog-cat-count {
    font-size: 0.72rem;
    font-weight: 700;
    background: rgba(30, 90, 168, 0.14);
    color: var(--brand-primary);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
}

.catalog-cat-link.active .catalog-cat-count {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.catalog-top-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.catalog-top-item {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.catalog-top-cover {
    flex-shrink: 0;
    width: 44px;
    height: 60px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--brand-gradient);
}

.catalog-top-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.catalog-top-cover .book-cover-fallback {
    font-size: 1.1rem;
}

.catalog-top-item-body {
    min-width: 0;
}

.catalog-top-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.catalog-top-rating {
    font-size: 0.72rem;
    color: #f1c40f;
    margin: 0;
}

.catalog-top-rating span {
    color: var(--text-muted);
}

/* ---------------------------------------------------------------
   CATALOG CARD - built on top of user.css's .book-card, with a
   ribbon badge, heart/favorite icon, and a Borrow Book button
   appended below the existing cover/title/author structure.
   --------------------------------------------------------------- */
.catalog-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(130px, 2fr));
	gap: 20px;
}

.catalog-card {
    animation: catalogFadeUp 0.4s var(--ease-standard) both;
}

.catalog-card .book-card {
    width: auto;
}

.catalog-ribbon {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 4px 9px;
    border-radius: var(--radius-pill);
    color: #fff;
    z-index: 2;
}

.catalog-ribbon.is-new { background: var(--success); }
.catalog-ribbon.is-trending { background: var(--brand-gradient-warm); }

.catalog-fav-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    z-index: 2;
    transition: transform var(--duration-fast) ease;
}

.catalog-fav-btn:hover {
    transform: scale(1.1);
}

.catalog-fav-btn.is-favorited {
    color: var(--danger);
}

.catalog-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin: 4px 0 2px;
    font-size: 0.72rem;
}

.catalog-card-category {
    color: var(--brand-primary);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.catalog-card-rating {
    color: #f1c40f;
    white-space: nowrap;
    font-weight: 600;
}

.catalog-card-rating span {
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 2px;
}

.catalog-stock-badge {
    font-size: 0.68rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 4px 0 8px;
}

.catalog-stock-badge.in-stock { color: var(--success); }
.catalog-stock-badge.out-of-stock { color: var(--text-muted); }

.catalog-borrow-btn {
    width: 100%;
    font-size: 0.78rem;
    padding: 8px 10px;
}

/* ---------------------------------------------------------------
   PAGINATION - circular Previous/Next + page buttons
   --------------------------------------------------------------- */
#catalogPagination .pagination {
    gap: 6px;
}

#catalogPagination .page-link {
    border: none;
    background: var(--bg-glass);
    color: var(--text-secondary);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

#catalogPagination .page-item.active .page-link {
    background: var(--brand-gradient);
    color: #fff;
}

#catalogPagination .page-item.disabled .page-link {
    opacity: 0.4;
}

/* ---------------------------------------------------------------
   LOGIN / REGISTER MODAL
   --------------------------------------------------------------- */
#catalogAuthModal .modal-content {
    padding: 8px;
}

.catalog-auth-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-glass);
    border-radius: var(--radius-pill);
    padding: 4px;
    margin-bottom: 20px;
}

.catalog-auth-tab {
    flex: 1;
    text-align: center;
    padding: 9px 12px;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background var(--duration-fast) ease, color var(--duration-fast) ease;
    user-select: none;
}

.catalog-auth-tab.active {
    background: var(--brand-gradient);
    color: #fff;
}

.catalog-auth-pane {
    display: none;
}

.catalog-auth-pane.active {
    display: block;
    animation: catalogFadeUp 0.25s var(--ease-standard) both;
}

@keyframes catalogFadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 576px) {
    .catalog-topnav-inner { flex-wrap: wrap; }
    .catalog-brand span { display: none; }
}

/* ---------------------------------------------------------------
   HOMEPAGE-STYLE DISCOVERY SECTIONS (Top Categories, Book of the
   Month, Featured Authors, Best Selling, Author Spotlight,
   Testimonials, feature strip, footer) - sit below the main search
   grid, built from render_public_book_card() in books.php reusing
   the exact same card markup/classes as catalog.js's own
   renderCatalogCard(), so .catalog-borrow-btn/.catalog-fav-btn keep
   working here via the same delegated handlers, no new JS needed
   for those two actions specifically.
   --------------------------------------------------------------- */
.catalog-scroll-row {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.catalog-scroll-item {
    flex: 0 0 200px;
}

.catalog-author-row {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.catalog-author-tile {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    width: 96px;
}

.catalog-author-avatar {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: var(--shadow-sm);
    transition: transform var(--duration-base) var(--ease-standard);
}

.catalog-author-tile:hover .catalog-author-avatar {
    transform: translateY(-3px);
}

.catalog-author-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-gradient);
    color: #fff;
    font-weight: 700;
    font-size: 1.4rem;
}

.catalog-author-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.catalog-spotlight {
    display: flex;
    align-items: center;
    gap: 32px;
    padding: 36px;
    flex-wrap: wrap;
}

.catalog-spotlight-text {
	flex: 1 1 auto;
}

.catalog-spotlight-label {
    color: var(--brand-primary);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.catalog-spotlight-text h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.catalog-spotlight-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.catalog-spotlight-bio {
    color: var(--text-secondary);
    line-height: 1.7;
    margin: 0;
}

.catalog-spotlight-covers {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(2, 64px);
    gap: 10px;
}

.catalog-spotlight-cover {
    aspect-ratio: 2 / 3;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.catalog-spotlight-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.catalog-testimonial {
    padding: 22px;
    height: 100%;
}

.catalog-testimonial-rating {
    color: #f1c40f;
    margin-bottom: 8px;
}

.catalog-testimonial-title {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.catalog-testimonial-comment {
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.6;
}

.catalog-testimonial-author {
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    margin: 8px 0 0;
}

.catalog-feature-strip-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
}

.catalog-feature-strip-item i {
    font-size: 1.6rem;
    color: var(--brand-primary);
}

.catalog-feature-strip-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.catalog-footer {
    border-top: 1px solid var(--border-glass);
    padding: 28px 20px;
    margin-top: 20px;
}

.catalog-footer-inner {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.catalog-footer-copy {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin: 0;
}

.catalog-footer-links {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.catalog-footer-links a {
    color: var(--text-secondary);
    font-size: 0.82rem;
    text-decoration: none;
}

.catalog-footer-links a:hover {
    color: var(--brand-primary);
}

@media (max-width: 768px) {
    .catalog-spotlight {
        flex-direction: column;
        text-align: center;
        padding: 24px;
    }

    .catalog-spotlight-covers {
        grid-template-columns: repeat(4, 1fr);
        width: 100%;
    }
}
