/* Islamic Content Website - Main Stylesheet */

/* Import elegant Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600;700;800;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Rouge+Script&display=swap');

/* CSS Custom Properties for Green and White Theme */
:root {
    --primary-green: #2d5016;
    --light-green: #4a7c59;
    --teal--green: #22392b;
    --accent-green: #6b8e23;
    --very-light-green: #f8fdf8;
    --black--green: #000000;
    --author-bg-green:#f0f8f0;
    --pure-white: #ffffff;
    --off-white: #f8f9fa;
    --beige-bg: #f5f5dc;
    --light-beige: #faf8f3;
    --text-dark: #2c3e50;
    --border-light: #e9ecef;
    --shadow-light: rgba(0, 0, 0, 0.1);

    --white--author--quranic: #ffffffed;
}

/* RTL Language Support - Fix spacing issues */
[dir="rtl"] {
    font-family: 'Times New Roman', serif !important;
}

[dir="rtl"] .nav-brand {
    margin-left: 2rem;
    margin-right: 0;
}

[dir="rtl"] .nav-item {
    margin-left: 1rem;
    margin-right: 0;
}

[dir="rtl"] .language-switcher {
    margin-inline-start: auto;
    margin-inline-end: 0;
}

[dir="rtl"] .mobile-menu-toggle {
    margin-inline-start: auto;
    margin-inline-end: 0;
}

/* Ensure consistent brand positioning in RTL */
[dir="rtl"] .brand-link {
    flex-direction: row; /* Keep icon and text in same order */
}

/* Fix dropdown positioning in RTL */
[dir="rtl"] .dropdown-menu {
    left: auto;
    right: 0;
}

/* Set Times New Roman for all text elements in RTL pages */
[dir="rtl"] * {
    font-family: 'Times New Roman', serif !important;
}

[dir="rtl"] .nav-website-name {
    font-family: 'Rouge Script', cursive !important;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}


body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--beige-bg);
}

/* Header Styles - Just background image */
.site-header {
    background-image: url('../assets/background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-bottom: 2px solid var(--primary-green);
    height: 120px;
    position: relative;
    z-index: 1; /* Lower z-index so icon can overlap */
}

.header-container {
    max-width: 1200px;
    height: 100%;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Navigation Styles with brand */
.main-navigation {
    background-color: var(--black--green);
    padding: 0.5rem 1rem;
    position: relative;
    overflow: visible; /* Allow icon to overflow */
    z-index: 5; /* Lower than icon but higher than header */
}

.nav-menu {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    list-style: none;
    padding: 0;
    gap: 0;
    height: 34px; /* Fixed height for one row */
    overflow: visible; /* Changed from hidden to visible to show icon */
    transition: height 0.3s ease;
}

/* Expandable nav - only when has-overflow class is added by JS */
/* Extra nav items are hidden by default, shown on hover */
.nav-menu.has-overflow {
    flex-wrap: nowrap;
    overflow: visible; /* Keep visible for icon */
}

/* Hide extra nav items when overflow is detected */
.nav-menu.has-overflow .nav-item.overflow-hidden {
    display: none;
    visibility: hidden; /* Extra hiding mechanism */
}

@media (min-width: 769px) {
    .main-navigation:hover .nav-menu.has-overflow {
        flex-wrap: wrap;
        height: auto; /* Allow natural height expansion */
        overflow: visible; /* Keep visible for icon */
    }
    
    .main-navigation:hover .nav-menu.has-overflow .nav-item.overflow-hidden {
        display: block;
        visibility: visible;
    }
}

.nav-brand {
    margin-right: 2rem;
    margin-left: 0;
    flex-shrink: 0;
    z-index: 1000; /* Very high z-index to overlap everything */
    align-self: flex-start; /* Keep at top when nav expands */
    position: relative; /* Needed for z-index to work */
    overflow: visible; /* Allow icon to overflow */
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    padding: 0.2rem 0.8rem;
    border-radius: 8px;
    height: 30px; /* Match adjusted nav-link height */
    overflow: visible; /* Allow icon to overflow */
}

.brand-link:hover {
    opacity: 0.9;
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-header-image {
    display: flex;
    align-items: center;
    position: relative;
    z-index: 1001; /* Higher than nav-brand */
    height: 50px; /* Reduced height for smaller nav */
    margin-top: -8px; /* Adjusted pull up for smaller nav */
}

.nav-header-icon {
    width: 90px; /* Reduced size to fit 34px nav height */
    height: 90px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    animation: iconGlow 3s ease-in-out infinite;
    transition: transform 0.3s ease;
    position: relative;
    z-index: 1002; /* Highest z-index to overlap everything */
}

.nav-header-icon:hover {
    transform: scale(1.1) rotate(5deg);
    animation: iconGlowHover 1.5s ease-in-out infinite;
}

/* Icon glow animation */
@keyframes iconGlow {
    0%, 100% {
        filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)) 
                drop-shadow(0 0 5px rgba(212, 175, 55, 0.3));
    }
    50% {
        filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4)) 
                drop-shadow(0 0 15px rgba(212, 175, 55, 0.6))
                drop-shadow(0 0 25px rgba(212, 175, 55, 0.4));
    }
}

