/* Encyclopedia Page CSS - Chapter pages with sidebar navigation */

/* Hero Section - Simplified for Chapter Pages if needed, or keep as is */
.encyclopedia-hero {
    position: relative;
    height: 55vh;
    min-height: 350px;
    background-image: url('/assets/images/encyclopedia_hero.jpg');
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--spacing-3xl);
    border-bottom: 4px solid var(--primary);
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    background: radial-gradient(circle, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.8) 100%);
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    color: var(--primary);
    padding: var(--spacing-2xl);
    max-width: 900px;
    margin: 0 var(--spacing-xl);

    /* Art Deco Border with Cut Corners (TL and BR only) */
    border: none;
    clip-path: polygon(
        20px 0, 100% 0,
        100% calc(100% - 20px), calc(100% - 20px) 100%,
        0 100%, 0 20px
    );
    background-color: rgba(0, 0, 0, 0.7);
    background-image:
        /* Diagonal Lines for Cut Corners */
        linear-gradient(135deg, transparent 14.2px, var(--primary) 14.2px, var(--primary) 16.2px, transparent 16.2px), /* TL */
        linear-gradient(315deg, transparent 14.2px, var(--primary) 14.2px, var(--primary) 16.2px, transparent 16.2px), /* BR */

        /* Straight Borders */
        linear-gradient(to right, var(--primary), var(--primary)), /* Top */
        linear-gradient(to bottom, var(--primary), var(--primary)), /* Right */
        linear-gradient(to right, var(--primary), var(--primary)), /* Bottom */
        linear-gradient(to bottom, var(--primary), var(--primary)); /* Left */

    background-position:
        top left, bottom right, /* Diagonals */
        top right, top right, /* Top & Right borders (anchored TR) */
        bottom left, bottom left; /* Bottom & Left borders (anchored BL) */

    background-size:
        20px 20px, 20px 20px, /* Diagonals size */
        calc(100% - 20px) 2px, /* Top border width */
        2px calc(100% - 20px), /* Right border height */
        calc(100% - 20px) 2px, /* Bottom border width */
        2px calc(100% - 20px); /* Left border height */

    background-repeat: no-repeat;
}

.hero-content h1 {
    font-family: var(--font-display);
    font-size: 3rem;
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.hero-subtitle {
    font-family: var(--font-ui);
    font-size: 1rem;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--primary-light);
    margin: 0;
}

/* Main layout with sidebar */
.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing-xl) var(--spacing-3xl);
    display: grid;
    grid-template-columns: 300px 1fr 250px; /* Left Sidebar, Content, Right ToC */
    gap: var(--spacing-2xl);
    align-items: start;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 280px 1fr; /* Hide ToC on smaller screens or move it */
    }
    .toc {
        display: none; /* Hide right sidebar on smaller screens */
    }
}



/* Left Sidebar Navigation */
.sidebar {
    background: white;
    border: 1px solid var(--primary); /* Gold border */
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    z-index: 10;
    order: -1; /* Ensure sidebar is visually first on desktop */
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-title {
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--warm-gray-900); /* Dark header */
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

.sidebar-nav {
    padding: 0;
    list-style: none;
    margin: 0;
    flex: 1;
}

.sidebar-nav li {
    border-bottom: 1px solid var(--warm-gray-200);
}

.sidebar-nav li:last-child {
    border-bottom: none;
}

.sidebar-nav a {
    display: block;
    padding: var(--spacing-sm) var(--spacing-lg);
    color: var(--warm-gray-800); /* Darker text for contrast */
    text-decoration: none;
    transition: all var(--transition-base);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
}

.sidebar-nav a:hover {
    background: var(--warm-gray-100);
    color: var(--primary-dark); /* Darker gold on hover */
    padding-left: calc(var(--spacing-lg) + 4px);
}

.sidebar-nav a.active {
    background: var(--warm-gray-100);
    color: var(--primary-dark);
    border-left: 4px solid var(--primary);
    font-weight: 700;
}

/* Submenu styling */
.submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: var(--warm-gray-50);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.submenu li {
    border-bottom: 1px solid var(--warm-gray-200);
}

.submenu a {
    padding-left: var(--spacing-2xl);
    font-size: 0.85rem;
    color: var(--warm-gray-600);
}

.submenu a:hover {
    color: var(--primary-dark);
    padding-left: calc(var(--spacing-2xl) + 4px);
}


/* Right Sidebar (Table of Contents) */
.toc {
    position: -webkit-sticky;
    position: sticky;
    top: 6rem;
    padding: var(--spacing-lg);
    border-left: 1px solid var(--primary); /* Gold border */
}

.toc-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--primary); /* Gold title */
    margin-bottom: var(--spacing-md);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 2px solid var(--primary);
    padding-bottom: var(--spacing-xs);
    display: inline-block;
}

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

