/**
 * Dual-surface pass v2 — peer mobile patterns (sticky Quote+WA) + user design rules
 * (no pill clusters, one primary convert path, brand chrome calm).
 * Loads AFTER site.css + refine-theme.css. Does NOT touch #homeHeroCarousel assets.
 */
:root {
  --ds-convert-h: 0px;
}

/* —— Desktop: keep catalog calm —— */
@media (min-width: 1025px) {
  .section-title h2,
  .section-title h1 {
    letter-spacing: -0.02em;
  }

  .blog-grid {
    gap: 28px;
  }

  .mobile-convert {
    display: none !important;
  }
}

@media (max-width: 1024px) {
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    gap: 18px;
  }

  .apps-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  }
}

/* —— Phone / tablet chrome —— */
@media (max-width: 980px) {
  :root {
    --ds-convert-h: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  .navbar .container > div:last-child {
    gap: 8px !important;
    flex-wrap: nowrap;
  }

  .navbar .lang-dropdown {
    display: none !important;
  }

  .logo {
    font-size: clamp(0.95rem, 3.8vw, 1.08rem);
    max-width: calc(100vw - 88px);
  }

  /* Hide legacy floats — convert bar is the single persistent action */
  .customer-widget,
  .to-top,
  .wa-float {
    display: none !important;
  }

  body {
    padding-bottom: calc(var(--ds-convert-h) + 12px);
  }

  /* Sticky convert bar (ChargeNow/Bajie-style Get Quote, adapted) */
  .mobile-convert {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10060;
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 10px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(248, 250, 252, 0.94);
    border-top: 1px solid rgba(148, 163, 184, 0.28);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .mobile-convert__quote,
  .mobile-convert__wa {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-weight: 750;
    font-size: 0.95rem;
    text-decoration: none;
    letter-spacing: 0.01em;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-convert__quote {
    background: #0f172a;
    color: #f8fafc !important;
    border: 1px solid #0f172a;
  }

  .mobile-convert__wa {
    background: #fff;
    color: #128c7e !important;
    border: 1px solid rgba(18, 140, 126, 0.45);
  }

  /* On inquiry page: keep WhatsApp only (form is already the quote) */
  body.is-contact-route .mobile-convert {
    grid-template-columns: 1fr;
  }

  body.is-contact-route .mobile-convert__quote {
    display: none;
  }

  /* Country strip: scroll tabs — rectangular, NOT rounded-full pills (user rule) */
  .seo-product-links {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 0;
    margin-top: 14px;
    padding: 0 0 10px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  }

  .seo-product-links a {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
    margin: 0;
    border: none;
    border-radius: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    white-space: nowrap;
    font-size: 0.86rem;
    font-weight: 650;
    color: var(--text-2, #334155);
    text-decoration: none;
  }

  .seo-product-links a:hover,
  .seo-product-links a:focus-visible {
    color: var(--accent, #1d4ed8);
    border-bottom-color: var(--accent, #1d4ed8);
  }

  /* Hub path under SEO lead — same calm tab treatment */
  .hub-path {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding-bottom: 6px;
  }

  .hub-path a {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
    white-space: nowrap;
  }

  /* Full-width CTAs */
  .oem-fs-actions .btn-primary,
  .oem-fs-actions .btn-outline,
  .blog-actions .blog-read-link,
  .inquiry-btn.btn-primary,
  .contact-form .btn-primary,
  .btn-primary.inquiry-btn,
  .home-catalog-actions .btn-primary,
  .home-catalog-actions .btn-outline {
    width: 100%;
    min-height: 48px;
    justify-content: center;
  }

  .oem-fs-actions,
  .home-catalog-actions,
  .hero-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }

  .oem-fs-actions .btn-outline,
  .home-catalog-actions .btn-outline {
    width: 100%;
  }

  /* Factory proof CTAs: side-by-side on phone (not stacked full-width towers) */
  .factory-proof__cta {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    flex-direction: unset;
  }

  .factory-proof__cta .btn-primary,
  .factory-proof__cta .btn-outline {
    width: 100%;
    min-height: 48px;
    justify-content: center;
  }

  /* Carousel chrome only — larger hit areas, no asset/markup change */
  #homeHeroCarousel .hero-carousel-nav {
    width: 44px;
    height: 44px;
    opacity: 0.92;
  }

  #homeHeroCarousel .hero-carousel-dot {
    min-width: 12px;
    min-height: 12px;
    padding: 10px 6px;
    box-sizing: content-box;
  }

  #homeHeroCarousel .hero-carousel-dots {
    bottom: max(18px, env(safe-area-inset-bottom, 0px));
    gap: 4px;
  }

  /* Drawer */
  .mobile-menu .panel {
    width: min(100vw - 40px, 360px);
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
  }

  .mobile-menu .panel-head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: inherit;
    padding-bottom: 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  }

  .mobile-menu .link {
    min-height: 48px;
    display: flex;
    align-items: center;
  }

  .mobile-lang {
    display: block;
    margin: 16px 0 8px;
    padding-top: 14px;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
  }

  .mobile-lang__label {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-3, #94a3b8);
    margin-bottom: 8px;
  }

  .mobile-lang__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .mobile-lang__grid button {
    min-height: 44px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(15, 23, 42, 0.04);
    color: inherit;
    font-size: 0.88rem;
    font-weight: 650;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-support {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
  }

  .mobile-support a,
  .mobile-support button {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: transparent;
    color: inherit;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
  }

  /* One job per section: tighten secondary copy on phone */
  .seo-answer-lead {
    font-size: 0.98rem;
    line-height: 1.55;
  }

  .catalog-cta-strip {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }
}

@media (max-width: 768px) {
  :root {
    --section-pad: 48px;
    --section-pad-mobile: 48px;
  }

  section {
    padding: 48px 0;
  }

  .section-title {
    margin-bottom: 22px;
  }

  .section-title h2,
  .section-title h1 {
    font-size: clamp(1.4rem, 5.8vw, 1.75rem);
    line-height: 1.22;
  }

  .section-title p {
    font-size: 0.92rem;
    line-height: 1.5;
    max-width: 36em;
  }

  .product-grid,
  .apps-grid,
  .blog-grid,
  .merge-grid,
  .trust-grid,
  #oemCaseGrid,
  #quickProductGrid {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }

  /* Interaction cards: less chrome, more tap area */
  .product-card,
  .blog-card {
    border-radius: 14px;
  }

  .blog-actions {
    flex-direction: column;
    align-items: stretch !important;
    gap: 8px;
  }

  .blog-actions .blog-read-link {
    width: 100%;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0 !important;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border, rgba(148, 163, 184, 0.28));
    background: rgba(255, 255, 255, 0.7);
  }

  .footer-social a,
  .footer-social .social {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .footer-row {
    gap: 24px;
    padding: 20px 14px;
  }

  .contact-form .btn-primary,
  .contact-form button[type="submit"],
  form .btn-primary {
    width: 100%;
    min-height: 52px;
    font-size: 1rem;
  }

  .pd-selling-row {
    grid-template-columns: 1fr !important;
  }

  .form-control {
    min-height: 48px;
  }

  textarea.form-control {
    min-height: 96px;
  }
}

@media (max-width: 480px) {
  :root {
    --section-pad: 40px;
    --section-pad-mobile: 40px;
  }

  section {
    padding: 40px 0;
  }

  .container {
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
  }

  .contact-info,
  .contact-form {
    padding: 1.1rem 0.9rem;
  }

  .mobile-convert__quote,
  .mobile-convert__wa {
    font-size: 0.9rem;
    min-height: 46px;
  }

  /* Hide decorative side brand on tiny screens if present outside frozen slides */
  .hero-side-brand {
    display: none;
  }
}

@media (min-width: 981px) {
  .mobile-lang,
  .mobile-support,
  .mobile-convert {
    display: none !important;
  }
}

.product-grid,
.apps-grid,
#quickProductGrid {
  width: 100%;
  max-width: 100%;
}

/* —— Dual-surface polish v3: intermittent mobile aesthetics + ops —— */
@media (max-width: 980px) {
  /* One source of truth for bottom inset (overrides site.css float padding) */
  body {
    padding-bottom: calc(var(--ds-convert-h) + 16px) !important;
  }

  /* Drawer / lightbox open: convert bar steals taps and looks broken */
  body.mobile-nav-open .mobile-convert,
  body:has(.detail-lightbox) .mobile-convert,
  body:has(.insight-modal.is-open) .mobile-convert,
  body:has(.mobile-menu.open) .mobile-convert {
    display: none !important;
  }

  /* Blog / PL sticky CTAs were sitting under (or fighting) the convert bar */
  .blog-footer-cta {
    bottom: var(--ds-convert-h) !important;
    padding-bottom: 14px !important;
    z-index: 40;
  }

  .pl-cta {
    bottom: var(--ds-convert-h) !important;
    padding-bottom: 14px !important;
    z-index: 40;
  }

  /* OEM full-viewport sections feel jumpy on phones */
  .oem-fs-section {
    min-height: 0 !important;
  }

  .oem-fs-section--hero,
  .oem-fs-section--interactive {
    min-height: 0 !important;
    padding-top: 28px;
    padding-bottom: 32px;
  }

  /* About jump: calm scroll tabs (same language as hub links) */
  .about-jump {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0;
    margin: 0 0 22px;
    padding: 0 0 8px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  }

  .about-jump::-webkit-scrollbar {
    display: none;
  }

  .about-jump a {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
  }

  .about-jump a:hover,
  .about-jump a:focus-visible {
    border-bottom-color: var(--accent, #1d4ed8);
  }

  /* Horizontal strips: fade edge so “cut off” feels intentional, not broken */
  .seo-product-links,
  .hub-path {
    mask-image: linear-gradient(90deg, #000 0%, #000 calc(100% - 28px), transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 calc(100% - 28px), transparent 100%);
  }

  /* Process / ship videos: keep full frame (no accidental crop of product) */
  .about-process-video,
  .about-ship-video,
  .factory-video,
  .about-main-visual-video {
    object-fit: contain !important;
    background: #0b1326;
  }

  .about-process-grid {
    grid-template-columns: 1fr !important;
  }

  .about-ship-grid {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }

  .about-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px;
  }

  .about-stat-card {
    padding: 14px 12px;
  }

  .about-stat-card .num {
    font-size: 1.45rem;
  }

  /* Scenario venue strip: horizontal snap on phone (less cramped than 2×3 stack) */
  .below-blog-section .scenario-grid-wrap {
    margin-left: calc(-1 * max(14px, env(safe-area-inset-left, 0px)));
    margin-right: calc(-1 * max(14px, env(safe-area-inset-right, 0px)));
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
  }

  .below-blog-section .scenario-grid,
  .scenario-grid {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 14px !important;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }

  .below-blog-section .scenario-card,
  .scenario-card {
    flex: 0 0 min(78vw, 300px);
    scroll-snap-align: start;
  }

  .scenario-card__label {
    font-size: 0.92rem;
  }

  .scenario-card__sku {
    font-size: 0.78rem;
  }

  .scenario-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .scenario-footer .btn-outline,
  .scenario-footer .btn-primary {
    width: 100%;
  }

  .factory-proof__video {
    animation: none !important;
    transform: none !important;
  }

  /* Convert bar: avoid covering video controls when a process video is playing */
  .about-process-card:focus-within,
  .about-ship-card:focus-within,
  .factory-video-slot:focus-within,
  .about-main-visual-slot:focus-within {
    scroll-margin-bottom: calc(var(--ds-convert-h) + 24px);
  }

  /* Forms: when typing, lift content above convert bar */
  .contact-form,
  .inquiry-form,
  #inquiryForm {
    scroll-margin-bottom: calc(var(--ds-convert-h) + 20px);
  }

  /* Tap targets: prevent accidental double-tap zoom on CTAs */
  .mobile-convert a,
  .btn-primary,
  .btn-outline,
  .factory-proof__clip {
    touch-action: manipulation;
  }
}

@media (max-width: 980px) and (prefers-reduced-motion: reduce) {
  .factory-proof__kicker,
  .factory-proof__copy h2,
  .factory-proof__lede,
  .factory-proof__spec li,
  .factory-proof__cta {
    animation: none !important;
  }
}

/* Contact route: single WA bar is shorter — shrink body inset */
@media (max-width: 980px) {
  body.is-contact-route {
    --ds-convert-h: calc(58px + env(safe-area-inset-bottom, 0px));
  }
}

/* Desktop polish: ship grid + process stay calm, no card clutter added */
@media (min-width: 981px) {
  .about-process-video,
  .about-ship-video {
    object-fit: contain;
  }

  .factory-proof__clips {
    max-width: 520px;
  }
}
