/* =====================================================
   Newin Best — 布局整改 v5
   重点：banner 宽度/高度、产品列表宽度、产品详情页布局、
         iframe/图片响应式、懒加载占位
   ===================================================== */

/* ---------- 1. 全局容器与间距 ---------- */
.container, .row, .row-large, .row-collapse, .row-small,
.elementor-section-boxed > .elementor-container,
.elementor-section-full_width > .elementor-container {
  max-width: 1440px;
}
#wrapper {
  overflow-x: hidden;
}

/* ---------- 2. 首页 Hero Banner（首屏） ---------- */
.elementor-632 .elementor-element-239f531f {
  position: relative !important;
  min-height: 70vh !important;
  max-height: 760px !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
  background-image: url('https://www.newinbest.com/wp-content/uploads/2023/03/Puzzle-Baby-play-mat.webp') !important;
  background-size: cover !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
}
/* 背景幻灯片铺满 */
.elementor-632 .elementor-element-239f531f .elementor-background-slideshow {
  position: absolute !important;
  inset: 0 !important;
  z-index: 0 !important;
  width: 100% !important;
  height: 100% !important;
}
.elementor-632 .elementor-element-239f531f .elementor-background-slideshow__slide,
.elementor-632 .elementor-element-239f531f .swiper-slide {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  opacity: 0 !important;
}
.elementor-632 .elementor-element-239f531f .swiper-slide-active {
  opacity: 1 !important;
  z-index: 1 !important;
}
.elementor-632 .elementor-element-239f531f .elementor-background-slideshow__slide__image {
  background-size: cover !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
  width: 100% !important;
  height: 100% !important;
}
/* 内容居中，限制宽度，避免两侧大留白 */
.elementor-632 .elementor-element-239f531f > .elementor-container {
  position: relative !important;
  z-index: 1 !important;
  width: 100% !important;
  max-width: 1440px !important;
  padding: 20px 24px !important;
}
.elementor-632 .elementor-element-239f531f .elementor-element-7da0ab2 > .elementor-element-populated {
  margin: 0 auto !important;
  padding: 0 !important;
  max-width: 900px !important;
  text-align: center !important;
}
/* 文字层级与可读性 */
.elementor-632 .elementor-element-239f531f .elementor-text-editor * {
  color: #ffffff !important;
}
.elementor-632 .elementor-element-239f531f h1 {
  font-size: clamp(34px, 5vw, 60px) !important;
  line-height: 1.1 !important;
  font-weight: 700 !important;
  margin: 0 0 0.35em !important;
  text-shadow: 0 2px 10px rgba(0,0,0,.35) !important;
}
.elementor-632 .elementor-element-239f531f .elementor-text-editor div {
  font-size: clamp(18px, 2.2vw, 26px) !important;
  line-height: 1.4 !important;
  text-shadow: 0 1px 6px rgba(0,0,0,.35) !important;
}
@media (max-width: 767px) {
  .elementor-632 .elementor-element-239f531f {
    min-height: 55vh !important;
    max-height: 520px !important;
  }
  .elementor-632 .elementor-element-239f531f h1 {
    font-size: clamp(26px, 8vw, 40px) !important;
  }
}

/* ---------- 3. 首页产品网格（Featured Products） ---------- */
.elementor-632 .elementor-element-3d4aaa33 .elementor-row {
  display: flex !important;
  flex-wrap: wrap !important;
  justify-content: center !important;
  gap: 24px !important;
}
/* 外层容器列保持 100%，只约束产品卡片列 */
.elementor-632 .elementor-element-3d4aaa33 > .elementor-container > .elementor-row > .elementor-column {
  width: 100% !important;
  max-width: none !important;
  flex: 0 0 100% !important;
}
.elementor-632 .elementor-element-3d4aaa33 .elementor-inner-section .elementor-column,
.elementor-632 .elementor-element-3d4aaa33 .elementor-col-25 {
  width: calc(25% - 18px) !important;
  min-width: 200px !important;
  max-width: 320px !important;
  flex: 0 0 auto !important;
  padding: 0 !important;
}
.elementor-632 .elementor-element-3d4aaa33 .elementor-image-box-img img {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 1 / 1 !important;
  object-fit: cover !important;
  border-radius: 8px !important;
}
.elementor-632 .elementor-element-3d4aaa33 .elementor-image-box-title {
  text-align: center !important;
  font-size: 1.05rem !important;
  margin-top: 12px !important;
  text-transform: capitalize !important;
  line-height: 1.25 !important;
}
@media (max-width: 1100px) {
  .elementor-632 .elementor-element-3d4aaa33 .elementor-inner-section .elementor-column,
  .elementor-632 .elementor-element-3d4aaa33 .elementor-col-25 {
    width: calc(33.333% - 16px) !important;
  }
}
@media (max-width: 767px) {
  .elementor-632 .elementor-element-3d4aaa33 .elementor-inner-section .elementor-column,
  .elementor-632 .elementor-element-3d4aaa33 .elementor-col-25 {
    width: calc(50% - 12px) !important;
    min-width: 140px !important;
  }
}

