/* ========================================
   YOYAGE Product Detail Page Styles
   Purpose: product detail page (page hero,
            overview, spec tables with sticky
            drawing bar & synced headbars,
            related products)
   Loaded after components.css on product
   detail pages only. Per-series table
   widths & key-column highlights live in
   product-tables.css (loaded right after
   this file).
   ======================================== */

/* ---------- 1. Page Hero (brand background, breadcrumb + centered title) ---------- */
.pd-hero {
  background-color: var(--color-brand);
  padding-top: 32px;
  padding-bottom: 32px;
}

.pd-hero .breadcrumb {
  justify-content: center;
  margin-bottom: 16px;
}

.pd-hero .breadcrumb a {
  color: rgba(255, 255, 255, 0.85);
}

.pd-hero .breadcrumb a:hover {
  color: var(--color-white);
}

.pd-hero .breadcrumb-separator {
  color: rgba(255, 255, 255, 0.5);
}

.pd-hero .breadcrumb-current {
  color: var(--color-white);
}

.pd-title {
  font-size: var(--fs-h2);
  color: var(--color-white);
  text-align: center;
  margin-bottom: 0;
}

/* ---------- 2. Overview (image + key specs) ---------- */
.pd-overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: stretch;
}

/* Two feature cards side by side below the overview grid, no section title;
   inset hairline separator above (via ::before) marks the boundary */
.pd-feature-cards {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 48px;
  padding-top: 48px;
}

/* Inset hairline: stops 24px short of both edges */
.pd-feature-cards::before {
  content: "";
  position: absolute;
  top: 0;
  left: 24px;
  right: 24px;
  height: 1px;
  background-color: var(--color-border);
}

.pd-feature-card {
  display: flex;
  flex-direction: column;
  padding: 24px;
}

/* Card footer link: "Click to View Details" pinned to card bottom */
.pd-feature-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  margin-top: auto;
  padding-top: 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-brand);
  transition: color var(--transition-fast);
}

.pd-feature-more:hover {
  color: var(--color-brand-dark);
}

.pd-feature-more .link-arrow {
  transition: transform var(--transition-fast);
}

.pd-feature-more:hover .link-arrow {
  transform: translateX(3px);
}

.pd-feature-card-title {
  font-size: var(--fs-h3);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-brand);
  margin-bottom: 24px;
}

/* Short brand-color dash separating card title from bullets */
.pd-feature-card-title::after {
  content: "";
  display: block;
  width: 40px;
  height: 2px;
  margin-top: 11px;
  border-radius: 2px;
  background-color: var(--color-brand);
}

.pd-feature-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pd-feature-list li {
  position: relative;
  padding-left: 16px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.6;
  color: var(--color-title);
}

/* Inline links inside feature bullets (e.g. Precision-ground gears) */
.pd-feature-list a {
  color: var(--color-brand);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--transition-fast);
}

.pd-feature-list a:hover {
  color: var(--color-brand-dark);
}

.pd-feature-list li + li {
  margin-top: 8px;
}

.pd-feature-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.45em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-brand);
}

/* Related products + FAQ: 1:2 columns with a hairline divider */
.pd-related-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 48px;
}

.pd-related-col--faq {
  border-left: 1px solid var(--color-border);
  padding-left: 48px;
}

/* 栏目头：品牌色 eyebrow 小标题（复用 .section-eyebrow）+ 一句话引导大标题 */
.pd-related-col .section-eyebrow {
  display: block;
  text-align: center;
  margin-bottom: 10px;
}

.pd-related-heading {
  margin: 0 0 28px;
  font-size: 22px;
  font-weight: 600;
  color: var(--color-title);
  text-align: center;
}

/* FAQ 数字圆标已上移至 components.css 全局规则（CSS counter 自动编号） */

