/* 
 * ==========================================
 * RESPONSIVE OVERRIDES & FINAL POLISH
 * ==========================================
 * Handles fluid typography, touch targets, and 
 * layout consolidation for mobile devices.
 */

/* ==========================================
   1. FLUID TYPOGRAPHY (Mobile Adjustments)
   ========================================== */
@media (max-width: 991.98px) {

    /* Scale down display headings significantly */
    .display-1 {
        font-size: calc(2.5rem + 2.5vw);
    }

    .display-2 {
        font-size: calc(2.2rem + 2vw);
    }

    .display-3 {
        font-size: calc(2rem + 1.5vw);
    }

    .display-4 {
        font-size: calc(1.8rem + 1.2vw);
    }

    .display-5 {
        font-size: calc(1.6rem + 1vw);
    }

    .display-6 {
        font-size: calc(1.4rem + 0.8vw);
        text-align: center;
    }

    /* Center text alignments on tablets for hero sections */
    .page-hero .col-lg-8,
    .page-hero .col-lg-7 {
        text-align: center;
        margin: 0 auto;
    }

    .page-hero p.lead {
        margin-left: auto;
        margin-right: auto;
    }

    /* Ensure hero buttons center properly */
    .page-hero .d-flex.flex-wrap {
        justify-content: center;
        margin-top: 1.5rem !important;
    }

    /* Reduce hero height */
    .page-hero {
        min-height: 40vh !important;
        padding-top: 5rem !important;
        padding-bottom: 3rem !important;
    }
}

@media (max-width: 767.98px) {

    /* Base typography adjustments */
    body {
        font-size: 15px;
    }

    .lead {
        font-size: 1.1rem;
    }

    /* Section padding condensation */
    .section-padding {
        padding-top: 3.5rem;
        padding-bottom: 3.5rem;
    }

    /* Force Data Tables to stack completely */
    .medical-translation-table thead {
        display: none;
        /* Hide headers */
    }

    .medical-translation-table,
    .medical-translation-table tbody,
    .medical-translation-table tr,
    .medical-translation-table td {
        display: block;
        width: 100%;
    }

    .medical-translation-table tr {
        margin-bottom: 1rem;
        background: var(--color-bg-white);
        border: 1px solid var(--color-border);
        border-radius: var(--border-radius);
        padding: 1rem;
    }

    .medical-translation-table td {
        text-align: left;
        padding: 0.5rem 0 !important;
        border: none !important;
    }

    /* Add pseudo-headers back */
    .medical-translation-table td:first-child::before {
        content: "Medical Term";
        display: block;
        font-weight: 700;
        color: var(--color-accent-gold);
        font-size: 0.75rem;
        text-transform: uppercase;
        margin-bottom: 0.25rem;
    }

    .medical-translation-table td:last-child::before {
        content: "What It Means";
        display: block;
        font-weight: 700;
        color: var(--color-primary);
        font-size: 0.75rem;
        text-transform: uppercase;
        margin-bottom: 0.25rem;
        margin-top: 0.5rem;
    }
}

/* ==========================================
   2. TOUCH TARGETS MIN 44PX (Accessibility)
   ========================================== */
