/* ==========================================
   Enhanced Responsive Design
   Advanced breakpoints and mobile optimizations
   ========================================== */

/* ==========================================
   Enhanced Breakpoint System
   ========================================== */
/* 
    xs: 0-479px    (Small phones)
    sm: 480-767px  (Large phones)
    md: 768-1023px (Tablets)
    lg: 1024-1439px (Small laptops)
    xl: 1440px+    (Desktops)
*/

/* ==========================================
   Extra Small Devices (< 480px)
   ========================================== */
@media (max-width: 479px) {
    :root {
        --space-3xl: 3rem;
        --space-4xl: 4rem;
    }
    
    /* Typography adjustments */
    .hero-title {
        font-size: clamp(var(--text-3xl), 10vw, var(--text-4xl));
        line-height: 1.2;
    }
    
    .page-title {
        font-size: var(--text-3xl);
    }
    
    /* Navigation */
    .nav-inner {
        padding: var(--space-sm) var(--space-md);
    }
    
    .logo-text {
        font-size: var(--text-base);
    }
    
    /* Hero section */
    .hero-content {
        padding: var(--space-lg);
    }
    
    .hero-cta {
        flex-direction: column;
        width: 100%;
    }
    
    .hero-cta .btn {
        width: 100%;
    }
    
    /* Cards and grids */
    .features-grid,
    .philosophy-grid,
    .programs-grid,
    .team-grid {
        grid-template-columns: 1fr;
    }
    
    /* Forms */
    .form-container {
        padding: 0 var(--space-md);
    }
    
    .newsletter-form {
        flex-direction: column;
    }
    
    .newsletter-form input,
    .newsletter-form button {
        width: 100%;
    }
    
    /* Footer */
    .footer-content {
        gap: var(--space-lg);
    }
    
    .footer-links {
        flex-direction: column;
        align-items: center;
        gap: var(--space-sm);
    }
}

/* ==========================================
   Small Devices (480px - 767px)
   ========================================== */
@media (min-width: 480px) and (max-width: 767px) {
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .programs-grid {
        grid-template-columns: 1fr;
    }
    
    .team-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
    
    .values-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================
   Medium Devices - Tablets (768px - 1023px)
   ========================================== */
@media (min-width: 768px) and (max-width: 1023px) {
    .container {
        padding: 0 var(--space-xl);
    }
    
    /* Hero adjustments */
    .hero {
        min-height: 80vh;
    }
    
    /* Grid layouts */
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-xl);
    }
    
    .programs-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .philosophy-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .team-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .values-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Timeline */
    .timeline-item {
        padding-left: 80px;
        text-align: left;
    }
    
    .timeline-item:nth-child(even) {
        padding-left: 80px;
        padding-right: 0;
        text-align: left;
    }
    
    .timeline-marker {
        left: 20px;
    }
    
    .timeline::before {
        left: 20px;
    }
}

/* ==========================================
   Large Devices - Laptops (1024px - 1439px)
   ========================================== */
@media (min-width: 1024px) and (max-width: 1439px) {
    .container {
        max-width: 1100px;
    }
    
    .features-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .programs-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .team-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ==========================================
   Extra Large Devices (1440px+)
   ========================================== */
@media (min-width: 1440px) {
    .container {
        max-width: 1300px;
    }
    
    .hero {
        min-height: 100vh;
    }
    
    .programs-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .team-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ==========================================
   Touch Device Optimizations
   ========================================== */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    .btn {
        min-height: 48px;
        padding: var(--space-md) var(--space-xl);
    }
    
    .nav-links a {
        padding: var(--space-md) var(--space-sm);
    }
    
    .form-input,
    .form-textarea,
    .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 48px;
    }
    
    /* Remove hover effects */
    .feature-card:hover,
    .program-card:hover,
    .team-card:hover {
        transform: none;
    }
    
    /* Simplify animations on touch devices */
    * {
        animation-duration: 0.3s !important;
    }
}

/* ==========================================
   Landscape Mobile Optimization
   ========================================== */
@media (max-width: 767px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: var(--space-3xl) 0;
    }
    
    .page-header {
        padding: var(--space-2xl) 0 var(--space-xl);
    }
    
    .section {
        padding: var(--space-2xl) 0;
    }
}

/* ==========================================
   iPad Pro and Tablet Specific
   ========================================== */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    .hero {
        min-height: 70vh;
    }
    
    .programs-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) and (max-width: 1366px) and (orientation: landscape) {
    .container {
        max-width: 900px;
    }
}

