/* ===== RESPONSIVE DESIGN - MOBILE FIRST ===== */

/* ===== EXTRA LARGE SCREENS (1400px+) ===== */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
    
    .hero-title {
        font-size: 5rem;
    }
    
    .section-title {
        font-size: 3.5rem;
    }
}

/* ===== LARGE SCREENS (1200px - 1399px) ===== */
@media (max-width: 1199px) {
    .container {
        max-width: 960px;
    }
    
    .quick-links-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .partners-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===== MEDIUM SCREENS (992px - 1199px) ===== */
@media (max-width: 991px) {
    .container {
        max-width: 720px;
        padding: 0 1rem;
    }
    
    /* Navigation */
    .nav-menu {
        position: fixed;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--primary-white);
        box-shadow: var(--shadow-lg);
        padding: 2rem 1rem;
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition-normal);
        z-index: 999;
    }
    
    .nav-menu.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
    
    .nav-list {
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 2rem;
    }
    
    .nav-actions {
        justify-content: center;
    }
    
    .nav-toggle {
        display: flex;
    }
    
    .nav-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .nav-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    
    .nav-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }
    
    /* Hero Section */
    .hero-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .hero-stats {
        gap: 2rem;
    }
    
    /* Content Grids */
    .mission-content,
    .app-content {
        grid-template-columns: 1fr;
        gap: 3rem;
    }
    
    .app-content .app-mockup {
        order: -1;
    }
    
    /* Footer */
    .footer-content {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }
    
    .footer-brand {
        grid-column: 1 / -1;
    }
}

