/* ===================================
   RESPONSIVE STYLESHEET
   Mobile-First Approach
   Breakpoints: 480px, 768px, 1024px, 1280px
   =================================== */

/* ========== EXTRA SMALL DEVICES (< 480px) ========== */
@media (max-width: 479px) {
    :root {
        --container-gutter-x: 0.75rem;
    }

    body {
        background-attachment: scroll;
    }

    .trust-bar {
        margin-top: -1.5rem;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    }
    
    .section-title {
        font-size: 1.75rem;
    }
    
    .section-subtitle {
        font-size: 1rem;
    }
    
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.9375rem;
    }
    
    .btn-lg {
        padding: 1rem 2rem;
        font-size: 1rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .hero-buttons .btn {
        width: 100%;
    }
    
    .trust-items {
        grid-template-columns: repeat(2, 1fr);
        gap: 0;
    }
    
    .trust-item {
        justify-content: center;
        text-align: center;
        flex-direction: column;
        border-right: 1px solid rgba(255, 255, 255, 0.15);
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
        padding: 1.25rem 1rem;
    }

    .trust-item:nth-child(2n) {
        border-right: none;
    }

    .trust-item:nth-child(3),
    .trust-item:nth-child(4) {
        border-bottom: none;
    }
    
    .services-grid {
        grid-template-columns: 1fr;
    }

    .service-card-body {
        padding: 1.75rem 1.25rem 1.25rem;
        padding-top: 2rem;
    }
    
    .why-us-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .stats-badge {
        flex-direction: column;
        gap: 1rem;
        left: 1rem;
        bottom: 1rem;
        padding: 1.5rem;
    }
    
    .contact-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .contact-form-wrapper {
        padding: 1.5rem;
    }
    
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

/* ========== SMALL DEVICES (480px - 767px) ========== */
@media (min-width: 480px) and (max-width: 767px) {
    .trust-items {
        grid-template-columns: repeat(2, 1fr);
        gap: 0;
    }

    .trust-item {
        text-align: center;
        flex-direction: column;
        justify-content: center;
        border-right: 1px solid rgba(255, 255, 255, 0.15);
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
        padding: 1.25rem 1rem;
    }

    .trust-item:nth-child(2n) {
        border-right: none;
    }

    .trust-item:nth-child(3),
    .trust-item:nth-child(4) {
        border-bottom: none;
    }
    
    .services-grid {
        grid-template-columns: 1fr;
    }

    .why-us-grid {
        grid-template-columns: 1fr;
    }
    
    .contact-grid {
        grid-template-columns: 1fr;
    }
    
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ========== MOBILE DEVICES (< 768px) ========== */
@media (max-width: 767px) {
    /* Header Mobile */
    .nav {
        position: fixed;
        top: 82px;
        left: -100%;
        width: 100%;
        height: calc(100vh - 82px);
        background: var(--white);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
        transition: left var(--transition-base);
        overflow-y: auto;
        z-index: var(--z-fixed);
    }
    
    .nav.active {
        left: 0;
    }
    
    .nav-list {
        flex-direction: column;
        align-items: flex-start;
        padding: 2rem;
        gap: 0;
    }
    
    .nav-list li {
        width: 100%;
        border-bottom: 1px solid var(--gray-200);
    }
    
    .nav-link {
        display: block;
        padding: 1.25rem 0;
        font-size: 1.125rem;
    }
    
    .mobile-toggle {
        display: flex;
    }
    
    .mobile-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(8px, 8px);
    }
    
    .mobile-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -7px);
    }
    
    .header-actions .btn-primary {
        display: none;
    }
    
    /* Hero Mobile */
    .hero {
        min-height: 90vh;
        padding: 6rem 0 3rem;
        background-attachment: scroll;
    }
    
    .hero-title {
        font-size: 2.25rem;
    }
    
    .hero-subtitle {
        font-size: 1.125rem;
    }
    
    .hero-scroll {
        display: none;
    }
    
    /* Sections Mobile */
    .services,
    .why-us,
    .reviews,
    .service-areas,
    .contact {
        padding: 3rem 0;
    }
    
    .section-header {
        margin-bottom: 2rem;
    }
    
    .why-us-image img {
        height: 350px;
    }
    
    .stats-badge {
        position: static;
        margin-top: 1.5rem;
    }
    
    .areas-grid {
        gap: 0.75rem;
    }
    
    .area-tag {
        padding: 0.625rem 1.25rem;
        font-size: 0.875rem;
    }
    
    /* Back to Top Mobile */
    .back-to-top {
        width: 45px;
        height: 45px;
        bottom: 1.5rem;
        right: 1.5rem;
    }
}

/* ========== TABLET PORTRAIT (768px - 1023px) ========== */
@media (min-width: 768px) and (max-width: 1023px) {
    .trust-items {
        grid-template-columns: repeat(4, 1fr);
        gap: 0;
    }

    .trust-item {
        border-right: 1px solid rgba(255, 255, 255, 0.15);
        border-bottom: none;
        padding: 1rem 1.25rem;
    }

    .trust-item:last-child {
        border-right: none;
    }
    
    .services-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .why-us-grid {
        grid-template-columns: 1fr;
        gap: 3rem;
    }
    
    .contact-grid {
        grid-template-columns: 1fr;
        gap: 3rem;
    }
    
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .hero-title {
        font-size: 3rem;
    }
}

