:root {
    --header-bg: #263532;
    --body-bg: #131413;
    --small-text: #44525a;
    --large-text: #dcccbb;
    --shelf-max-width: 800px;
}

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

body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--body-bg);
    color: var(--large-text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Header Styles */
header {
    background-color: var(--header-bg);
    text-align: center;
    padding: 3rem 2rem 2.5rem;
    position: relative;
}

.subtitle {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.875rem;
    font-weight: 300;
    letter-spacing: 0.25em;
    color: var(--small-text);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    animation: fadeInDown 0.8s ease-out;
}

h1 {
    font-family: 'Libre Baskerville', serif;
    font-size: clamp(2rem, 6vw, 4rem);
    font-weight: 400;
    letter-spacing: 0.08em;
    color: var(--large-text);
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

/* Main Content */
main {
    padding: 4rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* Desktop Bookshelf */
.bookshelf-container {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    margin-top: 12rem;
    animation: fadeIn 1s ease-out 0.4s both;
}

.bookshelf-image {
    width: 100%;
    height: auto;
    display: block;
}

.books-grid {
    position: absolute;
    bottom: 80%;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 2%;
    padding: 0 8%;
}

.book-slot {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    flex: 0 0 auto;
}

.book-slot.empty {
    opacity: 0;
}

.book-cover {
    display: block;
    width: 120px;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                filter 0.3s ease,
                box-shadow 0.3s ease;
    cursor: pointer;
    position: relative;
    animation: bookAppear 0.6s ease-out backwards;
}

.book-slot:nth-child(1) .book-cover { animation-delay: 0.6s; }
.book-slot:nth-child(2) .book-cover { animation-delay: 0.75s; }
.book-slot:nth-child(3) .book-cover { animation-delay: 0.9s; }
.book-slot:nth-child(4) .book-cover { animation-delay: 1.05s; }

.book-cover img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 2px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.book-cover:hover {
    transform: translateY(-12px) scale(1.05);
    filter: brightness(1.1);
    z-index: 10;
}

.book-cover:hover img {
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.6),
                0 0 0 1px rgba(220, 204, 187, 0.1);
}

/* Tooltip on hover */
.book-cover::after {
    content: attr(data-title);
    position: absolute;
    bottom: -2.5rem;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(38, 53, 50, 0.95);
    color: var(--large-text);
    font-family: 'Montserrat', sans-serif;
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.book-cover:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(4px);
}

/* Mobile Books List - Hidden on Desktop */
.mobile-books {
    display: none;
}

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

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes bookAppear {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Tablet Adjustments */
@media (max-width: 1024px) {
    .books-grid {
        gap: 1.5%;
        padding: 0 6%;
    }
    
    .book-cover {
        width: 100px;
    }
}

/* Mobile Styles */
@media (max-width: 768px) {
    header {
        padding: 2rem 1.5rem;
    }
    
    .subtitle {
        font-size: 0.75rem;
        letter-spacing: 0.2em;
    }
    
    h1 {
        font-size: 2rem;
        letter-spacing: 0.06em;
    }
    
    main {
        padding: 2rem 1rem;
    }
    
    /* Hide desktop bookshelf on mobile */
    .bookshelf-container {
        display: none;
    }
    
    /* Show mobile book list */
    .mobile-books {
        display: flex;
        flex-direction: column;
        gap: 2rem;
        max-width: 500px;
        margin: 0 auto;
    }
    
    .mobile-book-item {
        display: flex;
        align-items: center;
        gap: 1.5rem;
        text-decoration: none;
        background-color: rgba(38, 53, 50, 0.3);
        padding: 1.25rem;
        border-radius: 8px;
        transition: background-color 0.3s ease, transform 0.2s ease;
        animation: fadeInUp 0.5s ease-out backwards;
    }
    
    .mobile-book-item:nth-child(1) { animation-delay: 0.2s; }
    .mobile-book-item:nth-child(2) { animation-delay: 0.35s; }
    .mobile-book-item:nth-child(3) { animation-delay: 0.5s; }
    .mobile-book-item:nth-child(4) { animation-delay: 0.65s; }
    
    .mobile-book-item:active {
        transform: scale(0.98);
    }
    
    .mobile-book-item img {
        width: 80px;
        height: auto;
        border-radius: 3px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
        flex-shrink: 0;
    }
    
    .mobile-book-title {
        font-family: 'Libre Baskerville', serif;
        font-size: 1.125rem;
        color: var(--large-text);
        letter-spacing: 0.02em;
    }
    
    @media (hover: hover) {
        .mobile-book-item:hover {
            background-color: rgba(38, 53, 50, 0.5);
        }
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .mobile-book-item {
        padding: 1rem;
        gap: 1rem;
    }
    
    .mobile-book-item img {
        width: 60px;
    }
    
    .mobile-book-title {
        font-size: 1rem;
    }
}