.toc li {
    margin-bottom: var(--spacing-xs);
}

.toc a {
    color: var(--warm-gray-200); /* Light text for dark background */
    text-decoration: none;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    transition: color var(--transition-base);
    display: block;
    padding: 2px 0;
}

.toc a:hover {
    color: var(--primary); /* Gold on hover */
    text-decoration: none;
}

.toc .active {
    color: var(--primary);
    font-weight: 700;
}

/* Mobile ToC (Inside Content) */
.toc-mobile {
    background: var(--warm-gray-50);
    border: 1px solid var(--primary);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
    display: none; /* Hidden by default, shown via media query if needed */
}

@media (max-width: 1200px) {
    .toc-mobile {
        display: block;
    }
}


/* Content Area Styling */
.content {
    background: white; /* Keep white container */
    padding: var(--spacing-xl); /* Add some padding if needed, or rely on container */
    /* Typography */
    color: var(--warm-gray-900);
    font-family: var(--font-body);
    line-height: 1.8;
}

.content h1, .content h2, .content h3, .content h4 {
    font-family: var(--font-display);
    color: var(--primary-dark);
    margin-top: var(--spacing-2xl);
    margin-bottom: var(--spacing-md);
}

.content h1 {
    font-size: 2.5rem;
    border-bottom: 3px solid var(--primary);
    padding-bottom: var(--spacing-sm);
    margin-top: 0;
}

.content h2 {
    font-size: 2rem;
    border-bottom: 1px solid var(--warm-gray-200);
    padding-bottom: var(--spacing-xs);
}

.content h3 {
    font-size: 1.5rem;
}

.content p {
    margin-bottom: var(--spacing-lg);
    font-size: 1.1rem;
}

.content ul, .content ol {
    margin-bottom: var(--spacing-lg);
    padding-left: var(--spacing-2xl);
}

.content li {
    margin-bottom: var(--spacing-xs);
}

.content blockquote {
    border-left: 4px solid var(--primary);
    background: var(--warm-gray-50);
    margin: var(--spacing-xl) 0;
    padding: var(--spacing-lg);
    font-style: italic;
    font-family: var(--font-ui);
    color: var(--warm-gray-700);
}

.content a {
    color: var(--primary-dark);
    text-decoration: underline;
    transition: color var(--transition-base);
}

.content a:hover {
    color: var(--primary);
}

/* Images in content */
.content img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--warm-gray-200);
    box-shadow: var(--shadow-sm);
    margin: var(--spacing-lg) 0;
}

@media (max-width: 900px) {
    .encyclopedia-hero {
        height: 40vh;
        min-height: 250px;
    }

    .hero-content {
        padding: var(--spacing-lg) var(--spacing-md);
        margin: 0 var(--spacing-sm);
        width: auto;
    }

    .hero-content h1 {
        font-size: 1.75rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        line-height: 1.2;
    }

    .main-container {
        grid-template-columns: 1fr; /* Stack everything */
    }

    .sidebar {
        display: none; /* Hide sidebar on mobile */
    }
}