/* ========== TABLET LANDSCAPE & SMALL DESKTOP (1024px - 1279px) ========== */
@media (min-width: 1024px) and (max-width: 1279px) {
    .trust-items {
        grid-template-columns: repeat(4, 1fr);
        gap: 0;
    }

    .trust-item {
        border-right: 1px solid rgba(255, 255, 255, 0.15);
        border-bottom: none;
    }

    .trust-item:last-child {
        border-right: none;
    }
    
    .services-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .footer-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ========== LARGE DESKTOP (>= 1280px) ========== */
@media (min-width: 1280px) {
    .trust-items {
        grid-template-columns: repeat(4, 1fr);
        gap: 0;
    }
    
    .services-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ========== LANDSCAPE ORIENTATION ========== */
@media (orientation: landscape) and (max-height: 600px) {
    .hero {
        min-height: auto;
        padding: 10rem 0 4rem;
    }
    
    .hero-scroll {
        display: none;
    }
}

/* ========== HOVER EFFECTS (for devices with hover capability) ========== */
@media (hover: hover) {
    .service-card:hover {
        transform: translateY(-8px);
    }
    
    .area-tag:hover {
        transform: translateY(-2px);
    }
    
    .back-to-top:hover {
        transform: translateY(-5px);
    }
}

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

/* ========== PRINT STYLES ========== */
@media print {
    .header,
    .trust-bar,
    .hero-buttons,
    .contact-form,
    .back-to-top {
        display: none;
    }
    
    .hero {
        background: var(--white);
        color: var(--dark);
        min-height: auto;
        padding: 2rem 0;
    }
    
    .hero-overlay {
        display: none;
    }
    
    .hero-title,
    .hero-subtitle {
        color: var(--dark);
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    a[href]::after {
        content: " (" attr(href) ")";
    }
}

/* ========== HIGH CONTRAST MODE ========== */
@media (prefers-contrast: high) {
    .btn-primary,
    .btn-secondary {
        border: 3px solid currentColor;
    }
    
    .service-card,
    .review-card {
        border: 2px solid var(--dark);
    }
}

/* ========== DARK MODE (Optional - for future implementation) ========== */
@media (prefers-color-scheme: dark) {
    /* Dark mode styles can be added here if needed */
    /* NOOR Fitness — responsive layout */
}

/* ========== TOUCH DEVICE OPTIMIZATIONS ========== */
@media (pointer: coarse) {
    /* Larger touch targets for mobile */
    .btn {
        min-height: 48px;
        min-width: 48px;
    }
    
    .nav-link {
        min-height: 48px;
    }
    
    .mobile-toggle {
        min-height: 48px;
        min-width: 48px;
    }
    
    input,
    textarea,
    select {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* ========== SAFE AREA INSETS (for notch devices) ========== */
@supports (padding: max(0px)) {
    .header {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    .back-to-top {
        right: max(2rem, calc(2rem + env(safe-area-inset-right)));
        bottom: max(2rem, calc(2rem + env(safe-area-inset-bottom)));
    }
}

/* ========== ASPECT RATIO UTILITIES ========== */
@media (min-aspect-ratio: 16/9) {
    .hero {
        background-size: cover;
    }
}

@media (max-aspect-ratio: 4/3) {
    .hero-content {
        max-width: 100%;
    }
}

/* ========== RETINA DISPLAY OPTIMIZATIONS ========== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* High-resolution image optimizations */
    .hero {
        background-image: url('../images/hero-bg.jpg'); /* Use @2x image if available */
    }
}

/* ========== SPECIFIC DEVICE BREAKPOINTS ========== */
/* iPhone SE */
@media (max-width: 375px) {
    .hero-title {
        font-size: 2rem;
    }
    
    .btn-lg {
        padding: 0.875rem 1.75rem;
    }
}

/* iPhone 12/13/14 Pro */
@media (min-width: 390px) and (max-width: 393px) {
    :root {
        --container-gutter-x: 1.25rem;
    }
}

/* iPad Mini */
@media (min-width: 768px) and (max-width: 820px) {
    .services-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* iPad Pro 11" */
@media (min-width: 834px) and (max-width: 834px) {
    .why-us-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* iPad Pro 12.9" */
@media (min-width: 1024px) and (max-width: 1024px) {
    .services-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ========== ACCESSIBILITY: FOCUS VISIBLE ========== */
@media (prefers-reduced-motion: no-preference) {
    *:focus-visible {
        outline: 3px solid var(--primary);
        outline-offset: 2px;
    }
}

/* ========== FIX FOR SAFARI IOS ADDRESS BAR ========== */
@supports (-webkit-touch-callout: none) {
    .hero {
        min-height: -webkit-fill-available;
    }
}

/* ========== HORIZONTAL SCROLL FIX ========== */
body {
    overflow-x: hidden;
    width: 100%;
}

/* ========== IMAGE LOADING OPTIMIZATION ========== */
img {
    loading: lazy;
}

img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[loading="lazy"].loaded {
    opacity: 1;
}