/* Hover glow animation - faster and more intense */
@keyframes iconGlowHover {
    0%, 100% {
        filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4)) 
                drop-shadow(0 0 10px rgba(212, 175, 55, 0.5));
    }
    50% {
        filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5)) 
                drop-shadow(0 0 20px rgba(212, 175, 55, 0.8))
                drop-shadow(0 0 35px rgba(212, 175, 55, 0.6));
    }
}

.nav-website-name {
    color: var(--pure-white);
    font-size: 2.0rem;
    font-weight: 400;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 1.5px;
    font-family: 'Rouge Script', cursive;
    font-style: normal;
}

.nav-item {
    position: relative;
    margin-right: 1rem; /* Reduced from 2rem */
    flex-shrink: 0;
    align-self: flex-start; /* Keep items aligned to top */
}

.nav-link {
    color: var(--pure-white);
    text-decoration: none;
    padding: 0.4rem 1rem; /* Adjusted padding for 34px height */
    display: block;
    font-weight: 500;
    transition: background-color 0.3s ease;
    border-radius: 4px;
    margin: 2px 0;
    white-space: nowrap;
    height: 30px; /* Adjusted height to fit in 34px container */
    display: flex;
    align-items: center;
}

.nav-link:hover {
    background-color: var(--primary-green);
}

/* Mobile Hamburger Menu - Hidden on Desktop */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--pure-white);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0.5rem;
    margin-inline-start: auto; /* Works for both LTR and RTL */
    line-height: 1;
}

/* Language Switcher Styles */
.language-switcher {
    display: none; /* Hidden - using fixed-language-switcher instead */
    margin-inline-start: auto; /* Works for both LTR and RTL */
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    align-self: flex-start; /* Keep at top when nav expands */
    height: 50px; /* Match nav item height */
}

.language-option {
    color: var(--pure-white);
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 15px;
    transition: all 0.3s ease;
    cursor: pointer;
    background: none;
    border: 1px solid transparent;
}

.language-option:hover {
    background-color: var(--primary-green);
    border-color: var(--accent-green);
}

.language-option.active {
    background-color: var(--primary-green);
    border-color: var(--accent-green);
    font-weight: 600;
}

.language-separator {
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.8rem;
}

/* Fixed Language Switcher - Always Accessible */
.fixed-language-switcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
    background: linear-gradient(145deg, var(--primary-green), var(--light-green));
    padding: 12px 8px;
    border-radius: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 2px solid var(--accent-green);
}

.fixed-language-switcher .language-option {
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid transparent;
    color: var(--pure-white);
    cursor: pointer;
    transition: all 0.3s ease;
}

.fixed-language-switcher .language-option:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.fixed-language-switcher .language-option.active {
    background: var(--pure-white);
    color: var(--primary-green);
    border-color: var(--accent-green);
    font-weight: 700;
}

/* RTL positioning for fixed language switcher */
[dir="rtl"] .fixed-language-switcher {
    right: auto;
    left: 20px;
}

.mobile-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--black--green);
    border-top: 2px solid var(--primary-green);
    box-shadow: 0 4px 6px var(--shadow-light);
    z-index: 1000;
}

/* Mobile menu active state - only works on mobile */

.mobile-nav-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-nav-item:last-child {
    border-bottom: none;
}

.mobile-nav-link {
    color: var(--pure-white);
    text-decoration: none;
    padding: 1rem 1.5rem;
    display: block;
    font-weight: 500;
    transition: background-color 0.3s ease;
    cursor: pointer;
    position: relative;
}

.mobile-nav-link:hover {
    background-color: var(--primary-green);
}

