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

/* Hero Section */
.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: 3.5rem;
    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: 1.2rem;
    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: 320px 1fr;
    gap: var(--spacing-3xl);
}

/* No Sidebar Layout */
.main-container.no-sidebar {
    display: block;
    max-width: 1200px;
}

.intro-text {
    font-size: 1.2rem;
    line-height: 1.8;
    margin-bottom: var(--spacing-3xl);
    text-align: left;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.intro-text p:first-of-type::first-letter {
    font-family: var(--font-display);
    font-size: 4rem;
    float: left;
    line-height: 0.8;
    padding-right: var(--spacing-sm);
    color: var(--primary);
}

/* Encyclopedia Index Styles */
.encyclopedia-index {
    margin-top: var(--spacing-2xl);
}

.chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-xl);
}

.chapter-card {
    position: relative;
    /* background: var(--warm-gray-900); Removed to allow overlay to work */
    background: transparent;
    padding: var(--spacing-xl);
    text-decoration: none;
    color: var(--warm-gray-100);
    transition: all var(--transition-slow);
    border: 1px solid var(--primary-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    height: 100%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    overflow: hidden; /* Ensure image doesn't spill out */
    /* Art Deco Corner Cutout Effect */
    clip-path: polygon(
        10px 0, 100% 0,
        100% calc(100% - 10px), calc(100% - 10px) 100%,
        0 100%, 0 10px
    );
}

/* Background Image Container */
.card-bg-image {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    background-position: center;
    opacity: 0; /* Hidden by default */
    transition: opacity 0.5s ease, transform 6s ease; /* Smooth fade and slow zoom */
    z-index: 0;
    transform: scale(1.1);
}

/* Dark Overlay to ensure text readability */
.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--warm-gray-900);
    opacity: 1;
    transition: opacity 0.5s ease;
    z-index: 1;
}

/* Reveal on Hover */
.chapter-card:hover .card-bg-image {
    opacity: 0.8; /* Stronger reveal */
    transform: scale(1.0); /* Gentle zoom out effect */
}

.chapter-card:hover .card-overlay {
    opacity: 0.4; /* More transparent to show image */
}

/* Content needs to be above the background */
.card-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    flex: 1;
}

.card-border {
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    border: 1px solid var(--primary);
    opacity: 0.5;
    transition: all var(--transition-slow);
    pointer-events: none;
    z-index: 3;
    /* Inner border cutout */
    clip-path: polygon(
        10px 0, 100% 0,
        100% calc(100% - 10px), calc(100% - 10px) 100%,
        0 100%, 0 10px
    );
}

.chapter-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(212, 175, 55, 0.15); /* Gold glow */
    border-color: var(--primary);
    /* background: #222; Removed to let image show through */
}

.chapter-card:hover .card-border {
    opacity: 1;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border-width: 2px;
}

.chapter-badge {
    margin-bottom: var(--spacing-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid var(--primary-dark);
    padding: 0.5rem 1rem;
    background: rgba(0,0,0,0.3);
}

.chapter-badge .label {
    font-family: var(--font-ui);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--primary-light);
    margin-bottom: 0.2rem;
}

.chapter-badge .number {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--primary);
    line-height: 1;
    font-weight: 700;
}

.chapter-card h3 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    margin: var(--spacing-md) 0;
    color: var(--warm-gray-100);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.card-decoration {
    width: 60px;
    height: 3px;
    background: var(--primary);
    margin-top: auto;
    opacity: 0.7;
    position: relative;
}

.card-decoration::before,
.card-decoration::after {
    content: '';
    position: absolute;
    top: -4px;
    width: 6px;
    height: 6px;
    background: var(--primary);
    transform: rotate(45deg);
}

.card-decoration::before { left: -10px; }
.card-decoration::after { right: -10px; }

/* Sidebar Navigation */
.sidebar {
    position: -webkit-sticky;
    position: sticky;
    top: 6rem;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--warm-gray-200);
    overflow: hidden;
    max-height: calc(100vh - 7rem);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

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

.sidebar-title {
    padding: var(--spacing-xl);
    background: var(--gradient-primary);
    color: white;
    border-bottom: 1px solid var(--primary-dark);
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    flex-shrink: 0;
}

.sidebar-nav {
    overflow-y: auto;
    padding: var(--spacing-md) 0;
    list-style: none;
    margin: 0;
    flex: 1;
    min-height: 0;
}

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

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

.sidebar-nav a {
    display: block;
    padding: var(--spacing-md) var(--spacing-xl);
    color: var(--warm-gray-700);
    text-decoration: none;
    transition: all var(--transition-base);
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
}

.sidebar-nav a:hover {
    background: var(--warm-gray-50);
    color: var(--primary);
    padding-left: calc(var(--spacing-xl) + var(--spacing-sm));
}

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

/* Scrollbar styling for sidebar */
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: var(--warm-gray-50);
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--warm-gray-300);
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: var(--warm-gray-400);
}

/* Submenu styling */
.submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: var(--warm-gray-50);
}

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

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

.submenu a {
    padding-left: calc(var(--spacing-xl) + var(--spacing-md));
    font-size: 0.9rem;
    color: var(--warm-gray-600);
}

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

/* Encyclopedia Index Styles */
.encyclopedia-index {
    margin-top: var(--spacing-2xl);
}

.chapter-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.chapter-item {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--warm-gray-200);
}

.chapter-number {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-light);
    min-width: 3rem;
    margin-right: var(--spacing-md);
    text-align: right;
    opacity: 0.6;
}

.chapter-content {
    flex: 1;
}

.chapter-item h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
}

.chapter-item h3 a {
    color: var(--warm-gray-800);
    text-decoration: none;
    display: block;
    transition: color var(--transition-base);
}

.chapter-item h3 a:hover {
    color: var(--primary);
}

.chapter-sublist {
    margin: var(--spacing-xs) 0 0 0 !important;
    padding-left: 0 !important;
    list-style: none;
}

.chapter-sublist li {
    margin-bottom: 0;
    font-size: 0.9rem;
    padding-left: var(--spacing-md);
    border-left: 2px solid var(--warm-gray-200);
}

.chapter-sublist a {
    color: var(--warm-gray-600);
    text-decoration: none;
    display: block;
    padding: 2px 0;
}

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

/* Background Images */
.chapter-card.bg-1 .card-bg-image { background-image: url('/assets/images/card_bg_1.jpg'); }
.chapter-card.bg-2 .card-bg-image { background-image: url('/assets/images/card_bg_2.jpg'); }
.chapter-card.bg-3 .card-bg-image { background-image: url('/assets/images/card_bg_3.jpg'); }
.chapter-card.bg-4 .card-bg-image { background-image: url('/assets/images/card_bg_4.jpg'); }
.chapter-card.bg-5 .card-bg-image { background-image: url('/assets/images/card_bg_5.jpg'); }
.chapter-card.bg-6 .card-bg-image { background-image: url('/assets/images/card_bg_6.jpg'); }
.chapter-card.bg-7 .card-bg-image { background-image: url('/assets/images/card_bg_7.jpg'); }
.chapter-card.bg-8 .card-bg-image { background-image: url('/assets/images/card_bg_8.jpg'); }
.chapter-card.bg-9 .card-bg-image { background-image: url('/assets/images/card_bg_9.jpg'); }
.chapter-card.bg-10 .card-bg-image { background-image: url('/assets/images/card_bg_10.jpg'); }
