/* M29-B: Mobile Swipeable Sets + 98px Contain Shapes + Switchable Plant Cards
   Loaded at the very end of <head> so these mobile-only rules win the cascade. */
@media (max-width: 767px) {
  /* P0-06 · The set is the product. — 4 sets become a single 84vw snap rail */
  /* High-specificity prefix beats urgent-click-fix.css's `html body .fy3-sets__grid
     { max-height:900px; overflow:hidden }` which otherwise blocks touch swiping. */
  html body .fy3-sets__grid, html body .sets-grid {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow: auto !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    max-height: none !important;
    height: auto !important;
    scroll-snap-type: x mandatory !important;
    -webkit-overflow-scrolling: touch !important;
    gap: 12px !important;
    padding: 4px 20px 16px !important;
    margin: 0 -20px !important;
    scrollbar-width: none !important;
    align-items: stretch !important;
  }
  html body .fy3-sets__grid::-webkit-scrollbar, html body .sets-grid::-webkit-scrollbar { display: none !important; }
  html body .fy3-sets__grid > *, html body .sets-grid > * {
    flex: 0 0 84vw !important;
    max-width: 84vw !important;
    width: 84vw !important;
    scroll-snap-align: start !important;
    scroll-snap-stop: always !important;
  }
  /* Cards keep their own internal layout; only the outer card is snap-sized. */
  html body .fy3-sets__card { box-sizing: border-box !important; }

  /* P0-07 · A shape for your next collection. — 98px single-row contain rail
     The real inspectable thumbnails live in .fy3-grid (70 cards, hover/scroll
     limited to 300px on mobile by home-v3 CSS). Convert that grid to a single
     98px-high horizontal contain rail; keep every other legacy selector as a
     defensive alias so the rule also holds if the grid markup is swapped. */
  .fy3-grid[data-grid],
  .fy3-col__thumbs, .fy-shapes-thumb-grid, .shape-thumbs-grid {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    gap: 10px !important;
    height: 118px !important;
    max-height: 118px !important;
    min-height: 118px !important;
    padding: 8px 4px 12px !important;
    margin: 0 !important;
    scrollbar-width: none !important;
    scroll-snap-type: x proximity !important;
    align-items: center !important;
  }
  .fy3-grid[data-grid]::-webkit-scrollbar,
  .fy3-col__thumbs::-webkit-scrollbar,
  .fy-shapes-thumb-grid::-webkit-scrollbar,
  .shape-thumbs-grid::-webkit-scrollbar { display: none !important; }
  /* 98px visual card = 118px rail minus 8px top / 12px bottom padding. */
  .fy3-grid[data-grid] > *,
  .fy3-col__thumbs > *, .fy-shapes-thumb-grid > *, .shape-thumbs-grid > * {
    flex: 0 0 78px !important;
    width: 78px !important;
    height: 98px !important;
    max-height: 98px !important;
    min-height: 98px !important;
    padding: 8px 6px !important;
    background: #faf8f4 !important;
    border: 1px solid rgba(20, 19, 17, 0.1) !important;
    border-radius: 10px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    scroll-snap-align: start !important;
    box-sizing: border-box !important;
  }
  .fy3-grid[data-grid] img,
  .fy3-col__thumbs img, .fy-shapes-thumb-grid img, .shape-thumbs-grid img {
    width: 100% !important;
    height: 100% !important;
    max-height: 82px !important;
    object-fit: contain !important;
  }
  /* Title top clearance: the old mobile headline was clipped by the stage. */
  .fy3-collection .fy3-h2,
  .fy3-collection .fy3-col-head h2,
  .fy3-col__title, .shape-detail-title {
    margin-top: 16px !important;
    padding-top: 8px !important;
    line-height: 1.32 !important;
    overflow: visible !important;
  }
  /* Spec rows: give dt/dd real breathing room instead of a packed block. */
  .fy3-collection .fy3-spec-dl,
  .fy3-spec-dl { row-gap: 10px !important; }
  .fy3-collection .fy3-spec-row,
  .fy3-spec-row {
    padding-block: 8px !important;
    border-bottom: 1px solid rgba(20, 19, 17, 0.08) !important;
  }
  .fy3-collection .fy3-spec-row:last-child,
  .fy3-spec-row:last-child { border-bottom: 0 !important; }
  .fy3-collection .fy3-spec-name,
  .fy3-spec-name { margin-bottom: 6px !important; line-height: 1.3 !important; }

  /* P0-08 · Plant & process — 01/02/03 switchable cards + 16:10 cover images */
  .fy3-plant-notes__tabs { display: flex !important; gap: 8px !important; margin: 12px 0 12px !important; overflow-x: auto !important; scrollbar-width: none !important; }
  .fy3-plant-notes__tabs::-webkit-scrollbar { display: none !important; }
  .fy3-plant-notes__tab {
    flex: 0 0 auto !important; height: 44px !important; padding: 0 16px !important;
    border-radius: 999px !important; border: 1px solid rgba(20,19,17,.16) !important;
    background: #fff !important; color: #24221e !important; font-size: 12px !important; font-weight: 600 !important;
  }
  .fy3-plant-notes__tab.is-active { background: #1b4d3e !important; border-color: #1b4d3e !important; color: #fff !important; }
  html body .fy3-plant-notes__card[data-plant-hidden="true"] { display: none !important; }
  /* Keep the native grid layout of the journal entry — forcing `flex` collapsed
     its figure to 0x0 and produced an image-less card. One-column grid makes a
     proper card: 16:10 cover photo on top, text underneath. */
  html body .fy3-plant-notes__card[data-plant-hidden="false"] {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px !important;
  }
  /* The cover figure used to be a fixed 200x200 box with overflow:hidden while
     the image was 16:10 — the leftover strip showed up as a black vertical bar.
     Make the figure itself 16:10 and let cover fill it edge to edge. */
  html body .fy3-plant-notes__card .fy3-jentry__cover {
    width: 100% !important; max-width: none !important; height: auto !important;
    aspect-ratio: 16 / 10 !important; overflow: hidden !important; margin: 0 !important;
  }
  html body .fy3-plant-notes__card .fy3-jentry__cover img {
    width: 100% !important; height: 100% !important; object-fit: cover !important;
  }
  /* journal-thread.webp has a ~9.75% pure-black strip baked into its right edge
     (verified against the 800x800 source). A 1.12x zoom inside the overflow-hidden
     16:10 figure crops that strip off without distorting the bottles. */
  html body .fy3-plant-notes__card img[src*="journal-thread"] {
    transform: scale(1.12) !important;
    transform-origin: left center !important;
  }
  html body .fy3-plant-notes__grid img, html body section[id*="plant"] article img,
  html body #section-policies-journal .fy3-journal__col--news .fy3-jentry--visual img {
    width: 100% !important; height: auto !important;
    aspect-ratio: 16 / 10 !important; object-fit: cover !important;
    object-position: center !important;
    border-radius: 10px !important; background: #f3efe7 !important;
    display: block !important;
  }
}