/* 工厂视频未加载时整节隐藏（iframe 注入后 :empty 失配自动恢复显示） */
.elementor-632 .elementor-element-27d3d00:has(.elementor-video:empty) {
  display: none !important;
  margin: 0 !important;
}
.elementor-632 .elementor-element-27d3d00 iframe,
.elementor-632 .elementor-element-27d3d00 .elementor-video iframe {
  max-width: 100% !important;
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 16 / 9 !important;
}

/* ---------- 4. 证书/展览/流程图片统一尺寸 ---------- */
.elementor-632 .elementor-section-full_width:has(.elementor-col-16) .elementor-col-16 img,
.elementor-632 .elementor-section:has(h2.elementskit-section-title) .elementor-image img {
  width: 100% !important;
  height: auto !important;
  max-height: 280px !important;
  object-fit: contain !important;
}

/* ---------- 5. 产品列表页布局加宽 ---------- */
.archive.woocommerce .content-area > .row,
.woocommerce-page .content-area > .row {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 24px !important;
}
.archive.woocommerce .content-area > .row > .large-3,
.woocommerce-page .content-area > .row > .large-3,
.shop-sidebar,
#shop-sidebar {
  width: 22% !important;
  min-width: 220px !important;
  max-width: 280px !important;
  flex: 0 0 auto !important;
}
.archive.woocommerce .content-area > .row > .large-9,
.woocommerce-page .content-area > .row > .large-9 {
  width: auto !important;
  flex: 1 1 auto !important;
}
/* 产品网格图片统一 1:1 */
.shop-container .products .box-image img,
.shop-container .products .box-image .back-image {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 1 / 1 !important;
  object-fit: cover !important;
}
.shop-container .products .product-title,
.shop-container .products .product-title a {
  white-space: normal !important;
  font-size: 0.95rem !important;
  line-height: 1.25 !important;
  text-transform: capitalize !important;
}
@media (max-width: 767px) {
  .archive.woocommerce .content-area > .row,
  .woocommerce-page .content-area > .row {
    flex-wrap: wrap !important;
  }
  .archive.woocommerce .content-area > .row > .large-3,
  .woocommerce-page .content-area > .row > .large-3 {
    width: 100% !important;
    max-width: none !important;
    order: 2 !important;
  }
  .archive.woocommerce .content-area > .row > .large-9,
  .woocommerce-page .content-area > .row > .large-9 {
    width: 100% !important;
    order: 1 !important;
  }
}

/* ---------- 6. 产品详情页布局 ---------- */
.product-container {
  width: 100% !important;
  max-width: 1440px !important;
  margin: 0 auto !important;
}
.product-main > .row.content-row {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: flex-start !important;
  gap: 30px !important;
  margin-bottom: 40px !important;
}
.product-main .product-gallery {
  flex: 1 1 45% !important;
  max-width: 600px !important;
  width: auto !important;
}
.product-main .product-gallery img,
.product-main .woocommerce-product-gallery__image img,
.product-main .product-thumbnails img {
  width: 100% !important;
  height: auto !important;
}
.product-main .product-info.summary {
  flex: 1 1 45% !important;
  max-width: 620px !important;
  width: auto !important;
}
.product-main .product-title.product_title {
  font-size: clamp(26px, 3.5vw, 38px) !important;
  line-height: 1.2 !important;
}
.product-main .product-short-description p {
  font-size: 1rem !important;
  line-height: 1.6 !important;
}
/* 详情标签页内容全宽 */
.product-footer .woocommerce-tabs {
  width: 100% !important;
  max-width: 1440px !important;
  margin: 0 auto !important;
}
#tab-description,
.woocommerce-Tabs-panel {
  width: 100% !important;
  max-width: 1100px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}
/* 详情内图片响应式 */
#tab-description img,
.woocommerce-Tabs-panel img,
.product-footer .entry-content img {
  max-width: 100% !important;
  height: auto !important;
  display: block !important;
  margin: 1.25em auto !important;
}
/* iframe 响应式：YouTube 视频等 */
#tab-description iframe,
.woocommerce-Tabs-panel iframe,
.elementor-video,
.elementor-wrapper iframe,
.elementor-widget-video iframe,
.elementor-widget-video .elementor-wrapper > * {
  max-width: 100% !important;
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 16 / 9 !important;
  display: block !important;
  margin: 1.5em auto !important;
  border: none !important;
}
/* 修复因懒加载/加载失败导致的灰块占位 */
#tab-description iframe,
.woocommerce-Tabs-panel iframe {
  background: #f0f0f0 !important;
}
/* 详情内标题字号 */
#tab-description strong span,
#tab-description span strong {
  font-size: 1.25rem !important;
  line-height: 1.3 !important;
}

