:root {
    /* Light Theme (Nature/Day) - Default */
    --bg-color: #ffffff;
    --text-primary: #333333;
    --text-secondary: #555555;
    --accent-gold: #557c55;
    /* Olive Green */
    --card-bg: rgba(255, 255, 255, 0.95);
    --card-shadow: rgba(0, 0, 0, 0.1);
    --border-color: #e0e0e0;
    --slider-track: #e0e0e0;
    --slider-fill: #557c55;
    --nav-bg: rgba(255, 255, 255, 0.8);
}

[data-theme="dark"] {
    /* Dark Theme (Kiswah of Kaaba) */
    --bg-color: #000000;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --accent-gold: #90ee90;
    /* Green Accent */
    --card-bg: #121212;
    /* Solid background */
    --card-shadow: rgba(144, 238, 144, 0.1);
    --border-color: #444;
    --slider-track: #444;
    --slider-fill: #90ee90;
    --nav-bg: rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Amiri', serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.8;
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
    /* Light Mode Background Definition - White Kiswah */
    background-image: linear-gradient(rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.92)), url('../images/kiswah.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
}

[data-theme="dark"] body {
    /* Dark Mode Override */
    background-image: linear-gradient(rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.85)), url('../images/kiswah.png');
    background-size: cover;
    background-repeat: no-repeat;
}

/* --- UI Controls (Grouped) --- */
.controls-container {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    /* Align to left (LTR page usually, but RTL text) */
    z-index: 1000;
    display: flex;
    gap: 0.8rem;
    align-items: center;
    background: var(--nav-bg);
    padding: 0.5rem;
    border-radius: 30px;
    backdrop-filter: blur(5px);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px var(--card-shadow);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px var(--card-shadow);
}

.theme-toggle:hover {
    transform: scale(1.1);
    background: var(--accent-gold);
    color: var(--card-bg);
}

/* --- Serenity Mode --- */
.serenity-container {
    position: fixed;
    top: 5rem;
    /* Below theme toggle */
    left: 1.5rem;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

.serenity-container.hidden {
    display: none;
}

.serenity-toggle {
    background: var(--card-bg);
    border: 1px solid var(--accent-gold);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Reem Kufi', sans-serif;
    font-size: 0.9rem;
    box-shadow: 0 2px 10px var(--card-shadow);
    transition: all 0.3s ease;
}

.serenity-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--card-shadow);
    border-color: var(--text-primary);
}

.serenity-toggle.active {
    background: var(--accent-gold);
    color: var(--bg-color);
    border-color: var(--accent-gold);
}

.serenity-toggle .icon {
    font-size: 1.2rem;
}

/* --- Typography --- */
h1,
h2,
h3 {
    font-family: 'Aref Ruqaa', serif;
    font-weight: normal;
}

/* --- Loading Screen --- */
#loading-screen {
    position: fixed;
    inset: 0;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: opacity 0.8s ease;
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader-text {
    font-family: 'Aref Ruqaa', serif;
    font-size: 2.5rem;
    color: var(--accent-gold);
    margin-bottom: 1rem;
    opacity: 0;
    animation: fadeIn 2s ease forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* --- Layout --- */
main {
    position: relative;
    min-height: 100vh;
    margin-right: 0;
    transition: margin-right 0.3s;
}

@media (min-width: 768px) {
    main {
        margin-left: 80px;
        /* Space for desktop slider on Left */
    }
}

/* --- Intro Section --- */
.intro-section {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    scroll-snap-align: start;
}

.manuscript-border {
    border: 2px solid var(--accent-gold);
    padding: 4rem;
    border-radius: 4px;
    position: relative;
}

.manuscript-border::before {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1px solid var(--border-color);
}

.title {
    font-size: 5rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.subtitle {
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.scroll-instruction {
    margin-top: 3rem;
    color: var(--accent-gold);
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(10px);
    }
}

/* --- Age Slider (Nav) --- */
#age-nav {
    position: fixed;
    top: 0;
    left: 5rem;
    /* Increased from 2rem to prevent clipping */
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    /* Hide on mobile by default logic handling elsewhere, but let's style desktop first */
}

/* Mobile overwrites later, desktop default */
#age-nav .track {
    width: 6px;
    /* Increased from 4px */
    height: 80vh;
    background: var(--slider-track);
    position: relative;
    border-radius: 3px;
}

#age-nav .fill {
    width: 100%;
    background: var(--slider-fill);
    position: absolute;
    top: 0;
    left: 0;
    transition: height 0.1s linear;
}

