/* --- Global Reset & Variables --- */
:root {
    /* Light Mode Variables - Soft, Trustworthy Charity Colors */
    --bg-color: #f7f9fc;
    --text-color: #333333;
    --primary-color: #2ea3f2;
    /* Calming, trustworthy blue */
    --secondary-color: #4bc0c0;
    /* Soft teal for balance */
    --accent-color: #f07b3f;
    /* Warm orange to draw attention/emotion */
    --header-bg: rgba(255, 255, 255, 0.95);
    --card-bg: #ffffff;
    --footer-bg: #222b36;
    --footer-text: #e1e5ee;
    --border-color: #e2e8f0;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    /* enhanced drop shadow */
    --shadow-hover: 0 15px 40px rgba(0, 0, 0, 0.12);
    /* shadow on hover */
    --transition-speed: 0.4s;
    --values-gradient: linear-gradient(135deg, var(--accent-color) 0%, var(--secondary-color) 100%);
}

[data-theme="dark"] {
    /* Dark Mode Variables */
    --bg-color: #121826;
    --text-color: #e2e8f0;
    --primary-color: #3b82f6;
    /* slightly brighter for dark mode */
    --secondary-color: #2dd4bf;
    --accent-color: #fb923c;
    --header-bg: rgba(18, 24, 38, 0.95);
    --card-bg: #1e293b;
    --footer-bg: #0f172a;
    --footer-text: #94a3b8;
    --border-color: #334155;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 15px 40px rgba(0, 0, 0, 0.5);
    --values-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

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

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color var(--transition-speed), color var(--transition-speed);
    overflow-x: hidden;
    position: relative;
    /* For background animation positioning */
}

/* --- Global Background Animation --- */
#bg-animation-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    /* Changed from -1 to 0 so it sits above backgrounds but below content */
    overflow: hidden;
    pointer-events: none;
    /* Make unclickable */
}

.bg-shape {
    position: absolute;
    border-radius: 50%;
    /* Use the primary color variable but with very low opacity */
    background: radial-gradient(circle, var(--primary-color) 0%, transparent 70%);
    opacity: 0.15;
    /* We'll use JS to set explicit positions and animation delays/durations */
    animation: floatBackground linear infinite;
}

[data-theme="dark"] .bg-shape {
    opacity: 0.1;
    /* slightly dimmer in dark mode */
}

@keyframes floatBackground {
    0% {
        transform: translateY(100vh) scale(1) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 0.15;
    }

    90% {
        opacity: 0.15;
    }

    100% {
        transform: translateY(-20vh) scale(1.5) rotate(360deg);
        opacity: 0;
    }
}


a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    display: block;
}

/* --- Typography --- */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
}

h1 {
    font-size: 3rem;
}

h2 {
    font-size: 2.25rem;
}

h3 {
    font-size: 1.75rem;
}

p {
    margin-bottom: 1rem;
    font-size: 1.05rem;
}

.section-title {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
}

.section-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background: var(--accent-color);
    margin: 0.5rem auto 0;
    border-radius: 2px;
}

/* --- Layout --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    position: relative;
    z-index: 10;
}

section {
    padding: 5rem 0;
    position: relative;
    z-index: 1;
    /* Ensure sections sit above the global z-index 0 background effect */
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-speed);
    border: none;
    font-size: 1rem;
    box-shadow: var(--shadow);
}

.btn-primary {
    background-color: var(--primary-color);
    color: #fff;
}

.btn-primary:hover {
    background-color: #1c88d8;
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 10px 25px rgba(46, 163, 242, 0.4);
}

.btn-accent {
    background-color: var(--accent-color);
    color: #fff;
}

.btn-accent:hover {
    background-color: #d1642c;
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 10px 25px rgba(240, 123, 63, 0.4);
}

.btn-outline {
    background-color: transparent;
    color: var(--text-color);
    border: 2px solid var(--text-color);
}

.btn-outline:hover {
    background-color: var(--text-color);
    color: var(--bg-color);
    transform: translateY(-2px);
}

/* --- Header & Navigation --- */
header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background-color: transparent;
    transition: background-color var(--transition-speed), padding var(--transition-speed), box-shadow var(--transition-speed);
    padding: 1.5rem 0;
}

header.sticky {
    background-color: var(--header-bg);
    padding: 0.8rem 0;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo img {
    height: 160px;
    width: auto;
    object-fit: contain;
    transition: transform var(--transition-speed);
    mix-blend-mode: multiply;
    /* Removes white background on light surfaces */
}

.logo:hover img {
    transform: scale(1.05);
}

nav ul {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

nav a {
    font-weight: 500;
    font-size: 1rem;
    transition: color var(--transition-speed);
    position: relative;
    padding-bottom: 0.25rem;
}

nav a::before {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: var(--accent-color);
    transition: width var(--transition-speed);
}

nav a:hover::before,
nav a.active::before {
    width: 100%;
}

nav a:hover,
nav a.active {
    color: var(--accent-color);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.theme-toggle {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 1.25rem;
    cursor: pointer;
    transition: color var(--transition-speed), transform var(--transition-speed);
}

.theme-toggle:hover {
    color: var(--accent-color);
    transform: rotate(15deg);
}

.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-color);
    cursor: pointer;
}

/* --- Footer --- */
footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    padding: 4rem 0 2rem;
    margin-top: auto;
}

.footer-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.footer-col h3 {
    color: #fff;
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    position: relative;
    padding-bottom: 0.5rem;
}

.footer-col h3::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 30px;
    height: 2px;
    background: var(--primary-color);
}

.footer-col p {
    font-size: 0.9rem;
    color: var(--footer-text);
}

.footer-col ul li {
    margin-bottom: 0.75rem;
}

