/* Prakrit Library Styles */
/* Brand Colors: Dark Brown #3d2817, Gold #d4a574, Copper #b8860b, Cream #f5e6d3 */

/* Library Hero Section */
.library-hero {
    background: linear-gradient(135deg, #3d2817 0%, #5c3e2e 100%);
    color: #f5e6d3;
    padding: 4rem 0;
    text-align: center;
}

.library-hero .hero-content {
    max-width: 800px;
    margin: 0 auto;
}

.library-hero h1 {
    margin-bottom: 1.5rem;
}

.library-hero .prakrit-text {
    font-family: 'Adishila', 'Noto Sans Devanagari', serif;
    font-size: 3rem;
    display: block;
    margin-bottom: 0.5rem;
    color: #f5e6d3;
}

.library-hero .subtitle {
    font-size: 1.5rem;
    font-weight: 400;
    opacity: 0.95;
    color: #ffffff;
}

.library-hero .hero-description {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 2rem;
    opacity: 0.95;
}

.library-hero .hero-description a {
    color: #ffd699;
    text-decoration: underline;
}

.hero-features {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.hero-features .feature {
    background: rgba(245, 230, 211, 0.15);
    padding: 0.75rem 1.25rem;
    border-radius: 2rem;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #f5e6d3;
}

.hero-features .feature i {
    color: #ffd699;
}

/* Text Catalog Section */
.text-catalog {
    padding: 4rem 0;
    background: #faf8f3;
}

.catalog-filters {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.6rem 1.25rem;
    border: 2px solid #a67c52;
    background: #fff9f0;
    color: #5c3e2e;
    border-radius: 2rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    background: #f5e6d3;
    border-color: #8b6f47;
}

.filter-btn.active {
    background: #a67c52;
    color: #fff9f0;
    border-color: #a67c52;
}

/* Text Grid */
.text-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* Text Card */
.text-card {
    background: #fff9f0;
    border-radius: 1rem;
    box-shadow: 0 4px 6px rgba(61, 40, 23, 0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid #e8dcc8;
}

.text-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(61, 40, 23, 0.15);
}

.text-card-header {
    background: linear-gradient(135deg, #3d2817 0%, #5c3e2e 100%);
    color: #f5e6d3;
    padding: 1.5rem;
    text-align: center;
}

.text-title-devanagari {
    font-family: 'Adishila', 'Noto Sans Devanagari', serif;
    font-size: 2rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #ffd699;
}

.text-title-roman {
    font-size: 1.1rem;
    font-weight: 400;
    opacity: 0.9;
    color: #f5e6d3;
}

.text-card-body {
    padding: 1.5rem;
    flex: 1;
}

.text-card-body p {
    margin-bottom: 0.75rem;
    color: #4a3728;
    line-height: 1.6;
}

.text-card-body .text-author,
.text-card-body .text-period {
    font-size: 0.95rem;
    color: #6b5344;
}

.text-card-body .text-author i,
.text-card-body .text-period i {
    color: #a67c52;
    width: 20px;
}

.text-card-body .text-description {
    font-size: 0.95rem;
    margin-top: 1rem;
    color: #5a4437;
}

.text-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.meta-tag {
    background: #e8dcc8;
    color: #5c3e2e;
    padding: 0.3rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 500;
}

.text-card-footer {
    padding: 1.5rem;
    background: #faf8f3;
    border-top: 1px solid #e8dcc8;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.text-card-footer .btn {
    flex: 1;
    min-width: 120px;
    text-align: center;
    justify-content: center;
}

/* Coming Soon Card */
.text-card-coming-soon {
    border: 2px dashed #d4a574;
    background: #f9f7f3;
}

.text-card-coming-soon .text-card-header {
    background: linear-gradient(135deg, #7d6450 0%, #9b8268 100%);
}

.coming-soon-message {
    background: #ffeedd;
    padding: 1rem;
    border-radius: 0.5rem;
    text-align: center;
    color: #8b5a00;
    font-weight: 500;
}

.coming-soon-message i {
    margin-right: 0.5rem;
}

/* About Library Section */
.about-library {
    padding: 4rem 0;
    background: #fff9f0;
}

.about-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 3rem;
    max-width: 1200px;
    margin: 0 auto;
}

.about-text h3 {
    font-size: 1.5rem;
    color: #3d2817;
    margin-bottom: 1rem;
    margin-top: 2rem;
}

.about-text h3:first-child {
    margin-top: 0;
}

.about-text p {
    color: #5a4437;
    line-height: 1.8;
    margin-bottom: 1rem;
}

.about-text a {
    color: #8b6f47;
    text-decoration: underline;
}

.feature-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.feature-list li {
    padding: 0.75rem 0;
    border-bottom: 1px solid #e8dcc8;
    color: #4a3728;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.feature-list li:last-child {
    border-bottom: none;
}

.feature-list li i {
    color: #a67c52;
    font-size: 1rem;
}

/* Credits Section */
.about-credits h3 {
    font-size: 1.25rem;
    color: #3d2817;
    margin-bottom: 1.5rem;
}

.credit-card {
    background: #faf8f3;
    padding: 1.25rem;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    border-left: 4px solid #a67c52;
}

.credit-card h4 {
    font-size: 0.95rem;
    color: #5c3e2e;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.credit-card p {
    color: #4a3728;
    font-size: 1rem;
    margin: 0;
}

.credit-card .license {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #5c3e2e;
}

.credit-card .license i {
    margin-right: 0.25rem;
}

/* ===================================
   LIBRARY READER STYLES
   =================================== */

/* Reader Container */
.library-reader-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2rem;
    min-height: 100vh;
}

.library-reader-container.sidebar-collapsed {
    grid-template-columns: 1fr;
}

/* Reader Header */
.reader-header {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem 0;
    border-bottom: 2px solid #e8dcc8;
    margin-bottom: 1rem;
}

.reader-title {
    font-family: 'Adishila', 'Noto Sans Devanagari', serif;
    font-size: 2.5rem;
    color: #3d2817;
    margin-bottom: 0.5rem;
}

.reader-subtitle {
    font-size: 1.1rem;
    color: #ffffff;
}

/* Reader Controls */
.reader-controls {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem;
    background: #faf8f3;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #5c3e2e;
}

.control-group select {
    padding: 0.5rem 1rem;
    border: 1px solid #d4a574;
    border-radius: 0.5rem;
    background: #fff9f0;
    font-size: 0.9rem;
    cursor: pointer;
    color: #3d2817;
}

.script-toggle {
    display: flex;
    background: #e8dcc8;
    border-radius: 0.5rem;
    overflow: hidden;
}

.script-toggle button {
    padding: 0.6rem 1.25rem;
    border: none;
    background: transparent;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #5c3e2e;
}

.script-toggle button.active {
    background: #a67c52;
    color: #fff9f0;
}

.script-toggle button:hover:not(.active) {
    background: #d4a574;
}

/* Main Reading Area */
.reader-main {
    background: #fff9f0;
    border-radius: 1rem;
    box-shadow: 0 2px 8px rgba(61, 40, 23, 0.06);
    overflow: hidden;
}

/* Chapter Navigation */
.chapter-nav {
    background: #3d2817;
    color: #f5e6d3;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chapter-nav h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.chapter-nav-buttons {
    display: flex;
    gap: 0.5rem;
}

.chapter-nav-btn {
    background: rgba(245, 230, 211, 0.15);
    border: none;
    color: #f5e6d3;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s ease;
}

.chapter-nav-btn:hover:not(:disabled) {
    background: rgba(245, 230, 211, 0.25);
}

.chapter-nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Text Content */
.reader-content {
    padding: 2rem;
    font-family: 'Adishila', 'Noto Sans Devanagari', serif;
    font-size: 1.2rem;
    line-height: 2;
    color: #3d2817;
}

/* Verse Block */
.verse-block {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #faf8f3;
    border-radius: 0.75rem;
    border-left: 4px solid #a67c52;
    position: relative;
}

.verse-block:hover {
    background: #f5ede0;
}

.verse-number {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    background: #a67c52;
    color: #fff9f0;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: system-ui, sans-serif;
}

.verse-lines {
    text-align: center;
}

.verse-line {
    display: block;
    margin-bottom: 0.5rem;
}

.verse-line:last-child {
    margin-bottom: 0;
}

/* Prose Block */
.prose-block {
    margin-bottom: 1.5rem;
    padding: 1rem 1.5rem;
    line-height: 2;
}

.prose-block .sentence {
    display: inline;
}

/* Word Highlighting for Dictionary */
.word {
    cursor: pointer;
    border-radius: 0.25rem;
    transition: background 0.2s ease;
}

.word:hover {
    background: #ffeab8;
}

.word.selected {
    background: #d4a574;
    color: #fff9f0;
}

/* Dictionary Sidebar */
.dictionary-sidebar {
    background: #fff9f0;
    border-radius: 1rem;
    box-shadow: 0 2px 8px rgba(61, 40, 23, 0.06);
    position: sticky;
    top: 2rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
}

.sidebar-header {
    background: #3d2817;
    color: #f5e6d3;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
}

.sidebar-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: #f5e6d3;
    cursor: pointer;
    font-size: 1.2rem;
}

.sidebar-content {
    padding: 1.5rem;
}

.dictionary-search {
    margin-bottom: 1.5rem;
}

.dictionary-search input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #d4a574;
    border-radius: 0.5rem;
    font-size: 1rem;
    background: #fff9f0;
    color: #3d2817;
}

