/* ========================================
   YOYAGE Valve Gearbox Page (/valve-gearbox/)
   Purpose: 筛选面板 + 产品网格 + 配件侧栏
   Loaded after components.css
   ======================================== */

/* ---------- 1. Filter Panel ---------- */
.filter-panel {
  padding: 4px 28px;
  box-shadow: var(--shadow-sm);
  /* Hash jump target: clear the fixed header when scrolled into view */
  scroll-margin-top: calc(120px + var(--expo-bar-h));
}

/* Mobile-only summary bar; hidden on desktop */
.filter-mobile-toggle {
  display: none;
}

.filter-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  align-items: start;
  gap: 6px 20px;
  padding: 8px 0;
}

.filter-row + .filter-row {
  border-top: 1px solid var(--color-border);
}

.filter-label {
  font-size: var(--fs-small);
  font-weight: 700;
  color: var(--color-title);
  padding-top: 5px;
}

.filter-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* 筛选 chips（单选） */
.filter-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 14px;
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--color-text);
  background-color: var(--color-tag-bg);
  border: 1px solid transparent; /* reserve space so hover doesn't shift layout */
  border-radius: 999px;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.filter-chip:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
}

.filter-chip.is-active {
  background-color: var(--color-brand);
  border-color: var(--color-brand);
  color: var(--color-white);
}

.filter-chip:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

/* Standard Type 跳转链接 chips（不参与筛选） */
.filter-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 5px 14px;
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--color-brand);
  border: 1.5px solid var(--color-brand);
  border-radius: 999px;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.filter-link:hover {
  background-color: var(--color-brand);
  color: var(--color-white);
}

/* Standard Type 当前分区高亮（/valve-gearbox/part-turn/） */
.filter-link.is-active,
.filter-link.is-active:hover {
  background-color: var(--color-brand);
  border-color: var(--color-brand);
  color: var(--color-white);
}

.filter-link-arrow {
  transition: transform var(--transition-fast);
}

.filter-link:hover .filter-link-arrow {
  transform: translateX(3px);
}

/* 扭矩输入行 */
.filter-options--torque {
  gap: 14px;
}

.torque-field {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.torque-field input {
  width: 200px;
  min-height: 36px;
  padding: 6px 44px 6px 14px;
  font-family: inherit;
  font-size: var(--fs-small);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-button);
  transition: border-color var(--transition-fast);
}

.torque-field input:focus {
  outline: none;
  border-color: var(--color-brand);
}

.torque-unit {
  position: absolute;
  right: 14px;
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--color-text-muted);
  pointer-events: none;
}

.torque-hint {
  font-size: var(--fs-tag);
  color: var(--color-text-muted);
}

/* 状态行 + 全部重置（内联同行） */
.filter-meta {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 0;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
}

.filter-status {
  font-size: var(--fs-small);
  color: var(--color-text-muted);
}

.filter-reset-all {
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--color-brand);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--transition-fast);
}

.filter-reset-all:hover {
  color: var(--color-brand-dark);
}

/* ---------- 2. Display Grid（左 4/5 产品 + 右 1/5 配件） ---------- */
.display-grid {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
  margin-top: 20px; /* 与产品卡片间隙一致 */
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* ---------- 3. Product Card ---------- */
.product-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

.product-card:hover {
  box-shadow: var(--shadow-lg);
}

.product-card.is-hidden {
  display: none;
}

/* Fade-in when a card reappears after filtering (0.3s ease per spec) */
.product-card.is-entering {
  animation: vg-card-in 0.3s ease both;
}

@keyframes vg-card-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.product-media {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background-color: var(--color-bg-alt);
}

.product-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* 材质限制角标（图片右上角，与左上的操作方式角标并存） */
.product-badge.product-badge--material {
  left: auto;
  right: 10px;
  background-color: var(--color-text);
}

.product-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 16px;
}

.product-title {
  font-size: 18px;
  margin-bottom: 12px;
}

.product-title a {
  color: inherit;
}

/* Stretched link：整卡可点，锚文本仍为标题 */
.product-title a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.product-title a:hover,
.product-card:hover .product-title a {
  color: var(--color-brand);
}

.product-specs {
  margin: 0 0 16px;
}

.product-spec {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  font-size: var(--fs-tag);
  line-height: 1.4;
}

.product-spec + .product-spec {
  border-top: 1px dashed var(--color-border);
}

