/* -----------------------------------------------------
   BOOKWISE — Global Web Theme (v4)
   Consistent with Android theme + EPUB typography
------------------------------------------------------ */

:root {
    --bg: #0D0F12;
    --surface: #13161B;
    --surface-light: #1A1E24;
    --text-primary: #F2F4F7;
    --text-secondary: #BFC5D0;
    --accent: #1B5E3A;
    --accent-soft: #4F8F6A;
    --accent-glow: #8FD8B5;
    --radius: 14px;
    --max-width: 900px;       /* reading pages: about, book detail */
    --max-width-wide: 1440px; /* browsing pages: library, genre grids */
    --line-height: 1.65;
    --transition: 0.25s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    background: var(--bg);
    color: var(--text-primary);
    font-family: "Inter", "Georgia", serif;
    line-height: var(--line-height);
    -webkit-font-smoothing: antialiased;
}

.page { width: 100%; max-width: var(--max-width); margin: 0 auto; padding: 2rem 1.5rem; }
.page.wide { max-width: var(--max-width-wide); }

/* Typography */
h1, h2 { font-variant: small-caps; letter-spacing: 0.5px; }
h1 { font-size: 2.3rem; margin-bottom: 1.5rem; }
h2 { font-size: 1.4rem; margin-top: 2rem; margin-bottom: 0.75rem; }

p { margin: 1rem 0; color: var(--text-primary); }
p.lead { font-size: 1.15rem; opacity: 0.9; }

/* Header / Nav */
.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
}

.site-nav {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 0.5rem 0 1.5rem;
    border-bottom: 1px solid var(--surface-light);
    width: 100%;
    max-width: var(--max-width-wide);
    margin: 0 auto;
}

.site-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: var(--transition);
}

.site-nav a:hover,
.site-nav a.active {
    color: var(--accent-glow);
}

/* Premium Book Layout */
.book-premium-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 3rem;
    margin-top: 2rem;
}

.cover-box {
    width: 100%;
    aspect-ratio: 2/3;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

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

.book-meta { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 0.5rem; }

/* Buttons & Tags */
.actions { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.button {
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: white;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 600;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
}
.button:hover { background: var(--accent-soft); }
.button.secondary { background: var(--surface-light); }

.tags { margin: 1.5rem 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag {
    background: var(--surface-light);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}
.tag:hover { color: var(--accent-glow); background: var(--surface); }

/* Grid / Responsive — scales card count with screen width */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.catalog-item img { box-shadow: none; margin-bottom: 0; }

.overlay-title {
    font-weight: 600;
    font-size: var(--font-size);
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: visible;
    word-wrap: break-word;
    margin-bottom: 4px;
    transition: font-size 0.2s ease;
}

.catalog-title-overlay {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    padding: 10px;
    background: linear-gradient(to top, rgba(0,0,0,0.65), rgba(0,0,0,0.6));
    color: white;
    text-align: center;
    box-sizing: border-box;
    border-radius: 8px;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.overlay-author {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Tablet: tighten a bit so 4-5 cards fit instead of 3 huge ones */
@media (max-width: 1024px) {
    .catalog-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1.25rem;
    }
}

/* Phone: 3 columns (Standard Ebooks-style density) */
@media (max-width: 768px) {
    .catalog-grid {
        grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
        gap: 0.75rem;
    }
    .catalog-title-overlay { padding: 6px; min-height: 40px; border-radius: 6px; }
    .overlay-author { font-size: 0.65rem; }
    .page { padding: 1.5rem 1rem; }
}

/* Very small phones: cap at 2 columns so covers don't get illegibly small */
@media (max-width: 380px) {
    .catalog-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }
}

/* Genres */
.genre-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.genre-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1.25rem 1.5rem;
    background: var(--surface);
    border-radius: var(--radius);
    text-decoration: none;
    transition: var(--transition);
    border: 1px solid transparent;
}

.genre-card:hover {
    border-color: var(--accent-soft);
    background: var(--surface-light);
}

.genre-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.genre-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 3rem;
}

/* About page */
.about-page h2:first-of-type { margin-top: 2.5rem; }
.about-page a { color: var(--accent-glow); }

/* -----------------------------------------------------
   Ad slots — reserved space, fixed min-height to avoid
   layout shift once a real ad network script is dropped in.
   Swap the placeholder markup for AdSense/etc. units later.
------------------------------------------------------ */
.ad-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px dashed var(--surface-light);
    border-radius: var(--radius);
    color: var(--text-secondary);
}

.ad-label {
    font-size: 0.7rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    opacity: 0.55;
}

/* Leaderboard-style banner, e.g. above the catalog grid */
.ad-banner {
    width: 100%;
    min-height: 100px;
    margin: 0 0 1.5rem;
}

@media (min-width: 1024px) {
    .ad-banner { min-height: 90px; } /* ~728x90 desktop leaderboard */
}

/* In-feed unit, sized to sit naturally inside the book grid */
.ad-infeed {
    grid-column: 1 / -1;
    min-height: 110px;
}

@media (max-width: 768px) {
    .ad-infeed { min-height: 100px; }
}

@media (max-width: 768px) {
    .book-premium-layout { grid-template-columns: 1fr; text-align: center; }
    .actions { align-items: stretch; }
    .site-nav { gap: 1.25rem; }
}

.logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem 0;
}

.logo {
    height: 100px;
    width: auto;
    object-fit: contain;
    display: block;
}

.search-box {
    width: 100%;
    margin-bottom: 2rem;
}

#search-input {
    width: 100%;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    border: none;
    background: var(--surface-light);
    color: var(--text-primary);
    font-size: 1.1rem;
    outline: none;
    box-shadow: 0 0 12px rgba(0,0,0,0.25);
    transition: var(--transition);
}

#search-input:focus {
    background: var(--surface);
    box-shadow: 0 0 18px rgba(0,0,0,0.35);
}

.book-cover-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
}

.book-cover-wrapper img {
    width: 100%;
    display: block;
}
