@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600;700&family=Lora:ital,wght@0,400;0,500;0,600;1,400&display=swap');

:root {
    --primary-color: #5d4e37;
    --secondary-color: #8b7355;
    --accent-color: #c4a77d;
    --bg-color: #faf9f6;
    --text-color: #3d3d3d;
    --muted-color: #7a7a7a;
}

/*
 * Literary Haven - Custom Styles
 * Humanistic and elegant design for a literary reading experience
 */

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Lora', Georgia, serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.8;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    color: var(--primary-color);
}

.navbar {
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--accent-color);
    box-shadow: 0 2px 10px rgba(93, 78, 55, 0.08);
}

.navbar-brand {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color) !important;
    letter-spacing: 1px;
}

.nav-link {
    color: var(--text-color) !important;
    font-size: 0.95rem;
    transition: color 0.3s ease;
}

.nav-link:hover {
    color: var(--primary-color) !important;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    font-family: 'Lora', serif;
    font-size: 0.9rem;
    padding: 0.5rem 1.5rem;
    border-radius: 0;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
    border-radius: 0;
    font-size: 0.85rem;
    padding: 0.4rem 1.2rem;
    transition: all 0.3s ease;
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    color: white;
}

/* Custom scrollbar for chapter list */
.chapter-list::-webkit-scrollbar {
    width: 8px;
}

.chapter-list::-webkit-scrollbar-track {
    background: rgba(196, 167, 125, 0.1);
    border-radius: 4px;
}

.chapter-list::-webkit-scrollbar-thumb {
    background: rgba(93, 78, 55, 0.3);
    border-radius: 4px;
}

.chapter-list::-webkit-scrollbar-thumb:hover {
    background: rgba(93, 78, 55, 0.5);
}

.book-card {
    background: white;
    border: 1px solid rgba(196, 167, 125, 0.2);
    border-radius: 4px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100%;
}

.book-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 4px;
    box-shadow: inset 0 0 0 2px transparent;
    transition: box-shadow 0.3s ease;
    pointer-events: none;
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(93, 78, 55, 0.15);
    border-color: var(--accent-color);
}

.book-card:hover::before {
    box-shadow: inset 0 0 0 2px var(--accent-color);
}

.book-cover {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--bg-color) 0%, #f0ebe6 100%);
}

