/* ============================================================================
   wap.css — mobile-native layer for chinagwmexport.com
   Everything is inside @media (max-width:767px) and the file is linked with
   media="(max-width:767px)", so desktop never loads it and cannot regress.
   Loaded after gwm.css, so equal-specificity rules here win on mobile.
   Structure: tokens → anti-error baseline → header/drawer → bottom tab bar →
   grids & cards → tables/rows → listing page + sticky CTA → forms/filters →
   FAQ → footer → RTL.
   ========================================================================== */

/* mobile-only controls are hidden until the media query turns them on, otherwise
   they would render on desktop where this file is not even loaded — but some
   components (sticky bar) exist in the HTML, so hide them by default too. */
.m-tabbar, .pd-mbar { display: none; }

@media (max-width: 767px) {

  :root {
    color-scheme: light;
    --tap: 44px;
    --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-error 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)); }
  a:active, button:active, [role="button"]:active { opacity: .82; }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  input, select, textarea { font-size: 16px; }               /* ≥16px stops iOS zoom-on-focus */
  .hero-cta, .mast-cta { flex-wrap: wrap; }
  .hero-cta .btn, .mast-cta .btn { flex: 1 1 100%; justify-content: center; }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  }
  .reveal { opacity: 1 !important; transform: none !important; }

  /* ---- header + full-screen drawer menu ----------------------------------
     PITFALL: the desktop header uses backdrop-filter, which makes a fixed
     descendant position against the header box instead of the viewport — the
     drawer would be trapped in a 72px strip. Kill it on mobile. */
  .site-header { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; background: var(--bg); }
  .nav-wrap { height: 60px; gap: 12px; }
  .brand .b-gwm { font-size: 25px; }
  .brand .b-rule { height: 22px; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); color: var(--ink); }
  .main-nav { margin-left: auto; }
  .main-nav ul {
    position: fixed; inset: 0; z-index: 200; display: none;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--bg); min-height: 100vh; min-height: 100dvh;
    padding: calc(var(--safe-t) + 12px) 0 calc(var(--safe-b) + 16px);
    overflow-y: auto; overscroll-behavior: contain;
  }
  .main-nav ul.open { display: flex; }                        /* default off + open override, always paired */
  .main-nav > ul > li { width: 100%; }
  .main-nav > ul > li > a { display: flex; align-items: center; min-height: 52px; margin: 0; padding: 14px 22px; border-radius: 0; font-size: 17px; border-bottom: 1px solid var(--line); }
  .main-nav > ul > li > a::after { display: none; }           /* underline nah on mobile */
  .main-nav > ul > li > a.active { color: var(--accent); }
  .main-nav .caret { margin-left: auto; }
  .main-nav .submenu { position: static !important; opacity: 1 !important; visibility: visible !important; transform: none !important; box-shadow: none; border: 0; padding: 0 0 6px 22px; min-width: 0; }
  .main-nav .submenu a { min-height: 46px; padding: 12px 22px; font-size: 15px; }
  .main-nav .nav-lang-item { margin-top: 8px; padding: 0 22px; }
  .main-nav .nav-lang { width: 100%; }
  .main-nav .nav-lang-btn { width: 100%; justify-content: space-between; min-height: var(--tap); }
  .main-nav .cta { margin: 14px 22px 0; }
  .main-nav li.cta a { width: 100%; justify-content: center; min-height: var(--tap); }
  body.nav-open { overflow: hidden; }

  /* ---- bottom tab bar ---- */
  .m-tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 120;
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: var(--safe-b);
  }
  .m-tabbar .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: var(--tabbar-h); font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none;
  }
  .m-tabbar .tab .icon { width: 21px; height: 21px; }
  .m-tabbar .tab.on, .m-tabbar .tab[aria-current="page"] { color: var(--accent); }
  .m-tabbar .tab.wa { color: #1DA851; }

  /* ---- grids: 2-up cards on phones ---- */
  .range-wall { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
  .prod-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
  .range-card .rc-body { padding: 12px 13px; }
  .range-card .rc-head h3 { font-size: 15px; }
  .range-card .rc-price, .prod-card .pc-price { font-size: 14px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr !important; }
  .steps { grid-template-columns: 1fr !important; }
  .dest-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .qgrid { grid-template-columns: 1fr !important; }
  .mkt-grid { grid-template-columns: 1fr !important; }

  /* ---- hero ---- */
  .mast-in { padding: 30px 18px 34px !important; }
  .mast h1 { font-size: clamp(27px, 8.4vw, 34px) !important; line-height: 1.12; }
  .mast-sub { font-size: 15px; }
  .mast-answer { font-size: 14.5px; padding-left: 12px; }
  .mast-manifest { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .mast-img { opacity: .14; }

  /* ---- tables → cards / compact rows ---- */
  .specstrip { flex-wrap: wrap; }
  .specstrip .sc { flex: 1 1 50%; }
  .sindex .srow { grid-template-columns: 1.4fr .7fr 1fr !important; gap: 6px; padding: 11px 4px; font-size: 13.5px; }
  .sindex .srow span:nth-child(2), .sindex .srow span:nth-child(4), .sindex .srow span:nth-child(5) { display: none; }
  .mrow { grid-template-columns: 54px 1fr auto; row-gap: 4px; }
  .mrow-seg, .mrow-km { display: none; }
  .fact-list .fact-row { grid-template-columns: 22px 1fr; row-gap: 2px; }
  .fact-list .fact-label { display: block; }

  /* ---- filter bar → horizontal scroller; .fdrop stays a tap-to-open panel ---- */
  .filter-bar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 8px; padding-bottom: 4px; }
  .filter-bar::-webkit-scrollbar { display: none; }
  .filter-group { flex-wrap: nowrap; flex: none; }
  .filter-chip { flex: none; white-space: nowrap; min-height: 38px; }
  .fbar { top: 60px; }
  .chips { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .chips > * { flex: none; }

  /* ---- listing page: gallery scroll + sticky CTA ---- */
  .gallery-thumbs { display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
  .gallery-thumb { flex: 0 0 auto; scroll-snap-align: start; }
  .pd-top { padding-top: 10px; }
  .pd-h2 { font-size: 21px; }
  .pd-mbar {
    display: flex; align-items: center; gap: 10px;
    position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b)); z-index: 110;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 9px 12px calc(9px + 0px);
  }
  .pd-mbar .pd-mbar-price { font-family: var(--font-display); font-weight: 800; font-size: 16px; color: var(--accent); flex: none; }
  .pd-mbar .pd-mbar-price em { display: block; font-family: var(--font-body); font-style: normal; font-weight: 600; font-size: 10px; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
  .pd-mbar .btn { flex: 1; justify-content: center; min-height: var(--tap); }
  body.has-mbar { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 66px); }

  /* ---- FAQ readable stack ---- */
  .faq-grid { grid-template-columns: 1fr !important; gap: 0; }
  .faq { padding: 14px 0; }

  /* ---- footer ---- */
  .foot-grid { grid-template-columns: 1fr 1fr !important; gap: 20px; }
  .foot-cta-inner { flex-direction: column; align-items: flex-start; gap: 14px; }
  .foot-cta .btn { width: 100%; justify-content: center; }
  .wa-float { bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px) !important; right: calc(var(--safe-r) + 14px) !important; }

  /* ---- touch targets ---- */
  .btn { min-height: var(--tap); }
  .foot-grid a, .crumb-in a, .crumb-in span { min-height: 40px; display: inline-flex; align-items: center; }

  /* ---- RTL ---- */
  [dir="rtl"] .main-nav .submenu { padding: 0 22px 6px 0; }
  [dir="rtl"] .main-nav .caret { margin-left: 0; margin-right: auto; transform: scaleX(-1); }
  [dir="rtl"] .mast-answer { border-left: 0; border-right: 3px solid var(--accent); padding-left: 0; padding-right: 12px; }
  [dir="rtl"] .wa-float { right: auto !important; left: calc(var(--safe-l) + 14px) !important; }
}

