/**
 * Single responsibility: Mobile responsive overrides and design optimizations.
 * Loaded last to guarantee zero regression on desktop views.
 */

/* ─── Breakpoint: 960px (Primary Table / Mobile Collapse) ────────────────── */
@media (max-width: 960px) {
  /* Header Dropdown Optimization */
  .mobile-menu {
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Hero Section Grid Stacking */
  .hero_grid {
    grid-template-columns: 1fr !important;
    gap: var(--space-8) !important;
    text-align: center !important;
  }

  .hero_content {
    align-items: center;
    text-align: center;
    padding-inline: var(--space-4);
    order: 1;
  }

  /* Form goes below content */
  .hero_form_wrapper {
    order: 2;
  }

  /* Grid Stacking Fixes */
  .premium-pillars,
  .solution-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: var(--space-4);
  }

  /* Improved 2x2 Stats Grid for Mobile */
  .stats_grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--space-4) !important;
  }

  .stat_card {
    padding: var(--space-4) !important;
    border-radius: var(--radius-xl) !important;
  }
  
  .stat_card-inner {
    gap: var(--space-3) !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
  }

  .stat_icon-box {
    width: 44px !important;
    height: 44px !important;
    margin: 0 auto !important;
  }

  .stat_icon-box svg {
    width: 22px !important;
    height: 22px !important;
  }

  .stat_number {
    font-size: 1.75rem !important;
    line-height: 1.1 !important;
  }

  .stat_label {
    font-size: 11px !important;
    line-height: 1.3 !important;
  }
  
  .stat_content {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
  }

  .announcement-badge {
    margin-inline: auto !important;
    white-space: normal !important;
    text-align: center !important;
    height: auto !important;
    line-height: 1.4 !important;
    padding: var(--space-2) var(--space-4) !important;
  }

  .hero_headline {
    font-size: clamp(2rem, 6.5vw, 2.75rem);
    margin-inline: auto;
  }

  .hero_benefits {
    align-items: flex-start;
    margin-inline: auto;
    max-width: max-content;
  }

  .hero_actions {
    justify-content: center;
    width: 100%;
  }

  .trust-badges {
    justify-content: center;
  }

  .hero_form_wrapper {
    max-width: 500px !important;
    width: 100% !important;
    margin-inline: auto !important;
    padding-inline: var(--space-4) !important;
    box-sizing: border-box !important;
  }

  .hero_form-card, 
  .hs-form-frame, 
  .hs-form-frame iframe {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Ensure HubSpot form renders on mobile */
  .hero_form-card {
    padding: var(--space-6) var(--space-4);
  }

  .hero_form-header {
    margin-bottom: var(--space-5);
  }

  .hero_form-title {
    font-size: 1.25rem;
  }

  .hero_form-subtitle {
    font-size: 0.85rem;
  }

  .hs-form-frame {
    min-height: 320px;
  }

  /* Hero benefits left-align even in centered grid for readability */
  .hero_benefit-item {
    text-align: left;
  }

  /* Mockup Visual Adjustments */
  .hero_mockup-wrapper {
    margin-top: var(--space-8);
  }

  /* Product Value Columns Centering */
  .hero_value-pillars-intro {
    text-align: center;
  }

  .hero_value-pillars-title {
    font-size: clamp(1.25rem, 4.5vw, 1.75rem);
  }

  .hero_value-pillar-stack {
    max-width: 580px;
    margin-inline: auto;
    width: 100%;
  }

  .value-row:hover {
    /* Translate upwards on mobile instead of shifting right */
    transform: translateY(-4px);
  }
}