.mobile-dropdown {
    background-color: rgba(0, 0, 0, 0.2);
    display: none; /* Hidden by default */
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.mobile-dropdown.active {
    display: block;
    max-height: 500px; /* Enough for dropdown items */
}

/* Add arrow indicator for items with dropdowns */
.mobile-nav-item.has-dropdown .mobile-nav-link::after {
    content: '▼';
    position: absolute;
    right: 1.5rem;
    font-size: 0.7rem;
    transition: transform 0.3s ease;
}

.mobile-nav-item.has-dropdown.active .mobile-nav-link::after {
    transform: rotate(180deg);
}

.mobile-dropdown-link {
    color: var(--pure-white);
    text-decoration: none;
    padding: 0.75rem 2.5rem;
    display: block;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
}

.mobile-dropdown-link:hover {
    background-color: var(--primary-green);
}

/* Mobile Language Switcher */
.mobile-language-switcher {
    display: none;
    padding: 1rem 1.5rem;
    background-color: rgba(255, 255, 255, 0.05);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-language-title {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mobile-language-options {
    display: flex;
    gap: 0.5rem;
}

.mobile-language-option {
    color: var(--pure-white);
    text-decoration: none;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 15px;
    transition: all 0.3s ease;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex: 1;
    text-align: center;
}

.mobile-language-option:hover {
    background-color: var(--primary-green);
    border-color: var(--accent-green);
}

.mobile-language-option.active {
    background-color: var(--primary-green);
    border-color: var(--accent-green);
    font-weight: 600;
}

/* Dropdown Menu Styles */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--black--green);
    border: 1px solid var(--primary-green);
    box-shadow: 0 4px 6px var(--shadow-light);
    list-style: none;
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
    border-radius: 4px;
}

.nav-item:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-link {
    color: var(--pure-white);
    text-decoration: none;
    padding: 0.75rem 1rem;
    display: block;
    transition: background-color 0.3s ease;
    border-radius: 4px;
    margin: 2px;
}

.dropdown-link:hover {
    background-color: var(--primary-green);
    color: var(--pure-white);
}

/* Main Content Layout */
.main-content {
    max-width: 1500px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.content-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
}

/* Main Body Section */
.main-body {
    background-color: var(--pure-white);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 4px var(--shadow-light);
}

/* Navigation Overview Section - Ancient/Medieval Style */
.navigation-overview {
    text-align: center;
    padding: 3rem 2rem;
    background: linear-gradient(135deg, var(--beige-bg) 0%, var(--light-beige) 100%);
    border-radius: 15px;
    border: 3px solid var(--accent-green);
    box-shadow: inset 0 0 20px rgba(45, 80, 22, 0.1);
}

.overview-title {
    font-size: 2.5rem;
    color: var(--primary-green);
    margin-bottom: 3rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    font-family: 'Times New Roman', serif;
}

.overview-title::before {
    content: '۞';
    position: absolute;
    left: -3rem;
    color: var(--accent-green);
    font-size: 2rem;
}

.overview-title::after {
    content: '۞';
    position: absolute;
    right: -3rem;
    color: var(--accent-green);
    font-size: 2rem;
}

/* Ancient Manuscript List Style */
.knowledge-index {
    max-width: 800px;
    margin: 0 auto;
    background-color: var(--pure-white);
    border: 2px solid var(--primary-green);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    position: relative;
}

.knowledge-index::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    background: linear-gradient(45deg, var(--accent-green), var(--primary-green), var(--accent-green));
    border-radius: 15px;
    z-index: -1;
}

.category-section {
    margin-bottom: 2.5rem;
    border-bottom: 2px dotted var(--accent-green);
    padding-bottom: 1.5rem;
}

.category-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.category-title {
    font-size: 1.6rem;
    color: var(--primary-green);
    margin-bottom: 1rem;
    font-weight: 600;
    text-align: left;
    position: relative;
    padding-left: 2rem;
    font-family: 'Times New Roman', serif;
}

.category-title::before {
    content: '◆';
    position: absolute;
    left: 0;
    color: var(--accent-green);
    font-size: 1.2rem;
    top: 0.2rem;
}

/* Ancient List Styling */
.subcategory-list {
    list-style: none;
    padding: 0;
    margin-left: 1rem;
}

.subcategory-item {
    margin-bottom: 0.8rem;
    position: relative;
    padding-left: 2rem;
}

.subcategory-item::before {
    content: '▸';
    position: absolute;
    left: 0.5rem;
    color: var(--accent-green);
    font-size: 1rem;
    top: 0.1rem;
}

