/* Chapters Page Specific Styles */
.page-header {
    background-color: var(--secondary-bg);
    padding: 5rem 0;
    text-align: center;
    background-image: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('images/header.jpg');
    background-size: cover;
    background-position: center;
    position: relative;
}

.page-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(230, 57, 70, 0.1) 0%, rgba(18, 18, 18, 0.9) 70%);
}

.page-header h1 {
    position: relative;
    z-index: 1;
    font-size: 3rem;
    color: var(--text-color);
    text-shadow: 0 0 10px rgba(230, 57, 70, 0.7),
                 0 0 20px rgba(230, 57, 70, 0.5),
                 0 0 30px rgba(230, 57, 70, 0.3);
}

.chapters-section {
    padding: 5rem 5%;
    background-color: var(--primary-bg);
}

/* Search bar styles */
.chapters-search {
    display: flex;
    gap: 0.8rem;
    max-width: 800px;
    margin: 0 auto 1.5rem;
    align-items: center;
}

#chapter-search-input {
    flex: 1;
    padding: 0.8rem 1rem;
    background-color: var(--secondary-bg);
    color: var(--text-color);
    border: 1px solid rgba(76, 201, 240, 0.5);
    border-radius: 5px;
    font-family: var(--body-font);
    outline: none;
}

#chapter-search-input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 5px rgba(76, 201, 240, 0.5);
}

#chapter-search-button {
    padding: 0.8rem 1.2rem;
}
.chapters-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 0.8rem;
    max-width: 1400px;
    margin: 0 auto;
}

.chapters-section .chapter-card {
    background: linear-gradient(135deg, rgba(30, 30, 30, 0.9), rgba(18, 18, 18, 0.9));
    border: 1px solid rgba(76, 201, 240, 0.3);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.chapters-section .chapter-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(76, 201, 240, 0.1), transparent);
    transition: left 0.5s ease;
}

.chapters-section .chapter-card:hover::before {
    left: 100%;
}

.chapters-section .chapter-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0 15px rgba(76, 201, 240, 0.5);
    border-color: rgba(76, 201, 240, 0.5);
}

.chapters-section .chapter-number {
    font-family: var(--title-font);
    font-weight: 700;
    color: var(--accent-cyan);
    font-size: 1.1rem;
    margin: 0;
    z-index: 1;
    position: relative;
}

/* Chapter View Page Styles */
.chapter-view {
    padding: 3rem 5%;
    background-color: var(--primary-bg);
}

.chapter-header {
    background-color: var(--secondary-bg);
    padding: 5rem 0;
    text-align: center;
    background-image: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('images/header.jpg');
    background-size: cover;
    background-position: center;
    position: relative;
    margin-bottom: 3rem;
}

.chapter-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(244, 196, 48, 0.1) 0%, rgba(18, 18, 18, 0.9) 70%);
}

.chapter-title {
    position: relative;
    z-index: 1;
    font-size: 2.5rem;
    color: var(--accent-gold);
    text-shadow: 0 0 10px rgba(244, 196, 48, 0.7),
                 0 0 20px rgba(244, 196, 48, 0.5),
                 0 0 30px rgba(244, 196, 48, 0.3);
}

.chapter-content {
    max-width: 1000px;
    margin: 0 auto;
    background-color: var(--secondary-bg);
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
}

.panel {
    width: 100%;
    min-height: 600px;
    height: auto;
    background: linear-gradient(45deg, var(--secondary-bg), #2a2a2a);
    margin-bottom: 1rem;
    border-radius: 5px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
}

.panel img {
    width: 100%;
    height: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
    opacity: 1 !important;
    visibility: visible !important;
}

.panel::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, 
                rgba(76, 201, 240, 0.1) 0%, 
                rgba(18, 18, 18, 0) 50%,
                rgba(230, 57, 70, 0.1) 100%);
}

.chapter-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(76, 201, 240, 0.3);
}

.nav-button {
    display: inline-block;
    padding: 0.8rem 1.5rem;
    background-color: var(--secondary-bg);
    color: var(--text-color);
    border: 1px solid rgba(76, 201, 240, 0.5);
    border-radius: 5px;
    font-family: var(--title-font);
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-button:hover {
    background-color: var(--accent-cyan);
    color: var(--primary-bg);
    box-shadow: 0 0 10px rgba(76, 201, 240, 0.7);
}

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

.nav-button.disabled:hover {
    background-color: var(--secondary-bg);
    color: var(--text-color);
    box-shadow: none;
}

.chapter-select {
    padding: 0.8rem 1.5rem;
    background-color: var(--secondary-bg);
    color: var(--text-color);
    border: 1px solid rgba(76, 201, 240, 0.5);
    border-radius: 5px;
    font-family: var(--body-font);
    outline: none;
    cursor: pointer;
}

.chapter-select:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 5px rgba(76, 201, 240, 0.5);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .chapters-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.5rem;
    }
    
    .chapter-card {
        padding: 0.6rem;
        min-height: 60px;
    }
    
    .chapter-number {
        font-size: 0.9rem;
    }
    
    /* Hide "Chapter" text on mobile, show only numbers */
    .chapter-number::before {
        content: "Ch ";
        display: none;
    }
    
    .page-header h1 {
        font-size: 2rem;
    }
    
    .chapter-navigation {
        flex-direction: column;
        gap: 1rem;
    }
    
    .chapter-select {
        width: 100%;
    }
    
    /* Fix search bar layout on mobile */
    .chapters-search {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    #chapter-search-input {
        width: 100%;
        box-sizing: border-box;
    }
    #chapter-search-button {
        width: 100%;
        box-sizing: border-box;
        flex: none;
        min-height: 44px; /* ensure tappable target */
        padding: 0.9rem 1.2rem; /* add comfortable inner space */
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .chapters-grid {
        grid-template-columns: repeat(8, 1fr);
        gap: 0.6rem;
    }
    /* Prevent overlap between input and button on tablets */
    #chapter-search-button {
        flex-shrink: 0;
    }
}

@media (min-width: 1025px) {
    .chapters-grid {
        grid-template-columns: repeat(10, 1fr);
    }
}