/* ─── Breakpoint: 768px (General Section Grid Stack) ─────────────────────── */
@media (max-width: 768px) {
  /* Scale down sticky header height slightly */
  .site-logo_img {
    height: 48px;
  }

  .site-header {
    padding: var(--space-3) 0;
  }

  /* Checkout Section & Speed Visual */
  .checkout-visual {
    padding: var(--space-6) var(--space-4);
    min-height: auto;
  }

  .checkout-visual-back-layer {
    display: none !important; /* Remove giant decorative blur block to prevent overflow */
  }

  .checkout-visual-composite {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    width: 100%;
    align-items: center;
  }

  .stat-card--main {
    padding: var(--space-8) var(--space-6);
    width: 100%;
    max-width: 360px;
    margin-inline: auto;
    gap: var(--space-6);
  }

  .stat-card_header {
    justify-content: center;
  }

  .stat-value {
    font-size: clamp(3.5rem, 15vw, 5.25rem);
    justify-content: center;
    line-height: 0.9;
  }

  .stat-subtitle {
    justify-content: center;
  }

  /* Transform floating badges into a clean stacked list under the main stat card */
  .stat-card-float {
    position: relative !important;
    top: unset !important;
    bottom: unset !important;
    left: unset !important;
    right: unset !important;
    width: 100% !important;
    max-width: 320px !important;
    margin: 0 auto !important;
    animation: none !important;
    transform: none !important;
    box-shadow: var(--shadow-sm) !important;
    justify-content: flex-start;
  }

  .stat-card-float:hover {
    transform: translateY(-4px) !important;
  }

  /* ── Demo Tabs: Hide desktop tabs, show dropdown on mobile ─────── */
  .demo-tab-nav-desktop {
    display: none !important;
  }

  /* Dropdown wrapper */
  .demo-tab-dropdown-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: var(--space-6);
    z-index: 10;
  }

  /* Trigger button — looks like a premium select */
  .demo-tab-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 20px;
    background: rgba(59, 130, 246, 0.12);
    border: 1.5px solid rgba(59, 130, 246, 0.5);
    border-radius: 14px;
    color: white;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.25s ease, border-color 0.25s ease;
    text-align: left;
  }

  .demo-tab-dropdown-trigger:hover {
    background: rgba(59, 130, 246, 0.2);
  }

  .demo-tab-dropdown-trigger[aria-expanded="true"] {
    border-radius: 14px 14px 0 0;
    border-color: rgba(59, 130, 246, 0.8);
    background: rgba(59, 130, 246, 0.18);
  }

  /* Chevron rotation */
  .demo-tab-dropdown-chevron {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--color-accent, #3b82f6);
    transition: transform 0.3s ease;
  }

  .demo-tab-dropdown-trigger[aria-expanded="true"] .demo-tab-dropdown-chevron {
    transform: rotate(180deg);
  }

  /* Dropdown menu panel */
  .demo-tab-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #0d1117;
    border: 1.5px solid rgba(59, 130, 246, 0.5);
    border-top: none;
    border-radius: 0 0 14px 14px;
    list-style: none;
    padding: 8px 0;
    margin: 0;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  }

  .demo-tab-dropdown-menu.is-open {
    display: block;
  }

  /* Each option row */
  .demo-tab-dropdown-option {
    padding: 14px 20px;
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    border-left: 3px solid transparent;
  }

  .demo-tab-dropdown-option:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
  }

  .demo-tab-dropdown-option.is-selected {
    color: var(--color-accent, #3b82f6);
    font-weight: 700;
    border-left-color: var(--color-accent, #3b82f6);
    background: rgba(59, 130, 246, 0.08);
  }

  /* Fix demo image screenshot stretching */
  .demo-screenshot-img {
    min-height: 220px;
    height: auto;
    object-fit: contain; /* Avoid crop distortions on screenshots */
  }

  /* Accordion Header margins */
  .faq-visual-title {
    font-size: clamp(2rem, 5vw, 2.75rem);
    text-align: center;
  }

  .faq-visual-sub {
    text-align: center;
    margin-inline: auto;
  }

  .faq-visual-content {
    align-items: center;
  }

  /* Testimonials CSS Carousel */
  .reviews-grid {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    gap: var(--space-4);
    padding-bottom: var(--space-4);
    margin-inline: -1rem;
    padding-inline: 1rem;
  }
  .reviews-grid::-webkit-scrollbar {
    display: none;
  }
  .review-card {
    flex: 0 0 85% !important;
    scroll-snap-align: center;
    min-width: 280px;
  }

  /* Comparison Table Scroll — only when above 640px (below 640 uses card layout) */
  .comparison-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-inline: -1rem;
    padding-inline: 1rem;
    scrollbar-width: none;
  }
  .comparison-table-wrapper::-webkit-scrollbar {
    display: none;
  }

  /* Footer Stack */
  .footer-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: var(--space-8);
    text-align: center;
  }
  .footer-brand {
    align-items: center;
    display: flex;
    flex-direction: column;
  }
  .footer-col {
    align-items: center;
  }
  .footer-address-item, .footer-contact-info, .footer-col_links {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .footer-social-premium {
    justify-content: center;
    margin-top: var(--space-4);
  }
  .footer-bottom {
    display: flex;
    flex-direction: column;
    text-align: center;
    gap: var(--space-4);
  }

  /* Bento Grid Card Mobile Scaling */
  .feature-card_icon-wrap,
  .feature-card:nth-child(n) .feature-card_icon-wrap {
    width: 48px !important;
    height: 48px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-bottom: var(--space-4) !important;
  }
  
  .feature-card_icon svg,
  .feature-card:nth-child(n) .feature-card_icon svg {
    width: 24px !important;
    height: 24px !important;
  }
}

