/* ============================================================
   Xuanzhen Ge · mobile optimisation layer
   Loaded LAST (after fonts.css, xzg(-en).css, overrides.css, woo.css).

   Goals
   1. No horizontal scrolling anywhere; nothing clipped at the edges.
   2. Header: one tidy row on a 320px phone — brand, language, cart, menu.
   3. The promo bar stops floating over the content on phones.
   4. Comfortable reading: fluid type, 44px+ tap targets, safe areas.
   5. Product / cart / checkout layouts that actually fit a phone.
   ============================================================ */

/* ------------------------------------------------------------------
   0. Global guards
   ------------------------------------------------------------------ */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
}
body {
  overflow-x: hidden;
  min-height: 100%;
}
/* Nothing may be wider than the viewport. */
.marquee-bar,
.section,
.trust-bar,
.footer,
nav,
.cart-drawer,
.toast { max-width: 100vw; }

/* Long unbroken strings (product names, emails) must wrap. */
.prod-name,
.cart-item-name,
.footer-copy,
.modal-body p { overflow-wrap: anywhere; }

/* ------------------------------------------------------------------
   1. Header on phones and small tablets
   The original row needed ~490px, so on a 375px screen the brand wrapped
   to two lines, was pushed past the left edge and the page scrolled
   sideways. Everything is now sized so the row fits from 320px up.
   ------------------------------------------------------------------ */
