/* ============================================================
   AUTOCNEX wap.css — mobile-native layer (≤767px only)
   loaded via <link media="(max-width:767px)"> — desktop zero-cost
   ============================================================ */

/* ---- hide mobile-only widgets on desktop (before media) ---- */
.m-tabbar, .m-fab-inquire, .f-toggle { display: none; }

@media (max-width: 767px) {
  :root {
    color-scheme: light;                      /* force light, per user */
    --tap: 44px; --tap-sm: 40px;
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-l: env(safe-area-inset-left, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
    --tabbar-h: 56px;
    -webkit-tap-highlight-color: transparent;
  }

  /* ---- anti-break baseline ---- */
  html, body { overflow-x: hidden; }
  body {
    -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
    padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px);  /* give way to tab bar */
  }
  a:active, button:active, [role="button"]:active { opacity: .82; }
  :focus-visible { outline: 2px solid var(--accent, #8b6f4e); outline-offset: 2px; }

  /* ---- header: compact + hide desktop nav ---- */
  .site-header { position: fixed; top: 0; left: 0; right: 0; padding: 0;
                 background: rgba(250,250,247,.96); backdrop-filter: none; /* 关键：backdrop-filter 困 fixed 抽屉 */
                 border-bottom: 1px solid var(--line, #e3dfd3); z-index: 50; }
  .header-inner { height: 56px; padding: 0 12px 0 16px; gap: 8px; }
  .nav.primary-nav { display: none; }          /* desktop dropdowns off */
  .header-right .header-wa, .header-right .header-account,
  .header-right .header-wish, .header-right .lang-dropdown,
  .header-right .account-label, .header-right .btn-inquiry { display: none; }
  .header-right .nav-toggle { display: flex; }
  .brand { font-size: 18px; }

  /* ---- main: clear fixed header ---- */
  .main { padding-top: 56px; }

  /* ---- container padding ---- */
  .container { padding-left: 16px; padding-right: 16px; }

  /* ---- product grid: 2 columns ---- */
  .products { grid-template-columns: repeat(2, 1fr) !important; gap: 12px; }
  .product-img { aspect-ratio: 3/4; }

  /* ---- category hero: single column (image hidden) ---- */
  .cat-hero-grid { grid-template-columns: 1fr; gap: 20px; }
  .cat-hero-img { display: none; }
  .cat-hero h1 { font-size: 34px; line-height: 1.1; }

  /* ---- touch targets ≥44px ---- */
  .btn, .btn-primary, .btn-outline, button { min-height: var(--tap); }
  .nav-toggle { width: var(--tap); height: var(--tap); }
  input, select, textarea { font-size: 16px; }  /* 防 iOS 聚焦缩放 */

  /* ---- prose / article: full-width ---- */
  .prose { max-width: 100%; }
  .prose table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* ---- horizontal scroll-snap gallery ---- */
  .h-scroll { display: flex; gap: 12px; overflow-x: auto;
    -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
  .h-scroll > * { flex: 0 0 auto; scroll-snap-align: start; }

  /* ---- FAQ accordion (details) ---- */
  details.faq-item summary { list-style: none; cursor: pointer; padding: 16px 28px 16px 0;
    position: relative; font-weight: 500; }
  details.faq-item summary::-webkit-details-marker { display: none; }
  details.faq-item summary::after { content: "+"; position: absolute; inset-inline-end: 4px;
    top: 14px; font-size: 22px; color: var(--accent, #8b6f4e); }
  details.faq-item[open] summary::after { content: "–"; }

  /* ---- mobile inquiry FAB (above tab bar, right) ---- */
  .m-fab-inquire { display: flex; position: fixed; inset-inline-end: 16px;
    bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); z-index: 90;
    width: var(--tap); height: var(--tap); border-radius: 50%;
    background: var(--ink, #16150f); color: #fff; align-items: center; justify-content: center;
    box-shadow: 0 6px 18px rgba(0,0,0,.25); }
  .m-fab-inquire svg { width: 20px; height: 20px; }

  /* ---- bottom tab bar ---- */
  .m-tabbar { display: grid; position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
    grid-template-columns: repeat(5, 1fr);
    background: rgba(255,255,255,.98); border-top: 1px solid var(--line, #e3dfd3);
    padding-bottom: var(--safe-b); }
  .m-tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; min-height: var(--tabbar-h); font-size: 11px; color: var(--ink-mute, #7a756a);
    text-decoration: none; position: relative; }
  .m-tabbar a.on { color: var(--accent, #8b6f4e); }
  .m-tabbar a.m-tab-quote { background: var(--ink, #16150f); color: #fff; }
  .m-tabbar svg { width: 21px; height: 21px; }
  .m-tabbar .cart-count { position: absolute; top: 7px; inset-inline-end: calc(50% - 22px);
    min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--accent, #8b6f4e);
    color: #fff; font-size: 10px; line-height: 16px; text-align: center; }

  /* WhatsApp FAB: lift above tab bar (fix overlap) */
  .wa-fab { bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px) !important; right: 14px !important; z-index: 79 !important; }
  .m-fab-inquire { display: none !important; }
  /* hide conversion-booster sticky WA bar (overlaps our tab bar) */
  .cv-sticky { display: none !important; }

  /* ===== cart: card-style mobile ===== */
  .cart-page { padding-top: 84px !important; }
  .cart-title { font-size: 34px; margin: 12px 0 28px; }
  .cart-list { border-top: none; }
  .cart-item { background: #fff; border: 1px solid var(--line); border-radius: 12px;
    padding: 16px; margin-bottom: 12px; }
  .ci-img { width: 76px; border-radius: 8px; }
  .ci-name { font-size: 18px; }
  .ci-qty button { width: 40px; height: 40px; }
  .ci-remove { width: 44px; height: 44px; }
  .cart-summary { border-radius: 12px; padding: 22px 18px; }
  .checkout-btn { width: 100%; justify-content: center; }
  .cart-moq-hint { background: #fff7e6; border: 1px solid #f0d9a8; color: #8a6d1f;
    border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; font-size: 13px; line-height: 1.6; }
  .cart-moq-hint .moq-chip { display: inline-block; margin: 4px 6px 0 0; padding: 3px 10px;
    background: #fff; border: 1px solid #e8d5a0; border-radius: 99px; font-size: 12px; }

  /* ===== homepage bottom: premium ===== */
  .about { padding: 64px 0; }
  .about-grid { gap: 32px; }
  .about-img-wrap { border-radius: 12px; overflow: hidden; }
  .capability { padding: 64px 0; }
  .cap-grid { gap: 10px; background: transparent; border: none; margin-top: 36px; }
  .cap-card { border: 1px solid var(--line); border-radius: 12px; padding: 26px 20px; background: #fff; }
  .cap-num { font-size: 26px; margin-bottom: 14px; }
  .cap-title { font-size: 19px; margin-bottom: 10px; }
  .cta-section { padding: 72px 0; }
  .cta-section h2 { font-size: 38px; }
  .cta-section p { font-size: 16px; margin-bottom: 36px; }
  .site-footer { padding: 52px 0 96px; }
  .ft-grid { grid-template-columns: 1fr 1fr; gap: 32px; margin-bottom: 36px; }
  .brand-ft { font-size: 26px; }
  .ft-bottom { flex-direction: column; align-items: center; text-align: center; gap: 10px; }

  /* ===== category filter drawer (bottom sheet) ===== */
  .f-toggle { display: flex; width: 100%; min-height: var(--tap); align-items: center;
    justify-content: center; gap: 8px; margin: 8px 0 12px; border: 1px solid var(--line);
    border-radius: var(--r-md, 8px); background: #fff; font-size: 14px; color: var(--ink); }
  .filter-grid { position: fixed; left: 0; right: 0; bottom: 0; z-index: 120;
    background: #fff; border-radius: 16px 16px 0 0; padding: 20px 16px calc(var(--safe-b) + 24px);
    max-height: 82vh; max-height: 82dvh; overflow-y: auto;
    transform: translateY(105%); transition: transform .25s ease;
    box-shadow: 0 -12px 40px rgba(0,0,0,.18); }
  .filter-grid.open { transform: none; }
  .filter-grid::before { content: ''; display: block; width: 40px; height: 4px; border-radius: 2px;
    background: var(--line); margin: 0 auto 14px; }

  /* ===== product page: sticky add-to-cart bar ===== */
  .dt-buy-row { position: fixed; left: 0; right: 0;
    bottom: calc(var(--tabbar-h) + var(--safe-b)); z-index: 70;
    background: #fff; border-top: 1px solid var(--line); padding: 10px 12px;
    margin: 0; gap: 8px; flex-wrap: nowrap; }
  .dt-buy-row .qty-stepper { height: 44px; flex: none; }
  .dt-buy-row .btn-add, .dt-buy-row .btn-buy { height: 44px; padding: 0 14px; flex: 1; }
  .dt-buy-row .btn-wish { width: 44px; height: 44px; flex: none; }
  body:has(.dt-buy-row) { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 76px); }

  /* RTL */
  [dir="rtl"] details.faq-item summary { padding: 16px 0 16px 28px; }
  [dir="rtl"] .caret { transform: scaleX(-1); }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  }
}
