:root {
    --bg: #1a1209;
    --bg-surface: #221a0e;
    --bg-card: #2a1f10;
    --text-main: #f2e8d5;
    --text-muted: #a08c6e;
    --accent: #c2834a;
    --accent-hover: #d9975a;
    --accent-gold: #d4a843;
    --border: rgba(194, 131, 74, 0.18);
    --border-light: rgba(194, 131, 74, 0.08);
    --success: #6aaa6a;
    --danger: #c25858;
    --shadow: rgba(0, 0, 0, 0.5);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    background-color: var(--bg);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    font-family: 'EB Garamond', Georgia, serif;
    background-image:
        radial-gradient(ellipse 80% 60% at 15% 10%, rgba(180, 100, 30, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse 60% 80% at 85% 90%, rgba(120, 60, 10, 0.08) 0%, transparent 60%);
}

/* Subtle wood-grain texture overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: -1;
}

/* Layout */
.app-container { max-width: 1440px; margin: 0 auto; padding: 0 2rem; }
.glass-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 4px 24px var(--shadow), inset 0 1px 0 rgba(255,255,255,0.04);
}

/* Navbar */
.navbar {
    padding: 1.25rem 3rem;
    margin: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: rgba(26, 18, 9, 0.95);
    backdrop-filter: blur(12px);
    border: none;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 0 var(--border-light);
    margin: 0;
    padding: 1.25rem 3rem;
}
.nav-brand { display: flex; align-items: center; gap: 0.75rem; }
.nav-brand i { color: var(--accent); font-size: 1.5rem; }
.nav-brand h1 { font-family: 'EB Garamond', Georgia, serif; font-size: 1.75rem; font-weight: 700; letter-spacing: 0.5px; font-style: italic; color: var(--text-main); }
.highlight { color: var(--accent-gold); font-style: italic; }

.nav-links { display: flex; gap: 0.25rem; align-items: center; }

.nav-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.6rem 1.25rem;
    border-radius: 2px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: 0.5px;
}
.nav-btn:hover { color: var(--text-main); background: rgba(194, 131, 74, 0.08); }
.nav-btn.active { color: var(--accent-gold); background: rgba(212, 168, 67, 0.1); border-bottom: 2px solid var(--accent-gold); }

/* Search Bar */
.search-bar {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.03);
    padding: 0.5rem 1rem;
    border-radius: 2px;
    margin-right: 1.5rem;
    border: 1px solid var(--border);
    transition: all 0.2s;
}
.search-bar:focus-within { border-color: var(--accent); background: rgba(194, 131, 74, 0.05); }
.search-bar i { color: var(--text-muted); margin-right: 0.6rem; font-size: 0.9rem; }
.search-bar input {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    width: 220px;
    font-family: 'EB Garamond', Georgia, serif;
}
.search-bar input::placeholder { color: var(--text-muted); }

/* Init Section */
.init-card { text-align: center; padding: 5rem 2rem; max-width: 560px; margin: 5rem auto; }
.init-icon { font-size: 4rem; color: var(--accent); margin-bottom: 2rem; }
.init-card h2 { font-family: 'EB Garamond', Georgia, serif; font-size: 2.4rem; margin-bottom: 0.75rem; font-style: italic; font-weight: 600; }
.init-card p { color: var(--text-muted); font-size: 1.1rem; line-height: 1.6; }

/* Buttons */
.btn { padding: 0.7rem 1.5rem; border-radius: 2px; border: none; font-family: 'EB Garamond', Georgia, serif; font-weight: 600; cursor: pointer; transition: all 0.2s ease; font-size: 1rem; display: inline-flex; align-items: center; gap: 0.5rem; letter-spacing: 0.3px; }
.primary-btn { background: var(--accent); color: #fff; border: 1px solid transparent; }
.primary-btn:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(194, 131, 74, 0.4); }
.secondary-btn { background: transparent; color: var(--text-main); border: 1px solid var(--border); }
.secondary-btn:hover { border-color: var(--accent); color: var(--accent); }
.hidden { display: none !important; }

/* Status */
.status-msg { margin-top: 1rem; display: flex; align-items: center; justify-content: center; gap: 0.75rem; font-size: 1rem; color: var(--text-muted); }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s infinite linear; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Section Headers */
.section-header { margin-bottom: 2.5rem; display: flex; align-items: flex-end; justify-content: space-between; padding-bottom: 1rem; border-bottom: 1px solid var(--border-light); }
.section-header h2 { font-family: 'EB Garamond', Georgia, serif; font-size: 2.4rem; font-weight: 600; font-style: italic; letter-spacing: 0.3px; }
.section-header p { color: var(--text-muted); font-size: 1rem; margin-top: 0.25rem; }

/* Main Grids */
.books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.75rem; padding-bottom: 4rem; }