#age-nav .handle {
    width: 24px;
    height: 24px;
    background: var(--bg-color);
    border: 2px solid var(--accent-gold);
    border-radius: 50%;
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: grab;
    box-shadow: 0 2px 5px var(--card-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Reem Kufi', sans-serif;
    font-size: 0.8rem;
    color: var(--text-primary);
}

#age-nav .markers {
    position: absolute;
    left: 20px;
    height: 80vh;
    width: 30px;
    /* Ensure space for markers */
    /* Removed flex space-between */
    color: var(--text-secondary);
    font-family: 'Reem Kufi', sans-serif;
    font-size: 0.9rem;
    pointer-events: none;

    /* Center aligning to match the track */
    top: 50%;
    transform: translateY(-50%);
}

/* Mobile Responsive Slider */
/* Mobile Responsive Slider */
@media (max-width: 768px) {
    #age-nav {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 70px;
        /* Taller touch area */
        background: var(--bg-color);
        border-top: 1px solid var(--border-color);
        padding: 0 1.5rem;
        display: flex;
        align-items: center;
        /* Center Vertically */
    }

    #age-nav .track {
        width: 100%;
        height: 12px;
        /* Much thicker track for easier tapping */
        border-radius: 6px;
    }

    #age-nav .handle {
        width: 32px;
        /* Larger Handle */
        height: 32px;
        box-shadow: 0 0 10px var(--card-shadow);
    }

    #age-nav .markers {
        display: none;
    }

    #age-nav .fill {
        height: 100%;
        right: 0;
        left: auto;
        border-radius: 6px;
    }

    /* On mobile, adjust main margin */
    main {
        margin-left: 0;
        margin-bottom: 80px;
        /* Space for bottom slider */
    }
}

/* --- Timeline Section --- */
.year-section {
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 0.3;
    transition: opacity 0.8s ease, transform 0.8s ease;
    border-right: 2px solid var(--border-color);
    margin-right: 20px;
    scroll-snap-align: center;
}

.year-section.active {
    opacity: 1;
    transform: scale(1.02);
}

.year-marker {
    font-family: 'Reem Kufi', sans-serif;
    font-size: 5rem;
    color: var(--border-color);
    position: absolute;
    right: -2.5rem;
    z-index: -1;
    opacity: 0.2;
    display: none;
    /* Hidden as requested */
}

.year-section.active .year-marker {
    color: var(--accent-gold);
    opacity: 0.15;
}

