/* CSS Variables from B's Architecture */
:root {
    --color-night-sky: #0f0f10;
    --color-text-cream: #fef7e6;
    --color-text-gold: #FFD966;
    --color-gold-light: #D4AF37;
    --color-gold-dark: #B8860B;
    --gradient-gold: linear-gradient(135deg, #FFD966, #D4AF37, #B8860B);
    --gradient-night: linear-gradient(135deg, #0f0f10 0%, #1a1a2e 100%);
    --glass-effect: rgba(255, 255, 255, 0.08);
    --backdrop-blur: blur(12px);
    --border-gold: 1px solid rgba(255, 217, 102, 0.3);
    --shadow-gold: 0 4px 20px rgba(255, 217, 102, 0.2);
    --shadow-night: 0 4px 20px rgba(0, 0, 0, 0.3);
    --radius-xl: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px; /* For fixed header */
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--color-text-cream);
    background: var(--color-night-sky);
    min-height: 100vh;
    background-image:
        radial-gradient(circle at 50% 50%, rgba(255, 217, 102, 0.1) 0%, transparent 70%),
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23FFD966' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    overflow-x: hidden;
    animation: gridPulse 20s ease-in-out infinite;
    user-select: none; /* Security protocol */
}

/* Re-enable selection for inputs and textareas */
input, textarea {
    user-select: auto;
}

@keyframes gridPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.98; }
}

/* Custom Scrollbar (A's Style) */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 217, 102, 0.05);
}

::-webkit-scrollbar-thumb {
    background: var(--gradient-gold);
    border-radius: 4px;
}

/* Selection Color */
::selection {
    background: rgba(255, 217, 102, 0.3);
    color: var(--color-text-cream);
}

/* Skip to Content */
.skip-to-content {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gradient-gold);
    color: var(--color-night);
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    z-index: 9999;
    transition: top 0.3s ease;
}

.skip-to-content:focus {
    top: 20px;
}

/* Glass Morphism (Enhanced) */
.glass {
    background: rgba(15, 15, 16, 0.7);
    backdrop-filter: var(--backdrop-blur);
    border: var(--border-gold);
    box-shadow: var(--shadow-night);
}

/* Navigation (Enhanced from A) */
.navbar {
    background: rgba(15, 15, 16, 0.95);
    backdrop-filter: var(--backdrop-blur);
    padding: 1rem 0;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1020;
    border-bottom: var(--border-gold);
    transition: all 0.3s ease;
}

.navbar.scrolled {
    padding: 0.75rem 0;
    background: rgba(15, 15, 16, 0.98);
}

.nav-link {
    position: relative;
    padding: 8px 0;
    color: var(--color-text-cream);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--gradient-gold);
    transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

.nav-link:hover,
.nav-link.active {
    color: var(--color-text-gold);
}

/* Mobile Menu (A's Style) */
.mobile-menu {
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.mobile-menu.open {
    transform: translateX(0);
}

/* Hero Section (Enhanced from A) */
.hero-bg {
    background: radial-gradient(ellipse at 50% 50%, rgba(255, 217, 102, 0.1) 0%, transparent 60%);
}

/* Category & Subcategory Cards (B's Architecture) */
.main-category {
    padding: 5rem 1rem;
    position: relative;
}

.main-category:nth-child(even) {
    background: var(--gradient-night);
}

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: var(--border-gold);
    flex-wrap: wrap;
    gap: 1rem;
}

.category-title {
    font-size: 2.5rem;
    font-weight: 800;
    background: var(--gradient-gold);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-family: 'Playfair Display', serif;
}

.category-count {
    color: var(--color-gold-light);
    font-size: 0.875rem;
    opacity: 0.8;
    font-weight: 500;
}

/* Badges (from B) */
.category-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 8px;
    margin-bottom: 8px;
}

.badge-spiritual {
    background: linear-gradient(135deg, #7C3AED, #8B5CF6);
    color: white;
}

.badge-prophets {
    background: linear-gradient(135deg, #DC2626, #EF4444);
    color: white;
}

.badge-history {
    background: linear-gradient(135deg, #D97706, #F59E0B);
    color: white;
}

.badge-islamic {
    background: linear-gradient(135deg, #059669, #10B981);
    color: white;
}

.badge-development {
    background: linear-gradient(135deg, #1E40AF, #3B82F6);
    color: white;
}

.badge-agriculture {
    background: linear-gradient(135deg, #065F46, #10B981);
    color: white;
}

/* Subcategories Grid (B's Layout) */
.subcategories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.subcategory-card {
    background: var(--glass-effect);
    backdrop-filter: var(--backdrop-blur);
    border-radius: var(--radius-xl);
    overflow: hidden;
    border: var(--border-gold);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.subcategory-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-gold);
    border-color: rgba(255, 217, 102, 0.5);
}

.subcategory-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    position: relative;
}

.subcategory-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, transparent 50%, rgba(15, 15, 16, 0.9) 100%);
}

.subcategory-content {
    padding: 1.5rem;
    position: relative;
    z-index: 1;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.subcategory-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-gold);
    margin-bottom: 0.5rem;
    font-family: 'Playfair Display', serif;
}

.subcategory-description {
    color: var(--color-text-cream);
    opacity: 0.8;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    flex-grow: 1;
    line-height: 1.6;
}

.subcategory-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--color-gold-light);
    font-size: 0.875rem;
    margin-top: auto;
}

