/* ============================================
   RESPONSIVE STYLES - Vision Global School
   Mobile-First Responsive Design
   Breakpoints: 320px → 480px → 768px → 1024px → 1200px → 1440px → 1920px+
   ============================================ */

/* ========== BASE / MOBILE FIRST (320px+) ========== */
/* All base styles are mobile-first by default */

/* ========== SMALL PHONES (320px - 480px) ========== */
@media (max-width: 480px) {
    :root {
        --container-padding: 1rem;
        --section-padding: 2rem 0;
    }

    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Ultra-compact header for very small screens */
    .header-logo .school-name {
        font-size: 0.95rem;
        white-space: nowrap;
    }

    .header-logo .affiliation-text {
        font-size: 0.6rem;
        white-space: nowrap;
    }

    .header-logo img {
        height: 30px;
    }

    /* Stack all grids */
    .grid-2,
    .grid-3,
    .grid-4,
    .academics-grid,
    .features-grid,
    .campus-grid,
    .testimonials-grid,
    .achievements-grid {
        grid-template-columns: 1fr;
        gap: var(--space-lg);
    }

    /* Compact buttons */
    .btn {
        width: 100%;
        padding: var(--space-sm) var(--space-md);
        font-size: var(--font-size-sm);
    }

    .btn-lg {
        padding: var(--space-md) var(--space-lg);
    }

    /* Reduce hero height on very small screens */
    .hero-section {
        min-height: 500px;
        height: 70vh;
    }

    /* Smaller feature icons */
    .feature-icon,
    .academic-icon {
        width: 60px;
        height: 60px;
        font-size: var(--font-size-2xl);
    }
}

/* ========== LARGE PHONES (481px - 767px) ========== */
@media (min-width: 481px) and (max-width: 767px) {
    .container {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    /* Slightly larger header */
    .header-logo img {
        height: 36px;
    }

    .header-logo .school-name {
        font-size: 1.25rem;
        white-space: nowrap;
    }

    .header-logo .affiliation-text {
        font-size: 0.7rem;
        white-space: nowrap;
    }

    /* Still single column but with more breathing room */
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
        gap: var(--space-xl);
    }

    .hero-section {
        height: 75vh;
        min-height: 550px;
    }

    /* Reduce spacing for large phones */
    :root {
        --section-padding: 2.5rem 0;
    }
}

/* ========== TABLETS PORTRAIT (768px - 1023px) ========== */
@media (min-width: 768px) and (max-width: 1023px) {
    :root {
        --container-padding: 2rem;
        --section-padding: 3.5rem 0;
    }

    .container {
        max-width: 720px;
        padding-left: 2rem;
        padding-right: 2rem;
    }

    /* 2-column layouts for tablets */
    .grid-2,
    .grid-3,
    .grid-4,
    .academics-grid,
    .features-grid,
    .campus-grid,
    .testimonials-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-2xl);
    }

    .achievements-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-xl);
    }

    /* About content side-by-side on tablet */
    .about-content {
        grid-template-columns: 1fr;
        gap: var(--space-3xl);
    }

    .hero-section {
        height: 80vh;
        min-height: 600px;
    }

    /* Tablet-optimized buttons */
    .btn {
        width: auto;
        min-width: 180px;
    }

    .hero-buttons,
    .cta-buttons {
        flex-direction: row;
        gap: var(--space-lg);
    }
}

/* ========== TABLETS LANDSCAPE (1024px - 1199px) ========== */
@media (min-width: 1024px) and (max-width: 1199px) {
    .container {
        max-width: 960px;
    }

    /* 3-column layouts */
    .grid-3,
    .academics-grid,
    .features-grid,
    .testimonials-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .grid-4,
    .achievements-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .campus-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Side-by-side about content */
    .about-content {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-4xl);
    }

    .hero-section {
        height: 90vh;
        min-height: 650px;
    }
}

/* ========== LAPTOPS (1200px - 1439px) ========== */
@media (min-width: 1200px) and (max-width: 1439px) {
    .container {
        max-width: 1140px;
    }

    /* Full 3-4 column layouts */
    .academics-grid,
    .features-grid,
    .testimonials-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-3xl);
    }

    .achievements-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .campus-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .hero-section {
        height: 100vh;
        min-height: 700px;
    }
}

/* ========== DESKTOP (1440px - 1919px) ========== */
@media (min-width: 1440px) and (max-width: 1919px) {
    .container {
        max-width: 1320px;
    }

    /* Optimal spacing for large screens */
    .academics-grid,
    .features-grid {
        gap: var(--space-4xl);
    }

    .campus-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-2xl);
    }
}