/* Related products: mini cards stacked vertically */
.pd-related-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Anchor targets: clear the sticky header when jumped to */
#product-features,
#custom-solutions,
#technical-data,
#related-products {
  scroll-margin-top: calc(120px + var(--expo-bar-h));
}

.mini-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.mini-card:hover {
  border-color: var(--color-brand);
  box-shadow: var(--shadow-md);
}

.mini-card-img {
  width: 88px;
  height: 88px;
  flex-shrink: 0;
  border-radius: var(--radius-button);
  overflow: hidden;
  background-color: var(--color-bg-alt);
}

/* 完整显示图片（contain，不裁剪），留白由背景色填充 */
.mini-card-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.mini-card-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.mini-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-title);
}

.mini-card:hover .mini-card-title {
  color: var(--color-brand);
}

.mini-card-reason {
  font-size: 13px;
  line-height: 1.4;
  color: var(--color-text-muted);
}

/* Two-column layout: image fills the left column and matches content height
   (no aspect-ratio here — it would shrink the width when the row is short) */
.pd-media {
  position: relative;
  overflow: hidden;
  background-color: var(--color-bg-alt);
}

/* 完整显示图片（contain，不裁剪）；容器与图片比例不一致时留白由背景色填充 */
.pd-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Operation badge reuses valve-gearbox.css colors; defined in section 5 */
/* Overview section: slightly larger vertical rhythm (64px standard) */
.section.pd-overview {
  padding-top: 64px;
  padding-bottom: 64px;
}

.pd-overview-text {
  line-height: 1.8;
  margin-bottom: 24px;
}

.key-specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 24px;
  padding: 16px 24px;
  margin-bottom: 24px;
}

.key-spec {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  font-size: var(--fs-small);
  line-height: 1.4;
  border-top: 1px dashed var(--color-border);
}

.key-spec:nth-child(-n + 2) {
  border-top: none;
}

.key-spec dt {
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.key-spec dd {
  margin: 0;
  font-weight: 600;
  color: var(--color-title);
  text-align: right;
}

/* Custom link inside spec values (e.g. Housing Material) */
.key-spec dd a {
  color: var(--color-brand);
  text-decoration: underline;
}

/* Action buttons: equal width, flush left & right (project convention: grid) */
.pd-overview-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* ---------- 3. Spec tables: sticky drawing bar + synced headbars ---------- */

/* Selection-guide link under the tables section title */
.pd-tables .section-subtitle a {
  color: var(--color-brand);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.pd-tables .section-subtitle a:hover {
  color: var(--color-brand-dark);
}

/* 操作提示：桌面显示 Shift+横滚，触摸端显示捏合缩放 */
.pd-table-tip {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--color-text-muted);
  opacity: 0.85;
}

.pd-table-tip strong {
  font-weight: 600;
  color: #000;
}

.pd-table-tip .tip-touch {
  display: none;
}

@media (max-width: 767px) {
  .pd-table-tip .tip-desktop {
    display: none;
  }

  .pd-table-tip .tip-touch {
    display: inline;
  }
}

.tables-wrap {
  position: relative;
}

/* 禁止滚动锚定：图纸条压缩/展开会改变布局高度，若浏览器自动补偿 scrollY
   会与吸顶判断形成反馈回路（边界处上下不停跳动） */
.tables-wrap,
.tables-wrap * {
  overflow-anchor: none;
}

/* Sticky zone: drawing bar + active table headbar. Sticks below the fixed site header.
   Background matches the section--alt color to cover scrolled content seamlessly. */
.tables-sticky {
  position: sticky;
  top: calc(72px + var(--expo-bar-h)); /* site header + expo bar */
  z-index: 60;
  background-color: var(--color-bg-alt);
  padding-top: 4px;
}

/* 3.1 Drawing bar (shared by both tables) */
.drawing-bar {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background-color: var(--color-bg);
  overflow: hidden;
  transition: box-shadow var(--transition-fast);
}

.tables-sticky.is-stuck .drawing-bar {
  box-shadow: var(--shadow-md);
}

.drawing-bar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
}