@media (max-width: 900px) {
  #nav {
    padding: 0.5rem max(0.85rem, env(safe-area-inset-left)) 0.5rem max(0.85rem, env(safe-area-inset-right));
    gap: 0.5rem;
    min-height: 56px;
    align-items: center;
  }
  .nav-brand {
    font-size: clamp(0.78rem, 3.5vw, 1rem);
    letter-spacing: 0.2em;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 0 1 auto;
    min-width: 0;
  }
  .brand-cn { font-size: 0.92em; letter-spacing: 0.1em; }

  .nav-links { display: none; }

  .nav-right { gap: 0.45rem; flex-shrink: 0; }

  .nav-lang {
    height: 40px;
    min-width: 40px;
    padding: 0 0.55rem;
    font-size: 0.68rem;
    letter-spacing: 0.1em;
  }

  .cart-btn {
    height: 40px;
    padding: 0 0.6rem;
    gap: 0.35rem;
    font-size: 0.6rem;
    letter-spacing: 0.1em;
  }
  .cart-count { min-width: 17px; height: 17px; font-size: 0.55rem; }

  .nav-menu-btn {
    display: inline-flex;
    width: 40px;
    height: 40px;
    padding: 0;
    flex-shrink: 0;
  }
  .nav-menu-btn svg { width: 17px; height: 17px; }

  /* --- slide-down menu panel, anchored under the bar --- */
  body.menu-open #nav {
    /* fully opaque: a translucent bar over a backdrop-filtered parent can
       composite oddly in Chrome, letting the hero show through. */
    background: #070d18;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-bottom: 1px solid rgba(138,156,184, 0.18);
  }
  body.menu-open #nav .nav-menu-btn {
    border-color: var(--gold);
    color: var(--gold2);
    background: rgba(138,156,184, 0.08);
  }
  body.menu-open .nav-links {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    padding: 0.3rem 1.15rem 1rem;
    background: #070d18;
    border-bottom: 1px solid rgba(138,156,184, 0.18);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.65);
    max-height: calc(100dvh - 96px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.menu-open .nav-links li {
    list-style: none;
    border-top: 1px solid rgba(138,156,184, 0.09);
  }
  body.menu-open .nav-links li:first-child { border-top: 0; }
  body.menu-open .nav-links a {
    display: block;
    padding: 0.95rem 0.1rem;
    font-size: 0.95rem;
    letter-spacing: 0.16em;
  }
  body.menu-open { overflow: hidden; }

  /* --- big-screen type scale --- */
  body { font-size: 17px; line-height: 1.75; }

  .hero {
    min-height: 100svh;
    padding: 6.8rem 1.15rem 3.6rem;
  }
  .hero-eyebrow {
    font-size: 0.64rem;
    letter-spacing: 0.34em;
    margin-bottom: 1.3rem;
  }
  .hero-title {
    font-size: clamp(2.1rem, 9.4vw, 3.1rem);
    line-height: 1.14;
    letter-spacing: 0.04em;
    text-wrap: balance;
  }
  .hero-sub {
    font-size: 1rem;
    line-height: 1.75;
    margin-bottom: 2.1rem;
    padding: 0 0.25rem;
  }
  .hero-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
  }
  .hero-cta .btn-primary,
  .hero-cta .btn-ghost {
    width: 100%;
    max-width: 320px;
    min-height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    font-size: 0.82rem;
    letter-spacing: 0.16em;
  }

  .marquee-bar { padding: 0.7rem 0; }
  .marquee-item {
    font-size: 0.6rem;
    letter-spacing: 0.18em;
    padding: 0 1.15rem;
  }

  /* --- trust bar: 2×2, left aligned, no more 3-line centred text --- */
  .trust-bar { padding: 2.2rem 1.15rem; }
  .trust-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem 1rem;
    text-align: left;
  }
  .trust-item { align-items: flex-start; text-align: left; }
  .trust-icon { width: 26px; height: 26px; margin-bottom: 0.65rem; }
  .trust-text strong {
    font-size: 0.62rem;
    letter-spacing: 0.13em;
    line-height: 1.55;
    margin-bottom: 0.35rem;
  }
  .trust-text span { font-size: 0.9rem; line-height: 1.5; color: rgba(241,235,221,0.68); }

  .section { padding: 3.4rem 1.15rem; }
  .section-head { margin-bottom: 2.1rem; }
  .eyebrow {
    font-size: 0.6rem;
    letter-spacing: 0.3em;
    margin-bottom: 0.7rem;
  }
  .section-title {
    font-size: clamp(1.75rem, 7vw, 2.35rem);
    line-height: 1.2;
    text-wrap: balance;
  }
  .section-sub { font-size: 1rem; line-height: 1.6; }

  /* --- promo bar: in the flow, not pinned over the page --- */
  .offer-banner {
    position: static;
    left: auto;
    top: auto;
    transform: none;
    width: auto;
    margin: 0 0 2.1rem;
    padding: 0.85rem 1rem;
    box-shadow: none;
  }
  .offer-banner strong {
    font-size: 0.58rem;
    letter-spacing: 0.1em;
    line-height: 1.6;
    margin-bottom: 0.45rem;
  }
  .offer-banner span { display: block; font-size: 0.78rem; line-height: 1.55; }

  .cat-section-label { font-size: 0.62rem; letter-spacing: 0.24em; }
  .cat-section-header { margin: 2.2rem 0 1.3rem; }

  /* --- product grid: 2 columns that actually fit --- */
  .cat-grid { grid-template-columns: 1fr; }
  .prod-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 0.8rem;
  }
  .prod-card { cursor: pointer; }
  .prod-img { aspect-ratio: 3 / 4; margin-bottom: 0.7rem; }
  .prod-char { font-size: 2.5rem; }
  .prod-badge {
    font-size: 0.54rem;
    letter-spacing: 0.08em;
    padding: 0.14rem 0.4rem;
    top: 7px;
    left: 7px;
  }
  .prod-series {
    font-size: 0.54rem;
    letter-spacing: 0.16em;
    margin-bottom: 0.22rem;
  }
  .prod-name { font-size: 0.95rem; line-height: 1.32; margin-bottom: 0.2rem; }
  .prod-tagline {
    font-size: 0.8rem;
    line-height: 1.42;
    margin-bottom: 0.3rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .prod-price { font-size: 0.95rem; }
  .prod-actions { opacity: 1; transform: none; margin-top: 0.5rem; }
  .add-cart-btn {
    min-height: 42px;
    padding: 0.5rem 0.3rem;
    font-size: 0.6rem;
    letter-spacing: 0.08em;
  }

  .video-caption {
    font-size: 0.58rem;
    letter-spacing: 0.1em;
    line-height: 1.8;
    padding: 0 0.5rem;
  }

  .steps { grid-template-columns: 1fr; gap: 1.7rem; }
  .step { padding: 0; }
  .steps::before { display: none; }
  .team-grid { grid-template-columns: 1fr; }
  .testi-grid { grid-template-columns: 1fr; }

  .footer-top { grid-template-columns: 1fr; gap: 1.9rem; }
  .footer-brand-name { font-size: 1.15rem; letter-spacing: 0.16em; }
  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.8rem;
    flex-wrap: wrap;
  }
  .footer-copy { font-size: 0.74rem; line-height: 1.7; }

  /* --- dialog / modal --- */
  .modal-overlay { padding: 3.2rem 1rem calc(2.4rem + env(safe-area-inset-bottom)); }
  .modal-close {
    top: calc(0.7rem + env(safe-area-inset-top));
    right: 0.75rem;
    width: 40px;
    height: 40px;
  }
  .modal-title { font-size: clamp(1.6rem, 7vw, 2.1rem); }
  .modal-body { font-size: 1rem; line-height: 1.85; }
  .modal-body p { font-size: 1rem; }

  .product-modal-inner { max-height: 100dvh; }
  .pm-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .pm-tabs::-webkit-scrollbar { display: none; }
  .pm-tab { padding: 0.65rem 0.7rem; font-size: 0.54rem; letter-spacing: 0.14em; }
  .pm-lore-row { grid-template-columns: 1fr; }

  /* --- toast: full width, above the home indicator --- */
  .toast {
    left: 1rem;
    right: 1rem;
    bottom: calc(1rem + env(safe-area-inset-bottom));
    transform: translateY(120%);
    max-width: none;
    white-space: normal;
    text-align: center;
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    padding: 0.75rem 1rem;
    line-height: 1.6;
  }
  .toast.show { transform: translateY(0); }
}