/* Episodes Grid (B's Expandable System) */
.episodes-container {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease;
}

.episodes-container.expanded {
    max-height: 500px;
    overflow-y: auto;
}

.episodes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.episode-card {
    background: rgba(15, 15, 16, 0.6);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid rgba(255, 217, 102, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    min-height: 100px;
}

.episode-card:hover {
    border-color: rgba(255, 217, 102, 0.3);
    background: rgba(15, 15, 16, 0.8);
    transform: translateY(-2px);
}

.episode-number {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(255, 217, 102, 0.2);
    border-radius: 4px;
    color: var(--color-text-gold);
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    align-self: flex-start;
}

.episode-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text-cream);
    margin-bottom: 4px;
    line-height: 1.4;
}

.episode-duration {
    color: var(--color-gold-light);
    font-size: 0.75rem;
    opacity: 0.8;
    margin-top: auto;
}

/* Show More Button (B's Style) */
.show-more-btn {
    width: 100%;
    background: transparent;
    border: var(--border-gold);
    color: var(--color-text-gold);
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
}

.show-more-btn:hover {
    background: rgba(255, 217, 102, 0.1);
}

/* Search Bar (from B) */
.search-container {
    max-width: 600px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: none;
}

.search-input {
    width: 100%;
    padding: 1rem 1.5rem;
    background: var(--glass-effect);
    backdrop-filter: var(--backdrop-blur);
    border: var(--border-gold);
    border-radius: 50px;
    color: var(--color-text-cream);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 217, 102, 0.1);
}

.search-input::placeholder {
    color: var(--color-gold-light);
    opacity: 0.5;
}

/* Now Playing Bar (Enhanced from A) */
.now-playing-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 15, 16, 0.98);
    backdrop-filter: blur(20px);
    border-top: var(--border-gold);
    padding: 1rem;
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.now-playing-bar.active {
    transform: translateY(0);
}

/* Progress Bar (Enhanced) */
.progress-bar {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    width: 100%;
}

.progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-gold-light);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 217, 102, 0.5);
}

/* Volume Control */
.volume-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.volume-slider {
    width: 80px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-text-gold);
    cursor: pointer;
}

/* Notification (from B) */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--gradient-gold);
    color: var(--color-night);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    z-index: 9999;
    transform: translateX(150%);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-gold);
}

.notification.show {
    transform: translateX(0);
}

/* Loading Spinner */
.loading-spinner {
    display: none;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 217, 102, 0.3);
    border-radius: 50%;
    border-top-color: var(--color-text-gold);
    animation: spin 1s ease-in-out infinite;
    margin: 2rem auto;
}

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

/* Dynamic Content Styles */
.view-more {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.1), rgba(184, 134, 11, 0.05));
    border: 2px dashed rgba(255, 217, 102, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
}

.view-more:hover {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.2), rgba(184, 134, 11, 0.1));
    border-color: rgba(255, 217, 102, 0.5);
    transform: translateY(-2px);
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Modal Styles */
.fixed {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

/* Search Results Styles */
#searchResults {
    max-height: 400px;
    overflow-y: auto;
}

#searchResults::-webkit-scrollbar {
    width: 6px;
}

#searchResults::-webkit-scrollbar-track {
    background: rgba(255, 217, 102, 0.05);
}

#searchResults::-webkit-scrollbar-thumb {
    background: rgba(255, 217, 102, 0.2);
    border-radius: 3px;
}

/* Loading Animation for Dynamic Content */
.content-loading {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Responsive Typography */
@media (max-width: 768px) {
    .text-responsive {
        font-size: calc(1.5rem + 1vw);
    }
    
    .nav-container {
        padding: 0 1rem;
        flex-wrap: wrap;
    }
    
    .nav-links {
        gap: 1rem;
        flex-wrap: wrap;
        justify-content: center;
        margin-top: 0.5rem;
        width: 100%;
    }
    
    .nav-link {
        font-size: 0.9rem;
        padding: 0.5rem;
    }
    
    .hero h1 {
        font-size: 2.5rem;
    }
    
    .hero-subtitle {
        font-size: 1.1rem;
    }
    
    .subcategories-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .episodes-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .category-title {
        font-size: 1.75rem;
    }
    
    .now-playing-bar .container {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .subcategory-card:hover {
        transform: none;
    }
    
    .episode-card:hover {
        transform: none;
        border-color: rgba(255, 217, 102, 0.1);
    }
    
    /* Active states for touch */
    .subcategory-card:active {
        transform: scale(0.98);
        border-color: rgba(255, 217, 102, 0.5);
    }
    
    .episode-card:active {
        background: rgba(15, 15, 16, 0.8);
        border-color: rgba(255, 217, 102, 0.3);
    }
}

/* Print optimization */
@media print {
    body {
        background-image: none !important;
        animation: none !important;
        background: white !important;
        color: black !important;
    }
    
    .navbar, .hero, .featured-section, .main-category {
        background: white !important;
        color: black !important;
        border-color: #ccc !important;
    }
    
    .text-gradient, .hero h1, .stat-number, .category-title, .section-title {
        background: none !important;
        -webkit-text-fill-color: black !important;
        color: black !important;
    }
}
