/* =====================================================================
   MetaXR site-wide type system and layout fixes (2026-11-29)
   Loaded after Avada/Elementor by functions.php (mtxr_site_css).
   Head: Bai Jamjuree · Body: IBM Plex Sans Thai (both have Thai + Latin).
   The homepage widgets (#mxb, #mxp-*) carry their own CSS and are skipped.
   ===================================================================== */

:root {
  --mx-cjk: "Noto Sans JP", "Noto Sans KR", "Noto Sans SC", sans-serif;
  --mx-head: "Bai Jamjuree", "IBM Plex Sans Thai", var(--mx-cjk);
  --mx-body: "IBM Plex Sans Thai", var(--mx-cjk);
}
html[lang^="ja"] { --mx-cjk: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", "Noto Sans JP", sans-serif; }
html[lang^="ko"] { --mx-cjk: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif; }
html[lang^="zh"] { --mx-cjk: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif; }

/* 1. Theme font variables: Avada typography sets and Elementor global fonts */
html body:is([class]) {
  --awb-typography1-font-family: var(--mx-head);
  --awb-typography2-font-family: var(--mx-head);
  --awb-typography3-font-family: var(--mx-head);
  --awb-typography4-font-family: var(--mx-body);
  --awb-typography5-font-family: var(--mx-body);
  --e-global-typography-primary-font-family: var(--mx-head);
  --e-global-typography-secondary-font-family: var(--mx-head);
  --e-global-typography-text-font-family: var(--mx-body);
  --e-global-typography-accent-font-family: var(--mx-head);
  font-family: var(--mx-body);
}

/* 2. One body face for reading text, one head face for titles.
      Zero-specificity :where() so deliberate component styles still win; icon fonts are excluded. */
:where(body) :where(p, li, td, th, dd, dt, label, blockquote, figcaption, input, select, textarea, .fusion-text, .elementor-widget-text-editor, .post-content, .product_meta, .woocommerce-tabs, .summary, .fusion-rollover-content, .fusion-rollover-content a, .fusion-footer-copyright-area, .fusion-copyright-notice, .fusion-copyright-notice *) {
  font-family: var(--mx-body) !important;
}
:where(body) :where(h1, h2, h3, h4, h5, h6, .elementor-heading-title, .fusion-title-heading, .product-title, .woocommerce-loop-product__title, .price, .fusion-button, .elementor-button, .button, button, .fusion-menu, .awb-menu__main-a, .menu-text) :where(:not(i):not([class*="icon"]):not([class*="fa-"]):not([class*="star"])),
:where(body) :where(h1, h2, h3, h4, h5, h6, .elementor-heading-title, .fusion-title-heading, .product-title, .woocommerce-loop-product__title, .price, .fusion-button, .elementor-button, .button, button, .awb-menu__main-a, .menu-text) {
  font-family: var(--mx-head) !important;
}
/* inline font-family left in old content (Sarabun, Kanit, Roboto, Montaga, Arial ...) */
:where(body) :where(#main, .fusion-footer) :where(span, font, p, div, strong, b, em, a)[style*="font-family"]:where(:not([class*="icon"])) {
  font-family: inherit !important;
}
:where(body) :where(#main, .fusion-footer) font[face] { font-family: inherit !important; }

/* 3. Heading scale. Desktop: blog posts read H1 > H2 > H3. */
@media (min-width: 768px) {
  body.single-post #main h1 { font-size: 36px !important; line-height: 1.3 !important; }
  body.single-post #main .post-content h2, body.single-post #main h2.fusion-title-heading { font-size: 28px !important; line-height: 1.35 !important; }
  body.single-post #main .post-content h3, body.single-post #main h3.fusion-title-heading { font-size: 22px !important; line-height: 1.4 !important; }
  body.single-post #main .post-content h4 { font-size: 19px !important; }
}
body.single-post #main .post-content { max-width: 760px; margin-left: auto; margin-right: auto; }
body.single-post #main .post-content p, body.single-post #main .post-content li { font-size: 17px; line-height: 1.8; }

/* blog / news cards */
:where(body) .fusion-blog-shortcode .blog-shortcode-post-title,
:where(body) .fusion-blog-shortcode .fusion-post-title { font-size: 20px !important; line-height: 1.4 !important; }
:where(body) .fusion-blog-shortcode .fusion-rollover-title { font-size: 18px !important; }

/* phones: no heading bigger than 32px (homepage widgets keep their own sizes) */
@media (max-width: 767px) {
  body #main :is(h1, .elementor-heading-title.elementor-size-xxl, .elementor-heading-title.elementor-size-xl):where(:not(#mxb *):not([id^="mxp-"] *)) { font-size: clamp(26px, 7.4vw, 32px) !important; line-height: 1.25 !important; }
  body #main h2:where(:not(#mxb *):not([id^="mxp-"] *)) { font-size: 24px !important; line-height: 1.3 !important; }
  body #main h3:where(:not(#mxb *):not([id^="mxp-"] *)) { font-size: 20px !important; line-height: 1.35 !important; }
  body #main h4:where(:not(#mxb *):not([id^="mxp-"] *)) { font-size: 18px !important; line-height: 1.4 !important; }
  body #main :is(h5, h6):where(:not(#mxb *):not([id^="mxp-"] *)) { font-size: 16px !important; }
  body #main :is(p, div, span).elementor-heading-title:where(:not(#mxb *):not([id^="mxp-"] *)) { font-size: min(1em, 26px) !important; }
  body #main .fusion-title :is(h1, h2, h3, h4, h5, h6) span:where(:not(#mxb *)) { font-size: inherit !important; }
  body.single-post #main .post-content p, body.single-post #main .post-content li { font-size: 16px; }
}

/* 4. Never stretch an image (fixed-height image widgets used object-fit: fill) */
:where(body #main) img { object-fit: contain; }

/* 5. TranslatePress floating switcher: compact pill, bottom-left */
.trp-floating-switcher { left: 10px !important; right: auto !important; bottom: 10px !important; opacity: .94; }
.trp-floating-switcher .trp-language-item, .trp-floating-switcher .trp-current-language-item__wrapper { padding: 6px 10px !important; min-height: 0 !important; }

/* 6. WooCommerce product grids: two per row on phones */
@media (max-width: 767px) {
  :where(body) ul.products:not(.elementor-element-f17b3b9 *) { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 !important; }
  :where(body) ul.products::before, :where(body) ul.products::after { content: none !important; display: none !important; }
  :where(body) ul.products > li.product { width: auto !important; margin: 0 !important; float: none !important; padding: 0 !important; }
  :where(body) ul.products .fusion-product-content { padding: 10px 10px 12px !important; }
  :where(body) ul.products .product-title, :where(body) ul.products .product-title a { font-size: 14px !important; line-height: 1.35 !important; }
  :where(body) ul.products .price { font-size: 14px !important; }
  :where(body) ul.products .fusion-content-sep { display: none !important; }
}

/* "Ask on LINE" button added under every product card (functions.php) */
.mx-ask-line { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 7px 12px; border-radius: 18px; background: #06c755; color: #fff !important; font-family: var(--mx-head) !important; font-size: 13px; font-weight: 600; line-height: 1.2; text-decoration: none !important; }
.mx-ask-line:hover { background: #05b04c; }
.mx-ask-line svg { width: 16px; height: 16px; fill: currentColor; flex: none; }
.fusion-product-content .mx-ask-line { margin: 4px 0 10px; }

/* 7. Single product: larger gallery on desktop */
@media (min-width: 1000px) {
  body.single-product .avada-single-product-gallery-wrapper { width: 48% !important; max-width: 560px; }
  body.single-product .avada-single-product-gallery-wrapper img { width: 100% !important; height: auto !important; }
}
body.single-product .product_meta .sku_wrapper:has(.sku:empty) { display: none; }

/* 8. Footer: drop the empty widget band, readable icons */
.fusion-footer-widget-area:not(:has(.widget, .fusion-column-wrapper > *)) { display: none !important; }
.fusion-footer .fusion-social-networks .fusion-social-network-icon { min-width: 40px; min-height: 40px; display: inline-flex !important; align-items: center; justify-content: center; }
.fusion-footer .fusion-social-networks img { width: 22px !important; height: auto !important; }
.fusion-footer-copyright-area { font-size: 13px; line-height: 1.7; }
.mx-footer-contact { display: block; margin-top: 6px; font-weight: 600; }
.mx-footer-contact a { color: inherit; }
html:not([lang^="th"]) .mx-th-only { display: none !important; }

/* 9. Service-page contact bar (functions.php mtxr_service_cta) */
.mx-cta-bar { position: fixed; z-index: 9990; right: 16px; bottom: 16px; display: flex; gap: 8px; }
.mx-cta-bar a { white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; height: 46px; padding: 0 18px; border-radius: 23px; font-family: var(--mx-head) !important; font-size: 15px; font-weight: 600; color: #fff !important; text-decoration: none !important; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.mx-cta-bar .line { background: #06c755; }
.mx-cta-bar .tel { background: #1d1a1a; }
.mx-cta-bar svg { width: 20px; height: 20px; fill: currentColor; }
@media (max-width: 767px) {
  .mx-cta-bar { left: 0; right: 0; bottom: 0; gap: 0; padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); background: rgba(255,255,255,.97); box-shadow: 0 -4px 16px rgba(0,0,0,.08); }
  .mx-cta-bar a { flex: 1; justify-content: center; box-shadow: none; height: 44px; margin: 0 4px; padding: 0 10px; font-size: 14px; white-space: nowrap; }
  body.mx-has-cta-bar { padding-bottom: 64px; }
  body.mx-has-cta-bar .trp-floating-switcher { bottom: 72px !important; }
}

/* 10. Tap targets on phones */
@media (max-width: 767px) {
  .single_add_to_cart_button, .show_details_button, .fusion-read-more { min-height: 36px; display: inline-flex; align-items: center; }
}

/* 11. In-content LINE call-to-action box (functions.php mtxr_cta_box) */
.mx-cta-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 20px; margin: 28px 0; padding: 18px 22px; border: 1px solid #c9eed8; border-radius: 14px; background: #f1fbf5; }
.mx-cta-box__txt { flex: 1 1 320px; min-width: 0; }
.mx-cta-box__txt p { margin: 0 !important; font-size: 15px; line-height: 1.6; color: #2b3a31; }
.mx-cta-box__txt .mx-cta-box__title { font-family: var(--mx-head) !important; font-size: 19px; font-weight: 700; color: #11251a; margin-bottom: 2px !important; }
.mx-cta-box__btns { display: flex; flex-wrap: wrap; gap: 10px; }
.mx-cta-box__btns a { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 22px; font-family: var(--mx-head) !important; font-size: 15px; font-weight: 600; text-decoration: none !important; white-space: nowrap; }
.mx-cta-line { background: #06c755; color: #fff !important; }
.mx-cta-line svg { width: 20px; height: 20px; fill: currentColor; }
.mx-cta-tel { background: #fff; color: #11251a !important; border: 1px solid #b9d9c6; }
.mx-cta-products { margin: 28px 0 0; }
.mx-cta-products ul.products { margin-bottom: 0 !important; }

/* 12. Product-card LINE button: full card width so the label never stacks letter by letter */
ul.products .mx-ask-line { display: flex; width: 100%; justify-content: center; text-align: center; white-space: normal; box-sizing: border-box; }
@media (max-width: 767px) { ul.products .mx-ask-line { font-size: 12px; padding: 7px 8px; } }

/* 13. Product cards inside article/page content (shortcode output outside WooCommerce templates) */
.mx-cta-products ul.products { display: grid !important; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; list-style: none !important; margin: 0 !important; padding: 0 !important; }
.mx-cta-products ul.products::before, .mx-cta-products ul.products::after { content: none !important; display: none !important; }
.mx-cta-products ul.products > li { list-style: none !important; width: auto !important; margin: 0 !important; padding: 12px !important; float: none !important; border: 1px solid #e9e9ee; border-radius: 12px; background: #fff; display: flex; flex-direction: column; }
.mx-cta-products ul.products > li::marker { content: none; }
.mx-cta-products ul.products img { width: 100% !important; height: auto !important; aspect-ratio: 1 / 1; object-fit: contain; margin: 0 0 8px !important; }
.mx-cta-products ul.products a { text-decoration: none !important; }
.mx-cta-products ul.products .woocommerce-loop-product__title, .mx-cta-products ul.products h2, .mx-cta-products ul.products h3 { font-size: 16px !important; line-height: 1.35 !important; margin: 0 0 4px !important; color: #1d1a1a; }
.mx-cta-products ul.products .price { font-size: 15px !important; color: #c8102e; margin-bottom: 4px; }
.mx-cta-products ul.products .button, .mx-cta-products ul.products .show_details_button { display: none !important; }
.mx-cta-products ul.products .mx-ask-line { margin-top: auto; }
@media (max-width: 767px) { .mx-cta-products ul.products { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }

/* 14. Product cards everywhere: Avada leaves 100px right padding and double separators in card content */
ul.products .fusion-product-content { padding: 12px 14px 14px !important; }
ul.products .fusion-content-sep { display: none !important; }
ul.products .product-buttons { padding-top: 6px !important; }
ul.products .product-title { line-height: 1.35 !important; }
.mx-cta-products ul.products > li { padding: 10px !important; }
.mx-cta-products ul.products .fusion-product-content { padding: 8px 0 0 !important; }

/* 15. H1 helpers (functions.php) */
.mx-sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mx-archive-head { max-width: 1140px; margin: 0 auto; padding: 28px 15px 4px; }
.mx-archive-head .mx-archive-title { margin: 0 !important; font-family: var(--mx-head) !important; font-size: clamp(26px, 3vw, 36px) !important; font-weight: 700 !important; line-height: 1.25 !important; color: #1d1a1a; }

/* 16. Blog archives (now Avada grid layout): card titles at card size */
body.archive #main .fusion-post-content h2.entry-title, body.archive #main .fusion-post-content h2.entry-title a,
body.archive #main .fusion-post-grid .entry-title { font-size: 20px !important; line-height: 1.4 !important; }
body.archive #main .fusion-post-content-container p { font-size: 15px; line-height: 1.65; }

/* 17. Tiny labels (9–11px) on promo / comparison pages → 12px minimum, 13px for links and spec values */
.mtxr-sec-kicker, .mtxr-group-txt, .mtxr-pc-cat, .mtxr-sc-badge, .mtxr-tag, .mtxr-topic-examples-label, .mtxr-inline-ad-label,
.ur-section-num, .ur-series-badge, .ur-spec-label, .ur-use-case, .ur-tier-badge, .ur-g1-card-badge, .ur-acc-badge, .ur-acc-spec-label,
.mxr-spec-badge { font-size: 12px !important; line-height: 1.4 !important; }
.mtxr-pc-link, .ur-acc-spec-val { font-size: 13px !important; }

/* 18. "operated by DAT" — Thai site only, low-contrast on the dark footer (#141617) */
.mx-operated { display: block; margin-top: 4px; font-size: 11px; letter-spacing: .02em; }
.mx-operated a, .fusion-footer-copyright-area .mx-operated a { color: rgba(255,255,255,.28) !important; text-decoration: none !important; }
.mx-operated a:hover { color: rgba(255,255,255,.55) !important; }