/* ─── Breakpoint: 480px (Mobile Screens) ────────────────────────────────── */
@media (max-width: 480px) {
  /* Bento Grid Card Padding scaling */
  .feature-card {
    padding: var(--space-5) !important;
    min-height: 260px;
  }

  .feature-card_title {
    font-size: var(--font-size-lg);
  }

  .feature-card_desc {
    font-size: var(--font-size-sm);
  }

  /* Pricing Amount and description */
  .pricing-amount {
    font-size: 3rem;
  }

  .pricing-currency {
    font-size: 1.5rem;
  }

  /* Action Buttons Spanning Full Width */
  .hero_actions .btn,
  .checkout-cta-group .btn,
  .demo-section .btn,
  .pricing-card-split_left .btn,
  .cta-banner-content .btn,
  .faq-accordion-col .btn {
    width: 100% !important;
    justify-content: center;
    display: inline-flex;
  }
}

/* ─── Breakpoint: 375px (Small Phones / iPhone SE) ──────────────────────── */
@media (max-width: 390px) {
  /* Reduce hero top padding so headline isn't pushed way down */
  .hero_inner {
    padding-top: 100px;
  }

  /* Section padding tighter */
  .section {
    padding-block: var(--space-12) !important;
  }

  /* Ensure container never overflows */
  .container,
  .container--narrow {
    padding-inline: var(--space-3);
  }

  /* Announcement badge wraps on tiny screens */
  .announcement-badge {
    white-space: normal;
    text-align: center;
    max-width: 100%;
  }

  /* Hero headline tighter on very small screens */
  .hero_headline {
    font-size: clamp(1.75rem, 8vw, 2.25rem);
  }

  /* Trust badges stack vertically */
  .trust-badges {
    flex-direction: column;
    gap: var(--space-2);
    align-items: center;
  }

  /* Pillar cards padding reduction */
  .pillar-card {
    padding: var(--space-3) var(--space-4) !important;
  }

  /* Solution card inner padding */
  .solution-card-premium {
    padding: var(--space-6) var(--space-4) !important;
  }

  /* Pricing card sides tighter */
  .pricing-card-split_left,
  .pricing-card-split_right {
    padding: var(--space-6) var(--space-4) !important;
  }

  /* CTA banner padding */
  .cta-banner {
    padding: var(--space-8) var(--space-4) !important;
  }

  /* Footer contact row stacks */
  .footer-contact-centered {
    flex-direction: column;
    gap: var(--space-3);
    align-items: center;
  }

  /* Footer dock stays fully visible */
  .footer-social-container {
    padding: 10px 16px !important;
  }

  .footer-social-premium {
    gap: var(--space-3) !important;
  }

  .footer-social-premium li a {
    width: 36px !important;
    height: 36px !important;
  }
}

