/* ==================== CSS Variables ==================== */
:root {
    /* Colors - Magazine Style */
    --color-bg: #FAFAFA;
    --color-bg-alt: #F5F3F0;
    --color-bg-card: #FFFFFF;
    --color-text: #1A1A1A;
    --color-text-secondary: #666666;
    --color-text-muted: #999999;
    --color-accent: #C9A86C;
    --color-accent-hover: #B89A5E;
    --color-border: #E5E5E5;
    --color-border-light: #F0F0F0;

    /* Typography */
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.15);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 20px;
}

/* ==================== Reset & Base ==================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

/* ==================== Header ==================== */
.site-header {
    position: sticky;
    top: 0;
    background: rgba(250, 250, 250, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border-light);
    z-index: 100;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-md) var(--space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--color-text);
    letter-spacing: -0.5px;
}

.site-tagline {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.stat {
    font-weight: 500;
}

.stat-divider {
    color: var(--color-border);
}

/* ==================== Main Content ==================== */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
}

/* ==================== Hero Section ==================== */
.hero-section {
    margin-bottom: var(--space-3xl);
    padding: var(--space-2xl);
    background: linear-gradient(135deg, var(--color-bg-alt) 0%, #F8F6F3 100%);
    border-radius: var(--radius-xl);
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 60%;
    height: 200%;
    background: radial-gradient(ellipse, rgba(201, 168, 108, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

.hero-content {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: var(--space-2xl);
    align-items: center;
    position: relative;
    z-index: 1;
}

.hero-book-cover {
    position: relative;
    aspect-ratio: 2/3;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    background: linear-gradient(135deg, #E8E4E0 0%, #D8D4D0 100%);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.hero-book-cover:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

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

.hero-label {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--color-accent);
    margin-bottom: var(--space-sm);
}

.hero-title {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: var(--space-sm);
    letter-spacing: -0.5px;
}

.hero-author {
    font-size: 1.1rem;
    color: var(--color-text-secondary);
    font-style: italic;
    margin-bottom: var(--space-lg);
}

.hero-description {
    font-size: 1rem;
    color: var(--color-text-secondary);
    line-height: 1.7;
    margin-bottom: var(--space-lg);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hero-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    background: var(--color-text);
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.hero-btn:hover {
    background: var(--color-accent);
    transform: translateX(4px);
}

.hero-btn::after {
    content: '';
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white' stroke-width='2'%3E%3Cpath d='M9 5l7 7-7 7'/%3E%3C/svg%3E");
    background-size: contain;
    transition: transform var(--transition-fast);
}

.hero-btn:hover::after {
    transform: translateX(4px);
}

/* ==================== Category Section ==================== */
.category-section {
    margin-bottom: var(--space-2xl);
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 2px solid var(--color-border-light);
}

.category-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.3px;
}

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

/* Horizontal Scroll Container */
.books-scroll-container {
    position: relative;
    margin: 0 calc(-1 * var(--space-lg));
    padding: 0 var(--space-lg);
}

.books-scroll {
    display: flex;
    gap: var(--space-lg);
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: var(--space-sm) 0 var(--space-md);
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.books-scroll::-webkit-scrollbar {
    display: none;
}

/* Book Card */
.book-card {
    flex-shrink: 0;
    width: 160px;
    cursor: pointer;
    transition: transform var(--transition-normal);
}

.book-card:hover {
    transform: translateY(-8px);
}

.book-cover {
    position: relative;
    aspect-ratio: 2/3;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: linear-gradient(135deg, #E8E4E0 0%, #D8D4D0 100%);
    box-shadow: var(--shadow-md);
    transition: box-shadow var(--transition-normal);
    margin-bottom: var(--space-md);
}

.book-card:hover .book-cover {
    box-shadow: var(--shadow-lg);
}

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

.book-cover-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Book Cover Colors */
.book-card.color-1 .book-cover-placeholder { background: linear-gradient(135deg, #C9A86C 0%, #B8955A 100%); }
.book-card.color-2 .book-cover-placeholder { background: linear-gradient(135deg, #7BA3B8 0%, #6A94A7 100%); }
.book-card.color-3 .book-cover-placeholder { background: linear-gradient(135deg, #9BA88A 0%, #8A9978 100%); }
.book-card.color-4 .book-cover-placeholder { background: linear-gradient(135deg, #D4B8A8 0%, #C4A898 100%); }
.book-card.color-5 .book-cover-placeholder { background: linear-gradient(135deg, #B89AA8 0%, #A78A98 100%); }
.book-card.color-6 .book-cover-placeholder { background: linear-gradient(135deg, #D4C49E 0%, #C4B48E 100%); }

.book-info {
    padding: 0 var(--space-xs);
}

.book-title {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: var(--space-xs);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-year {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: var(--space-xs);
}

/* Favorite Badge */
.book-favorite-badge {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    opacity: 0;
    transform: scale(0.8);
    transition: all var(--transition-fast);
}

.book-card:hover .book-favorite-badge,
.book-card.favorited .book-favorite-badge {
    opacity: 1;
    transform: scale(1);
}

.book-favorite-badge svg {
    width: 14px;
    height: 14px;
    stroke: #E53E3E;
    fill: none;
}

.book-card.favorited .book-favorite-badge svg {
    fill: #E53E3E;
}

/* ==================== Modal ==================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(26, 26, 26, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--color-bg-card);
    border-radius: var(--radius-xl);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    transform: scale(0.95) translateY(20px);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    width: 40px;
    height: 40px;
    background: var(--color-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--color-accent);
    color: white;
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

.modal-body {
    display: grid;
    grid-template-columns: 280px 1fr;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-cover {
    background: var(--color-bg-alt);
    padding: var(--space-2xl);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-cover img {
    width: 180px;
    height: auto;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.modal-info {
    padding: var(--space-2xl);
    display: flex;
    flex-direction: column;
}

.modal-meta {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.modal-genre {
    display: inline-block;
    padding: var(--space-xs) var(--space-md);
    background: var(--color-accent);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: var(--radius-sm);
}

.modal-year {
    display: inline-block;
    padding: var(--space-xs) var(--space-md);
    background: var(--color-bg-alt);
    color: var(--color-text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
}

.modal-title {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: var(--space-sm);
}

.modal-author {
    font-size: 1.1rem;
    color: var(--color-text-secondary);
    font-style: italic;
    margin-bottom: var(--space-lg);
}

.modal-divider {
    height: 1px;
    background: linear-gradient(90deg, var(--color-accent) 0%, transparent 100%);
    margin-bottom: var(--space-lg);
}

.modal-description {
    flex: 1;
    overflow-y: auto;
}

.modal-description h3 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-text-muted);
    margin-bottom: var(--space-md);
}

.modal-description p {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--color-text-secondary);
}

.modal-actions {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border-light);
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.favorite-btn {
    background: var(--color-bg-alt);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.favorite-btn:hover {
    background: #FEE2E2;
    border-color: #FECACA;
}

.favorite-btn.active {
    background: #FEE2E2;
    border-color: #E53E3E;
    color: #E53E3E;
}

.favorite-btn.active svg {
    fill: #E53E3E;
}

.share-btn {
    background: var(--color-text);
    color: white;
}

.share-btn:hover {
    background: var(--color-accent);
}

.action-btn svg {
    width: 18px;
    height: 18px;
}

/* ==================== Toast ==================== */
.toast {
    position: fixed;
    bottom: var(--space-xl);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--color-text);
    color: white;
    padding: var(--space-md) var(--space-xl);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all var(--transition-normal);
    z-index: 2000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast svg {
    width: 18px;
    height: 18px;
    stroke: #68D391;
}

/* ==================== Footer ==================== */
.site-footer {
    border-top: 1px solid var(--color-border-light);
    margin-top: var(--space-3xl);
}

.footer-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* ==================== Animations ==================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.book-card {
    animation: fadeInUp 0.4s ease forwards;
    opacity: 0;
}

/* Staggered animation for book cards */
.book-card:nth-child(1) { animation-delay: 0.05s; }
.book-card:nth-child(2) { animation-delay: 0.1s; }
.book-card:nth-child(3) { animation-delay: 0.15s; }
.book-card:nth-child(4) { animation-delay: 0.2s; }
.book-card:nth-child(5) { animation-delay: 0.25s; }
.book-card:nth-child(6) { animation-delay: 0.3s; }
.book-card:nth-child(7) { animation-delay: 0.35s; }
.book-card:nth-child(8) { animation-delay: 0.4s; }
.book-card:nth-child(9) { animation-delay: 0.45s; }
.book-card:nth-child(10) { animation-delay: 0.5s; }
.book-card:nth-child(11) { animation-delay: 0.55s; }
.book-card:nth-child(12) { animation-delay: 0.6s; }
.book-card:nth-child(13) { animation-delay: 0.65s; }
.book-card:nth-child(14) { animation-delay: 0.7s; }
.book-card:nth-child(15) { animation-delay: 0.75s; }

/* ==================== Responsive Design ==================== */
@media (max-width: 1024px) {
    .hero-content {
        grid-template-columns: 160px 1fr;
        gap: var(--space-xl);
    }

    .hero-title {
        font-size: 2rem;
    }

    .modal-body {
        grid-template-columns: 220px 1fr;
    }
}

@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .header-nav {
        font-size: 0.85rem;
    }

    .hero-section {
        padding: var(--space-xl);
    }

    .hero-content {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .hero-book-cover {
        width: 140px;
        margin: 0 auto;
    }

    .hero-title {
        font-size: 1.75rem;
    }

    .hero-description {
        -webkit-line-clamp: 4;
    }

    .category-title {
        font-size: 1.25rem;
    }

    .book-card {
        width: 140px;
    }

    .modal-body {
        grid-template-columns: 1fr;
    }

    .modal-cover {
        padding: var(--space-xl);
    }

    .modal-cover img {
        width: 140px;
    }

    .modal-info {
        padding: var(--space-lg);
    }

    .modal-title {
        font-size: 1.5rem;
    }

    .modal-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: var(--space-md);
    }

    .hero-section {
        padding: var(--space-lg);
        margin-bottom: var(--space-xl);
    }

    .hero-book-cover {
        width: 120px;
    }

    .hero-title {
        font-size: 1.5rem;
    }

    .hero-author {
        font-size: 1rem;
    }

    .book-card {
        width: 120px;
    }

    .book-title {
        font-size: 0.85rem;
    }

    .modal-cover {
        padding: var(--space-lg);
    }

    .modal-cover img {
        width: 120px;
    }

    .modal-info {
        padding: var(--space-md);
    }

    .modal-title {
        font-size: 1.25rem;
    }

    .toast {
        left: var(--space-md);
        right: var(--space-md);
        transform: translateY(100px);
    }

    .toast.show {
        transform: translateY(0);
    }
}