@media (max-width: 991.98px) {

    .btn,
    .accordion-button,
    .nav-link,
    .dropdown-item,
    a.text-decoration-none {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* Ensure form inputs are fat enough for thumbs */
    .form-control,
    .form-select {
        min-height: 50px;
        font-size: 16px;
        /* Prevents iOS auto-zoom on focus */
    }

    /* Hover Arrow links specifically */
    .hover-arrow {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
}

/* ==========================================
   3. SPECIFIC COMPONENT OVERRIDES
   ========================================== */

/* Swiper.js Pagination Fixes Bottom Padding */
.swiper-container {
    padding-bottom: 3rem !important;
}

.swiper-pagination-bullet {
    width: 10px;
    height: 10px;
}

.swiper-pagination-bullet-active {
    background: var(--color-accent-gold) !important;
}

/* GSAP Overrides (Prevent jank on mobile) */
@media (max-width: 767.98px) {

    /* Disable aggressive 3D tilt tracking on mobile */
    .tric-hover-3d-inner {
        transform: rotateX(0deg) rotateY(0deg) !important;
    }

    /* Convert horizontally scrolling flip-cards into standard vertical stack or strict snap */
    .flip-card-container {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        padding-bottom: 1.5rem;
        margin-left: -1rem;
        /* Break out of container */
        margin-right: -1rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .flip-card {
        scroll-snap-align: center;
        flex: 0 0 85%;
        /* Let following card peek */
        max-width: 320px;
        width: 100% !important;
    }

    /* Revert Timeline Alternation to strictly left-aligned on Mobile */
    .timeline-panel {
        width: 100% !important;
        float: none !important;
        padding: 0 0 0 45px !important;
        margin-bottom: 2rem !important;
    }

    .timeline-dot {
        left: 21px !important;
        /* Move dot to far left */
        margin-left: -8px !important;
    }

    .timeline::before {
        left: 21px !important;
        /* Move connecting line to far left */
    }

    /* Hide the SVG drawing vine on mobile to save performance, rely on CSS line */
    #timeline-vine path {
        display: none !important;
    }
}

/* Disable Hover effects on devices without mice */
@media (hover: none) {
    .hover-lift:hover {
        transform: none !important;
        box-shadow: inherit !important;
    }

    .group:hover .group-hover-scale {
        transform: none !important;
    }

    .group:hover .group-hover-opacity-10 {
        opacity: 0 !important;
    }
}

/* High Contrast mode safeties */
@media (prefers-contrast: high) {
    .bg-soft {
        background-color: transparent !important;
        border: 1px solid #000;
    }

    .text-secondary {
        color: #000 !important;
    }

    .opacity-75,
    .opacity-50 {
        opacity: 1 !important;
    }
}

/* ==========================================
   4. MARGIN/PADDING CONSOLIDATION
   ========================================== */
@media (max-width: 767.98px) {
    .p-5 {
        padding: 2rem !important;
    }

    /* Shrink vast padding blocks */
    .me-5,
    .pe-5 {
        margin-right: 0 !important;
        padding-right: 0 !important;
    }

    .ms-5,
    .ps-5 {
        margin-left: 0 !important;
        padding-left: 0 !important;
    }

    .mt-n4 {
        margin-top: -1.5rem !important;
    }

    /* Fix overlap intersections */

    /* Ensure borders don't break flex layouts */
    .border-start,
    .border-end {
        border: none !important;
        border-bottom: 1px solid var(--color-border) !important;
        padding-bottom: 1rem;
        margin-bottom: 1rem;
    }
}

/* ==========================================
   MOBILE MENU OVERLAY FIX
   ========================================== */
@media (max-width: 991.98px) {
    .mobile-menu-overlay nav {
        gap: 1.25rem !important;
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }

    .mobile-menu-overlay .mobile-nav-link {
        font-size: 1.75rem !important;
        line-height: 1.2 !important;
        display: block;
        width: 100%;
        text-align: center;
        padding: 0.25rem 0;
    }

    .mobile-menu-overlay #mobileExpertiseToggle {
        font-size: 1.75rem !important;
        line-height: 1.2 !important;
    }

    .mobile-menu-overlay #mobileExpertiseToggle svg {
        width: 20px;
        height: 20px;
    }

    .mobile-menu-overlay .mobile-dropdown-content a {
        font-size: 1.05rem !important;
        text-align: center;
    }

    .mobile-menu-overlay .btn-primary-cta {
        font-size: 1.1rem !important;
    }
}

@media (max-width: 400px) {
    .mobile-menu-overlay .mobile-nav-link,
    .mobile-menu-overlay #mobileExpertiseToggle {
        font-size: 1.5rem !important;
    }
}

/* ==========================================
   HERO DESKTOP — narrow desktop (lg only) tune
   At 992–1199px the 43%-wide doctor image crowds the headline.
   ========================================== */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .hero-doctor-img {
        width: 38% !important;
        right: -2% !important;
        top: auto !important;
        bottom: 0 !important;
        height: 86% !important;
    }
    .hero-section .hero-content {
        padding-right: 1rem;
    }
    .hero-line-1 {
        font-size: clamp(2.2rem, 3.6vw, 2.8rem) !important;
    }
    .hero-line-2 {
        font-size: clamp(1.85rem, 3vw, 2.45rem) !important;
    }
}

/* ==========================================
   HERO AVATAR (below lg, replaces full doctor image)
   ========================================== */