.product-spec dt {
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.product-spec dd {
  margin: 0;
  font-weight: 600;
  color: var(--color-text);
  text-align: right;
}

/* ---------- 4. 筛选空状态 ---------- */
.filter-empty {
  padding: 56px 32px;
  text-align: center;
}

.filter-empty-title {
  font-size: var(--fs-h3);
  font-weight: 700;
  color: var(--color-title);
  margin-bottom: 12px;
}

.filter-empty-text {
  max-width: 480px;
  margin: 0 auto 24px;
  color: var(--color-text-muted);
  line-height: 1.6;
}

.filter-empty-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* ---------- 5. Accessories 侧栏（不随筛选变化） ---------- */
.accessories-aside {
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.aside-title {
  font-size: 18px;
  margin-bottom: 8px;
}

.aside-list {
  display: flex;
  flex-direction: column;
}

.acc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.aside-list .acc-row:last-child {
  border-bottom: none;
}

.acc-row-img {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: var(--radius-tag);
  background-color: var(--color-bg-alt);
}

.acc-row-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.acc-row-title {
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--color-title);
  transition: color var(--transition-fast);
}

.acc-row:hover .acc-row-title {
  color: var(--color-brand);
}

.acc-row-desc {
  font-size: var(--fs-tag);
  color: var(--color-text-muted);
  line-height: 1.45;
}

/* ---------- 6. Page Header（与详情页 pd-hero 同构） ---------- */
.vg-hero {
  background-color: var(--color-brand);
  padding-top: 30px;
  padding-bottom: 38px;
}

.vg-hero .breadcrumb {
  justify-content: center;
  margin-bottom: 14px;
}

.vg-hero .breadcrumb a {
  color: rgba(255, 255, 255, 0.85);
}

.vg-hero .breadcrumb a:hover {
  color: var(--color-white);
}

.vg-hero .breadcrumb-separator {
  color: rgba(255, 255, 255, 0.5);
}

.vg-hero .breadcrumb-current {
  color: var(--color-white);
}

.vg-hero-title {
  font-size: var(--fs-h2);
  color: var(--color-white);
  text-align: center;
  margin-bottom: 10px;
}

.vg-hero-subtitle {
  max-width: 860px;
  margin: 0 auto;
  text-align: center;
  font-size: var(--fs-body);
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.88);
}

/* 产品区标题下方的入门阅读链接 */
.vg-products-note {
  font-size: var(--fs-small);
  line-height: 1.6;
}

.vg-products-note a {
  color: var(--color-brand);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.vg-products-note a:hover {
  color: var(--color-brand-dark);
}

/* ---------- 7. Selection Flow（一行四卡） ---------- */
.vg-flow {
  padding-top: 28px;
  padding-bottom: 28px;
}

/* 折叠面板：折叠时仅一条轻量卡片条 */
.vg-flow-panel {
  overflow: hidden;
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
}

.vg-flow-title {
  font-size: 20px;
}

.vg-flow-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 18px 22px;
  font: inherit;
  color: inherit;
  text-align: left;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.vg-flow-toggle:hover {
  background-color: var(--color-bg-alt);
  color: var(--color-brand);
}

.vg-flow-toggle:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: -2px;
  border-radius: var(--radius-card);
}

.vg-flow-chevron {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--color-tag-bg);
  color: var(--color-brand);
  transition: transform var(--transition-fast), background-color var(--transition-fast), color var(--transition-fast);
}

.vg-flow-toggle:hover .vg-flow-chevron,
.vg-flow.is-open .vg-flow-chevron {
  background-color: var(--color-brand);
  color: var(--color-white);
}

.vg-flow.is-open .vg-flow-chevron {
  transform: rotate(180deg);
}

.vg-flow-body {
  padding: 20px 22px 22px;
  background-color: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
}

.vg-flow-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 16px;
}

.vg-flow-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--color-brand);
}

.vg-flow-more .link-arrow {
  transition: transform var(--transition-fast);
}

.vg-flow-more:hover .link-arrow {
  transform: translateX(3px);
}

.vg-flow-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
}

.vg-flow-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

a.vg-flow-card:hover {
  border-color: var(--color-brand);
  box-shadow: var(--shadow-md);
}

a.vg-flow-card:focus-visible,
.vg-flow-more:focus-visible,
.vg-knowledge-links a:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

.vg-flow-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: var(--color-tag-bg);
  color: var(--color-brand);
  font-size: 13px;
  font-weight: 700;
}

