/* ==========================================================================
   OrthoAlign Rehab — Responsive Styles
   Mobile-first, professional, cross-browser responsive overrides
   ========================================================================== */

/* ── Global Mobile Safety ────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Prevent any element from causing horizontal overflow */
img,
video,
iframe,
svg {
    max-width: 100%;
    height: auto;
}

/* ── Tablet (Max 1024px) ─────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    :root {
        --section-padding: 5rem;
    }

    /* Hero */
    .hero__grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-8);
    }

    /* Trust Bar */
    .trust-bar__grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-8) var(--space-4);
    }

    /* Conditions */
    .conditions__grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Team */
    .team__grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Process */
    .process__grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-8) var(--space-4);
    }

    .process__grid::before {
        display: none;
    }

    /* Why Choose / Programs */
    .why-choose__grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Footer */
    .footer__grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-8);
    }
}

/* ── Mobile/Tablet (Max 768px) ───────────────────────────────────────────── */
@media (max-width: 768px) {

    /* ─ Root variables ─ */
    :root {
        --section-padding: 3.5rem;
        --nav-height: 64px;
    }

    /* ─ Container safety ─ */
    .container {
        padding-left: var(--space-4);
        padding-right: var(--space-4);
        width: 100%;
    }

    /* ─ Section headers ─ */
    .section-header {
        margin-bottom: var(--space-8);
    }

    .section-header__title {
        font-size: clamp(1.5rem, 6vw, 2rem);
    }

    /* ─ Navigation ─ */
    .mobile-menu-btn {
        display: flex;
    }

    /* Show mobile-only nav elements */
    .nav__mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding-bottom: var(--space-4);
        margin-bottom: var(--space-2);
        border-bottom: 2px solid var(--primary-50);
    }

    .nav__mobile-brand {
        font-size: var(--text-xl);
    }

    .nav__mobile-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: var(--radius-full);
        background: var(--gray-100);
        color: var(--navy);
        cursor: pointer;
        border: none;
        transition: background var(--duration-fast) ease;
    }

    .nav__mobile-close:hover {
        background: var(--gray-200);
    }

    .nav__mobile-cta {
        display: flex;
        width: 100%;
        margin-top: var(--space-6);
        justify-content: center;
    }

    /* Mobile nav panel — slides in from right */
    .nav__links {
        position: fixed !important;
        top: var(--nav-height) !important;
        right: -100vw !important;
        bottom: 0 !important;
        left: auto !important;
        width: min(75vw, 280px) !important;
        height: 100vh !important;
        height: 100dvh !important;
        background: #ffffff !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        padding: var(--space-5) !important;
        box-shadow: -4px 0 40px rgba(11, 37, 69, 0.2) !important;
        transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
        z-index: 9999 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        gap: 0 !important;
        display: flex !important;
    }

    .nav__links.active {
        right: 0 !important;
    }

    .nav__link {
        font-size: var(--text-base);
        width: 100%;
        padding: var(--space-4) 0;
        border-bottom: 1px solid var(--gray-100);
        color: var(--navy);
        display: block;
    }

    .nav__actions .btn {
        display: none;
    }

    .header.menu-open {
        z-index: 9999 !important;
    }

    /* ─ Menu Overlay ─ */
    .menu-overlay {
        position: fixed;
        inset: 0;
        background: rgba(11, 37, 69, 0.55);
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        z-index: 9998;
    }

    .menu-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    /* ─ Mobile Menu Button Animation ─ */
    .mobile-menu-btn.active span:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }

    .mobile-menu-btn.active span:nth-child(2) {
        opacity: 0;
    }

    .mobile-menu-btn.active span:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }

    /* ─ Hero Section (THE CRITICAL FIX) ─ */
    .hero {
        padding-top: calc(var(--nav-height) + 24px);
        padding-bottom: var(--space-12);
        text-align: center;
        overflow: hidden;
        /* Prevent badge overflow */
        min-height: auto;
    }

    .hero__grid {
        grid-template-columns: 1fr;
        gap: var(--space-8);
    }

    .hero__content {
        margin: 0 auto;
        max-width: 100%;
        width: 100%;
    }

    .hero__subtitle {
        font-size: var(--text-xs);
        padding: 6px 12px;
    }

    .hero__title {
        font-size: clamp(1.75rem, 7vw, 2.5rem);
        word-break: break-word;
        hyphens: auto;
    }

    .hero__description {
        font-size: var(--text-base);
        max-width: 100%;
    }

    /* Remove line breaks that cause overflow on mobile */
    .hero__description br {
        display: none;
    }

    .hero__actions {
        flex-direction: column;
        align-items: center;
        gap: var(--space-3);
        margin-bottom: var(--space-8);
    }

    .hero__actions .btn {
        width: 100%;
        max-width: 340px;
    }

    .hero__trust {
        justify-content: center;
        flex-wrap: wrap;
        gap: var(--space-4);
    }

    .hero__image-wrapper {
        justify-content: center;
        padding: 0;
        overflow: hidden;
    }

    .hero__image {
        max-height: 420px;
        width: 100%;
        object-fit: cover;
        border-radius: var(--radius-xl);
    }

    /* Floating badges — reposition so they stay inside on mobile */
    .hero__floating-badge {
        position: absolute;
        padding: var(--space-2) var(--space-3);
        font-size: var(--text-xs);
        border-radius: var(--radius-lg);
    }

    .hero__floating-badge--1 {
        top: auto;
        bottom: 65px;
        left: 8px;
        right: auto;
    }

    .hero__floating-badge--2 {
        bottom: 50px;
        right: 8px;
        left: auto;
    }

    .hero__floating-badge--3 {
        bottom: 12px;
        left: 8px;
        right: auto;
    }

    /* ─ Trust Bar ─ */
    .trust-bar__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-4);
    }

    /* ─ Conditions ─ */
    .conditions__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-4);
    }

    /* ─ About / Team Section ─ */
    .about__grid {
        grid-template-columns: 1fr;
        gap: var(--space-8);
    }

    .about__image-wrapper {
        max-width: 100%;
        margin: 0 auto;
    }

    .about__content {
        max-width: 100%;
        text-align: left;
    }

    /* ─ Team ─ */
    .team__grid {
        grid-template-columns: 1fr;
        max-width: 460px;
        margin: 0 auto;
    }

    /* ─ Process / How It Works ─ */
    .process__grid {
        grid-template-columns: 1fr;
        gap: var(--space-6);
        max-width: 400px;
        margin: 0 auto;
    }

    .process__grid::before {
        display: none;
    }

    /* ─ Methodology ─ */
    .methodology__grid {
        grid-template-columns: 1fr;
        gap: var(--space-8);
    }

    /* ─ Why Choose & Programs ─ */
    .why-choose__grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    /* ─ Assessment Section ─ */
    .pricing-card {
        max-width: 100%;
        margin: 0;
    }

    /* ─ Social ─ */
    .social__grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    /* ─ Footer ─ */
    .footer {
        padding-bottom: calc(var(--space-16) + 60px);
    }

    .footer__grid {
        grid-template-columns: 1fr;
        gap: var(--space-8);
        text-align: center;
    }

    .footer__bio {
        max-width: 100%;
        margin: 0 auto var(--space-4);
    }

    .footer__contact-item {
        justify-content: center;
    }

    .footer__socials {
        justify-content: center;
    }

    .footer__links {
        align-items: center;
    }

    /* ─ Modal ─ */
    .modal-container {
        padding: var(--space-6);
        margin: var(--space-4);
        max-height: 85vh;
    }

    /* ─ Cards ─ */
    .card {
        padding: var(--space-5);
    }

    /* ─ WhatsApp Float ─ */
    .whatsapp-float {
        bottom: calc(var(--space-4) + 68px + env(safe-area-inset-bottom));
        right: var(--space-4);
        width: 50px;
        height: 50px;
    }

    .whatsapp-float svg {
        width: 24px;
        height: 24px;
    }
}