/* ---------- 7. 相关/推荐产品 slider 兜底 ---------- */
.related-products-wrapper .row-slider,
.product-section .row-slider {
  display: flex !important;
  flex-wrap: wrap !important;
  justify-content: center !important;
  gap: 16px !important;
}
.related-products-wrapper .row-slider .col,
.product-section .row-slider .col {
  flex: 0 0 auto !important;
  width: calc(20% - 13px) !important;
  min-width: 150px !important;
}
.related-products-wrapper .box-image img,
.product-section .box-image img {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 1 / 1 !important;
  object-fit: cover !important;
}

/* ---------- 8. 通用图片与懒加载占位 ---------- */
img[width][height] {
  height: auto !important;
}
.elementor-image img,
.elementor-image-box-img img,
.wp-post-image,
.attachment-large {
  max-width: 100% !important;
}
/* 关键区域懒加载占位最小高度，避免布局抖动 */
.elementor-section img:not([src]) {
  min-height: 120px !important;
  background: #f5f5f5 !important;
}

/* ---------- 9. 多端适配加固（手机 / Pad / 电脑） ---------- */
/* 全局防溢出兜底：表格、代码块、内嵌内容永不撑破视口 */
body { overflow-x: hidden; }
table, pre {
  max-width: 100% !important;
  overflow-x: auto !important;
  display: block;
  -webkit-overflow-scrolling: touch;
}

/* 首页联系卡片区与 footer 间距 */
.elementor-632 .elementor-element-8a4a7b8 {
  margin-bottom: 70px !important;
  padding-bottom: 30px !important;
}
@media (max-width: 767px) {
  .elementor-632 .elementor-element-8a4a7b8 {
    margin-bottom: 40px !important;
    padding-bottom: 20px !important;
  }
}
/* footer 顶部统一留白 */
footer,
.footer-wrapper,
.footer {
  padding-top: 50px !important;
}

/* --- 手机（<768px）：恢复原生堆叠布局 --- */
@media (max-width: 767px) {
  /* 产品详情页：主图在上、摘要在下，各占整行 */
  .product-main > .row.content-row {
    flex-direction: column !important;
    gap: 24px !important;
  }
  .product-main .product-gallery,
  .product-main .product-info.summary {
    flex: 1 1 100% !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .product-main .product-gallery img {
    margin-left: auto !important;
    margin-right: auto !important;
  }
  /* 详情 tabs 标签条横向可滚动，不换行堆积 */
  .woocommerce-tabs ul.tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .woocommerce-tabs ul.tabs li {
    flex: 0 0 auto !important;
  }
  /* 相关产品 2 列 */
  .related-products-wrapper .row-slider .col,
  .product-section .row-slider .col {
    width: calc(50% - 8px) !important;
    min-width: 140px !important;
  }
  /* Hero 内边距收紧 */
  .elementor-element-239f531f > .elementor-container {
    padding: 12px 16px !important;
  }
  /* 产品列表卡片标题不挤成一行 */
  .shop-container .products .product-title {
    font-size: 0.88rem !important;
  }
  /* 详情页大标题缩小 */
  .product-main .product-title.product_title {
    font-size: 24px !important;
  }
}

/* --- Pad 竖屏（768–1024px）：双列布局收窄间距 --- */
@media (min-width: 768px) and (max-width: 1024px) {
  .product-main > .row.content-row { gap: 20px !important; }
  .product-main .product-gallery { flex: 1 1 48% !important; max-width: none !important; }
  .product-main .product-info.summary { flex: 1 1 48% !important; max-width: none !important; }
  #tab-description,
  .woocommerce-Tabs-panel { max-width: 100% !important; }
  /* Pad 上相关产品 3 列 */
  .related-products-wrapper .row-slider .col,
  .product-section .row-slider .col {
    width: calc(33.333% - 11px) !important;
  }
}

/* --- 桌面（>1440px）：超宽屏内容不过度拉伸 --- */
@media (min-width: 1600px) {
  .elementor-section-boxed > .elementor-container { max-width: 1400px; }
  #tab-description,
  .woocommerce-Tabs-panel { max-width: 1200px !important; }
}

/* ---------- 12. 首页工厂视频响应式嵌入 ---------- */
.elementor-wrapper.elementor-open-inline {
  position: relative;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
}
.elementor-video {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  background: #f5f7fa;
  border-radius: 8px;
  overflow: hidden;
}
.elementor-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
