/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=Crimson+Text:ital,wght@0,400;0,600;0,700;1,400;1,600&display=swap');

/* CSS Variables for Magisterial Color Palette */
html {
    scrollbar-gutter: stable;
    width: 100%;
    scroll-behavior: smooth;
}


:root {
    --crimson: #8B0000;
    --crimson-dark: #6B0000;
    --crimson-light: #A50000;
    --gold: #D4AF37;
    --gold-light: #E4BF47;
    --gold-dark: #B89F27;
    --cream: #F9F9F7;
    --cream-dark: #F0F0EE;
}

/* Base Styles */
body {
    font-family: 'Crimson Text', Georgia, serif;
    font-size: 18px;
    line-height: 1.75;
    color: #1f2937;
    background-color: var(--cream);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Cinzel', serif;
    color: var(--crimson);
    font-weight: 700;
}

h1 {
    font-size: 2.5rem;
    line-height: 1.2;
    margin: 0;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.75rem;
}

h4 {
    font-size: 1.5rem;
}

@media (min-width: 768px) {
    h1 {
        font-size: 3rem;
    }

    h2 {
        font-size: 2.5rem;
    }

    h3 {
        font-size: 2rem;
    }
}

@media (min-width: 1024px) {
    h1 {
        font-size: 3.75rem;
    }
}

