/* ============================================
   RESPONSIVE CONSOLIDATED - Single Source of Truth
   Loads LAST to override all other styles

   Breakpoints (standardized):
   - Mobile:          max-width: 480px
   - Mobile-landscape: 481px - 767px
   - Tablet:          768px - 1023px
   - Desktop:         1024px+
   - Large:           1440px+
   ============================================ */

/* ============================================
   BASE MOBILE PREVENTION
   These rules prevent common mobile issues
   ============================================ */

html {
    overflow-x: hidden;
    max-width: 100vw;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
    max-width: 100vw;
    position: relative;
}

/* Global overflow prevention */
* {
    max-width: 100vw;
}

img, video, iframe, svg {
    max-width: 100%;
    height: auto;
}

/* Prevent iOS zoom on inputs */
input, textarea, select {
    font-size: 16px;
}

/* Touch-friendly tap targets */
button, .btn, a {
    min-height: 44px;
    touch-action: manipulation;
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* Default desktop grid layout for hero preview */
.preview-grid {
    grid-template-columns: repeat(2, 1fr);
}

/* ============================================
   MOBILE (max-width: 480px)
   Small phones - iPhone SE, etc.
   ============================================ */

@media (max-width: 480px) {
    /* Container */
    .container {
        padding: 0 1.25rem;
        width: 100%;
        box-sizing: border-box;
    }

    /* Container inside hero must fill hero */
    .hero > .container {
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    /* Hero section - FULL VIEWPORT */
    .hero {
        min-height: 100svh;
        height: 100svh;
        max-height: 100svh;
        display: flex;
        flex-direction: column;
        padding: 0;
        overflow: hidden;
    }

    /* Hero content - FLEX COLUMN FULL HEIGHT */
    .hero-content {
        display: flex;
        flex-direction: column;
        height: 100%;
        width: 100%;
        text-align: center;
        align-items: center;
        padding: 5rem 0 2.5rem;
    }

    /* Content wrapper - TOP SECTION */
    .hero-content-wrapper {
        flex: 0 0 auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 0 0.5rem;
    }

    /* CTA GROUP - PUSHED TO BOTTOM */
    .hero-cta-group {
        margin-top: auto;
        width: 100%;
        max-width: 300px;
        gap: 1rem;
        display: flex;
        flex-direction: column;
    }

    /* CTA text - BOTTOM */
    .hero-cta-text {
        margin-top: 1.5rem;
        margin-bottom: 0;
        font-size: 1rem;
        color: #64748b;
    }

    /* Dashboard preview - HIDDEN on mobile */
    .hero-visual {
        display: none;
    }

    /* Eyebrow - REFINED */
    .hero-eyebrow {
        margin-bottom: 1.25rem;
        font-size: 0.7rem;
        letter-spacing: 0.2em;
        text-transform: uppercase;
        color: #64748b;
    }

    /* Main headline - BOLD & LARGE */
    .hero-display {
        font-size: 2.5rem;
        line-height: 1.05;
        margin-bottom: 1.25rem;
        font-weight: 700;
        letter-spacing: -0.02em;
    }

    .hero-title {
        font-size: 2.5rem;
        line-height: 1.05;
    }

    /* Subtitle - READABLE */
    .hero-subtitle {
        font-size: 1.1rem;
        line-height: 1.6;
        margin-bottom: 1.5rem;
        color: #475569;
        max-width: 320px;
    }

    /* Value props - SPACED */
    .hero-value-props {
        gap: 0.875rem;
        margin: 0;
        flex-direction: column;
    }

    .hero-value-prop {
        font-size: 1rem;
        font-weight: 500;
    }

    /* CTA buttons - PREMIUM */
    .hero-cta-group .btn {
        width: 100%;
        padding: 1.125rem 2rem;
        font-size: 1.1rem;
        font-weight: 600;
        border-radius: 12px;
    }

    .hero-cta {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }

    .hero-cta .btn {
        width: 100%;
        padding: 1.125rem 2rem;
        font-size: 1.1rem;
    }

    /* Hide decorative elements */
    .hero::before,
    .hero::after {
        display: none;
    }

    /* "Every Call. Handled." section */
    .section-how-it-works {
        display: block;
    }

    /* Grids - single column */
    .automation-grid,
    .pricing-grid,
    .capabilities-grid,
    .summary-comparison {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Force single column on ALL inline grid styles */
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    .preview-content div[style*="grid"] {
        grid-template-columns: 1fr !important;
    }

    /* Preview grid in hero section */
    .preview-grid {
        grid-template-columns: 1fr !important;
    }

    /* Dashboard preview - constrain width */
    .dashboard-preview {
        max-width: 100%;
        overflow: hidden;
    }

    .preview-content {
        padding: 1rem !important;
    }

    /* How It Works - Stack vertically on mobile */
    .section-how-it-works > .container > div[style*="display: flex"] {
        flex-direction: column !important;
        align-items: center !important;
        gap: 1rem !important;
    }

    /* Hide arrows between flow items on mobile */
    .section-how-it-works svg[width="24"][height="24"] {
        display: none !important;
    }

    /* Flow cards - full width on mobile */
    .section-how-it-works div[style*="min-width: 120px"] {
        min-width: unset !important;
        width: 100% !important;
        max-width: 280px !important;
    }

    /* Cards */
    .automation-card,
    .pricing-card,
    .capability-card {
        padding: 1rem;
    }

    /* Typography scaling */
    .automation-title,
    .section-title {
        font-size: 1.75rem;
    }

    .automation-subtitle,
    .section-subtitle {
        font-size: 0.95rem;
    }

    .cta-title {
        font-size: 1.5rem;
    }

    /* Buttons - ensure proper sizing */
    .btn-lg {
        padding: 0.875rem 1.5rem !important;
        font-size: 1rem !important;
        width: 100%;
    }

    .hero-cta-group .btn {
        width: 100%;
        max-width: 320px;
        margin: 0 auto;
    }

    /* Modal */
    .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 1rem;
    }

    .modal-header,
    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        flex-direction: column;
        gap: 0.5rem;
        padding: 1rem;
    }

    .modal-footer .btn {
        width: 100%;
    }

    /* Footer */
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 1.5rem;
    }

    .footer-section ul {
        align-items: center;
    }

    /* Performance: Hide non-essential animations */
    .hero-visual::before,
    .hero-visual::after {
        display: none !important;
    }
}