/* ─── Global: Prevent any element from causing horizontal overflow ───────── */
@media (max-width: 768px) {
  /* Sections that use absolute-positioned decorative orbs */
  .features-section,
  .value-props-section,
  .checkout-section {
    overflow: hidden;
  }

  /* Hero needs overflow-x hidden only to prevent horizontal scroll from orbs,
     but overflow-y must remain visible so the form doesn't get clipped */
  .hero {
    overflow: hidden;
  }

  /* Reduce hero inner padding-top slightly on tablet/mobile */
  .hero_inner {
    padding-top: 110px;
  }

  /* Trust band logos: allow wrapping with tighter gap */
  .trust-logos {
    gap: var(--space-6);
    flex-wrap: wrap;
    justify-content: center;
  }

  /* Comparison table: ensure wrapper clips overflow cleanly */
  .comparison-table-wrapper {
    border-radius: var(--radius-md);
  }

  /* Demo highlight strip: remove border-left on mobile for cleaner look */
  .demo-highlight-strip {
    flex-direction: column;
    text-align: center;
    align-items: center;
    border-left: none;
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-6);
  }

  /* CTA section: center all content */
  .cta-section .cta-banner {
    text-align: center;
  }

  /* Reviews grid: cards take more width on mobile */
  .review-card {
    flex: 0 0 88% !important;
  }

  /* Features CTA strip: center on mobile */
  .features-cta-strip {
    padding: var(--space-8) var(--space-4) !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   HERO SECTION — Mobile-specific fixes
   ═══════════════════════════════════════════════════════════════════════════ */

/* Tablet (960px): Reduce form card padding after grid collapses to 1 col */
@media (max-width: 960px) {
  .hero_inner {
    padding-top: 120px;
    padding-bottom: var(--space-16);
  }

  /* Reduce the large form card padding so it doesn't feel like a giant block */
  .hero_form-card {
    padding: var(--space-6) !important;
    border-radius: var(--radius-xl) !important;
  }

  /* Clamp benefits list width so it never overflows narrow screens */
  .hero_benefits {
    max-width: min(max-content, 100%) !important;
    width: 100%;
  }

  /* Tighten the space below the mockup */
  .hero_mockup-wrapper {
    padding-inline: var(--space-3);
  }

  /* Value-row should be full width on mobile */
  .hero_value-pillar-stack .value-row {
    width: 100%;
    box-sizing: border-box;
  }
}

/* Phone (480px): Further tighten hero for smaller viewports */
@media (max-width: 480px) {
  .hero_inner {
    padding-top: 95px;
    padding-bottom: var(--space-12);
  }

  .hero_grid {
    gap: var(--space-6) !important;
  }

  .hero_form-card {
    padding: var(--space-4) !important;
    border-radius: var(--radius-lg) !important;
  }

  /* ── HUBSPOT FORM FORCE-VISIBLE FIX ───────────────────────────────── */
  /* Guarantee form container and HubSpot injected iframe always show */
  .hero_form_wrapper,
  .hero_form-card {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    overflow: visible !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .hs-form-frame {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    overflow: visible !important;
    width: 100% !important;
    min-height: 380px !important;
    height: auto !important;
  }

  /* Force any iframe HubSpot injects to render at full width */
  .hs-form-frame iframe,
  #hubspot-form-container iframe,
  #hubspot-form-container > * {
    display: block !important;
    width: 100% !important;
    min-height: 380px !important;
    height: auto !important;
    border: none !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  /* Headline tighter */
  .hero_headline {
    font-size: clamp(1.85rem, 7.5vw, 2.4rem);
    line-height: 1.15;
  }

  /* Trust badge items wrap to 2-col grid on phones */
  .trust-badges {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2) var(--space-4);
    justify-items: start;
    width: 100%;
    max-width: 340px;
    margin-inline: auto;
  }

  /* Mockup screenshots: reduce chrome bar height on tiny screens */
  .mockup-window_bar {
    padding: 8px 14px;
  }

  /* Hero form wrapper full width on phones */
  .hero_form_wrapper {
    max-width: 100% !important;
    padding-inline: 0 !important;
  }

  /* Value section tighter */
  .hero_value-section {
    margin-top: var(--space-4) !important;
    padding-bottom: var(--space-3) !important;
  }

  /* Stats strip tighter on mobile */
  .hero_innovation-stats {
    padding: var(--space-2) 0 var(--space-8) !important;
  }

  .hero_value-split {
    padding-inline: var(--space-3) !important;
  }

  /* Value rows: more compact on small phones */
  .value-row {
    padding: var(--space-3) var(--space-4) !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   COMPARISON TABLE — Card stacking layout on mobile (≤640px)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  /* Step 1: Remove scroll container constraints — replaced by card layout */
  .comparison-table-wrapper {
    overflow-x: visible !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin-inline: 0 !important;
    padding-inline: 0 !important;
  }

  /* Remove min-width that was inherited from 768px breakpoint */
  .comparison-table {
    min-width: unset !important;
  }

  /* Step 2: Make table elements block-level so rows stack vertically */
  .comparison-table,
  .comparison-table tbody {
    display: block;
    width: 100%;
  }

  /* Step 3: Hide the thead — column headers appear as inline labels instead */
  .comparison-table thead {
    display: none;
  }

  /* Step 4: Each <tr> becomes a self-contained card */
  .comparison-table tbody tr {
    display: block;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
    overflow: hidden;
  }

  .comparison-table tbody tr:last-child {
    margin-bottom: 0;
  }

  /* Step 5: Each <td> becomes a flex row within the card */
  .comparison-table td {
    display: flex;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border);
    font-size: var(--font-size-sm);
    width: 100%;
    box-sizing: border-box;
    text-align: left;
  }

  .comparison-table td:last-child {
    border-bottom: none;
  }

  /* Step 6: Feature cell — acts as the card's title row */
  .comparison-table .td-feature {
    background: rgba(255, 255, 255, 0.04);
    font-weight: 800;
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    letter-spacing: -0.01em;
  }

  /* Step 7: Elixir + Traditional rows show a label prefix from data-label */
  .comparison-table .td-elixir::before,
  .comparison-table .td-traditional::before {
    content: attr(data-label);
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-text-muted);
    flex-shrink: 0;
    min-width: 100px;
    margin-right: var(--space-3);
  }

  /* Elixir row gets a blue left accent */
  .comparison-table .td-elixir {
    background: rgba(59, 130, 246, 0.06);
    border-left: 3px solid rgba(59, 130, 246, 0.5);
    gap: 0;
  }

  .comparison-table .td-traditional {
    gap: 0;
  }

  /* Win pill: smaller & wrappable inside the card */
  .comparison-table .td-elixir .win-pill {
    font-size: 0.7rem;
    padding: 4px var(--space-3);
    white-space: normal;
    line-height: 1.4;
    flex-shrink: 1;
  }

  .comparison-table .td-elixir .win-pill svg {
    flex-shrink: 0;
  }
}

/* On desktop: hide the mobile dropdown, show desktop tab nav normally */
@media (min-width: 769px) {
  .demo-tab-dropdown-wrapper {
    display: none !important;
  }

  .demo-tab-nav-desktop {
    display: block !important;
  }
}