/* Desktop: if a viewport was mobile when the tab JS initialised and then
   widened, restore all three stacked cards and hide the tab bar. */
@media (min-width: 768px) {
  html body .fy3-plant-notes__tabs { display: none !important; }
  html body .fy3-plant-notes__card[data-plant-hidden] { display: grid !important; }
}

/* ==========================================================================
   M29M-B · 390 首页总高度收口 + LOGO 05 胶囊换行 + 订阅箭头避让
   （2026-11-30 · 全部只在 ≤767px；桌面 ≥1024 一行不碰）

   基线：本地 390×844 实测 docH 15706（门禁线 14500）。本节只收「段间内距 /
   可压缩的图片高度 / 行距」，不删功能、不删文案、不重排信息层级：
     · .fy3-section 上下内距 64 → 36（5 段）
     · craft 工艺卡图 1:1 → 16:10；LOGO 组 05 卡胶囊改为静态换行（不截字）
     · LOGO 组「Need a special finish?」整行跨两列（右侧不再留空）
     · Plant & process 3 篇 → 01/02/03 切换卡（下方规则 + 04-plant-tabs.js）
     · 数据条 4 列 → 2 列；journal/terms/faq 行距收紧
     · 目录翻书竖版窗口限高 300（仍可翻页、contain 不裁页）
     · KEEP ME POSTED 表单右侧留 56px，箭头不再被 52px 绿钮压住
   ========================================================================== */
