/* ========================================
   MOBILE STYLES - Consolidated
   All mobile media queries in one place
   ======================================== */

/* === TABLET: 768px and below === */
@media (max-width: 768px) {
    :root {
        --mobile-nav-offset: 5.75rem;
    }

    /* Base Document */
    html, body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 0;
    }

    section {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        position: relative;
    }

    .container {
        max-width: 100%;
        padding-left: 1rem;
        padding-right: 1rem;
        margin: 0 auto;
    }

    .absolute {
        max-width: 100vw;
    }

    [class*="w-96"],
    [class*="w-80"],
    [class*="w-72"] {
        max-width: 100%;
    }

    /* Main Scene */
    #main-scene {
        height: auto;
        min-height: 100vh;
        width: 100%;
        position: relative;
        overflow: hidden;
        margin: 0;
        padding: 0;
    }

    .sticky-container {
        width: 100%;
        height: auto;
        min-height: 100vh;
        position: relative;
        top: 0;
        overflow: hidden;
        margin: 0;
        padding: 0;
    }

    #sphere-canvas {
        /* Canvas sizing and positioning now controlled by JS for proper aspect ratio on iOS */
        /* JS sets: position, top, left, transform, width, height */
        max-width: none;
        margin: 0;
        padding: 0;
    }

    #mockup-sphere-canvas {
        z-index: 15 !important;
        visibility: visible !important;
        display: block !important;
    }

    /* Hero Section */
    .hero-emerge {
        position: relative;
        width: 100%;
        min-height: auto;
        padding: 0.5rem;
        display: flex;
        align-items: flex-start;
        padding-top: var(--mobile-nav-offset, 5.75rem);
        padding-top: calc(var(--mobile-nav-offset, 5.75rem) + env(safe-area-inset-top));
        padding-bottom: 1rem;
    }

    .hero-emerge .h-full {
        height: auto;
        width: 100%;
    }

    .hero-emerge .grid {
        display: flex !important;
        flex-direction: column !important;
        height: 100%;
        width: 100%;
        max-width: 100%;
        gap: 1.5rem !important;
    }

    #hero-content {
        min-height: auto;
        width: 100%;
        max-width: 100%;
        overflow: visible;
        position: relative;
        display: flex;
        align-items: flex-start;
    }

    .hero-emerge .text-left {
        text-align: center !important;
        padding: 0 0.75rem !important;
        max-width: 100%;
        order: 1 !important;
        width: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        flex: 0 0 auto;
    }

    /* Trim button spacing before logos on mobile */
    .hero-emerge .text-left .mb-6 {
        margin-bottom: 1.5rem !important;
    }

    .hero-emerge .text-left::after {
        display: none;
    }

    #hero-animation-container {
        min-height: 240px !important;
        width: 100% !important;
        margin: 0 !important;
        order: 3 !important;
        position: relative !important;
        background: transparent;
        z-index: 10 !important;
        padding: 0.5rem;
        display: block !important;
        opacity: 1 !important;
        transform: none !important;
        flex: 0 0 auto;
        overflow: visible !important;
    }

    #hero-animation-container .hero-animation-window {
        height: 100% !important;
        max-height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .hero-emerge .research-update-container {
        position: relative !important;
        z-index: 20 !important;
        margin: 1rem auto 0;
        order: 2;
        width: 100%;
        max-width: 85%;
        transform: none !important;
        opacity: 1 !important;
    }

    .hero-emerge .research-update-container p {
        font-size: 1.15rem !important;
        line-height: 1.5 !important;
        margin-bottom: 0.3rem !important;
    }

    .research-update-container a {
        font-size: 1rem !important;
        line-height: 1.45 !important;
        margin-top: 0.35rem !important;
        display: inline-block;
    }

    .hero-emerge h1 {
        font-size: 2rem !important;
        line-height: 1.15 !important;
        margin-bottom: 0.85rem !important;
        text-align: center;
        font-weight: 700;
    }

    .hero-emerge p {
        font-size: 1rem !important;
        line-height: 1.4 !important;
        margin-bottom: 1.15rem !important;
        text-align: center;
    }

    .hero-emerge .btn-primary {
        margin: 0 auto;
        display: inline-block;
        margin-top: 0.25rem;
        padding: 0.75rem 2rem !important;
        font-size: 1.1rem !important;
    }

    /* Hero logos: tighten vertical rhythm and scale text down */
    .hero-logos-container {
        margin-top: 2rem !important;
    }

    .hero-emerge .hero-logos-title {
        font-size: clamp(0.5rem, 1.9vw, 0.58rem) !important;
        letter-spacing: 0.06em;
        line-height: 1.15;
        margin-bottom: 0.55rem !important;
    }

    /* Hero Animation Window */
    .hero-animation-window {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        transform: none;
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
        border-radius: 12px;
        background: rgba(17, 24, 39, 0.9) !important;
    }

    .hero-animation-content {
        padding: 0.5rem;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

    .hero-animation-inner {
        height: 100%;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        transform: none !important;
    }

    .hero-animation-window.visible {
        opacity: 1 !important;
    }

    /* Use Case Grid */
    .use-case-grid-container {
        transform: translate(-50%, -50%) scale(0.95) !important;
        width: 95% !important;
    }

    .use-case-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.375rem;
        padding: 0;
        max-width: 100%;
        margin: 0 auto;
        width: 100%;
    }

    .use-case-card-mini {
        padding: 0.625rem;
        min-height: 65px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        text-align: center;
        border-radius: 8px;
    }

    .use-case-card-mini h4 {
        font-size: 0.7rem;
        margin-bottom: 0.125rem;
        line-height: 1.2;
    }

    .use-case-card-mini p {
        font-size: 0.6rem;
        line-height: 1.1;
        opacity: 0.8;
    }

    /* Persona Sphere */
    .persona-sphere-container {
        min-height: 350px;
        width: 100%;
        position: relative;
        overflow: visible;
    }

    .persona-sphere-container canvas {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(0.85);
        width: 90%;
        height: 90%;
        max-width: 320px;
        max-height: 320px;
        object-fit: contain;
    }

    .persona-info-box {
        min-width: 180px !important;
        max-width: 200px !important;
        transform: translateY(-50%) !important;
        padding: 0 !important;
    }

    .persona-avatar-section {
        padding: 16px 16px 12px !important;
    }

    .persona-avatar-icon {
        width: 50px !important;
        height: 50px !important;
    }

    .persona-avatar-icon svg {
        width: 28px !important;
        height: 28px !important;
    }

    .persona-info-content {
        padding: 12px 16px 16px !important;
    }

    .persona-info-content p {
        font-size: 0.75rem !important;
        line-height: 1.5 !important;
    }

    .persona-tag {
        font-size: 0.65rem !important;
        padding: 2px 8px !important;
    }

    /* Feature Section */
    .feature-section {
        padding: 1rem 1rem;
        min-height: auto;
        overflow: visible;
        isolation: isolate;
    }

    .feature-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 0 1rem;
    }

    .feature-text {
        order: 1;
        text-align: center;
    }

    .feature-text h3 {
        font-size: 2rem;
        margin-bottom: 1rem;
    }

    .feature-text p {
        font-size: 1rem;
    }

    .feature-highlight {
        font-size: 1.1rem !important;
    }

    .feature-details {
        font-size: 0.95rem !important;
    }

    .feature-mockup {
        order: 2;
    }

    #features .feature-section:first-child {
        padding-top: 1rem;
    }

    /* Tabs */
    .tab-content-wrapper {
        min-height: auto !important;
    }

    /* Tab Panel Mobile Layout Fix - use normal flow instead of absolute positioning */
    .tab-panel {
        position: static !important;
        opacity: 1 !important;
        transform: none !important;
        display: none;
        padding: 0 !important;
    }

    .tab-panel.active {
        display: block !important;
        animation: none !important;
    }

    /* Tab Panel Content - reduce horizontal padding */
    .tab-panel > div {
        padding: 1rem !important;
    }

    .tab-panel .glass-content {
        padding: 1rem !important;
    }

    /* Get Started Section */
    #get-started {
        padding-top: 3rem !important;
        padding-bottom: 3rem !important;
    }

    #get-started .btn-primary {
        padding: 0.75rem 1.5rem !important;
        font-size: 1rem !important;
    }

    .feature-section[data-feature="how-it-works"] .tab-text {
        font-size: 0.875rem;
    }

    .feature-section[data-feature="how-it-works"] .tab-button {
        padding: 0.75rem 0.75rem 0.75rem 3rem;
    }

    /* Navigation */
    nav {
        padding: 0.5rem 1rem;
    }

    #mobile-menu {
        top: var(--mobile-nav-offset, 5.75rem);
        top: calc(var(--mobile-nav-offset, 5.75rem) + env(safe-area-inset-top));
    }

    /* Video Section */
    .video-demo-section {
        padding: 60px 0;
    }

    .video-demo-container {
        padding: 0 1rem;
    }

    .video-demo-header h2 {
        font-size: 2rem;
    }

    .video-wrapper {
        padding: 1rem;
        border-radius: 16px;
    }

    /* Industry Showcase */
    .industry-showcase-container {
        height: auto;
        padding: 2rem 1rem;
        gap: 2rem;
    }

    .industries-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        max-width: 100%;
    }

    .industry-card {
        padding: 1.5rem 1rem;
    }

    .industry-icon {
        width: 2.5rem;
        height: 2.5rem;
        margin-bottom: 0.75rem;
    }

    .industry-icon svg {
        width: 1.25rem;
        height: 1.25rem;
    }

    .industry-card h4 {
        font-size: 0.875rem;
    }

    .industry-card p {
        font-size: 0.7rem;
    }

    .trust-metrics {
        flex-direction: column;
        gap: 1rem;
        padding: 1.25rem;
        width: 100%;
    }

    /* Trust Badge */
    .trust-badge-container {
        margin-top: 0.5rem;
        padding: 0.75rem;
    }

    .trust-badge-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .soc-badge {
        height: 60px;
    }

    /* Backed By Section */
    .backed-by-section {
        padding: 3rem 0;
    }

    .backed-by-title {
        font-size: 0.75rem;
        margin-bottom: 2rem;
    }

    .vc-logos-container {
        gap: 1rem;
    }

    .vc-logo-wrapper {
        padding: 1rem 1.5rem;
    }

    .vc-logo {
        height: 50px;
        max-width: 140px;
    }

    .metric-divider {
        width: 3rem;
        height: 1px;
    }

    .metric-value {
        font-size: 1.25rem;
    }

    .metric-label {
        font-size: 0.7rem;
    }

    /* Footer */
    .footer-soc-badge {
        margin-left: 0;
        margin-top: 1rem;
    }

    .footer-soc-badge img {
        height: 40px;
    }

    footer {
        padding: 2rem 1rem;
    }

    footer .container {
        flex-direction: column;
        gap: 1.5rem;
    }

    /* Main footer layout - stack vertically */
    footer > .container > div {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
    }

    /* Keep logo and text on same line */
    footer .items-center.space-x-2 {
        flex-direction: row !important;
        justify-content: center;
    }

    /* Keep Terms/Privacy/Contact links on same line */
    footer .flex.gap-6 {
        flex-direction: row !important;
    }

    footer .text-xl {
        font-size: 1.125rem;
    }

    footer .text-sm {
        text-align: center;
    }

    /* Footer logo - maintain square aspect ratio */
    footer .items-center.space-x-2 img {
        width: 28px !important;
        height: 28px !important;
    }

    /* Feature Animation Container */
    #feature-animation-container {
        height: clamp(480px, 78vh, 640px);
        max-height: 85vh;
        aspect-ratio: auto;
        min-height: 0;
        overflow: hidden;
    }

    .feature-animation-window {
        position: relative;
        top: auto;
        left: auto;
        width: 100%;
        height: 100%;
        min-height: 0;
        overflow: hidden;
    }

    .feature-animation-inner {
        position: relative;
        height: 100%;
        min-height: 0;
    }

    .feature-slide {
        position: relative;
        padding: 1.5rem;
        width: 100%;
        height: 100%;
        opacity: 0;
        transform: none;
        display: none;
        align-items: stretch;
        justify-content: flex-start;
        pointer-events: none;
        overflow: hidden;
    }

    .feature-slide.active {
        opacity: 1;
        display: flex;
        pointer-events: auto;
    }

    #feature-loading-screen,
    #feature-results-screen {
        overflow: hidden;
        -webkit-overflow-scrolling: touch;
    }

    #feature-results-screen {
        align-items: stretch;
    }

    #feature-results-content-wrapper {
        height: 100%;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    #feature-results-screen .feature-results-scroll {
        position: relative;
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: scroll;
        scrollbar-gutter: stable;
        scrollbar-width: thin;
        scrollbar-color: var(--accent-primary) rgba(255, 255, 255, 0.08);
        -webkit-overflow-scrolling: touch;
        padding-right: 0.75rem;
        margin-right: -0.75rem;
    }

    #feature-results-screen .feature-results-scroll::-webkit-scrollbar {
        width: 8px;
    }

    #feature-results-screen .feature-results-scroll::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.08);
        border-radius: 9999px;
    }

    #feature-results-screen .feature-results-scroll::-webkit-scrollbar-thumb {
        background: var(--accent-primary);
        border-radius: 9999px;
    }

    /* Touch fallback: always-visible indicator so users know the area scrolls */
    #feature-results-screen .feature-results-scroll::after {
        content: '';
        position: absolute;
        top: 12px;
        right: 6px;
        width: 4px;
        height: 32px;
        border-radius: 9999px;
        background: rgba(255, 255, 255, 0.25);
        pointer-events: none;
        opacity: 0.9;
    }

    @media (hover: hover) and (pointer: fine) {
        #feature-results-screen .feature-results-scroll::after {
            display: none;
        }
    }

    .feature-loading-persona-grid {
        gap: 12px;
        flex-wrap: wrap;
        max-width: 300px;
        margin-bottom: 2rem;
    }

    .feature-participant-avatar .avatar {
        width: 40px;
        height: 40px;
    }

    .feature-participant-avatar .avatar svg {
        width: 22px;
        height: 22px;
    }

    #feature-spinner-container {
        width: 8rem;
        height: 8rem;
    }

    #feature-main-heading {
        font-size: 1.25rem;
    }

    #feature-progress-container {
        width: 90%;
    }

    #feature-progress-labels {
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
    }

    #feature-progress-labels span:nth-child(2),
    #feature-progress-labels span:nth-child(4) {
        display: none;
    }

    /* Speed Comparison */
    .speed-method {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 10px 12px;
    }

    .speed-method-row {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
    }

    .method-name {
        font-size: 0.75rem;
    }

    .time-value {
        font-size: 0.875rem;
    }

    .speed-metric {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    .speed-label {
        display: none;
    }

    .visual-bar {
        height: 6px;
    }

    .speed-time {
        font-size: 1.2rem;
    }

    .multiplier-label {
        font-size: 0.75rem;
    }

    .multiplier-value {
        font-size: 0.9rem;
    }

    .speed-bar-wrapper {
        height: 10px;
    }
}