/* Genre Rows */
.genre-section { margin-bottom: 3.5rem; }
.genre-section h3 {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 1.6rem;
    font-weight: 600;
    font-style: italic;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    color: var(--accent-gold);
    letter-spacing: 0.5px;
}
.genre-row { display: flex; gap: 1.5rem; overflow-x: auto; padding-bottom: 1.5rem; padding-top: 0.25rem; scroll-snap-type: x mandatory; -ms-overflow-style: none; scrollbar-width: none; }
.genre-row::-webkit-scrollbar { display: none; }
.genre-row .book-card { min-width: 240px; max-width: 240px; scroll-snap-align: start; flex-shrink: 0; }

/* Book Card */
.book-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 2px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.25s ease;
    position: relative;
}
.book-card:hover {
    transform: translateY(-5px);
    border-color: rgba(194, 131, 74, 0.45);
    box-shadow: 0 8px 24px var(--shadow), 0 0 0 1px rgba(194, 131, 74, 0.1);
}

.cover-wrapper { width: 100%; aspect-ratio: 2/3; position: relative; overflow: hidden; background: #120d07; }
.book-cover { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; opacity: 0.92; }
.book-card:hover .book-cover { transform: scale(1.04); opacity: 1; }
.genre-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(26, 18, 9, 0.88);
    padding: 4px 10px;
    border-radius: 2px;
    font-size: 0.7rem;
    font-weight: 500;
    border: 1px solid var(--border);
    color: var(--accent-gold);
    z-index: 2;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-family: 'EB Garamond', Georgia, serif;
    font-style: normal;
}

.book-info { padding: 1.25rem; display: flex; flex-direction: column; flex: 1; }
.book-title {
    font-family: 'EB Garamond', Georgia, serif;
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1.3;
    margin-bottom: 0.3rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.book-author { color: var(--accent); font-size: 0.9rem; font-weight: 500; margin-bottom: 0.75rem; font-style: italic; }
.book-desc {
    font-size: 0.88rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 1rem;
    line-height: 1.55;
}

.interaction-bar { 
    display: flex; 
    justify-content: space-evenly; 
    margin-top: auto; 
    padding-top: 1rem; 
    border-top: 1px solid var(--border-light); 
    align-items: center;
}
.rate-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    width: 36px;
    height: 36px;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.rate-btn:hover { background: rgba(194, 131, 74, 0.08); color: var(--text-main); }
.rate-btn.like:hover { color: var(--success); }
.rate-btn.dislike:hover { color: var(--danger); }
.rate-btn.bookmark:hover { color: var(--accent-gold); }

/* Star Rating */

.star-rating {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}
.star-rating .fa-star {
    font-size: 1.6rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}
.star-rating .fa-star.active,
.star-rating .fa-star:hover,
.star-rating .fa-star:hover ~ .fa-star {
    color: var(--accent-gold);
}
/* This makes all stars to the LEFT of the hovered star light up */
.star-rating {
    flex-direction: row-reverse;
    justify-content: center;
}
.star-rating .fa-star:hover,
.star-rating .fa-star:hover ~ .fa-star,
.star-rating .fa-star.active {
    color: var(--accent-gold);
}

.dislike-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 2px;
    cursor: pointer;
    font-family: 'EB Garamond', serif;
    transition: all 0.2s;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.dislike-btn:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(194, 88, 88, 0.05);
}

.library-stars {
    color: var(--accent-gold);
    font-size: 0.9rem;
    display: flex;
    gap: 2px;
}
.library-dislike {
    color: var(--danger);
    font-size: 0.9rem;
    font-style: italic;
}


/* Modal */
.modal { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(10, 7, 3, 0.85); backdrop-filter: blur(8px); z-index: 1000; display: flex; align-items: center; justify-content: center; opacity: 1; transition: opacity 0.3s; }
.modal.hidden { opacity: 0; pointer-events: none; visibility: hidden; display: flex !important; }
.modal-content { width: 90%; max-width: 920px; max-height: 90vh; overflow-y: auto; overflow-x: hidden; position: relative; padding: 2.5rem; border: 1px solid var(--border); background: var(--bg-surface); border-radius: 4px; }
.modal-bg-blur { position: absolute; top:0; left:0; width:100%; height:100%; object-fit: cover; opacity: 0.08; filter: blur(40px); z-index: -1; transform: scale(1.15); pointer-events: none; }
.close-btn { position: absolute; top: 1.25rem; right: 1.25rem; background: rgba(194, 131, 74, 0.1); border: 1px solid var(--border); color: var(--text-muted); width: 36px; height: 36px; border-radius: 2px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1rem; transition: all 0.2s; z-index: 10; }
.close-btn:hover { color: var(--text-main); border-color: var(--accent); }