.book-cover img {
    width: 100%;
    height: 280px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.book-card:hover .book-cover img {
    transform: scale(1.03);
}

.book-info {
    padding: 1.2rem;
}

.book-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.book-author {
    font-size: 0.9rem;
    color: var(--muted-color);
    margin-bottom: 0.6rem;
}

.book-intro {
    font-size: 0.85rem;
    color: var(--text-color);
    line-height: 1.6;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.pagination .page-link {
    color: var(--primary-color);
    border-color: rgba(196, 167, 125, 0.3);
    background: white;
    border-radius: 0;
}

.pagination .page-item.active .page-link {
    color: #fff;
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.pagination .page-item.active .page-link:hover {
    color: #fff;
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.pagination .page-link:hover {
    background-color: rgba(196, 167, 125, 0.1);
    border-color: var(--primary-color);
}

@media (max-width: 767.98px) {
    .row.g-4 {
        min-width: 0;
    }

    .row.g-4 > [class*="col-"] .book-card {
        height: auto;
    }

    .row.g-4 .book-cover:not(.book-detail-cover) img {
        height: 148px;
    }

    .book-detail-cover {
        max-width: min(220px, 72vw);
        margin-left: auto;
        margin-right: auto;
    }

    .book-detail-cover img {
        max-height: 280px;
        object-fit: contain;
    }

    .book-pagination-nav {
        display: block;
        box-sizing: border-box;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        margin-left: calc(-1 * var(--bs-gutter-x, 0.75rem));
        margin-right: calc(-1 * var(--bs-gutter-x, 0.75rem));
        padding-left: var(--bs-gutter-x, 0.75rem);
        padding-right: var(--bs-gutter-x, 0.75rem);
    }

    .book-pagination-nav ul.pagination {
        display: flex;
        flex-wrap: nowrap;
        justify-content: flex-start;
        align-items: stretch;
        width: max-content;
        margin-bottom: 0;
    }

    .book-pagination-nav .page-item {
        flex-shrink: 0;
    }

    .book-pagination-nav .page-link {
        padding: 0.25rem 0.4rem;
        font-size: 0.75rem;
        white-space: nowrap;
    }
}

@media (max-width: 575.98px) {
    .row.g-4 .book-cover:not(.book-detail-cover) img {
        height: 118px;
    }

    .book-detail-cover {
        max-width: min(200px, 65vw);
    }

    .book-detail-cover img {
        max-height: 260px;
    }
}

.section-title {
    position: relative;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
    font-size: 1.8rem;
    letter-spacing: 1px;
}

.section-title::before {
    content: '❧';
    position: absolute;
    left: -2rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent-color);
    font-size: 1.2rem;
    opacity: 0.6;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 2px;
    background-color: var(--accent-color);
}

.chapter-item {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid rgba(196, 167, 125, 0.2);
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.chapter-item:hover {
    background-color: rgba(196, 167, 125, 0.08);
    padding-left: 1.3rem;
}

.chapter-item.active {
    background-color: rgba(93, 78, 55, 0.08);
    color: var(--primary-color);
    border-left: 3px solid var(--accent-color);
    padding-left: 0.8rem;
    font-weight: 500;
}

.reading-content {
    font-size: 1.15rem;
    line-height: 2;
    color: #2a2a2a;
}

.reading-content p {
    margin-bottom: 1.5rem;
}

.reading-content p:first-of-type::first-letter {
    font-size: 3.5rem;
    float: left;
    line-height: 0.8;
    padding-right: 0.1em;
    color: var(--primary-color);
    font-family: 'Playfair Display', serif;
}

.footer {
    background-color: #f5f3f0;
    border-top: 1px solid rgba(196, 167, 125, 0.2);
    padding: 2.5rem 0;
    margin-top: 3rem;
    position: relative;
}

.footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.search-form {
    background: white;
    padding: 1.5rem;
    border: 1px solid rgba(196, 167, 125, 0.2);
    border-radius: 4px;
    margin-bottom: 2rem;
}

.form-control {
    border-radius: 0;
    border-color: rgba(196, 167, 125, 0.3);
}

.form-control:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 0.2rem rgba(196, 167, 125, 0.15);
    outline: none;
}

.recommended-book-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
    border: 1px solid rgba(196, 167, 125, 0.2);
    border-radius: 4px;
    transition: all 0.3s ease;
    background: white;
    overflow: hidden;
}

.recommended-book-cover {
    flex: 0 0 168px;
    height: 168px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(196, 167, 125, 0.08);
    overflow: hidden;
}

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

.recommended-book-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    padding: 0.75rem 1rem 1rem;
    min-height: 0;
}

.recommended-book-title {
    color: var(--primary-color);
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.35;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.recommended-book-author {
    font-size: 0.85rem;
    color: var(--muted-color);
    margin-top: auto;
}

.recommended-book-card:hover {
    border-color: var(--accent-color);
    box-shadow: 0 4px 15px rgba(93, 78, 55, 0.1);
}

/* Button enhancements */
.btn-primary::after,
.btn-outline-primary::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-primary:active::after,
.btn-outline-primary:active::after {
    width: 300px;
    height: 300px;
}

/* Loading animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.book-card {
    animation: fadeIn 0.6s ease-out forwards;
}

.book-card:nth-child(1) { animation-delay: 0.1s; }
.book-card:nth-child(2) { animation-delay: 0.2s; }
.book-card:nth-child(3) { animation-delay: 0.3s; }
.book-card:nth-child(4) { animation-delay: 0.4s; }

.ornament {
    text-align: center;
    color: var(--accent-color);
    margin: 1.5rem 0;
    font-size: 1.2rem;
    letter-spacing: 3px;
}

.text-mute {
    color: var(--muted-color);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .navbar-brand {
        font-size: 1.3rem;
    }

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

@media (max-width: 576px) {
    .section-title::before {
        display: none;
    }

    .reading-content {
        font-size: 1rem;
    }

    .reading-content p {
        text-indent: 1.5em;
    }
}

/* Print styles */
@media print {
    .navbar,
    .footer,
    .chapter-sidebar,
    .chapter-navigation {
        display: none !important;
    }

    .reading-container {
        box-shadow: none !important;
        border: none !important;
    }
}