/* ========== ULTRA-WIDE (1920px+) ========== */
@media (min-width: 1920px) {
    .container {
        max-width: 1600px;
    }

    /* Prevent excessive stretching on ultra-wide */
    .hero-content {
        max-width: 1000px;
    }

    .section-heading p {
        max-width: 800px;
    }

    /* 4-column layouts for ultra-wide */
    .campus-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ========== MOBILE & TABLET (max-width: 1023px) ========== */

/* ========== DESKTOP (992px - 1399px) ========== */
@media (max-width: 1399px) {
    :root {
        --font-size-6xl: 3.5rem;
        --font-size-7xl: 4rem;
    }
}

/* ========== MOBILE & TABLET (max-width: 1023px) ========== */
@media (max-width: 1023px) {

    /* Mobile Navigation */
    .nav-menu {
        position: fixed;
        top: 72px;
        /* Below fixed header */
        left: -100%;
        width: 100%;
        height: calc(100vh - 72px);
        background-color: var(--color-bg-white);
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        padding: var(--space-3xl) var(--space-xl);
        gap: var(--space-md);
        box-shadow: var(--shadow-xl);
        transition: left 0.3s ease-in-out;
        z-index: var(--z-dropdown);
        overflow-y: auto;
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-menu a {
        padding: var(--space-md) 0;
        font-size: var(--font-size-lg);
        border-bottom: 1px solid var(--color-bg-light);
        text-align: left;
    }

    .nav-menu a::after {
        display: none;
    }

    .menu-toggle {
        display: flex;
    }

    /* Header adjustments */
    .header .container {
        padding-top: 6px;
        padding-bottom: 6px;
    }

    /* Footer responsive */
    .footer {
        padding: var(--space-3xl) 0 0 !important;
    }

    .footer-content {
        grid-template-columns: 1fr;
        /* Single column on tablet */
        gap: var(--space-xl);
        text-align: center;
    }

    /* Cards and components */
    .card-body {
        padding: var(--space-lg);
    }

    .feature-card {
        padding: var(--space-xl);
    }

    /* Section headings */
    .section-heading {
        margin-bottom: var(--space-2xl);
    }

    /* Touch-friendly interactions */
    .btn,
    .social-link,
    .nav-menu a {
        min-height: 44px;
        min-width: 44px;
    }

    /* Disable hover effects on touch devices */
    .card:hover {
        transform: none;
    }

    .feature-card:hover {
        transform: none;
    }

    /* Add active states instead */
    .card:active,
    .feature-card:active {
        transform: scale(0.98);
    }
}

/* ========== MOBILE ONLY (max-width: 767px) ========== */
@media (max-width: 767px) {

    /* Typography adjustments */
    :root {
        --section-padding: 2.5rem 0;
        --section-padding-sm: 1.5rem 0;
        --container-padding: 1rem;
    }

    /* Header */
    .header-logo .school-name {
        font-size: 1.125rem;
        white-space: nowrap;
    }

    .header-logo .affiliation-text {
        font-size: 0.65rem;
        white-space: nowrap;
    }

    .header-logo img {
        height: 34px;
    }

    /* Footer single column */
    .footer-content {
        grid-template-columns: 1fr;
        gap: var(--space-2xl);
        text-align: center;
    }

    .footer-about {
        grid-column: 1;
    }

    .footer-links,
    .footer-contact-item {
        justify-content: center;
    }

    .social-links {
        justify-content: center;
    }

    /* Full-width buttons */
    .btn {
        width: 100%;
        justify-content: center;
    }

    .hero-buttons,
    .cta-buttons {
        flex-direction: column;
        gap: var(--space-md);
        width: 100%;
    }

    /* Section headings */
    .section-heading h2 {
        font-size: var(--font-size-3xl);
    }

    .section-heading p {
        font-size: var(--font-size-base);
    }

    /* Compact spacing */
    section {
        padding: var(--section-padding);
    }

    section.section-sm {
        padding: var(--section-padding-sm);
    }

    /* Fixed Button Stacking on Mobile */
    .sticky-cta {
        bottom: 1rem !important;
        right: 1rem !important;
    }

    .back-to-top {
        bottom: 5.5rem !important;
        /* Move above sticky CTA */
        right: 1rem !important;
    }

    /* Stat Badge Fix */
    .image-badge {
        position: relative !important;
        bottom: 0 !important;
        right: 0 !important;
        margin-top: -30px;
        margin-left: auto;
        margin-right: auto;
        max-width: fit-content;
        z-index: 5;
    }

    .about-image {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    /* Modal adjustments */
    .modal-content {
        max-width: 95%;
        max-height: 85%;
    }

    .modal-close {
        top: -35px;
        font-size: var(--font-size-2xl);
    }

    /* Gallery adjustments */
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: var(--space-lg);
    }

    /* Form inputs */
    .form-control {
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    /* Campus items */
    .campus-item {
        height: 250px;
    }

    /* Achievement counters */
    .counter {
        font-size: var(--font-size-4xl);
    }

    /* Testimonial cards */
    .testimonial-card {
        padding: var(--space-2xl);
    }

    /* CRITICAL FIX: Force ALL grids to single column on mobile */
    .grid-2,
    .grid-3,
    .grid-4,
    div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* Activities grid - FORCE 1 COLUMN */
    .activities-grid,
    .events-grid,
    .activity-grid {
        grid-template-columns: 1fr !important;
        gap: var(--space-xl);
    }
}

/* ========== CRITICAL MOBILE FIXES (max-width: 480px) ========== */
@media (max-width: 480px) {

    /* Force single column for ALL grid layouts */
    [class*="grid"],
    [class*="-grid"],
    .grid-2,
    .grid-3,
    .grid-4,
    .academics-grid,
    .features-grid,
    .campus-grid,
    .testimonials-grid,
    .achievements-grid,
    .gallery-grid,
    .activities-grid,
    .events-grid,
    .event-gallery {
        grid-template-columns: 1fr !important;
        gap: var(--space-lg) !important;
    }

    /* Ensure cards have proper width */
    .card,
    .feature-card,
    .academic-card,
    .value-card,
    .activity-card {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    /* Prevent text truncation */
    .card h3,
    .feature-card h3,
    .academic-card h3,
    .value-card h3 {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        word-wrap: break-word !important;
    }
}

/* ========== GALLERY MOBILE OVERRIDE (max-width: 767px) ========== */
@media (max-width: 767px) {

    /* Force gallery grids to 1 column on all mobile devices */
    .event-gallery,
    .gallery-grid,
    [class*="gallery"] {
        grid-template-columns: 1fr !important;
        gap: var(--space-md) !important;
    }
}

/* ========== LANDSCAPE MOBILE OPTIMIZATION ========== */
@media (max-width: 1023px) and (orientation: landscape) {
    .nav-menu {
        height: auto;
        max-height: calc(100vh - 60px);
        overflow-y: auto;
        padding: var(--space-2xl) var(--space-xl);
    }

    .hero-section {
        height: auto;
        min-height: 500px;
        padding: var(--space-4xl) 0;
    }

    /* Reduce vertical spacing in landscape */
    section {
        padding: var(--space-3xl) 0;
    }
}

/* ========== TOUCH DEVICE OPTIMIZATIONS ========== */
@media (hover: none) and (pointer: coarse) {

    /* Increase all touch targets */
    .btn {
        min-height: 48px;
        min-width: 48px;
        padding: var(--space-md) var(--space-lg);
    }

    .nav-menu a {
        padding: var(--space-md) 0;
        min-height: 48px;
    }

    .social-link {
        width: 48px;
        height: 48px;
    }

    /* Remove all hover effects */
    .card:hover,
    .feature-card:hover,
    .hover-lift:hover,
    .hover-scale:hover {
        transform: none;
        box-shadow: inherit;
    }

    /* Add tap feedback */
    .card:active,
    .feature-card:active,
    .btn:active {
        opacity: 0.9;
        transform: scale(0.98);
    }

    /* Larger tap areas for links */
    a {
        padding: var(--space-xs) 0;
    }

    /* Prevent text selection on buttons */
    .btn,
    .menu-toggle {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
}

/* ========== PRINT STYLES ========== */
@media print {

    .header,
    .footer,
    .btn,
    .menu-toggle,
    .back-to-top,
    .slider-control,
    .slider-dots {
        display: none !important;
    }

    body {
        background-color: #E1D5BF;
        color: black;
    }

    section {
        page-break-inside: avoid;
    }

    .container {
        max-width: 100%;
    }
}

/* ========== HIGH RESOLUTION DISPLAYS ========== */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    /* Optimize images for retina */
    img {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* ========== ACCESSIBILITY - 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;
    }

    .parallax {
        transform: none !important;
    }
}

/* ========== DARK MODE SUPPORT (Future Enhancement) ========== */
@media (prefers-color-scheme: dark) {
    /* Currently using light theme as per design requirements */
    /* Can be implemented if needed in future */
}

/* ========== PERFORMANCE OPTIMIZATIONS ========== */
/* Prevent layout shifts */
img,
video,
iframe {
    max-width: 100%;
    height: auto;
}

/* Optimize animations for performance */
@media (prefers-reduced-motion: no-preference) {

    .fade-in,
    .slide-up,
    .zoom-in {
        will-change: opacity, transform;
    }
}

/* ========== NO HORIZONTAL SCROLL ========== */
html,
body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Ensure all content respects viewport */
* {
    max-width: 100%;
}

/* Allow specific elements to exceed */
.container,
section,
.hero-section {
    max-width: none;
}