/* ===== SMALL SCREENS (768px - 991px) ===== */
@media (max-width: 767px) {
    .container {
        max-width: 540px;
    }
    
    /* Typography */
    h1 {
        font-size: 2.5rem;
    }
    
    h2 {
        font-size: 2rem;
    }
    
    h3 {
        font-size: 1.5rem;
    }
    
    .lead {
        font-size: 1.125rem;
    }
    
    /* Sections */
    .section {
        padding: 4rem 0;
    }
    
    .section-header {
        margin-bottom: 3rem;
    }
    
    /* Hero */
    .hero {
        min-height: 80vh;
    }
    
    .hero-title {
        font-size: 2.5rem;
        margin-bottom: 1rem;
    }
    
    .hero-subtitle {
        font-size: 1.125rem;
        margin-bottom: 2rem;
    }
    
    .hero-stats {
        gap: 1.5rem;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    /* Quick Links */
    .quick-links {
        padding: 4rem 0;
    }
    
    .quick-links-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .quick-link-card {
        padding: 2rem 1.5rem;
    }
    
    .card-icon {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
    
    /* Mission */
    .mission-statement {
        font-size: 1.25rem;
    }
    
    .mission-pillars {
        gap: 1rem;
    }
    
    .pillar {
        padding: 1rem;
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    
    /* App Download */
    .download-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    /* Partners */
    .partners {
        padding: 4rem 0;
    }
    
    .partners-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .partner-logo {
        padding: 0.75rem;
    }
    
    .partner-logo img {
        max-width: 100px;
        max-height: 50px;
    }
    
    /* Newsletter */
    .newsletter {
        padding: 3rem 0;
    }
    
    .form-group {
        flex-direction: column;
    }
    
    /* Footer */
    .footer {
        padding: 2rem 0 1rem;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }
    
    .footer-bottom-content {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .footer-legal {
        justify-content: center;
    }
    
    /* Page Header */
    .page-header {
        padding: 6rem 0 3rem;
    }
}

/* ===== EXTRA SMALL SCREENS (576px - 767px) ===== */
@media (max-width: 575px) {
    .container {
        padding: 0 0.75rem;
    }
    
    /* Navigation */
    .navbar {
        padding: 0.75rem 0;
    }
    
    .brand-text {
        font-size: 1.125rem;
    }
    
    .logo {
        height: 32px;
    }
    
    /* Buttons */
    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.875rem;
    }
    
    .btn-large {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
    
    /* Hero */
    .hero-title {
        font-size: 2rem;
        line-height: 1.2;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .hero-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    .hero-stats {
        flex-direction: column;
        gap: 1rem;
    }
    
    .stat {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 1rem;
    }
    
    .stat-number {
        font-size: 1.75rem;
        margin-bottom: 0;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    /* Cards */
    .quick-link-card {
        padding: 1.5rem 1rem;
    }
    
    .card-icon {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }
    
    /* Mission */
    .mission-statement {
        font-size: 1.125rem;
    }
    
    .pillar {
        padding: 0.75rem;
    }
    
    .pillar i {
        font-size: 1.25rem;
    }
    
    /* Partners */
    .partners-grid {
        grid-template-columns: 1fr;
    }
    
    /* Newsletter */
    .newsletter-input {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Footer */
    .social-links {
        justify-content: center;
    }
    
    .social-link {
        width: 36px;
        height: 36px;
        font-size: 0.875rem;
    }
    
    .footer-legal {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ===== ULTRA SMALL SCREENS (320px - 575px) ===== */
@media (max-width: 479px) {
    /* Partners - small phones */
    .partners-grid { grid-template-columns: 1fr; }
    .partners .partner-logo { padding: 0.75rem; }
    .partners .partner-image { height: 72px; display: flex; align-items: center; justify-content: center; }
    .partners .partner-image img { max-height: 72px; width: auto; max-width: 100%; object-fit: contain; }
    .partners .partner-name { font-size: 0.95rem; margin-top: 0.5rem; text-align: center; }
    /* Typography */
    .hero-title {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.75rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    /* Spacing */
    .section {
        padding: 3rem 0;
    }
    
    .section-header {
        margin-bottom: 2rem;
    }
    
    /* Hero */
    .hero {
        min-height: 70vh;
    }
    
    .hero-content {
        padding: 1rem 0;
    }
    
    /* Cards */
    .quick-link-card {
        padding: 1.25rem 0.75rem;
    }
    
    /* Mission */
    .pillar {
        padding: 0.5rem;
    }
    
    /* Newsletter */
    .newsletter {
        padding: 2rem 0;
    }
    
    /* Page Header */
    .page-header {
        padding: 5rem 0 2rem;
    }
}

/* ===== LANDSCAPE ORIENTATION ===== */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: 100vh;
        padding: 2rem 0;
    }
    
    .hero-content {
        padding: 1rem 0;
    }
    
    .hero-title {
        font-size: 2rem;
        margin-bottom: 0.5rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
        margin-bottom: 1rem;
    }
    
    .hero-actions {
        margin-bottom: 1rem;
    }
    
    .hero-stats {
        gap: 1rem;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
}

/* ===== HIGH DPI DISPLAYS ===== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .hero-background img,
    .mission-image,
    .app-mockup,
    .partner-logo img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .hero-background video {
        animation: none;
    }
    
    .loading::after {
        animation: none;
    }
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #f8fafc;
        --text-secondary: #cbd5e1;
        --text-light: #94a3b8;
        --background-light: #1e293b;
        --background-gray: #0f172a;
        --border-light: #334155;
        --border-medium: #475569;
    }
    
    .header {
        background: rgba(15, 23, 42, 0.95);
        border-bottom-color: var(--border-light);
    }
    
    .quick-link-card,
    .pillar,
    .feature,
    .partner-logo {
        background: var(--background-light);
        border-color: var(--border-light);
    }
    
    .newsletter-input {
        background: var(--background-light);
        color: var(--text-primary);
        border: 1px solid var(--border-light);
    }
    
    .language-select {
        background: var(--background-light);
        color: var(--text-primary);
        border-color: var(--border-light);
    }
    
    /* Ensure text visibility in dark mode for all sections */
    .member-info h3,
    .member-info h4,
    .advisor-info h4,
    .director-info h4,
    .representative-info h4 {
        color: #f87171 !important; /* Light red for dark mode */
    }
    
    .member-title,
    .advisor-expertise,
    .director-position,
    .representative-country {
        color: #a78bfa !important; /* Light purple for dark mode */
    }
    
    .member-org,
    .advisor-org,
    .director-expertise,
    .representative-focus {
        color: #cbd5e1 !important; /* Light gray for dark mode */
    }
}

/* Language Switcher Styles */
.language-switcher {
    margin-left: 20px;
}

.language-select {
    background: var(--color-white);
    border: 2px solid var(--color-primary);
    border-radius: 25px;
    padding: 8px 15px;
    font-size: 0.9rem;
    color: var(--color-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

.language-select:hover,
.language-select:focus {
    background: var(--color-primary);
    color: var(--color-white);
    box-shadow: 0 5px 15px rgba(114, 47, 55, 0.3);
}

.language-select option {
    background: var(--color-white);
    color: var(--color-primary);
    padding: 10px;
}

/* Responsive Language Switcher */
@media (max-width: 768px) {
    .language-switcher {
        margin: 10px 0;
        text-align: center;
    }
    
    .language-select {
        width: 100%;
        max-width: 200px;
    }
}

/* SEO and Performance Optimizations */
.lazy-load {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lazy-load.loaded {
    opacity: 1;
}

/* WebP Support */
.webp-supported .hero {
    background-image: url('../images/hero-bg.webp');
}

.no-webp .hero {
    background-image: url('../images/hero-bg.jpg');
}

/* Critical CSS for above-the-fold content */
.critical-content {
    display: block;
    visibility: visible;
}

.non-critical-content {
    display: none;
}

.non-critical-content.loaded {
    display: block;
}

/* Preload animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease;
}

.animate-on-scroll.animated {
    opacity: 1;
    transform: translateY(0);
}

/* Performance optimizations */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .animate-on-scroll,
    .lazy-load {
        transition: none;
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .card {
        border: 2px solid var(--color-text);
    }
}

/* Focus improvements for keyboard navigation */
.language-select:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

/* Print optimizations */
@media print {
    .language-switcher,
    .mobile-menu-toggle,
    .btn-donate {
        display: none !important;
    }
    
    .hero {
        background: none !important;
        color: black !important;
    }
    
    .hero-title {
        color: black !important;
    }

    @page {
        margin: 1in;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    .section {
        padding: 1rem 0;
        break-inside: avoid;
    }
    
    .quick-links-grid,
    .partners-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .mission-content,
    .app-content {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .hero {
        min-height: auto;
        padding: 2rem 0;
    }
    
    .hero-title {
        font-size: 2rem;
        color: var(--text-primary) !important;
    }
    
    .hero-subtitle {
        color: var(--text-secondary) !important;
    }
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
@media (max-width: 767px) {
    /* Larger touch targets for mobile */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .nav-link {
        padding: 0.75rem 0;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .social-link {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Better spacing for readability */
    p {
        line-height: 1.7;
    }
    
    .pillar {
        min-height: 60px;
    }
    
    /* Hero Banners Responsive */
    .hero-banners {
        height: 50vh;
        min-height: 400px;
    }
    
    .banner-content h2 {
        font-size: clamp(1.75rem, 4vw, 2.5rem);
    }
    
    .banner-content p {
        font-size: clamp(1rem, 2vw, 1.125rem);
    }
    
    .banner-arrow {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .banner-prev {
        left: 15px;
    }
    
    .banner-next {
        right: 15px;
    }
    
    .banner-nav {
        bottom: 20px;
    }
    
    .banner-dot {
        width: 10px;
        height: 10px;
    }
}

/* ===== CONTAINER QUERIES (Future-proofing) ===== */
@supports (container-type: inline-size) {
    .quick-links {
        container-type: inline-size;
    }
    
    @container (max-width: 600px) {
        .quick-links-grid {
            grid-template-columns: 1fr;
        }
    }
    
    .partners {
        container-type: inline-size;
    }
    
    @container (max-width: 800px) {
        .partners-grid {
            grid-template-columns: repeat(2, 1fr);
        }
    }

    @container (max-width: 400px) {
        .partners-grid {
            grid-template-columns: 1fr;
        }
    }
}

/* ===== VERY SMALL MOBILE OPTIMIZATIONS (<= 400px) ===== */
@media (max-width: 400px) {
    html { font-size: 15px; }
    body { line-height: 1.6; }

    .container { padding: 0 0.5rem; }

    /* Header & Navigation */
    .brand-text { display: none; }
    .logo { height: 28px; }
    .navbar { padding: 0.5rem 0; }
    .nav-menu { padding: 1rem; }
    .nav-list { gap: 0.75rem; }
    .nav-actions { margin-top: 0.5rem; }
    .language-select { width: 100%; max-width: none; }

    /* Hero */
    .hero { min-height: 65vh; }
    .hero-content { padding: 0.75rem 0; }
    .hero-title { font-size: 1.6rem; }
    .hero-subtitle { font-size: 0.95rem; }
    .hero-actions .btn { padding: 0.625rem 1rem; }
    .hero-background .hero-video { display: none; }

    /* Sections & Spacing */
    .section { padding: 2.5rem 0; }
    .section-header { margin-bottom: 1.5rem; }
    .section-title { font-size: 2rem; }
    .section-subtitle { font-size: 0.95rem; }

    /* Cards & Grids */
    .quick-links-grid { gap: 1rem; }
    .quick-link-card { padding: 1rem; }
    .partners-grid { grid-template-columns: 1fr; gap: 0.75rem; }
    .partners .partner-image { height: 80px; }
    .partners .partner-image img { max-height: 80px; }
    .media-grid { grid-template-columns: 1fr !important; }
    .media-card { margin-bottom: 1rem; }

    /* Forms */
    .form-group { flex-direction: column; gap: 0.5rem; }
    .newsletter-input { width: 100%; }

    /* Footer */
    .footer-content { gap: 1rem; }
    .footer-bottom-content { gap: 0.5rem; }
}