.drawing-bar-title {
  font-size: var(--fs-small);
  font-weight: 700;
  color: var(--color-title);
  flex-shrink: 0;
}

.drawing-bar-hint {
  flex: 1;
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawing-toggle {
  display: none; /* shown when stuck (desktop) or always on mobile */
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-brand);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-tag);
  flex-shrink: 0;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.drawing-toggle:hover {
  border-color: var(--color-brand);
}

.drawing-toggle svg {
  transition: transform var(--transition-fast);
}

.tables-sticky.is-expanded .drawing-toggle svg {
  transform: rotate(180deg);
}

.tables-sticky.is-stuck .drawing-toggle {
  display: inline-flex;
}

/* Drawing body: 桌面默认完全展开，吸顶后按下述状态类收起 / 展开，0.3s 过渡 */
.drawing-body {
  max-height: 400px;
  overflow: hidden;
  padding-left: 16px;
  padding-right: 16px;
  transition: max-height 0.3s ease;
}

.tables-sticky.is-stuck .drawing-body {
  max-height: 0;
}

.tables-sticky.is-stuck.is-expanded .drawing-body {
  max-height: 400px;
}

/* 图纸图片：固定高度 + contain 完整显示（工程图不可裁切），点击可放大 */
.drawing-placeholder {
  display: block;
  width: 100%;
  height: 360px;
  object-fit: contain;
  margin-bottom: 16px;
  cursor: zoom-in;
}

/* ---------- 3.1b Drawing lightbox（点击图纸全屏查看，支持缩放/拖动） ---------- */
.drawing-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 24, 45, 0.94);
  overflow: hidden;
  touch-action: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.drawing-lightbox.is-open {
  opacity: 1;
}

.drawing-lightbox img {
  max-width: 95vw;
  max-height: 85vh;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  cursor: grab;
  will-change: transform;
}

.drawing-lightbox.is-grabbing img {
  cursor: grabbing;
}

.drawing-lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  line-height: 1;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.drawing-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

.drawing-lightbox-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
}

/* 3.2 Table headbars (visible copy of the active table header).
   Same width & centering as the table frame below, so the sticky
   header always aligns with the table body.
   展开/收起用 max-height + opacity + margin 过渡，不用 display 切换——
   display 突变会在吸顶瞬间造成高度跳变（与图纸条压缩叠加产生拉扯感）。
   opacity 同时隐藏 0 高度元素的 box-shadow 残影。 */
.table-headbar {
  overflow: hidden;
  width: fit-content;
  max-width: 100%;
  max-height: 0;
  opacity: 0;
  margin: 0 auto;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-md);
  transition: max-height 0.25s ease, opacity 0.25s ease, margin-top 0.25s ease;
}

.table-headbar.is-active {
  max-height: 96px;
  opacity: 1;
  margin-top: 8px;
}

/* 3.3 Spec table base */
.spec-table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

/* All header and data cells are horizontally centered */
.spec-table thead th,
.spec-table tbody th,
.spec-table td {
  text-align: center;
  font-size: var(--fs-small);
  line-height: 1.4;
}

.spec-table thead th {
  background-color: var(--color-title);
  color: var(--color-white);
  padding: 10px 8px;
  font-weight: 700;
  vertical-align: middle;
}

.th-name {
  display: block;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.th-sub {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.65);
  margin-top: 2px;
}

/* First column locked while horizontal scrolling */
.spec-table thead th:first-child,
.spec-table tbody th {
  position: sticky;
  left: 0;
  z-index: 2;
}

.spec-table thead th:first-child {
  z-index: 3;
}

.spec-table tbody th,
.spec-table tbody td {
  padding: 10px 8px;
  border-top: 1px solid var(--color-border);
  white-space: nowrap;
}

.spec-table tbody th {
  font-weight: 700;
  color: var(--color-title);
  border-right: 1px solid var(--color-border);
}