/* ── Mobile Small (Max 480px) ────────────────────────────────────────────── */
@media (max-width: 480px) {
    :root {
        --section-padding: 3rem;
    }

    .container {
        padding-left: var(--space-4);
        padding-right: var(--space-4);
    }

    /* Hero */
    .hero__title {
        font-size: clamp(1.5rem, 8vw, 2rem);
    }

    /* Trust Bar */
    .trust-bar__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-3);
    }

    /* Conditions */
    .conditions__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-3);
    }

    /* Methodology Stats */
    .methodology__stats {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-4);
    }

    /* Pricing Card */
    .pricing-card {
        padding: var(--space-5);
    }

    .pricing-card__current {
        font-size: 2.25rem;
    }

    /* Testimonial Card */
    .testimonial-card {
        min-width: 260px;
        padding: var(--space-5);
    }

    /* Programs grid */
    .why-choose__grid {
        grid-template-columns: 1fr;
    }
}

/* ── Extra Small (Max 360px) ─────────────────────────────────────────────── */
@media (max-width: 360px) {
    .hero__title {
        font-size: 1.375rem;
    }

    .hero__subtitle {
        font-size: 0.65rem;
    }

    .btn--lg {
        padding: 14px 20px;
        font-size: var(--text-sm);
    }

    .conditions__grid {
        grid-template-columns: 1fr;
    }
}

/* ── Cross-Browser Fixes ─────────────────────────────────────────────────── */

/* Safari iOS viewport fix */
@supports (-webkit-touch-callout: none) {
    .hero {
        min-height: -webkit-fill-available;
    }

    .nav__links {
        height: -webkit-fill-available;
    }
}

/* Firefox specific fixes */
@-moz-document url-prefix() {
    .hero__image {
        object-fit: cover;
    }
}