:root {
    --bg: #1a1a1a;
    --text: #ececec;
    --accent: #00adb5;
    --secondary: #393e46;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    margin: 0;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

nav { margin-bottom: 2rem; }

a { color: var(--accent); text-decoration: none; font-weight: bold; }
a:hover { text-decoration: underline; }

.container { max-width: 800px; width: 100%; }

.btn-home {
    display: inline-block;
    margin-top: 2rem;
    padding: 0.5rem 1rem;
    background: var(--secondary);
    border-radius: 5px;
    transition: 0.3s;
}
 
.btn-home:hover { background: var(--accent); color: #fff; }

h1 { border-bottom: 2px solid var(--accent); padding-bottom: 10px; }

/* --- LIBRARY SPECIFIC STYLES --- */
.books-page {
    background-color: #0a0a0a; /* Deep black */
    color: #e0e0e0;
}

.library-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
}

/* Buttons */
.btn-gold {
    background: transparent;
    color: #d4af37; /* Classy Gold */
    border: 1px solid #d4af37;
    padding: 8px 16px;
    cursor: pointer;
    font-weight: bold;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-gold:hover {
    background: #d4af37;
    color: #000;
}

/* Tag Dropdown & Grid (3 columns) */
.dropdown { position: relative; display: inline-block; }
.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: #1a1a1a;
    min-width: 300px;
    border: 1px solid #d4af37;
    z-index: 1;
    padding: 10px;
}
.dropdown:hover .dropdown-content { display: grid; }
.tags-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.tag-item {
    color: #d4af37;
    font-size: 0.8rem;
    cursor: pointer;
    text-align: center;
}

/* Search Area */
#search-view { margin-bottom: 2rem; }
#search-input {
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    background: #1a1a1a;
    border: 1px solid #d4af37;
    color: white;
}
.quick-filters {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

/* The Book Card (Gold Box, Image left, Data right) */
.book-card {
    display: flex;
    border: 2px solid #d4af37;
    background-color: #111;
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 5px;
    gap: 20px;
}

/* Image constraints (Taller than wide, gray placeholder fallback) */
.book-card img {
    width: 150px;
    height: 225px;
    object-fit: cover;
    background-color: #333; /* The Gray Placeholder */
    border: 1px solid #444;
}

.book-info-short {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.subratings-box {
    border-left: 2px solid #d4af37;
    padding-left: 10px;
    margin: 10px 0;
    font-size: 0.9rem;
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
}

/* Base Background */
body.books-page {
    background-color: #000000;
    color: #fff;
}

/* Multi-Select Tags - Wider by default */
.tag-item {
    cursor: pointer;
    padding: 8px 12px;
    background: #222;
    margin: 5px;
    display: inline-block;
    border-radius: 5px;
    transition: 0.2s;
    white-space: nowrap;
    min-width: 150px; /* Fits roughly ~15 characters */
    text-align: center;
}
.tag-item.active-tag {
    background: #d4af37 !important;
    color: #000 !important;
    font-weight: bold;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.5);
}

/* Similar Books Carousel */
.similar-books-container {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding: 10px 0 20px 0;
    scrollbar-width: thin;
    scrollbar-color: #d4af37 #1a1a1a;
}
.similar-book-card {
    flex: 0 0 auto;
    width: 120px;
    cursor: pointer;
    text-align: center;
    transition: transform 0.2s;
}
.similar-book-card:hover {
    transform: scale(1.05);
}
.similar-book-card img {
    width: 120px;
    height: 180px;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid #444;
}
.similar-book-title {
    font-size: 0.85em;
    color: #d4af37;
    margin-top: 8px;
    line-height: 1.2;
    word-wrap: break-word;
}
/* --- STAR RATINGS & FILTERS --- */
/* Visual 5-Star Display (Hides the out-of-10 number) */
.stars-outer {
    display: inline-block;
    position: relative;
    font-family: monospace;
    font-size: 1.5rem;
    color: #444; /* Empty star color */
    letter-spacing: 2px;
}
.stars-outer::before {
    content: "☆☆☆☆☆";
}
.stars-inner {
    position: absolute;
    top: 0;
    left: 0;
    white-space: nowrap;
    overflow: hidden;
    color: #d4af37; /* Filled star color */
}
.stars-inner::before {
    content: "★★★★★";
}

/* Interactive Star Filter */
.interactive-stars {
    display: inline-flex;
    cursor: pointer;
    font-size: 1.5rem;
    font-family: monospace;
    color: #444;
    user-select: none;
}
.interactive-stars .star {
    position: relative;
    transition: 0.2s color;
}
.interactive-stars .star.filled {
    color: #d4af37;
}
.interactive-stars .star::before {
    content: "☆";
}
.interactive-stars .star.filled::before {
    content: "★";
}
/* Hover previews for the interactive stars */
.interactive-stars .star:hover ~ .star {
    color: #444 !important; 
}
.interactive-stars:hover .star {
    color: #d4af37; 
}

/* Enforce Aspect Ratios to prevent image warping */
.book-card img, .similar-book-card img {
    aspect-ratio: 2 / 3;
    object-fit: cover;
}
#single-book-container img {
    aspect-ratio: 2 / 3;
    object-fit: cover;
    width: 100%;
    max-width: 300px;
}

/* --- UPDATED INTERACTIVE STAR FILTER --- */
#rating-filter-container {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

/* We use the same structure as the display stars for consistency */
.filter-stars-outer {
    display: inline-block;
    position: relative;
    font-family: monospace;
    font-size: 1.8rem; /* Slightly larger for easier clicking */
    color: #444;
    letter-spacing: 2px;
}
.filter-stars-outer::before {
    content: "☆☆☆☆☆";
}

.filter-stars-inner {
    position: absolute;
    top: 0;
    left: 0;
    white-space: nowrap;
    overflow: hidden;
    color: #d4af37;
    width: 0%; /* Controlled by JS */
    pointer-events: none; /* Let clicks pass through to the outer container */
}
.filter-stars-inner::before {
    content: "★★★★★";
}

#clear-rating-filter {
    color: #666;
    font-size: 0.8rem;
    text-decoration: underline;
    cursor: pointer;
}
#clear-rating-filter:hover { color: #d4af37; }