/* Tablets: two hero buttons side by side rather than a narrow stack. */
@media (min-width: 600px) and (max-width: 900px) {
  .hero-cta { flex-direction: row; justify-content: center; gap: 0.9rem; }
  .hero-cta .btn-primary,
  .hero-cta .btn-ghost { width: auto; max-width: none; padding: 0 2.1rem; }
}

/* ------------------------------------------------------------------
   2. Phones
   ------------------------------------------------------------------ */
@media (max-width: 600px) {
  .section { padding: 3rem 1rem; }
  .trust-bar { padding: 2rem 1rem; }
  .hero { padding: 6.4rem 1rem 3.2rem; }
  .cat-grid { grid-template-columns: 1fr; }
  .cat-card { padding: 2.2rem 1.2rem; }
}

/* Drop the Chinese suffix from the wordmark so the brand never truncates. */
@media (max-width: 480px) {
  .brand-cn { display: none; }
}

/* Very narrow devices: drop the word "Cart", keep the icon + badge. */
@media (max-width: 380px) {
  .cart-label { display: none; }
  .cart-btn { width: 40px; padding: 0; justify-content: center; }
  .cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 16px;
    height: 16px;
    font-size: 0.5rem;
  }
  .trust-grid { grid-template-columns: 1fr; gap: 1.1rem; }
  .trust-item {
    flex-direction: row;
    align-items: center;
    gap: 0.9rem;
  }
  .trust-icon { flex: 0 0 24px; width: 24px; height: 24px; margin: 0; }
  .nav-brand { letter-spacing: 0.14em; }
}

/* Landscape phones: stop the hero from eating the whole screen. */
@media (max-height: 520px) and (orientation: landscape) {
  .hero { min-height: auto; padding: 6rem 1.15rem 3rem; }
}

/* ------------------------------------------------------------------
   3. Cart drawer — full width, thumb-friendly
   ------------------------------------------------------------------ */
@media (max-width: 520px) {
  .cart-drawer {
    width: 100vw;
    max-width: 100vw;
    border-left: 0;
  }
  .cart-header { padding: 1rem 1.15rem; }
  .cart-items { padding: 1rem 1.15rem; }
  .cart-footer {
    padding: 1.1rem 1.15rem calc(1.1rem + env(safe-area-inset-bottom));
  }
  .cart-item { gap: 0.85rem; padding: 1rem 0 1.1rem; }
  .cart-item-img { width: 56px; height: 74px; }
  .cart-item-char { font-size: 1.5rem; }
  .cart-item-name { font-size: 0.95rem; }
  .cart-note { font-size: 0.76rem; line-height: 1.6; }
  .cart-checkout-btn { min-height: 50px; font-size: 0.78rem; }
  .cart-close { width: 38px; height: 38px; }
}

/* ------------------------------------------------------------------
   4. WooCommerce on phones
   The 3-column shop grid, the cart table and the checkout columns all
   assume desktop widths, so they are re-flowed here.
   ------------------------------------------------------------------ */