/* ==========================================
   Mobile Navigation Enhancements
   ========================================== */
@media (max-width: 768px) {
    .nav-container {
        padding: 0;
    }
    
    /* .nav-inner {
        padding: var(--space-md) var(--space-lg);
    } */
    
    .nav-links {
        position: fixed;
        top: 73px;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--color-white);
        flex-direction: column;
        gap: 0;
        padding: var(--space-lg);
        transform: translateX(100%);
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition-base);
        overflow-y: auto;
        box-shadow: var(--shadow-lg);
    }
    
    body[dir="rtl"] .nav-links {
        transform: translateX(-100%);
    }
    
    .nav-links.active {
        transform: translateX(0);
        opacity: 1;
        visibility: visible;
    }
    
    .nav-links li {
        width: 100%;
        text-align: center;
        padding: var(--space-md) 0;
        border-bottom: 1px solid var(--color-light-gray);
        animation: slideInFromRight 0.3s ease-out forwards;
        opacity: 0;
    }
    
    .nav-links.active li {
        animation: slideInFromRight 0.3s ease-out forwards;
    }
    
    .nav-links.active li:nth-child(1) { animation-delay: 0.05s; }
    .nav-links.active li:nth-child(2) { animation-delay: 0.1s; }
    .nav-links.active li:nth-child(3) { animation-delay: 0.15s; }
    .nav-links.active li:nth-child(4) { animation-delay: 0.2s; }
    .nav-links.active li:nth-child(5) { animation-delay: 0.25s; }
    .nav-links.active li:nth-child(6) { animation-delay: 0.3s; }
    .nav-links.active li:nth-child(7) { animation-delay: 0.35s; }
    
    @keyframes slideInFromRight {
        from {
            opacity: 0;
            transform: translateX(30px);
        }
        to {
            opacity: 1;
            transform: translateX(0);
        }
    }
    
    body[dir="rtl"] .nav-links li {
        animation: slideInFromLeft 0.3s ease-out forwards;
    }
    
    @keyframes slideInFromLeft {
        from {
            opacity: 0;
            transform: translateX(-30px);
        }
        to {
            opacity: 1;
            transform: translateX(0);
        }
    }
    
    .nav-links a {
        font-size: var(--text-lg);
        display: block;
        width: 100%;
    }
    
    /* Overlay for mobile menu */
    .nav-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition-base);
        z-index: 998;
        backdrop-filter: blur(4px);
    }
    
    .nav-overlay.active {
        opacity: 1;
        visibility: visible;
    }
}

/* ==========================================
   Container Fluid Option
   ========================================== */
.container-fluid {
    max-width: 100%;
    padding: 0 var(--space-lg);
}

@media (min-width: 1920px) {
    .container-fluid {
        padding: 0 var(--space-3xl);
    }
}

/* ==========================================
   Grid System Enhancements
   ========================================== */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 calc(-1 * var(--space-md));
}

.col {
    flex: 1;
    padding: 0 var(--space-md);
}

.col-12 { flex: 0 0 100%; max-width: 100%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-4 { flex: 0 0 33.333%; max-width: 33.333%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }

@media (max-width: 767px) {
    .col,
    .col-12,
    .col-6,
    .col-4,
    .col-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ==========================================
   Utility Classes for Responsive
   ========================================== */
.hide-mobile {
    display: block;
}

.show-mobile {
    display: none;
}

@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
    
    .show-mobile {
        display: block !important;
    }
}

.hide-tablet {
    display: block;
}

@media (min-width: 768px) and (max-width: 1023px) {
    .hide-tablet {
        display: none !important;
    }
}

/* ==========================================
   Improved Spacing on Mobile
   ========================================== */
@media (max-width: 767px) {
    .section {
        padding: var(--space-2xl) 0;
    }
    
    .page-header {
        padding: calc(var(--space-3xl) + 80px) 0 var(--space-2xl);
    }
    
    /* Reduce margins and paddings */
    h1, h2, h3 {
        margin-bottom: var(--space-md);
    }
    
    p {
        margin-bottom: var(--space-md);
    }
    
    /* Better button spacing */
    .cta-buttons,
    .hero-cta {
        gap: var(--space-sm);
    }
    
    /* Form improvements */
    .form-group {
        margin-bottom: var(--space-md);
    }
}

/* ==========================================
   Performance: Reduce Animations on Low-End Devices
   ========================================== */
@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;
    }
}