/* === SMALL MOBILE: 480px and below === */
@media (max-width: 480px) {
    .hero-emerge {
        padding: 0.5rem;
        padding-top: var(--mobile-nav-offset, 5.75rem);
        padding-top: calc(var(--mobile-nav-offset, 5.75rem) + env(safe-area-inset-top));
        padding-bottom: 0.25rem;
    }

    .hero-emerge h1 {
        font-size: 1.85rem !important;
        margin-bottom: 0.85rem !important;
    }

    .hero-emerge p {
        font-size: 0.95rem !important;
        margin-bottom: 1rem !important;
        line-height: 1.4 !important;
    }

    .hero-emerge .hero-logos-title {
        font-size: clamp(0.46rem, 2.5vw, 0.52rem) !important;
        letter-spacing: 0.05em;
        line-height: 1.1;
        margin-bottom: 0.45rem !important;
    }

    .hero-emerge .text-left .mb-6 {
        margin-bottom: 0.9rem !important;
    }

    .hero-emerge .btn-primary {
        padding: 0.6rem 1.5rem !important;
        font-size: 1rem !important;
    }

    #hero-animation-container {
        min-height: 200px !important;
        padding: 0.25rem !important;
        overflow: visible !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        z-index: 10 !important;
    }

    .hero-animation-content .use-case-grid {
        gap: 0.25rem !important;
    }

    .hero-animation-content .use-case-card-mini h4 {
        font-size: 0.55rem !important;
    }

    .hero-animation-content .use-case-card-mini p {
        display: none !important;
    }

    .hero-animation-content .use-case-card-mini {
        min-height: 40px !important;
    }

    .hero-animation-window {
        margin: 0.25rem;
        border-radius: 8px;
    }

    .hero-animation-content {
        padding: 0.75rem;
    }

    /* Use Case Grid */
    .use-case-grid {
        gap: 0.375rem;
    }

    .use-case-card-mini {
        padding: 0.625rem;
        min-height: 70px;
    }

    .use-case-card-mini h4 {
        font-size: 0.7rem;
    }

    .use-case-card-mini p {
        font-size: 0.6rem;
    }

    .study-ui-content h3 {
        font-size: 1.125rem;
    }

    .study-ui-content p {
        font-size: 0.8125rem;
    }

    /* Persona Sphere */
    .persona-sphere-container {
        min-height: 300px;
    }

    .persona-sphere-container canvas {
        transform: translate(-50%, -50%) scale(0.75);
        width: 85%;
        height: 85%;
        max-width: 280px;
        max-height: 280px;
    }

    .persona-info-box {
        min-width: 150px !important;
        max-width: 170px !important;
    }

    .persona-avatar-section {
        padding: 12px 12px 10px !important;
    }

    .persona-avatar-icon {
        width: 40px !important;
        height: 40px !important;
    }

    .persona-avatar-icon svg {
        width: 24px !important;
        height: 24px !important;
    }

    .persona-info-content {
        padding: 10px 12px 12px !important;
    }

    .persona-info-content p {
        font-size: 0.7rem !important;
    }

    .persona-tag {
        font-size: 0.6rem !important;
    }

    /* Feature Section */
    #features .feature-section:first-child {
        padding-top: 0.75rem;
    }

    .feature-section {
        padding: 0.75rem 1rem;
    }

    /* Industry Grid */
    .industries-grid {
        gap: 0.75rem;
    }

    .industry-card {
        padding: 1.25rem 0.75rem;
    }

    /* Feature Animation */
    .feature-loading-persona-grid {
        gap: 8px;
        max-width: 240px;
    }

    .feature-participant-avatar .avatar {
        width: 36px;
        height: 36px;
    }

    #feature-spinner-container {
        width: 7rem;
        height: 7rem;
    }

    #feature-main-heading {
        font-size: 1.125rem;
    }
}

/* === iPhone Safe Area Fixes === */
@supports (-webkit-touch-callout: none) {
    #main-scene {
        width: 100%;
        margin: 0;
        padding: 0;
    }

    body {
        width: 100vw;
        overflow-x: hidden;
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    nav {
        padding-top: calc(0.75rem + env(safe-area-inset-top));
    }

    #mobile-menu {
        top: calc(var(--mobile-nav-offset, 5.75rem) + env(safe-area-inset-top));
    }

    footer {
        padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    }

    /* Safari mobile viewport height fix */
}

/* === Trusted Leaders Section Mobile Fix === */
@media (max-width: 768px) {
    #trusted-leaders .feature-section {
        padding-bottom: 1rem;
    }

    #trusted-leaders .industries-grid {
        margin-bottom: 1rem;
    }

    #trusted-leaders .industry-showcase-container {
        padding-bottom: 1.5rem;
    }
}