/* ============================================
   IPHONE PRO / MODERN PHONES (375px - 430px)
   iPhone Pro: 393px, iPhone Pro Max: 430px
   Only typography tweaks - hero structure from 480px rules
   ============================================ */

@media (min-width: 375px) and (max-width: 430px) {
    .hero-eyebrow {
        font-size: 0.65rem;
        letter-spacing: 0.15em;
    }

    .hero-display {
        font-size: 1.85rem;
        line-height: 1.12;
    }

    .hero-subtitle {
        font-size: 0.92rem;
        line-height: 1.45;
    }

    .hero-value-prop {
        font-size: 0.9rem;
    }

    .hero-cta-group .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.95rem;
    }

    .hero-cta-text {
        font-size: 0.82rem;
    }
}

/* ============================================
   MOBILE LANDSCAPE (481px - 767px)
   Larger phones, small tablets in portrait
   ============================================ */

@media (min-width: 481px) and (max-width: 767px) {
    .container {
        padding: 0 1.25rem;
        box-sizing: border-box;
    }

    /* Hero section - exact viewport height, content centered */
    .hero {
        height: 100dvh;
        min-height: 100dvh;
        max-height: 100dvh;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding-top: 60px !important;
        padding-bottom: 0 !important;
        overflow: hidden;
    }

    .hero > .container {
        display: flex;
        align-items: center;
        justify-content: center;
        height: auto;
    }

    /* Hide dashboard preview on mobile landscape */
    .hero-visual {
        display: none !important;
    }

    /* Hero content - vertically centered */
    .hero-content {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        gap: 0.75rem;
    }

    .hero-content-wrapper {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .hero-cta-group {
        margin-top: 1rem;
    }

    .hero-cta-text {
        margin-top: 0.75rem;
        margin-bottom: 0;
    }

    .hero-title {
        font-size: 2.25rem;
    }

    .hero-subtitle {
        font-size: 1.05rem;
        margin-bottom: 0.5rem;
    }

    /* 2-column grids where appropriate */
    .automation-grid,
    .pricing-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

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

    /* How It Works - Wrap on larger mobile */
    .section-how-it-works > .container > div[style*="display: flex"] {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 1rem !important;
    }

    /* Hide arrows on mobile landscape too */
    .section-how-it-works svg[width="24"][height="24"] {
        display: none !important;
    }

    /* Flow cards sizing */
    .section-how-it-works div[style*="min-width: 120px"] {
        min-width: 140px !important;
        flex: 0 1 45% !important;
        max-width: 200px !important;
    }

    .automation-title,
    .section-title {
        font-size: 2rem;
    }

    .cta-title {
        font-size: 1.75rem;
    }

    .footer-content {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

/* ============================================
   TABLET (768px - 1023px)
   iPads, tablets
   ============================================ */

@media (min-width: 768px) and (max-width: 1023px) {
    .container {
        padding: 0 1.5rem;
    }

    .hero {
        height: 100dvh;
        min-height: 100dvh;
        max-height: 100dvh;
        padding-top: 100px;
        padding-bottom: 3rem;
        overflow: hidden;
    }

    /* Hide dashboard preview on tablet - too tall for viewport */
    .hero-visual {
        display: none;
    }

    .hero-title {
        font-size: 2.75rem;
    }

    .hero-subtitle {
        font-size: 1.125rem;
    }

    .hero-cta {
        flex-direction: row;
        gap: 1rem;
    }

    .hero-cta .btn {
        width: auto;
    }

    /* 2-column grids */
    .automation-grid,
    .pricing-grid,
    .capabilities-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }

    .summary-comparison {
        grid-template-columns: repeat(2, 1fr);
    }

    .automation-title,
    .section-title {
        font-size: 2.5rem;
    }

    .cta-title {
        font-size: 2rem;
    }

    /* Footer */
    .footer-content {
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
    }

    /* Modal */
    .modal-content {
        width: 85%;
        max-width: 600px;
    }

    .modal-footer {
        flex-direction: row;
        justify-content: flex-end;
    }

    .modal-footer .btn {
        width: auto;
    }
}

/* ============================================
   SIGNATURE NAV - MOBILE OVERRIDES
   The new nav-sig-* navigation system
   ============================================ */

@media (max-width: 767px) {
    :root {
        --nav-height-mobile: calc(48px + 1rem + env(safe-area-inset-top));
    }

    /* Nav container */
    .nav-signature {
        padding: 0.5rem 0.75rem;
    }

    .nav-signature-inner {
        height: 48px;
        padding: 0 0.75rem;
        width: 100%;
        max-width: 100%;
    }

    /* Hide desktop elements */
    .nav-signature-inner::before,
    .nav-signature-inner::after,
    .nav-sig-waveform {
        display: none;
    }

    /* Logo sizing */

    .nav-sig-logo-text {
        font-size: 0.55rem;
        letter-spacing: 0.1em;
    }

    /* Hide desktop links, show mobile button */
    .nav-sig-links {
        display: none;
    }

    /* Hide decorative hero gradient blobs on mobile */
    .hero::before,
    .hero::after {
        display: none !important;
    }

    .nav-sig-mobile-btn {
        display: flex;
    }

    /* Theme toggle compact */
    .nav-sig-theme-toggle {
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
        max-width: 28px;
        max-height: 28px;
        margin: 0 0.5rem 0 0;
    }

    /* Right group layout */
    .nav-sig-right-group {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    /* Mobile menu dropdown */
    .nav-sig-links.mobile-open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: calc(100% + 0.5rem);
        right: 0.5rem;
        width: auto;
        min-width: 180px;
        padding: 0.5rem;
        border-radius: 12px;
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(16px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
        z-index: 1001;
    }

    [data-theme="light"] .nav-sig-links.mobile-open {
        background: rgba(255, 255, 255, 0.95);
        border-color: rgba(15, 23, 42, 0.1);
    }

    .nav-sig-links.mobile-open a {
        width: 100%;
        padding: 0.625rem 0.875rem;
        font-size: 0.85rem;
        justify-content: flex-start;
    }

    .nav-sig-links.mobile-open a.btn-nav-cta {
        margin-top: 0.5rem;
        justify-content: center;
    }

    /* Body padding for fixed nav - tighter for mobile */
    body {
        padding-top: var(--nav-height-mobile, 56px);
    }
}

/* Tablet nav adjustments */
@media (min-width: 768px) and (max-width: 1023px) {
    .nav-sig-links a {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }


    .nav-signature .nav-sig-links a.nav-live-demo,
    .nav-signature .nav-sig-links a.btn-nav-cta {
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
        height: 24px;
    }
}

/* ============================================
   OLD NAV SYSTEM - DISABLE ON MOBILE
   Prevents .nav-* from conflicting with .nav-sig-*
   ============================================ */

@media (max-width: 1023px) {
    /* If signature nav exists, hide old nav completely */
    .nav-signature ~ .nav,
    .nav-signature ~ .nav-content,
    .nav-signature ~ .mobile-menu-button,
    .nav-signature ~ .mobile-menu-overlay {
        display: none;
    }
}

/* ============================================
   TABLET LANDSCAPE (1024px - 1279px)
   Prevents overflow on iPad landscape and similar
   ============================================ */

@media (min-width: 1024px) and (max-width: 1279px) {
    .container {
        box-sizing: border-box;
        padding: 0 1.5rem;
        max-width: 100%;
        width: 95%;
    }

    /* Ensure pricing cards don't overflow */
    .pricing-grid {
        max-width: 100%;
        overflow: hidden;
    }

    .pricing-card {
        max-width: 100%;
    }

    .hero {
        height: 100dvh;
        min-height: 100dvh;
        max-height: 100dvh;
        padding-top: 100px;
        padding-bottom: 3rem;
        overflow: hidden;
    }

    .hero-title {
        font-size: 2.75rem;
    }

    .hero-subtitle {
        font-size: 1.125rem;
    }

    /* Hide dashboard preview on tablet landscape - too tall for viewport */
    .hero-visual {
        display: none;
    }

    /* 2-column grids for tablet landscape */
    .automation-grid,
    .pricing-grid,
    .capabilities-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }

    .automation-title,
    .section-title {
        font-size: 2.5rem;
    }

    .cta-title {
        font-size: 2rem;
    }

    /* Footer */
    .footer-content {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
}

/* ============================================
   DESKTOP (1280px+)
   ============================================ */

@media (min-width: 1280px) {
    .container {
        padding: 0 2rem;
        max-width: 1400px;
    }

    .hero {
        height: 100dvh;
        min-height: 100dvh;
        max-height: 100dvh;
        padding-top: 120px;
        padding-bottom: 4rem;
        overflow: hidden;
    }

    .hero-title {
        font-size: 3.5rem;
    }

    .hero-subtitle {
        font-size: 1.25rem;
    }

    /* Hide dashboard preview on desktop - too tall for viewport */
    .hero-visual {
        display: none;
    }

    /* 3-column grids */
    .automation-grid,
    .pricing-grid,
    .capabilities-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }

    .automation-title,
    .section-title {
        font-size: 3rem;
    }

    .cta-title {
        font-size: 2.5rem;
    }

    /* Footer */
    .footer-content {
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }

    /* Hide mobile nav elements */
    .nav-sig-mobile-btn {
        display: none;
    }

    .nav-sig-links {
        display: flex;
    }

    body {
        padding-top: 84px;
    }
}

/* ============================================
   LARGE DESKTOP (1440px+)
   ============================================ */

@media (min-width: 1440px) {
    .container {
        max-width: 1600px;
        padding: 0 3rem;
    }

    .hero-title {
        font-size: 4rem;
    }

    .automation-title,
    .section-title {
        font-size: 3.5rem;
    }

    .nav-signature-inner {
        max-width: 96%;
    }
}

/* ============================================
   3D VIEWER PAGE - SPECIAL HANDLING
   Full viewport on mobile
   ============================================ */

@media (max-width: 767px) {
    .viewer-page body,
    body.viewer-page {
        padding-top: 0;
    }

    .viewer-page .nav-signature {
        position: absolute;
        background: transparent;
    }

    .viewer-page .nav-signature-inner {
        background: rgba(15, 23, 42, 0.7);
    }

    /* Viewer fills viewport */
    .segmentation-viewer-container,
    #viewer-container {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile */
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Bottom controls above safe area */
    .viewer-controls-bottom {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .nav-signature,
    .nav,
    .mobile-menu-button,
    .nav-sig-mobile-btn {
        display: none;
    }

    body {
        padding-top: 0;
    }
}