.vg-flow-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-title);
  transition: color var(--transition-fast);
}

.vg-flow-card-text {
  font-size: var(--fs-small);
  line-height: 1.55;
  color: var(--color-text-muted);
}

a.vg-flow-card:hover .vg-flow-card-title {
  color: var(--color-brand);
}

/* ---------- 8. Product Knowledge（2×2 内容卡） ---------- */
.vg-knowledge-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.vg-knowledge-card {
  display: flex;
  flex-direction: column;
  padding: 28px;
}

.vg-knowledge-title {
  margin-bottom: 14px;
  font-size: var(--fs-h3);
  font-weight: 700;
  color: var(--color-title);
}

.vg-knowledge-card p {
  margin-bottom: 12px;
  font-size: var(--fs-small);
  line-height: 1.75;
  color: var(--color-text);
}

.vg-knowledge-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: auto;
  padding-top: 4px;
  font-size: var(--fs-small);
}

/* ---------- 9. FAQ（复用全局手风琴，仅约束宽度） ---------- */
.vg-faq-list {
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

.vg-faq .faq-question:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: -4px;
}

/* ---------- 10. Responsive ---------- */
@media (max-width: 1279px) {
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 991px) {
  .display-grid {
    grid-template-columns: 1fr;
  }

  .accessories-aside {
    order: 2;
  }
}

@media (max-width: 767px) {
  .filter-panel {
    padding: 4px 20px;
    scroll-margin-top: calc(88px + var(--expo-bar-h));
  }

  .filter-mobile-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
    background: transparent;
    font-size: var(--fs-small);
    color: var(--color-title);
    text-align: left;
  }

  .filter-panel.is-collapsed .filter-mobile-toggle {
    border-bottom-color: transparent;
  }

  .filter-panel.is-collapsed .filter-body {
    display: none;
  }

  .filter-mobile-label {
    flex-shrink: 0;
    font-weight: 700;
  }

  .filter-mobile-summary {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--color-text-muted);
  }

  .filter-mobile-count {
    flex-shrink: 0;
    font-weight: 600;
    color: var(--color-brand);
  }

  .filter-mobile-chevron {
    flex-shrink: 0;
    color: var(--color-text-muted);
    transition: transform var(--transition-fast);
  }

  .filter-mobile-toggle[aria-expanded="true"] .filter-mobile-chevron {
    transform: rotate(180deg);
  }

  .filter-mobile-toggle:focus-visible {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
    border-radius: var(--radius-tag);
  }

  .filter-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 8px 0;
  }

  .filter-label {
    padding-top: 0;
  }

  .filter-chip,
  .filter-link {
    min-height: 40px;
  }

  .filter-options--torque {
    flex-direction: column;
    align-items: stretch;
  }

  .torque-field,
  .torque-field input {
    width: 100%;
  }

  .torque-hint {
    align-self: flex-start;
  }

  .display-grid {
    gap: 20px;
    margin-top: 12px; /* 与产品卡片移动端间隙一致 */
  }

  /* 产品卡手机端每行 2 张，内容收紧 */
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .product-body {
    padding: 12px;
  }

  .product-title {
    font-size: 15px;
    margin-bottom: 8px;
  }

  .product-spec {
    padding: 3px 0;
    font-size: 12px;
  }

  .product-specs {
    margin-bottom: 12px;
  }

  .product-badge {
    top: 8px;
    left: 8px;
    padding: 3px 8px;
    font-size: 10px;
  }

  .filter-empty {
    padding: 40px 20px;
  }

  .filter-empty-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (prefers-reduced-motion: reduce) {
  .product-card.is-entering {
    animation: none;
  }
}

/* ---------- 11. Responsive: Page Header / Flow / Knowledge ---------- */
@media (max-width: 991px) {
  .vg-flow-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  .vg-hero {
    padding-top: 24px;
    padding-bottom: 30px;
  }

  .vg-flow {
    padding-top: 16px;
    padding-bottom: 16px;
  }

  .vg-flow-title {
    font-size: 18px;
  }

  .vg-flow-toggle {
    padding: 16px 18px;
    gap: 12px;
  }

  .vg-flow-chevron {
    width: 28px;
    height: 28px;
  }

  .vg-flow-body {
    padding: 16px 16px 18px;
  }

  .vg-flow-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .vg-flow-card {
    padding: 16px;
  }

  .vg-knowledge-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .vg-knowledge-card {
    padding: 18px;
  }
}