.modal-split { display: grid; grid-template-columns: 300px 1fr; gap: 3rem; }
.modal-cover { width: 100%; border-radius: 2px; box-shadow: 0 12px 40px var(--shadow), 4px 4px 0 rgba(194, 131, 74, 0.2); }
.modal-info h2 { font-family: 'EB Garamond', Georgia, serif; font-size: 2.4rem; line-height: 1.15; margin-bottom: 0.4rem; font-style: italic; }
.modal-info h3 { color: var(--accent); font-size: 1.15rem; margin-bottom: 1.5rem; font-style: italic; font-weight: 500; }
.modal-desc { font-size: 1.05rem; line-height: 1.8; color: var(--text-muted); margin-bottom: 2rem; font-family: 'EB Garamond', Georgia, serif; }
.modal-meta { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 2rem; }
.meta-tag { background: rgba(194, 131, 74, 0.08); padding: 0.4rem 1rem; border-radius: 2px; font-size: 0.85rem; border: 1px solid var(--border); color: var(--accent-gold); letter-spacing: 0.3px; text-transform: uppercase; font-style: normal; font-family: 'EB Garamond', Georgia, serif; }
/* Responsive Design */
@media (max-width: 992px) {
    .books-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

@media (max-width: 768px) {
    /* Navbar & Layout */
    .app-container { padding: 0 1rem; }
    .navbar {
        flex-direction: column;
        padding: 1rem;
        gap: 1.2rem;
    }
    .nav-brand { margin-bottom: 0.5rem; }
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
        gap: 0.5rem;
    }
    .search-bar { margin: 0 0 0.5rem 0; width: 100%; max-width: 400px; }
    .search-bar input { width: 100%; }

    /* Typography */
    .section-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .section-header h2 { font-size: 2rem; }
    .init-card h2 { font-size: 2rem; }
    .init-card { padding: 3rem 1.5rem; }

    /* Modals */
    .modal-split { grid-template-columns: 1fr; gap: 1.5rem; }
    .modal-content { padding: 1.5rem; border-radius: 8px; width: 95%; max-height: 85vh; }
    .modal-cover { max-width: 250px; margin: 0 auto; display: block; }
    .modal-info h2 { font-size: 1.8rem; }
    
    /* Footer */
    .site-footer { flex-direction: column; text-align: center; gap: 1.5rem; padding: 2rem 1rem; }
}

@media (max-width: 480px) {
    /* 2 columns on mobile looks great for book covers */
    .books-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1rem; }
    .book-info { padding: 1rem; }
    .book-title { font-size: 1rem; }
    .book-desc { display: none; /* Hide description on tiny screens to save space */ }
    
    /* Genre Row Adjustments */
    .genre-row .book-card { min-width: 160px; max-width: 160px; }
    
    .nav-btn { font-size: 0.9rem; padding: 0.5rem 1rem; }
    .close-btn { top: 0.75rem; right: 0.75rem; }
}

/* ─── Visual Polish ─── */

/* Smooth scroll */
html { scroll-behavior: smooth; }

/* Page-load fade */
body { animation: pageFadeIn 0.6s ease-out; }
@keyframes pageFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Card entrance animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.book-card {
    opacity: 0;
    transform: translateY(24px);
}
.book-card.visible {
    animation: fadeInUp 0.5s ease-out forwards;
}

/* Cover subtle warm-glow on hover */
.cover-wrapper::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(212, 168, 67, 0) 0%,
        rgba(212, 168, 67, 0.08) 50%,
        rgba(212, 168, 67, 0) 100%
    );
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: 1;
}
.book-card:hover .cover-wrapper::after { opacity: 1; }

/* Genre row custom scrollbar */
.genre-row {
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}
.genre-row::-webkit-scrollbar { display: block; height: 4px; }
.genre-row::-webkit-scrollbar-track { background: transparent; }
.genre-row::-webkit-scrollbar-thumb { background: rgba(194, 131, 74, 0.35); border-radius: 2px; }
.genre-row::-webkit-scrollbar-thumb:hover { background: rgba(194, 131, 74, 0.6); }

/* Empty state illustration */
.empty-msg { text-align: center; padding: 4rem 2rem; color: var(--text-muted); font-style: italic; }

/* ─── Footer ─── */
.site-footer {
    margin-top: 4rem;
    padding: 2.5rem 3rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.footer-brand {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 1.2rem;
    font-style: italic;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.footer-brand i { color: var(--accent); }
.footer-links {
    display: flex;
    gap: 1.5rem;
}
.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
    font-family: 'EB Garamond', Georgia, serif;
}
.footer-links a:hover { color: var(--accent-gold); }
.footer-copy {
    width: 100%;
    text-align: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
    font-size: 0.8rem;
    letter-spacing: 0.3px;
}

/* Active state pulse on like/dislike */
.rate-btn:active {
    transform: scale(0.88);
}

/* Navbar subtle shadow on scroll (added via JS) */
.navbar.scrolled {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}