@media (max-width: 768px) {
  .woocommerce ul.products,
  .woocommerce-page ul.products {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.9rem !important;
    margin-bottom: 2rem;
  }
  .woocommerce ul.products li.product .woocommerce-loop-product__title {
    font-size: 0.95rem;
    padding: 0.8rem 0.7rem 0.25rem;
    line-height: 1.35;
  }
  .woocommerce ul.products li.product .price {
    font-size: 0.9rem;
    padding: 0 0.7rem;
  }
  .woocommerce ul.products li.product .button,
  .woocommerce ul.products li.product .added_to_cart {
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    margin: -0.3rem 0.7rem 0.8rem;
    min-height: 40px;
    line-height: 1.4;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .woocommerce .woocommerce-result-count { font-size: 0.8rem; float: none; margin-bottom: 0.5rem; }
  .woocommerce .woocommerce-ordering { float: none; margin-bottom: 1.2rem; }
  .woocommerce .woocommerce-ordering select { width: 100%; font-size: 16px; }

  .woocommerce .woocommerce-breadcrumb { font-size: 0.66rem; line-height: 1.7; }

  /* single product */
  .woocommerce div.product div.images,
  .woocommerce div.product div.summary {
    width: 100%;
    float: none;
    margin-bottom: 1.6rem;
  }
  .woocommerce div.product .product_title { font-size: 1.6rem; line-height: 1.3; }
  .woocommerce div.product p.price { font-size: 1.25rem; }
  .woocommerce div.product form.cart .button { width: 100%; min-height: 48px; }
  .woocommerce div.product form.cart div.quantity { margin-right: 0.6rem; }
  .woocommerce div.product .woocommerce-tabs ul.tabs {
    padding: 0;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .woocommerce div.product .woocommerce-tabs ul.tabs li { margin: 0 0.2rem 0 0; }

  /* cart */
  .woocommerce table.shop_table { font-size: 0.9rem; }
  .woocommerce table.shop_table th,
  .woocommerce table.shop_table td { padding: 0.6rem 0.45rem; }
  .woocommerce table.cart .product-thumbnail img { width: 54px; }
  .woocommerce table.cart td.actions .coupon {
    float: none;
    width: 100%;
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.7rem;
  }
  .woocommerce table.cart td.actions .coupon .input-text { flex: 1; min-width: 0; font-size: 16px; }
  .woocommerce table.cart td.actions .button { width: 100%; min-height: 46px; }
  .woocommerce .cart-collaterals .cart_totals,
  .woocommerce-page .cart-collaterals .cart_totals { width: 100%; float: none; }
  .woocommerce .wc-proceed-to-checkout a.checkout-button { min-height: 50px; font-size: 0.72rem; }

  /* checkout */
  .woocommerce-checkout .col2-set .col-1,
  .woocommerce-checkout .col2-set .col-2 { width: 100%; float: none; }
  .woocommerce form .form-row-first,
  .woocommerce form .form-row-last,
  .woocommerce-page form .form-row-first,
  .woocommerce-page form .form-row-last { width: 100%; float: none; }
  .woocommerce .woocommerce-checkout-review-order { padding: 1rem; }
  .woocommerce form.checkout_coupon,
  .woocommerce form.login,
  .woocommerce form.register { padding: 1.1rem; }

  /* iOS zooms the page when a field is under 16px. */
  .woocommerce input.input-text,
  .woocommerce input[type="text"],
  .woocommerce input[type="email"],
  .woocommerce input[type="tel"],
  .woocommerce input[type="password"],
  .woocommerce input[type="number"],
  .woocommerce select,
  .woocommerce textarea,
  .newsletter input { font-size: 16px; }

  .woocommerce .woocommerce-message,
  .woocommerce .woocommerce-info,
  .woocommerce .woocommerce-error { font-size: 0.85rem; line-height: 1.6; padding: 0.9rem 1rem; }
}

/* ------------------------------------------------------------------
   4b. Small-print legibility + thumb-sized controls
   The desktop sheet keeps these details at 9-12px with low contrast,
   which is unreadable on a phone held at arm's length.
   ------------------------------------------------------------------ */
@media (max-width: 900px) {
  .hero-cn {
    font-size: 0.82rem;
    letter-spacing: 0.2em;
    line-height: 1.9;
    opacity: 0.6;
    margin-bottom: 1rem;
  }
  .prod-disclaimer {
    font-size: 0.68rem;
    line-height: 1.55;
    color: rgba(241,235,221, 0.5);
  }
  .video-caption {
    font-size: 0.64rem;
    letter-spacing: 0.12em;
    opacity: 0.72;
    line-height: 1.9;
  }
  .marquee-item { color: rgba(207,171,104, 0.62); }

  /* quantity stepper: 24px buttons become 40px tap targets */
  .qty-btn,
  .pm-qty-btn {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
  .cart-item-qty,
  .pm-qty { gap: 0.5rem; }
  .qty-num,
  .pm-qty-num { min-width: 30px; font-size: 0.9rem; }

  /* cart drawer: bigger remove target, roomier item text */
  .cart-item-remove {
    width: 34px;
    height: 34px;
    margin: -6px -4px 0 0;
  }
  .cart-video-label { font-size: 0.78rem; line-height: 1.5; }
  .cart-video-label input[type="checkbox"] { width: 16px; height: 16px; }
}

/* ------------------------------------------------------------------
   5. Touch ergonomics & motion
   ------------------------------------------------------------------ */
@media (hover: none) {
  .prod-actions { opacity: 1 !important; transform: none !important; }
  a, button, .nav-lang, .add-cart-btn { -webkit-tap-highlight-color: rgba(207,171,104, 0.12); }
}

@media (prefers-reduced-motion: reduce) {
  .marquee-inner { animation: none !important; }
  .hero-inner { animation: none !important; opacity: 1 !important; transform: none !important; }
  .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
  * { scroll-behavior: auto !important; }
}