/* ---- mobile depth pass (2026-09-23): overflow guards + bottom-sheet filters ---- */
@media (max-width: 767px) {
  html, body { max-width: 100%; }
  img, svg, video, table { max-width: 100%; }
  .wrap { width: 100%; }
  .mast-answer, .mast-sub, .mast-kick, .lead, .meta { overflow-wrap: anywhere; }
  .fact-list .fact-label { min-width: 0; }
  .cmp-table { min-width: 0; }               /* the wrapper already scrolls */
  .fact-row { min-width: 0; }

  /* filters: .fdrop stays a native <details>; on mobile its panel becomes a bottom sheet */
  .fbar { position: sticky; top: 58px; z-index: 45; background: var(--bg); }
  .fdrop { flex: 1 1 auto; min-width: 0; }
  .fdrop > summary { min-height: var(--tap); display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface); }
  .fdrop-panel { left: 0; right: 0; bottom: 0; top: auto; position: fixed; z-index: 130;
    width: 100%; min-width: 0; max-width: none; max-height: 68vh; max-height: 68dvh;
    border-radius: 16px 16px 0 0; padding: 18px 16px calc(var(--safe-b) + 18px);
    box-shadow: 0 -14px 44px rgba(20,28,22,.20); }
  .fdrop[open] > summary { border-color: var(--line2); }

  /* long single-row tables: allow horizontal scroll instead of squeezing */
  .sindex, .manifest { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* section rhythm on mobile */
  .blk { padding: 34px 0; }
  .blk-head h2 { font-size: 24px; }
  .pd-h2 { font-size: 21px; line-height: 1.25; }
  .range-card .rc-chips .rc-chip:nth-child(n+3) { display: none; }   /* keep chips from wrapping 3 lines */
  .m-tabbar .tab span { line-height: 1.1; }
}

/* ---- mobile FAQ accordion (markup is converted by main.js at <=767px only) ---- */
@media (max-width: 767px) {
  .faq-item { border-bottom: 1px solid var(--line); }
  .faq-item:last-child { border-bottom: 0; }
  .faq-q { list-style: none; cursor: pointer; position: relative; padding: 16px 34px 16px 0; font-weight: 700; font-size: 16px; color: var(--ink); min-height: var(--tap); }
  .faq-q::-webkit-details-marker { display: none; }
  .faq-q::after { content: "+"; position: absolute; inset-inline-end: 4px; top: 13px; font-size: 24px; line-height: 1; color: var(--accent); }
  .faq-item[open] > .faq-q::after { content: "\2013"; }
  .faq-a { padding: 0 0 16px; color: var(--ink2); font-size: 15px; line-height: 1.7; }
}