/* Gold Horizontal Rules */
.gold-rule {
    position: relative;
    border: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--gold), transparent);
    margin: 2.5rem auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gold-rule::after {
    content: "◈";
    /* Scholarship diamond symbol */
    position: absolute;
    color: var(--gold);
    background: var(--cream);
    padding: 0 10px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.home-page .gold-rule {
    max-width: 320px;
    /* max-w-smish */
}

.gold-rule-solid {
    border: 0;
    height: 1px;
    background: var(--gold);
    margin: 1.5rem 0;
}

/* Ethereal Frosted Header */
.glass-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background-color: rgba(255, 255, 255, 0.5);
    /* Light frost */
    backdrop-filter: blur(50px);
    -webkit-backdrop-filter: blur(50px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

/* Site Title Responsive Logic */
.site-title {
    white-space: nowrap;
    line-height: 1;
    transition: all 0.2s ease;
    display: inline-block;
}

.site-subtitle {
    display: block;
    transition: all 0.2s ease;
}

/* Breakpoint 1: Title wraps, subtitle hidden. 
   Triggered when the viewport is narrow enough that title/logo/icons collide. */
@media (max-width: 500px) {
    .site-title {
        white-space: normal;
        max-width: 140px;
        /* Force wrap into two narrow lines */
    }

    .site-subtitle {
        display: none !important;
    }
}

/* Breakpoint 2: Title hidden entirely if viewport is extremely skinny to prevent collision with icons */
@media (max-width: 370px) {
    .site-title {
        display: none !important;
    }
}

/* Ensure header partial works with rules */
.glass-header .gold-rule-solid {
    margin: 0;
    opacity: 0.3;
}


/* Link Styles */
a {
    text-decoration: none;
    transition: color 0.2s ease;
}

.article-link {
    color: #374151;
    text-decoration: none;
    transition: color 0.2s ease;
}

.article-link:hover {
    color: var(--crimson);
    text-decoration: underline;
}

.nav-link {
    color: #374151;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s ease;
}

.nav-link:hover {
    color: var(--crimson);
}

/* Category Sections */
.category-section {
    margin-bottom: 3rem;
}

.category-title {
    font-size: 1.5rem;
    font-family: 'Cinzel', serif;
    font-weight: 700;
    color: var(--crimson);
    margin-bottom: 0.5rem;
    border-bottom: 2px solid var(--gold);
    padding-bottom: 0.5rem;
}

@media (min-width: 768px) {
    .category-title {
        font-size: 1.875rem;
    }
}

.subcategory-title {
    font-size: 1.25rem;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    color: var(--crimson-dark);
    margin-bottom: 0.75rem;
    margin-top: 0.5rem;
}

/* Article Container */
.article-container {
    max-width: 750px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

/* Cinematic Hero Layout */
.hero-cinematic {
    position: relative;
    height: 284px;
    /* Default h-96 */
    overflow: hidden;
}

@media (min-width: 768px) {
    .hero-cinematic {
        height: 384px;
    }
}

.hero-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.hero-backdrop-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: sepia(50%) grayscale(20%) blur(20px) opacity(80%) brightness(1);
    transform: scale(1.15);
    /* Prevent blur edges from showing */
}

.hero-focal-container {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-focal-img {
    max-height: 90%;
    max-width: 90%;
    width: auto;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 15px 30px rgba(0, 0, 0, 0.7));
    transition: transform 0.3s ease;
    border-radius: 9px;
}

/* Standardized Spacing & Animations */
.section-spacing {
    padding: 2.5rem 1.5rem 0 1.5rem;
}

@media (min-width: 768px) {
    .section-spacing {
        padding: 3.5rem 2rem 0 2rem;
    }
}

.reveal-on-scroll {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s cubic-bezier(0.165, 0.84, 0.44, 1), transform 0.8s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.reveal-on-scroll.visible {
    opacity: 1;
    transform: none;
    /* Crucial: transform: none removes the containing block restriction */
}

.home-page .section-title-group {
    margin-bottom: 4rem;
}

/* Homepage-Specific Refinements (Restored) */
.home-page .glass-header {
    display: none !important;
}

.home-page .hero-backdrop {
    display: none !important;
}

@media (min-width: 1024px) {
    .home-page .hero-cinematic {
        height: 484px;
    }
}

.home-page .hero-focal-img {
    max-height: none !important;
    max-width: none !important;
}

@media (max-width: 768px) {
    .home-page .hero-focal-img {
        object-fit: cover !important;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0;
    }
}

/* Old Hero Styles Removed */

/* Buttons */
.btn-primary {
    background-color: var(--crimson);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.125rem;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.header-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: var(--crimson);
    background: transparent;
    transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
    border: none;
    cursor: pointer;
}

.header-icon-btn:hover {
    background-color: rgba(139, 0, 0, 0.08);
    transform: scale(1.05);
}

.header-icon-btn:active {
    transform: scale(0.95);
}

/* Scholar Quote & Mission Section */
.scholar-quote {
    border-left: 4px solid var(--gold);
    border-radius: 0.75rem;
    /* Matches rounded-xl */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.quote-mark {
    position: absolute;
    font-family: 'Cinzel', serif;
    font-size: 5rem;
    color: var(--gold);
    opacity: 0.2;
    line-height: 1;
}

.border-gold-faint {
    border-color: rgba(212, 175, 55, 0.15);
}

.btn-secondary {
    background-color: var(--gold);
    color: var(--crimson);
    padding: 0.75rem 1.5rem;
    border-radius: 0.125rem;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-secondary:hover {
    background-color: var(--gold-dark);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    /* Push above iOS home indicator bar on Face ID iPhones (iPhone X+).
       env() is ignored by browsers that don't support it (safe fallback). */
    bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
    right: calc(2rem + env(safe-area-inset-right, 0px));
    background-color: var(--crimson);
    color: white;
    padding: 1rem;
    border-radius: 9999px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
    z-index: 50;
}

.back-to-top:hover {
    background-color: var(--crimson-dark);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
}

.back-to-top.hidden {
    display: none;
}

/* Search Bar */
.search-bar {
    width: 100%;
    padding: 0.5rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.125rem;
    font-family: 'Crimson Text', Georgia, serif;
}

/* Hide native Clear (X) in Chrome/Safari/Edge */
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
    display: none;
}

.search-bar:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 1px var(--gold);
}

.search-bar:disabled {
    background-color: #f3f4f6;
    cursor: not-allowed;
}

@media (min-width: 768px) {
    .search-bar {
        width: 24rem;
    }
}

/* Mobile Menu */
.mobile-menu {
    position: fixed;
    inset: 0;
    background-color: var(--cream);
    z-index: 50;
    transform: translateX(0);
    transition: transform 0.3s ease;
}

.mobile-menu.hidden {
    transform: translateX(100%);
}

/* Standard Category Grid (Landing Page) */
.category-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* 2 columns on mobile (2x3 grid) */
    gap: 1.5rem;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

@media (min-width: 768px) {
    .category-grid {
        grid-template-columns: repeat(3, 1fr);
        /* 3 columns on desktop (3x2 grid) */
        gap: 2rem;
    }
}

/* Category Grid Masonry (Category Pages) */
.masonry-grid {
    column-count: 3;
    column-gap: 2rem;
    width: 100%;
}

@media (max-width: 1024px) {
    .masonry-grid {
        column-count: 2;
    }
}

@media (max-width: 640px) {
    .masonry-grid {
        column-count: 1;
    }
}

.category-section {
    break-inside: avoid-column;
    display: inline-block;
    width: 100%;
    margin-bottom: 2rem;
    background: white;
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(141, 14, 38, 0.1);
}

.subcategory-title {
    font-family: 'Cinzel', serif;
    font-size: 1.25rem;
    color: var(--crimson);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gold);
}

.article-link {
    color: var(--charcoal);
    padding: 0.5rem 0;
    transition: color 0.3s ease;
    display: block;
    line-height: 1.5;
    text-decoration: none !important;
}

.article-link:hover {
    color: var(--crimson);
}

.article-link span {
    transition: text-decoration 0.3s ease;
}

.article-link:hover span {
    text-decoration: underline !important;
}

/* Breadcrumb Styling */
.breadcrumb {
    font-size: 1rem;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 2rem;
    font-family: 'Crimson Text', serif;
    display: block;
    /* Change from flex to block */
    white-space: normal;
    /* Ensure normal wrapping */
    text-transform: capitalize;
    line-height: 1.6;
}

.breadcrumb a,
.breadcrumb span {
    display: inline;
    /* Ensure all items are inline for natural flow */
}

.breadcrumb a {
    color: var(--crimson);
    transition: color 0.2s ease;
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--gold-dark);
    text-decoration: underline;
}

.breadcrumb .current-page {
    color: #374151;
}

.breadcrumb span.separator {
    color: #d1d5db;
    user-select: none;
    display: inline;
}

/* Category Card (Original Style Restored) */
.category-card {
    position: relative;
    background-color: white;
    border-radius: 0.85rem;
    border: 1px solid rgba(212, 175, 55, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    height: 120px;
    width: 100%;
    padding: 1rem;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

@media (min-width: 768px) {
    .category-card {
        height: 160px;
        padding: 1.5rem;
    }
}

.category-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transform: translateY(-4px);
    border-color: var(--gold);
}

.category-card .title {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    color: var(--crimson);
    font-size: 1rem;
    line-height: 1.2;
    transition: color 0.3s ease;
    margin: 0;
}

@media (min-width: 768px) {
    .category-card .title {
        font-size: 1.35rem;
    }
}

/* Social Media Cards */
.social-card {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 600px;
    border: 1px solid rgba(212, 175, 55, 0.2);
}

.social-card-header {
    background-color: var(--cream-dark);
    padding: 1rem 1.5rem;
    border-bottom: 2px solid var(--gold);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.social-card-body {
    flex: 1;
    overflow-y: auto;
    background-color: white;
}

.social-card-footer {
    padding: 1rem 1.5rem;
    background-color: var(--cream);
    border-top: 1px solid rgba(212, 175, 55, 0.1);
}

.facebook-embed-container {
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

/* Social Scaling HUD */
.iframe-scaler {
    position: relative;
    width: 100%;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

.iframe-scaler iframe {
    position: absolute;
    left: 50%;
    top: 0;
    transform-origin: top center;
    transform: translateX(-50%);
}

.substack-card-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: space-between;
}

.substack-embed-frame {
    width: 100%;
    border: none;
    background: white;
}

/* Scholar Side-Panel Styles */
.scholar-panel {
    background-color: rgba(242, 242, 235, 0.6);
    /* Pale stone/cream */
    padding: 2rem;
    border-radius: 8px;
    border: none;
    position: sticky;

    top: 100px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    transition: all 0.3s ease;
    width: 300px;
}

.sidebar-label {
    font-family: 'Cinzel', serif;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--gold-dark);
    text-transform: uppercase;
    margin-bottom: 1rem;
    display: block;
}

.toc-link {
    display: block;
    padding: 0.5rem 0;
    color: #4b5563;
    font-size: 0.95rem;
    text-decoration: none;
    transition: color 0.2s ease;
    border-bottom: 1px solid transparent;
}

.toc-link:hover {
    color: var(--crimson);
}

.sibling-link {
    display: block;
    padding: 0.75rem 0;
    font-family: 'Crimson Text', serif;
    font-style: italic;
    color: #1f2937;
    border-bottom: 1px solid rgba(212, 175, 55, 0.1);
    transition: color 0.2s ease;
}

.sibling-link:last-child {
    border-bottom: none;
}

.sibling-link:hover {
    color: var(--crimson);
    text-decoration: underline;
}

.article-heading {
    scroll-margin-top: 120px;
}

/* Custom Scrollbar for Panel */
.scholar-panel::-webkit-scrollbar {
    width: 4px;
}

.scholar-panel::-webkit-scrollbar-thumb {
    background: var(--gold-dark);
    border-radius: 10px;
}

/* Mobile Navigation Panel */
.mobile-article-nav {
    margin-bottom: 2.5rem;
    background-color: var(--cream-dark);
    border-radius: 8px;
    border-left: 4px solid var(--gold);
}

.mobile-article-nav summary {
    padding: 1rem;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    color: var(--crimson);
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-article-nav[open] summary {
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

.mobile-article-nav summary::after {
    content: '+';
    font-size: 1.25rem;
}

.mobile-article-nav[open] summary::after {
    content: '-';
}

/* Text Shadows */

.text-shadow-sm {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.text-shadow {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--cream);
}

::-webkit-scrollbar-thumb {
    background: var(--gold);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gold-dark);
}

/* Scrollbar/Layout Utils */
body.overflow-hidden {
    overflow: hidden !important;
}

/* Prose Styles for Article Content */
.prose {
    max-width: none;
}

.prose p {
    margin-bottom: 1.5rem;
    line-height: 1.8;
}

.prose blockquote {
    /* padding-left: 1.5rem; */
    /* font-style: italic; */
    color: #374151;
    /* margin: 1.5rem 0; */
    background-color: var(--cream-dark);
    /* padding: 1rem 1.5rem; */
}

.prose blockquote p {
    margin-bottom: 0rem;
}

.prose blockquote footer {
    font-size: 0.875rem;
    margin-top: 0.5rem;
    font-style: normal;
    color: #6b7280;
}

/* Utility Classes */
.max-w-article {
    max-width: 750px;
}

.bg-cream {
    background-color: var(--cream);
}

.bg-cream-dark {
    background-color: var(--cream-dark);
}

.text-crimson {
    color: var(--crimson);
}

.text-crimson-dark {
    color: var(--crimson-dark);
}

.text-gold {
    color: var(--gold);
}

.text-cream {
    color: var(--cream);
}

.text-cream-dark {
    color: var(--cream-dark);
}

.border-gold {
    border-color: var(--gold);
}

.bg-crimson {
    background-color: var(--crimson);
}

/* Modal Overlay Navigation */
.modal-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease-out, visibility 0.15s;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-content {
    background-color: white;
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    border-radius: 0.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

@media (max-width: 768px) {
    .modal-content {
        max-width: 90vw;
    }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: none;
    /* Remove gold border line */
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: white;
    /* White background */
}

body {
    background-color: var(--cream);
    color: var(--charcoal);
    font-family: 'Crimson Text', Georgia, serif;
    line-height: 1.6;
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* FOUC Prevention */
#categoryGrid,
#categoryDetail,
#accordionContainer {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

main {
    flex: 1;
}

/* Modal Overlay Navigation (Restored) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(18, 12, 10, 0.85);
    /* Original dark overlay */
    backdrop-filter: blur(15px);
    /* Original blur strength */
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 650px;
    max-height: 85vh;
    border-radius: 0.85rem;
    overflow: clip;
    /* Preserves border-radius clipping without blocking sticky positioning */
    display: flex;
    flex-direction: column;
    box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.15);
    transform: translateY(40px) scale(0.98);
    transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.modal-content.relative {
    position: relative;
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

.modal-header-centered {
    padding: 1.5rem clamp(1rem, 5vw, 2rem);
    padding-right: clamp(4rem, 12vw, 5.5rem);
    /* Protect the 'X' button */
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    width: 100%;
    flex-shrink: 0;
    /* Never shrink in the flex column */
    position: sticky;
    top: 0;
    z-index: 5;
    /* Glass effect matching .glass-header */
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(50px);
    -webkit-backdrop-filter: blur(50px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}

.modal-title {
    font-family: 'Cinzel', serif;
    font-size: clamp(1.4rem, 6vw, 2.22rem);
    font-weight: 700;
    color: var(--crimson);
    margin: 0;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    width: 100%;
    word-break: break-word;
    hyphens: auto;
}

.modal-close {
    position: absolute;
    right: clamp(1rem, 4vw, 2rem);
    background: rgba(0, 0, 0, 0.04);
    border: none;
    font-size: 1.75rem;
    color: var(--gold-dark);
    cursor: pointer;
    width: clamp(2.5rem, 8vw, 3.2rem);
    height: clamp(2.5rem, 8vw, 3.2rem);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.08);
    transform: rotate(90deg);
    color: var(--crimson);
}

.modal-body-spacious {
    overflow-y: auto;
    padding: 1.5rem clamp(1rem, 5vw, 4rem);
    flex-grow: 1;
    min-height: 0;
    /* Required: allows flex child to scroll rather than overflow */
}

.modal-body-spacious::-webkit-scrollbar {
    width: 4px;
    /* Thin scrollbar */
}

.modal-body-spacious::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body-spacious::-webkit-scrollbar-thumb {
    background: var(--gold);
    border-radius: 4px;
}

.modal-body-spacious::-webkit-scrollbar-thumb:hover {
    background: var(--gold-dark);
}

.modal-body-spacious::-webkit-scrollbar-button {
    display: none;
    /* Remove scrollbar arrows */
    height: 0;
}

/* Accordion Styles */
.accordion {
    list-style: none;
    padding: 0;
    margin: 0;
}

.accordion-item {
    margin-bottom: 1.25rem;
    border: none;
}

.accordion-header {
    width: 100%;
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.02);
    /* Refined grey */
    border: 1px solid transparent;
    border-radius: 0.85rem;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.accordion-header .title {
    font-family: 'Cinzel', serif;
    font-size: clamp(1.1rem, 4vw, 1.35rem);
    font-weight: 700;
    color: #4b5563;
    letter-spacing: 0.02em;
    line-height: 1.2;
    display: flex;
    align-items: center;
    transition: color 0.3s ease;
    word-break: break-word;
    hyphens: auto;
    flex: 1;
}

.accordion-header .icon {
    color: var(--gold);
    font-size: 1.4rem;
    opacity: 0.6;
    transition: all 0.3s ease;
}

.accordion-arrow {
    margin-left: auto;
    color: var(--gold-dark);
    opacity: 0.3;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.accordion-header:hover {
    background-color: var(--cream-dark);
    /* Cream hover */
    transform: translateX(10px);
}

.accordion-header:hover .title {
    color: var(--crimson);
}

.accordion-header:hover .icon {
    opacity: 1;
    transform: scale(1.1);
}

.accordion-header.active {
    background-color: var(--cream-dark);
    /* Consistent active bg */
    border-color: rgba(212, 175, 55, 0.2);
}

.accordion-header.active .title {
    color: var(--crimson);
}

.accordion-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.accordion-links {
    list-style: none;
    padding: 0.75rem 0 1rem 0;
    margin: 0;
}

.accordion-links a {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.8rem clamp(1rem, 4vw, 2rem);
    color: #6b7280;
    text-decoration: none;
    font-family: 'Crimson Text', serif;
    font-size: clamp(1rem, 3.5vw, 1.15rem);
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    border-radius: 0.5rem;
    line-height: 1.4;
    word-break: break-word;
}

.accordion-links a .icon {
    color: var(--gold-dark);
    font-weight: bold;
    opacity: 0.3;
}

.accordion-links a:hover {
    color: var(--crimson);
    transform: translateX(12px);
    background-color: rgba(0, 0, 0, 0.015);
}

.accordion-links a:hover .icon {
    opacity: 1;
}

.modal-footer-catalog {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: center;
    width: 100%;
}

.catalog-link {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    color: var(--crimson);
    text-decoration: none;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
}

.catalog-link:hover {
    transform: scale(1.05);
    letter-spacing: 0.02em;
}

/* Dynamic Content Utilities */
.cursor-default {
    cursor: default !important;
}

.opacity-0 {
    opacity: 0;
    pointer-events: none;
}

.opacity-100 {
    opacity: 1 !important;
}

.transition-opacity {
    transition: opacity 0.5s ease-in-out;
}

/* Responsive Video Embeds */
.video-container {
    position: relative;
    width: 100%;
    height: 0;
}

.aspect-video {
    padding-bottom: 56.25%;
    /* 16:9 Aspect Ratio */
}

.aspect-video-4-3 {
    padding-bottom: 75%;
    /* 4:3 Aspect Ratio */
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.video-container-wrapper {
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* TTS System Styles */
#tts-control-bar {
    background: transparent;
    border: none;
    padding: 0;
    margin: 2rem 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

#tts-control-bar.tts-sticky {
    position: fixed;
    bottom: 2rem;
    height: 56px;
    /* Matching back-to-top button exactly */
    z-index: 1000;
    left: 1rem;
    right: calc(1rem + 56px + 1rem);
    /* Space for back-to-top button and gap */
    margin: 0;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(50px);
    -webkit-backdrop-filter: blur(50px);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 9999px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    padding: 0 1.5rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    overflow: hidden;
    animation: slideUpFloat 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Desktop alignment: constrain to article column width */
@media (min-width: 768px) {
    #tts-control-bar.tts-sticky {
        /* Left edge aligns with page container margin */
        left: calc((100vw - min(100vw, 1280px)) / 2 + 1.5rem);
        /* Right edge leaves room for 300px sidebar, 3rem gap, and back-to-top area */
        right: calc((100vw - min(100vw, 1280px)) / 2 + 300px + 3rem + 56px + 2.5rem);
        padding: 0 2rem;
    }
}

@keyframes slideUpFloat {
    from {
        transform: translateY(100px) scale(0.95);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.tts-main-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 1.25rem;
    height: 100%;
    width: 100%;
}

/* Hide labels/extra padding in sticky mode to keep it slim */
#tts-control-bar.tts-sticky .tts-inner {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    width: 100%;
}

.tts-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #b22222;
    transition: transform 0.2s ease, color 0.2s ease;
    padding: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.tts-btn:hover {
    transform: scale(1.1);
    background: rgba(178, 34, 34, 0.05);
}

#tts-speed {
    font-size: 0.75rem;
    font-weight: 700;
    color: #b22222;
    border: 1.5px solid rgba(178, 34, 34, 0.15);
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.tts-progress-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    padding: 0 0.5rem;
}

#tts-progress {
    flex-grow: 1;
    height: 4px;
    background: #ecd3ac;
    -webkit-appearance: none;
    border-radius: 2px;
    cursor: pointer;
}

#tts-progress::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #b22222;
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}

.tts-highlight {
    color: #8b0000 !important;
    text-decoration-line: underline !important;
    text-decoration-style: dotted !important;
    text-decoration-color: #8b0000 !important;
    text-underline-offset: 3px;
    /* transition: color 0.2s ease; Safari handles background transitions better for highlighting, maybe add back if needed */
}

.hidden {
    display: none;
}

/* Scholar Panel - hidden on mobile, visible on desktop */
.scholar-panel {
    display: none;
}

@media (min-width: 768px) {
    .scholar-panel {
        display: block;
        position: sticky;
        top: 120px;
    }
}

/* =============================================================================
   TTS CONTROL BAR
   ============================================================================= */

/* Anchor: static in-flow height placeholder for when bar goes fixed */
#tts-anchor {
    width: 100%;
    /* height set dynamically by JS */
}

/* ── INLINE (top-of-article) STATE ────────────────────────────────────────── */
/* Scholarly, transparent — sits directly on the page with no box */
.tts-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0.5rem 0;
    box-shadow: none;
    /* Keep on GPU layer even in inline state — prevents iOS scroll flicker */
    will-change: transform;
}

/* ── STICKY (fixed / floating) STATE ──────────────────────────────────────── */
.tts-container.tts-sticky {
    position: fixed;
    /* Above iOS home indicator bar */
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    /* Left edge with small margin */
    left: 1rem;
    /* Right edge: back-to-top button is ~56px wide at right:2rem.
       Buffer = 56px (btn) + 2rem (btn's right offset) + 0.75rem (gap) = ~4.5rem+56px.
       Using env() for Face ID iPhones. */
    right: calc(56px + 2.75rem + env(safe-area-inset-right, 0px));
    width: auto;
    /* Panel appearance only in sticky state */
    background: #ffffff;
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 14px;
    padding: 0.6rem 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 40;
}

/* ── Row layout ────────────────────────────────────────────────────────────── */
.tts-main-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* Seek bar: expands to fill remaining space */
.tts-progress-container {
    flex: 1;
    min-width: 0;
}

/* Inline (non-sticky) state: hide seek bar only on very narrow screens */
@media (max-width: 340px) {
    .tts-container:not(.tts-sticky) .tts-progress-container {
        display: none;
    }
}

/* Sticky compact mode: hide seek bar and shrink to fit-content at ≤450px */
@media (max-width: 450px) {
    .tts-container.tts-sticky .tts-progress-container {
        display: none;
    }

    /* Shrink sticky bar to only the space its buttons need */
    .tts-container.tts-sticky {
        width: fit-content;
        right: calc(56px + 2.75rem + env(safe-area-inset-right, 0px));
    }
}

.tts-slider {
    width: 100%;
    accent-color: var(--crimson);
    cursor: pointer;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.tts-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    /* No permanent background — scholarly, minimal look */
    background: transparent;
    color: var(--crimson);
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
    flex-shrink: 0;
}

.tts-btn:hover {
    background: rgba(139, 0, 0, 0.08);
}

.tts-btn:active {
    transform: scale(0.92);
}

/* Play/Pause: consistent with other btns — no permanent fill */
.tts-play-trigger {
    width: 46px;
    height: 46px;
}

.tts-play-trigger:hover {
    background: rgba(139, 0, 0, 0.1);
}

.speed-indicator {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--crimson);
    background: transparent;
    border: 1px solid rgba(139, 0, 0, 0.2);
    border-radius: 6px;
    padding: 0.2rem 0.45rem;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.speed-indicator:hover {
    background: rgba(139, 0, 0, 0.07);
}

/* ── TTS Highlight (active reading sentence) ──────────────────────────────── */
.tts-highlight {
    color: #8b0000 !important;
    text-decoration-line: underline !important;
    text-decoration-style: dotted !important;
    text-decoration-color: #8b0000 !important;
    text-underline-offset: 3px;
}