@media (max-width: 991.98px) {
    .hero-avatar-mobile {
        width: 128px;
        height: 128px;
        margin: 0 0 1.5rem 0;
        border-radius: 50%;
        overflow: hidden;
        background: linear-gradient(145deg, #F5F3EE 0%, #ECE6D8 100%);
        box-shadow:
            0 0 0 1px rgba(200,155,94,0.35),
            0 0 0 5px rgba(245,243,238,1),
            0 0 0 6px rgba(31,61,43,0.08),
            0 14px 28px rgba(31,61,43,0.10);
        position: relative;
    }
    .hero-avatar-mobile::after {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: 50%;
        background: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,0.45) 0%, transparent 55%);
        pointer-events: none;
    }
    .hero-avatar-mobile img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: 50% 18%;
        display: block;
    }
}

@media (max-width: 767.98px) {
    .hero-avatar-mobile {
        width: 104px;
        height: 104px;
        margin-bottom: 1.25rem;
    }
}

/* ==========================================
   MOBILE POLISH — Home & global
   ========================================== */
@media (max-width: 767.98px) {

    /* Tighter, more confident container gutters */
    .container,
    .container-xl,
    .container-lg,
    .container-md,
    .container-sm {
        padding-left: 1.25rem !important;
        padding-right: 1.25rem !important;
    }

    /* Hero: keep full doctor image hidden on mobile */
    .hero-doctor-img {
        display: none !important;
    }

    /* Hero is too tall on mobile when only text — pull it in */
    .hero-section {
        min-height: 88vh !important;
        padding-top: 4.5rem !important;
        padding-bottom: 92px !important;
    }

    .hero-content {
        padding-top: 0 !important;
    }

    .hero-subheadline {
        font-size: 1rem !important;
        margin-bottom: 1.5rem !important;
    }

    /* Hero buttons: split clean side-by-side at tiny sizes, full-rounded */
    .hero-buttons {
        gap: 0.75rem !important;
    }
    .hero-buttons .btn {
        padding: 0.7rem 1.4rem !important;
        font-size: 0.92rem !important;
        flex: 1 1 auto;
        text-align: center;
        justify-content: center;
    }

    /* Cinematic ribbon — quieter on mobile */
    .expertise-chip {
        font-size: 0.72rem !important;
        padding: 0 1.25rem !important;
        min-width: 0 !important;
    }
    .hero-expertise-ribbon {
        padding-top: 0.45rem;
        padding-bottom: 0.45rem;
        background: rgba(245,243,238,0.85);
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        border-top: 1px solid rgba(31,61,43,0.06);
    }

    /* Section rhythm — slightly tighter than tablet */
    .section-padding {
        padding-top: 3rem !important;
        padding-bottom: 3rem !important;
    }

    /* Section headings — measured size, balanced wrap */
    .section-padding h2,
    section h2.display-4,
    section h2.display-5 {
        font-size: clamp(1.65rem, 6.2vw, 2.1rem) !important;
        line-height: 1.18 !important;
        letter-spacing: -0.01em;
        text-wrap: balance;
    }

    section .lead,
    section p.lead {
        font-size: 1rem !important;
        line-height: 1.6 !important;
    }

    /* Card polish — softer shadow, larger inner padding, refined radius */
    .card,
    .service-card,
    .testimonial-card,
    .flip-card,
    .feature-card {
        border-radius: 14px !important;
        box-shadow: 0 1px 2px rgba(31,61,43,0.04), 0 6px 24px rgba(31,61,43,0.06) !important;
        border-color: rgba(31,61,43,0.06) !important;
    }
    .card .card-body {
        padding: 1.35rem 1.25rem !important;
    }

    /* Grid gaps — give cards breathing room */
    .row.g-4 > [class*="col-"],
    .row.g-3 > [class*="col-"] {
        margin-bottom: 1rem;
    }

    /* Section dividers — gentler on mobile */
    .section-divider-leaf {
        transform: scale(0.7);
    }

    /* Images in content — never let them dwarf the column */
    section img:not(.hero-doctor-img img):not([class*="signature"]) {
        max-width: 100%;
        height: auto;
        border-radius: 10px;
    }

    /* Buttons — uniform mobile feel */
    .btn {
        border-radius: 999px;
        font-weight: 600;
        letter-spacing: 0.01em;
    }

    /* Footer breathing room */
    footer {
        padding-top: 2.5rem !important;
        padding-bottom: 1.5rem !important;
    }
    footer h5, footer h6 {
        margin-top: 1.25rem;
        font-size: 0.8rem;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        opacity: 0.7;
    }
}

@media (max-width: 400px) {
    .hero-section {
        min-height: 86vh !important;
        padding-top: 4rem !important;
    }
    .hero-buttons {
        flex-direction: column !important;
    }
    .hero-buttons .btn {
        width: 100%;
    }
}