.dictionary-search input:focus {
    outline: none;
    border-color: #a67c52;
}

/* Dictionary Result */
.dictionary-result {
    padding: 1rem;
    background: #faf8f3;
    border-radius: 0.5rem;
    border-left: 3px solid #a67c52;
}

.dict-word {
    font-family: 'Adishila', 'Noto Sans Devanagari', serif;
    font-size: 1.5rem;
    color: #3d2817;
    margin-bottom: 0.5rem;
}

.dict-roman {
    font-size: 0.95rem;
    color: #5c3e2e;
    font-style: italic;
    margin-bottom: 1rem;
}

.dict-meaning h4 {
    font-size: 0.9rem;
    color: #5c3e2e;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.dict-meaning p {
    color: #3d2817;
    line-height: 1.6;
}

.dict-link {
    display: inline-block;
    margin-top: 1rem;
    color: #8b6f47;
    font-size: 0.9rem;
    text-decoration: none;
}

.dict-link:hover {
    text-decoration: underline;
}

.dictionary-placeholder {
    text-align: center;
    color: #b8860b;
    padding: 2rem 1rem;
}

.dictionary-placeholder i {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

/* Chapter TOC Dropdown */
.chapter-toc-dropdown {
    position: relative;
}

.chapter-toc-btn {
    background: rgba(245, 230, 211, 0.15);
    border: none;
    color: #f5e6d3;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chapter-toc-list {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff9f0;
    border-radius: 0.5rem;
    box-shadow: 0 4px 20px rgba(61, 40, 23, 0.15);
    min-width: 200px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.chapter-toc-list.show {
    display: block;
}

.chapter-toc-list a {
    display: block;
    padding: 0.75rem 1rem;
    color: #5c3e2e;
    text-decoration: none;
    border-bottom: 1px solid #e8dcc8;
    transition: background 0.2s ease;
}

.chapter-toc-list a:hover {
    background: #faf8f3;
}

.chapter-toc-list a.active {
    background: #f5ede0;
    color: #8b6f47;
    font-weight: 600;
}

/* Loading State */
.reader-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: #5c3e2e;
}

.reader-loading .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e8dcc8;
    border-top-color: #a67c52;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .library-reader-container {
        grid-template-columns: 1fr;
    }

    .dictionary-sidebar {
        position: fixed;
        right: -100%;
        top: 0;
        bottom: 0;
        width: 320px;
        border-radius: 0;
        z-index: 1000;
        transition: right 0.3s ease;
    }

    .dictionary-sidebar.open {
        right: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(61, 40, 23, 0.5);
        z-index: 999;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .about-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .library-hero {
        padding: 2.5rem 0;
    }

    .library-hero .prakrit-text {
        font-size: 2rem;
    }

    .library-hero .subtitle {
        font-size: 1.25rem;
    }

    .library-hero .hero-description {
        font-size: 1rem;
        padding: 0 1rem;
    }

    .hero-features {
        flex-direction: column;
        gap: 0.5rem;
    }

    .hero-features .feature {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .text-catalog {
        padding: 2rem 0;
    }

    .text-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 0 0.5rem;
    }

    .reader-controls {
        flex-direction: column;
        gap: 1rem;
    }

    .reader-content {
        padding: 1rem;
        font-size: 1.1rem;
    }

    .verse-block {
        padding: 1rem;
    }

    .library-reader-container {
        padding: 1rem;
    }

    .about-library {
        padding: 2rem 0;
    }

    .about-text h3 {
        font-size: 1.25rem;
    }

    .feature-list li {
        padding: 0.5rem 0;
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .library-hero {
        padding: 1.5rem 0;
    }

    .library-hero .prakrit-text {
        font-size: 1.6rem;
    }

    .library-hero .subtitle {
        font-size: 1.1rem;
    }

    .library-hero .hero-description {
        font-size: 0.9rem;
        line-height: 1.6;
        margin-bottom: 1rem;
    }

    .hero-features .feature {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    .text-catalog {
        padding: 1.5rem 0;
    }

    .section-title {
        font-size: 1.4rem;
        margin-bottom: 1rem;
    }

    .catalog-filters {
        gap: 0.4rem;
        margin-bottom: 1.5rem;
        padding: 0 0.5rem;
    }

    .filter-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    .text-grid {
        gap: 1rem;
    }

    .text-card-header {
        padding: 1rem;
    }

    .text-title-devanagari {
        font-size: 1.4rem;
        margin-bottom: 0.25rem;
    }

    .text-title-roman {
        font-size: 0.95rem;
    }

    .text-card-body {
        padding: 1rem;
    }

    .text-card-body .text-author,
    .text-card-body .text-period {
        font-size: 0.85rem;
    }

    .text-card-body .text-description {
        font-size: 0.9rem;
    }

    .text-meta {
        gap: 0.4rem;
    }

    .meta-tag {
        padding: 0.2rem 0.5rem;
        font-size: 0.75rem;
    }

    .text-card-footer {
        padding: 1rem;
    }

    .text-card-footer .btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }

    .chapter-nav {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .about-library {
        padding: 1.5rem 0;
    }

    .about-content {
        gap: 1.5rem;
    }

    .credit-card {
        padding: 1rem;
    }
}

/* Very small screens */
@media (max-width: 360px) {
    .library-hero .prakrit-text {
        font-size: 1.4rem;
    }

    .filter-btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
    }

    .text-title-devanagari {
        font-size: 1.25rem;
    }
}

/* Print Styles */
@media print {
    .reader-controls,
    .dictionary-sidebar,
    .chapter-nav-buttons,
    .sidebar-toggle {
        display: none !important;
    }

    .library-reader-container {
        display: block;
    }

    .verse-block {
        page-break-inside: avoid;
        border-left: 2px solid #000;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles */
button:focus,
select:focus,
input:focus,
a:focus {
    outline: 2px solid #a67c52;
    outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .verse-block {
        border-left-width: 6px;
    }

    .word:hover {
        outline: 2px solid #3d2817;
    }
}