.phase-label {
    font-size: 0.9rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* --- Event Card --- */
.event-card {
    background: var(--card-bg);
    padding: 2.5rem;
    /* Increased padding */
    width: 100%;
    /* Full width of container */
    max-width: 800px;
    /* Larger on desktop (was 500px) */
    min-height: 350px;
    /* Fixed minimum height for consistency */
    box-shadow: 0 10px 30px var(--card-shadow);
    border-right: 6px solid var(--accent-gold);
    /* Thicker border */
    margin-bottom: 2rem;
    transform: translateY(30px);
    opacity: 1;
    transition: all 0.6s ease-out;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    /* Aligns content */
}

.event-title {
    font-size: 2.2rem;
    /* Larger title */
    margin-bottom: 1.2rem;
    color: var(--text-primary);
}

.event-summary {
    font-size: 1.3rem;
    /* Larger text */
    color: var(--text-secondary);
    line-height: 2;
    margin-bottom: auto;
    /* Pushes button to bottom */
    padding-bottom: 1.5rem;
}

.read-more-btn {
    background: none;
    border: none;
    color: var(--accent-gold);
    font-family: 'Amiri', serif;
    font-weight: bold;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    align-self: flex-end;
    /* Align button to the left (RTL end is Left) */
    position: relative;
    padding: 0.5rem 1rem;
    transition: transform 0.3s ease;
}

.read-more-btn::after {
    content: "←";
    transition: transform 0.3s ease;
}

.read-more-btn:hover {
    transform: translateX(-5px);
}

/* Mobile Responsive Event Card */
@media (max-width: 768px) {
    .event-card {
        padding: 1.5rem;
        max-width: 95%;
        /* Use full width on mobile */
        min-height: 250px;
        /* Slightly smaller for mobile but consistent */
    }

    .event-title {
        font-size: 1.6rem;
    }

    .event-summary {
        font-size: 1.1rem;
    }
}

/* --- Spiritual Elements --- */
.spiritual-quote {
    font-style: italic;
    color: var(--accent-gold);
    text-align: center;
    max-width: 600px;
    margin: 1rem 0;
    font-size: 1.2rem;
}

.arabic-text {
    font-family: 'Amiri', serif;
    font-size: 1.6rem;
    color: var(--text-primary);
    text-align: center;
    margin-top: 1.5rem;
    line-height: 2.2;
}

/* Age Lookup Widget Removed */

/* Resources Footer Removed */

/* --- Resources Toggle --- */
.resources-toggle {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    /* Top Right corner (opposite to theme toggle if RTL? No, theme toggle is left: 1.5rem) */
    /* Wait, RTL Left is Left physically. So Right is Right. */
    /* Let's put it next to theme toggle? Theme toggle is Left. */
    /* Let's put Resources Toggle on the RIGHT side for balance, or below theme toggle? */
    /* User said "Corner (next to theme toggle)". Theme toggle is fixed left: 1.5rem. */
    /* Serenity container is top: 5rem, left: 1.5rem. */
    /* Let's put this one at top: 1.5rem, left: 5rem (next to theme toggle horizontally). */
    left: 5rem;
    z-index: 1000;
    background: var(--card-bg);
    border: 1px solid var(--accent-gold);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px var(--card-shadow);
}

.resources-toggle:hover {
    transform: scale(1.1);
    background: var(--accent-gold);
    color: var(--card-bg);
}

/* --- Tree Toggle --- */
.tree-toggle {
    position: fixed;
    top: 1.5rem;
    left: 8.5rem;
    /* Next to resources toggle */
    z-index: 1000;
    background: var(--card-bg);
    border: 1px solid var(--accent-gold);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px var(--card-shadow);
}

.tree-toggle:hover {
    transform: scale(1.1);
    background: var(--accent-gold);
    color: var(--card-bg);
}

/* --- Modal --- */
/* --- Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid var(--accent-gold);
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.modal-overlay.open .modal-content {
    transform: translateY(0);
}

.close-modal {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    z-index: 10;
}

.modal-title {
    font-family: 'Aref Ruqaa', serif;
    color: var(--accent-gold);
    font-size: 2rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.modal-links {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-link-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: var(--text-primary);
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    font-family: 'Amiri', serif;
    font-size: 1.1rem;
}


/* --- Tree Lineage Styles --- */
.tree-content {
    max-height: 80vh;
    overflow-y: auto;
    /* Allow scrolling for long tree */
}

.prophetic-tree {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0;
}

.tree-node {
    background: var(--bg-color);
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    font-family: 'Amiri', serif;
    font-weight: bold;
    box-shadow: 0 2px 4px var(--card-shadow);
    color: var(--text-primary);
    width: fit-content;
    min-width: 120px;
}

.tree-line {
    color: var(--accent-gold);
    font-size: 0.8rem;
    opacity: 0.7;
}

.prophet-node {
    background: var(--accent-gold);
    color: var(--bg-color);
    border-color: var(--accent-gold);
    font-size: 1.2rem;
    padding: 1rem 2rem;
    margin-top: 0.5rem;
    box-shadow: 0 0 15px var(--accent-gold);
}

/* --- End of Styles --- */

/* --- Contact Card Styles --- */
.contact-info-container {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.contact-divider {
    width: 40px;
    height: 1px;
    background: var(--accent-gold);
    margin-bottom: 1rem;
    opacity: 0.3;
}

.contact-card {
    background: linear-gradient(145deg, var(--card-bg), rgba(85, 124, 85, 0.03));
    border: 1px solid rgba(85, 124, 85, 0.3);
    padding: 1.2rem 2rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
    min-width: 250px;
    max-width: 300px;
}

.contact-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    border-color: var(--accent-gold);
}

.contact-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-gold);
    opacity: 0.7;
}

.contact-role {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.contact-name {
    font-family: 'Aref Ruqaa', serif;
    font-size: 1.4rem;
    color: var(--accent-gold);
    margin: 0 0 0.6rem 0;
    font-weight: normal;
}

.contact-phone {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    text-decoration: none;
    color: var(--text-secondary);
    padding: 0.3rem 0.8rem;
    background: transparent;
    border-radius: 15px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    font-family: 'Amiri', serif;
    font-size: 0.95rem;
    direction: ltr;
    /* Ensure number displays correctly */
}

.contact-phone:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    background: rgba(85, 124, 85, 0.05);
}

.phone-icon {
    font-size: 1rem;
}

.phone-number {
    letter-spacing: 0.5px;
    font-weight: normal;
}