.spec-table tbody td {
  color: var(--color-text);
}

/* Zebra striping: background must sit on cells so the sticky first column stays opaque */
.spec-table tbody tr > * {
  background-color: var(--color-bg);
}

.spec-table tbody tr:nth-child(even) > * {
  background-color: var(--color-bg-alt);
}

.spec-table tbody tr:hover > * {
  background-color: var(--color-tag-bg);
}

/* Model row-header cells stay white across zebra rows and hover (all spec tables) */
.spec-table tbody tr > th[scope="row"] {
  background-color: var(--color-bg);
}

/* Footnote under a spec table */
.spec-table-note {
  margin-top: 12px;
  font-size: var(--fs-small);
  color: var(--color-text);
  text-align: center;
}

/* 3.4 Table frame & horizontal scroll */
.spec-table-block {
  margin-top: 28px;
}

.spec-table-title {
  font-size: var(--fs-h3);
  margin-bottom: 14px;
  text-align: center;
}

/* Frame hugs the table width and centers within the container;
   max-width keeps horizontal scrolling on narrow screens */
.table-frame {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  overflow: hidden;
  background-color: var(--color-bg);
}

.table-scroll {
  overflow-x: auto;
  /* 触摸端：单指平移交给原生滚动，双指手势留给 JS 捏合缩放（禁用浏览器页面级捏合） */
  touch-action: pan-x pan-y;
}

/* 捏合缩放层：JS 动态包裹 .table-scroll / .table-headbar 内的表格，
   transform 缩放 + 按比例设置占位尺寸，使外层滚动范围随缩放正确变化 */
.table-zoom {
  transform-origin: 0 0;
}

/* Right-edge fade hints more columns; hidden when scrolled to the end */
.table-frame::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 36px;
  background: linear-gradient(90deg, transparent 0%, var(--color-border) 100%);
  opacity: 0.7;
  pointer-events: none;
  z-index: 5;
  transition: opacity var(--transition-fast);
}

.table-frame.is-at-end::after {
  opacity: 0;
}

/* ---------- 6. Responsive ---------- */
@media (max-width: 991px) {
  /* Single column: image → content */
  .pd-overview-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .pd-media {
    width: 100%;
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
    /* Single column: keep the declared 600:500 image ratio, no letterboxing under contain */
    aspect-ratio: 6 / 5;
  }

  /* Feature cards stack on narrow screens */
  .pd-feature-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  .pd-hero {
    padding-top: 24px;
    padding-bottom: 24px;
  }

  .key-specs {
    grid-template-columns: 1fr;
  }

  /* Single column: only the very first item drops the top border */
  .key-spec:nth-child(-n + 2) {
    border-top: 1px dashed var(--color-border);
  }

  .key-spec:first-child {
    border-top: none;
  }

  /* Related + FAQ columns stack on mobile; divider becomes horizontal */
  .pd-related-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .pd-related-col--faq {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--color-border);
    padding-top: 24px;
  }

  /* Overview action buttons stack full-width on mobile */
  .pd-overview-actions {
    grid-template-columns: 1fr;
  }

  /* Drawing bar: collapsed by default on mobile, toggle always visible */
  .drawing-bar-hint {
    display: none;
  }

  .drawing-toggle {
    display: inline-flex;
  }

  .drawing-body {
    max-height: 0;
    /* overflow-x 非 visible 时 overflow-y 会被浏览器算成 auto，须显式 hidden */
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .tables-sticky.is-expanded .drawing-body {
    max-height: 400px;
  }

  /* 移动端：图纸不整图压缩（看不清），保持可读高度、框内横滑查看 */
  .drawing-placeholder {
    width: auto;
    max-width: none;
    height: 300px;
    object-fit: initial;
  }

  .tables-sticky {
    padding-top: 0;
  }

  .spec-table-block {
    margin-top: 20px;
  }
}