.footer-col ul a {
    color: var(--footer-text);
    transition: color var(--transition-speed), padding-left var(--transition-speed);
}

.footer-col ul a:hover {
    color: var(--primary-color);
    padding-left: 5px;
}

.social-icons {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.social-icons a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: #fff;
    transition: background-color var(--transition-speed), transform var(--transition-speed);
}

.social-icons a:hover {
    background-color: var(--primary-color);
    transform: translateY(-3px);
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.85rem;
}

/* --- Animations --- */
.fade-in {
    opacity: 0;
    transform: translateY(40px) scale(0.96);
    transition: opacity 0.8s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.fade-in.appear {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.delay-100 {
    transition-delay: 100ms;
}

.delay-200 {
    transition-delay: 200ms;
}

.delay-300 {
    transition-delay: 300ms;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .mobile-menu-btn {
        display: block;
    }

    nav ul {
        position: fixed;
        top: 0;
        right: -100%;
        width: 250px;
        height: 100vh;
        background-color: var(--card-bg);
        flex-direction: column;
        justify-content: center;
        gap: 2rem;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
        transition: right var(--transition-speed);
        padding: 2rem;
        z-index: 999;
    }

    nav ul.open {
        right: 0;
    }

    /* Fix RTL mobile menu stacking */
    [dir="rtl"] nav ul {
        flex-direction: column !important;
        align-items: center;
        /* or flex-start based on preference */
    }

    /* Fix programs page inline styles for tablet/mobile */
    .values-section,
    .programs-offer-section {
        padding: 1.5rem !important;
        text-align: center !important;
    }

    .values-section h2,
    .programs-offer-section h2 {
        font-size: 2rem !important;
        margin-left: auto;
        margin-right: auto;
    }

    .values-section p,
    .programs-offer-section p {
        font-size: 1rem !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .values-section>div {
        flex-direction: column;
        gap: 1.5rem !important;
    }

    .values-section>div>div {
        min-width: 100% !important;
    }
}

@media (max-width: 480px) {

    /* --- Mobile Typography --- */
    h1 {
        font-size: 2.2rem;
    }

    h2 {
        font-size: 1.8rem;
    }

    h3 {
        font-size: 1.4rem;
    }

    p {
        font-size: 0.95rem;
    }

    /* Fix oversized Farsi text on mobile */
    [dir="rtl"] h1 {
        font-size: 1.8rem;
        line-height: 1.4;
    }

    [dir="rtl"] h2 {
        font-size: 1.5rem;
        line-height: 1.4;
    }

    [dir="rtl"] h3 {
        font-size: 1.3rem;
    }

    .logo img {
        height: 80px;
        /* Prevent huge logo from pushing content */
    }

    .nav-actions {
        gap: 0.4rem;
    }

    .nav-actions .btn-accent {
        padding: 0.3rem 0.6rem !important;
        font-size: 0.8rem !important;
    }

    .lang-switcher {
        margin-right: 0.2rem;
    }

    [dir="rtl"] .lang-switcher {
        margin-left: 0.2rem;
        margin-right: 0;
    }

    .theme-toggle {
        font-size: 1rem;
    }

    .mobile-menu-btn {
        font-size: 1.25rem;
    }
}

/* --- Language Switcher --- */
.lang-switcher {
    position: relative;
    display: inline-block;
    margin-right: 1.5rem;
}

.lang-btn {
    background: none;
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--text-color);
    transition: all 0.3s ease;
    line-height: 1;
    min-width: 45px;
    justify-content: center;
}

.flag-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 50%;
}

.lang-btn:hover {
    border-color: var(--primary-color);
    background: rgba(46, 163, 242, 0.05);
}

.lang-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
    min-width: 60px;
    /* Reduced for flag-only */
    padding: 0.2rem 0;
    z-index: 1000;
    display: none;
    margin-top: 0.5rem;
    animation: fadeInDown 0.3s ease;
}

.lang-dropdown.active {
    display: block;
}

.lang-option {
    padding: 0.6rem;
    /* More compact */
    cursor: pointer;
    display: flex;
    justify-content: center;
    /* Center flags */
    align-items: center;
    transition: all 0.2s ease;
}

.lang-option:hover {
    background: rgba(46, 163, 242, 0.1);
    color: var(--primary-color);
}

.lang-option.active {
    color: var(--primary-color);
    background: rgba(46, 163, 242, 0.05);
}

/* --- RTL Support --- */
[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] body {
    font-family: 'Tahoma', 'Arial', sans-serif;
}

[dir="rtl"] .nav-container {
    flex-direction: row-reverse;
}

[dir="rtl"] nav ul {
    flex-direction: row-reverse;
}

[dir="rtl"] .nav-actions {
    flex-direction: row-reverse;
}

[dir="rtl"] .lang-switcher {
    margin-right: 0;
    margin-left: 1.5rem;
}

[dir="rtl"] .lang-dropdown {
    right: auto;
    left: 0;
}

[dir="rtl"] .footer-container {
    flex-direction: row-reverse;
}

[dir="rtl"] .footer-col {
    text-align: right;
}

[dir="rtl"] .hero-btns {
    justify-content: center;
    flex-direction: row-reverse;
}

[dir="rtl"] .mission-grid,
[dir="rtl"] .values-grid,
[dir="rtl"] .features,
[dir="rtl"] .projects-grid,
[dir="rtl"] .team-grid {
    direction: rtl;
}

[dir="rtl"] .feature-card,
[dir="rtl"] .value-card,
[dir="rtl"] .project-card-colored {
    text-align: right;
}

[dir="rtl"] .fa-chevron-right {
    transform: rotate(180deg);
}

[dir="rtl"] .fa-chevron-left {
    transform: rotate(180deg);
}

[dir="rtl"] .btn i {
    margin-left: 0.5rem;
    margin-right: 0;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}