@media (max-width: 767px) {
  /* ---------- 0. 段间内距收敛（hero 自己的 padding 归 01-hero.css 管） ---------- */
  html body .fy3-section:not(.fy3-hero) { padding-block: 36px !important; }
  html body .fy3-sets { padding-top: 12px !important; }

  /* ---------- 1. 数据条 4 列 → 2 列（4×120 → 2×2） ---------- */
  html body #section-policies-journal .fy3-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    margin-bottom: 24px !important;
  }
  html body #section-policies-journal .fy3-metric { padding: 12px 14px !important; }
  html body #section-policies-journal .fy3-journal__head { margin-bottom: 10px !important; }
  html body #section-policies-journal .fy3-jentry { padding: 12px 0 !important; }
  html body #section-policies-journal .fy3-faq__item summary { padding-block: 10px !important; }
  html body #section-policies-journal .fy3-term > summary { padding-block: 10px !important; }
  html body #section-policies-journal .fy3-policies__head { margin-bottom: 20px !important; }

  /* ---------- 2. Plant & process 切换卡：tab 条与卡内距 ---------- */
  /* 3 枚完整 tab 在 350px 内放不下（截到「03 Sea」）→ 允许换行，两行显示完整标签，
     不横向滚动、不截字。 */
  html body .fy3-plant-notes__tabs {
    margin: 8px 0 10px !important;
    flex-wrap: wrap !important;
    overflow: visible !important;
  }
  html body .fy3-plant-notes__card .fy3-jentry__body { gap: 4px !important; }
  html body .fy3-plant-notes__card .fy3-jentry__title { font-size: 15px !important; line-height: 1.3 !important; }

  /* ---------- 3. A shape for your next collection · 98px 单行滑轨内 img 拉满 ----------
     .fy3-card 基础 img 是 aspect-ratio:1/1（64×64），瓶身只占 1/4 高。
     这里把图片盒拉到 80px 高、取消方形容器，object-fit:contain 保证全瓶身。 */
  html body .fy3-grid[data-grid] > .fy3-card > img {
    width: 100% !important;
    height: 72px !important;
    max-height: 72px !important;
    aspect-ratio: auto !important;
    object-fit: contain !important;
    object-position: center !important;
    padding: 0 4px !important;
    background: transparent !important;
  }
  html body .fy3-grid[data-grid] > .fy3-card { padding: 8px 4px 4px !important; justify-content: center !important; }
  html body .fy3-collection .fy3-col-head { margin-bottom: 10px !important; }

  /* ---------- 4. 工艺卡（Bottle surface / Logo branding） ----------
     390 下两组都改 2 列窄卡（LOGO 组原本就是 2 列，Bottle 组 M9 起是 1 列）；
     宣传图 1:1 保持不变（M21 甲方硬规范：官图完整构图不裁切，object-fit:contain），
     只收 meta 行距与内距。这样既消掉「1 列 4:3/1:1 大图」的 1476px 长列，
     也不产生 contain 横向留白条。文案一字不删。 */
  html body #surface-finishes .fy3-craft-grid[data-craft-grid] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }
  html body #surface-finishes .fy3-craft-card__meta { gap: 5px !important; padding: 8px 10px 0 !important; }
  html body #surface-finishes .fy3-craft-card { padding-bottom: 8px !important; }
  html body #surface-finishes .fy3-craft-card__name { font-size: 13.5px !important; line-height: 1.28 !important; }
  html body #surface-finishes .fy3-craft-card__desc { font-size: 12px !important; line-height: 1.5 !important; }
  html body #surface-finishes .fy3-finishes__groups { gap: 18px !important; }

  /* 内置胶囊卡（02/03/05）：2 列窄卡里原来 nowrap + 横向滚动，
     末尾按钮被卡片右缘截断（05 卡「Foil + Silk-Screen」→「...Silk」）。
     改为静态多行、不横向滚动、按钮不许断字、不切词。 */
  html body #surface-finishes [data-finish-switcher] .fy3-craft-card__media {
    aspect-ratio: auto !important;
    overflow: visible !important;
    display: flex !important;
    flex-direction: column !important;
    background: var(--fy-bg-elevated, #F3EFEA) !important;
  }
  html body #surface-finishes [data-finish-switcher] .fy3-craft-card__media img {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1 !important;
    object-fit: contain !important;
  }
  html body #surface-finishes [data-finish-switcher] .fy3-subfinish-pills {
    position: static !important;
    inset: auto !important;
    margin: 6px 8px 8px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 4px !important;
    padding: 4px !important;
    overflow: visible !important;
    background: #141311 !important;
    border-radius: 999px !important;
  }
  html body #surface-finishes [data-finish-switcher] .fy3-subfinish-pills button {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    min-height: 28px !important;
    height: auto !important;
    padding: 4px 8px !important;
    font-size: 9.5px !important;
    line-height: 1.15 !important;
    /* 11 语（de/ru 复合词）在小胶囊里也要能落行，不切词、不溢出卡片 */
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }
  html body #surface-finishes .fy3-craft-card__name,
  html body #surface-finishes .fy3-craft-card__desc { overflow-wrap: anywhere !important; }
  /* 质量徽章（胶囊）在 2 列窄卡里同样允许换行：de/es/it/pt 全称比 EN 长，原来 nowrap 会伸出卡右缘 */
  html body #surface-finishes .fy3-badge-pill {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    max-width: 100% !important;
    line-height: 1.25 !important;
  }

  /* 「Need a special finish?」整行跨两列，右侧不再空一格；内距按窄屏收 */
  html body #surface-finishes .fy3-craft-card--special { grid-column: 1 / -1 !important; }
  html body #surface-finishes .fy3-craft-card__special { padding: 18px !important; gap: 10px !important; }
  html body #surface-finishes .fy3-craft-card--special .fy3-craft-card__actions { gap: 10px !important; }

  /* ---------- 5. Company · 厂区/证书/目录/品牌墙 高度收口 ---------- */
  html body .fy3-company__intro .fy3-h2 { margin-bottom: 12px !important; }
  html body .fy3-company__intro > .fy3-btn { margin-top: 16px !important; }
  html body .fy3-company__stats { margin-top: 14px !important; }
  html body .fy3-company__stats > div { padding: 8px 0 !important; }
  html body .fy3-floor__stage { max-height: 240px !important; }
  html body .fy3-floor__stage video,
  html body .fy3-floor__stage .fy3-floor__poster { max-height: 240px !important; object-fit: cover !important; }
  html body .fy3-floor__tabs { margin-top: 8px !important; }
  html body .fy3-company__proof { gap: 18px !important; }
  html body .fy3-company__patents { margin-top: 6px !important; }
  html body .fy3-books { gap: 16px !important; }
  html body .fy3-book__head { margin-bottom: 8px !important; }
  html body .fy3-book__stage { padding: 10px !important; }
  /* 竖版目录（Edition B，1000×1414）390 下按 330 宽会撑到 466px 高；限高 300 后
     页面仍 contain 完整显示、左右翻页逻辑不变。横版 Instock 目录不受影响。 */
  html body .fy3-book:not([data-fy3-book="instock"]) .fy3-book__viewport { max-height: 300px !important; }
  html body .fy3-book__bar { margin-top: 8px !important; }
  html body .fy3-book__foot { margin-top: 6px !important; }
  html body .fy3-company__qr { margin-top: 16px !important; padding-top: 12px !important; }
  html body #section-brands .fy3-brands__grid { gap: 6px !important; }

  /* ---------- 6. KEEP ME POSTED 订阅箭头避让 52px 绿钮 ----------
     绿钮几何：right 16 → x 322~374、bottom 22 → y 716~768（视口固定）。
     footer 表单行右端原为 370，滚动经过时箭头（x 321~365）必被压住。
     表单行右侧让出 56px → 行右端 314 < 322，箭头与绿钮不重叠。 */
  html body footer.site-footer .foot-sub { padding-right: 56px !important; box-sizing: border-box !important; }
  html body footer.site-footer .foot-sub__row { box-sizing: border-box !important; }
  html body footer.site-footer .foot-sub__btn { flex: 0 0 44px !important; width: 44px !important; }

  /* ---------- 7. Hero 下 01 02 03 tab 条与套装标题之间的空白再收 ---------- */
  html body .fy3-sets .fy3-sets__head { margin-bottom: 10px !important; }
}