.subcategory-link {
    color: var(--text-dark);
    text-decoration: none;
    font-size: 1.1rem;
    padding: 0.6rem 1rem;
    display: block;
    border-radius: 6px;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    background: linear-gradient(90deg, transparent 0%, var(--very-light-green) 2%, transparent 100%);
    font-family: 'Times New Roman', serif;
    position: relative;
    text-align: left;
}

.subcategory-link:hover {
    background: linear-gradient(90deg, var(--author-bg-green) 0%, var(--very-light-green) 50%, var(--author-bg-green) 100%);
    border-left-color: var(--primary-green);
    color: var(--primary-green);
    transform: translateX(8px);
    box-shadow: 2px 2px 8px rgba(45, 80, 22, 0.2);
}

/* Decorative Elements */
.knowledge-index::after {
    content: '';
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 30px;
    height: 30px;
    background: radial-gradient(circle, var(--accent-green) 30%, transparent 30%);
    background-size: 6px 6px;
    opacity: 0.3;
}

/* Latest Posts Sidebar */
.latest-posts-sidebar {
    background-color: var(--off-white);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px var(--shadow-light);
    height: fit-content;
}

.sidebar-title {
    color: var(--primary-green);
    font-size: 1.3rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--primary-green);
    padding-bottom: 0.5rem;
}

.latest-posts-list {
    list-style: none;
}

.latest-post-item {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.latest-post-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.latest-post-link {
    color: var(--primary-green);
    text-decoration: none;
    font-weight: 500;
    display: block;
    margin-bottom: 0.25rem;
    transition: color 0.3s ease;
}

.latest-post-link:hover {
    color: var(--accent-green);
    text-decoration: underline;
}

.post-date {
    font-size: 0.9rem;
    color: #666;
}

/* Footer */
.site-footer {
    background-color: var(--primary-green);
    color: var(--pure-white);
    text-align: center;
    padding: 1rem 0;
    margin-top: 3rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }
    
    .content-container {
        grid-template-columns: 1fr;
    }
    
    /* Fix mobile navigation overflow */
    .main-navigation {
        overflow: visible;
        padding: 0.5rem 0.5rem;
    }
    
    .nav-menu {
        height: 50px; /* Fixed smaller height on mobile */
        overflow: visible;
        width: 100%;
    }
    
    /* Hide desktop navigation items on mobile */
    .nav-item:not(.nav-brand) {
        display: none;
    }
    
    /* Hide language switcher on mobile, show in mobile menu instead */
    .language-switcher {
        display: none;
    }
    
    /* Show mobile language switcher */
    .mobile-language-switcher {
        display: block;
    }
    
    /* Show mobile hamburger menu */
    .mobile-menu-toggle {
        display: block;
    }
    
    /* Allow mobile menu to show when active */
    .mobile-menu.active {
        display: block;
    }
    
    .nav-brand {
        margin-right: 0;
        flex: 1;
    }
    
    .brand-link {
        padding: 0.3rem 0.3rem;
        gap: 0.8rem;
        height: 50px; /* Match nav-menu height */
        align-items: center; /* Center icon vertically */
    }
    
    .nav-header-image {
        height:50px; /* Match brand-link height */
        margin-top: 0;
        margin-bottom: 0;
        display: flex;
        align-items: center;
    }
    
    .nav-website-name {
        font-size: 2.0rem;
        letter-spacing: 0.3px;
    }
    
    .nav-header-icon {
        width: 50px;
        height: 50px;
    }
    
    .header-container {
        flex-direction: column;
        text-align: center;
    }
    
    /* Fix main content width */
    .main-content {
        padding: 0 0.5rem;
        margin: 1rem auto;
    }
    
    .main-body {
        padding: 1rem;
    }
    
    .navigation-overview {
        padding: 2rem 1rem;
    }
    
    .overview-title {
        font-size: 1.6rem;
        margin-bottom: 2rem;
    }
    
    .overview-title::before,
    .overview-title::after {
        display: none;
    }
    
    .knowledge-index {
        margin: 0;
        padding: 1rem;
    }
    
    .category-title {
        font-size: 1.3rem;
        padding-left: 1.5rem;
    }
    
    .subcategory-link {
        font-size: 1rem;
        padding: 0.5rem 0.8rem;
    }
}

/* Desktop-only styles - ensure desktop navigation works properly */
@media (min-width: 769px) {
    /* Ensure desktop navigation items are visible */
    .nav-item {
        display: block;
    }
    
    /* Hide mobile elements on desktop */
    .mobile-menu-toggle {
        display: none;
    }
    
    .mobile-menu {
        display: none !important;
    }
}