/**
 * nav.css — 导航全站样式（单文件，hd- 命名空间）
 *
 * ⚠️  改导航前先读: docs/nav-refactor-summary.md（维护手册 + 禁止事项 + 验收流程）
 *
 * 尺寸 token：全部定义在 .hd-header 上，不污染 :root
 * 断点：唯一分界线 max-width:1279px（移动）/ min-width:1280px（桌面）
 */

/* ==========================================================================
   0. Size tokens (on .hd-header, NOT :root)
   ========================================================================== */

.hd-header {
  --hd-nav-link-size: 1rem;        /* 顶级导航链接（1rem ≈ 16px，保留缩放响应） */
  --hd-panel-link-size: 14px;      /* 下拉面板链接 */
  --hd-drawer-link-size: 15px;     /* 抽屉一级链接 */
  --hd-drawer-sub-size: 14px;      /* 抽屉二级链接 */
}

/* ==========================================================================
   1. .hd-header — shell / logo / tools / search / hamburger
   ========================================================================== */

.hd-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100000;
  background-color: var(--nav-bg, #FFFEF9);
  border-bottom: 1px solid var(--nav-border, rgba(27, 58, 95, 0.08));
}

.hd-header__container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 2rem;
  position: relative;
}

.hd-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 5rem;
}

.hd-header__logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--nav-text, #1B3A5F);
  flex-shrink: 0;
}

.hd-header__logo-img {
  max-height: 2.5rem;
  width: auto;
}

.hd-header__tools {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.hd-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  width: 40px;
  height: 40px;
  color: var(--nav-text, #1B3A5F);
  transition: color 0.2s ease, background-color 0.2s ease;
  border-radius: 0.25rem;
}

.hd-icon-btn:hover {
  color: var(--nav-hover, #FF9933);
  background-color: rgba(124, 179, 66, 0.1);
}

/* Search bar */
.hd-search {
  position: fixed;
  top: 80px;
  right: 0;
  width: 0;
  height: 70px;
  background: var(--nav-bg, #FFFEF9);
  border-bottom: 1px solid var(--nav-border, rgba(27, 58, 95, 0.08));
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  z-index: 999;
  overflow: hidden;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
}

.hd-search.active {
  width: 500px;
  max-width: 90vw;
}

.hd-search__container {
  width: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease 0.1s;
}

.hd-search.active .hd-search__container {
  opacity: 1;
}

.hd-search__form {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 0.625rem;
  position: relative;
}

.hd-search__input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid var(--nav-border, rgba(27, 58, 95, 0.08));
  border-radius: 0.5rem;
  font-size: 15px;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.3s ease, background-color 0.3s ease;
  background-color: var(--nav-bg, #f8f8f8);
}

.hd-search__input:focus {
  border-color: var(--nav-hover, #FF9933);
  background-color: #fff;
}

/* Hamburger button */
.hd-header__hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  position: relative;
  width: 40px;
  height: 40px;
}

.hd-hamburger {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 24px;
  height: 18px;
}

.hd-hamburger__line {
  display: block;
  width: 100%;
  height: 2px;
  background-color: var(--nav-text, #1B3A5F);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.hd-header__hamburger.active .hd-hamburger__line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.hd-header__hamburger.active .hd-hamburger__line:nth-child(2) {
  opacity: 0;
}

.hd-header__hamburger.active .hd-hamburger__line:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

/* Language zone */
.hd-header__lang {
  display: none;
}

/* ==========================================================================
   2. .hd-nav — desktop horizontal navigation (>=1280px)
   ========================================================================== */

.hd-header__nav {
  display: none;
  align-items: center;
  flex-grow: 1;
  justify-content: center;
  height: 100%;
}

.hd-header__menu,
.hd-nav__list {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 20px;
}

/* Top-level nav link — replicates pre-refactor rendered values (browser defaults) */
.hd-nav__link {
  text-decoration: none;
  font-size: var(--hd-nav-link-size);
  white-space: nowrap;
  transition: color 0.2s ease;
}

.hd-nav__link:hover {
  color: var(--nav-hover, #FF9933);
}

/* Toggle arrow button */
.hd-nav__toggle {
  flex-shrink: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--nav-text, #1B3A5F);
}

.hd-nav__toggle:hover {
  color: var(--nav-hover, #FF9933);
}

.hd-nav__toggle:focus {
  color: var(--nav-hover, #FF9933);
  outline: none;
}

.hd-nav__toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 12px;
}

.hd-nav__toggle-icon svg {
  display: block;
  width: 16px;
  height: 12px;
}

.hd-nav__toggle-icon path {
  stroke: currentColor;
  stroke-width: 7;
  fill: none;
  stroke-linecap: butt;
  stroke-linejoin: miter;
  transition: transform 0.2s ease;
  transform-origin: 50% 50%;
}

/* Arrow rotation when open */
.hd-nav__item--has-panel.hd-is-open .hd-nav__toggle-icon path {
  transform: rotate(180deg);
}

/* ==========================================================================
   3. .hd-panel — dropdown panel base
   ========================================================================== */

.hd-panel {
  position: fixed;
  top: 81px;                    /* header 80px + 1px border */
  background-color: var(--sub-menu-bg, var(--nav-bg, #FFFEF9));
  border: 1px solid var(--nav-border, rgba(27, 58, 95, 0.08));
  padding: 1.5rem 2.5rem;
  display: none;
  list-style: none;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
  z-index: 100000;
  gap: 2rem;
  overflow-y: auto;
  pointer-events: auto;
}

/* Open state — hd-is-open controls panel visibility */
.hd-nav__item--has-panel.hd-is-open > .hd-panel {
  display: block;
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  height: auto;
  max-height: none;
}

/* Hover does NOT open panels (click-only policy) */
.hd-nav__item--has-panel:not(.hd-is-open):hover > .hd-panel {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Panel inner container */
.hd-panel__inner {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
}

/* Panel column */
.hd-panel__col {
  display: flex;
  flex-direction: column;
  flex: 0 0 220px;
  width: 220px;
  min-width: 220px;
  flex-shrink: 0;
  flex-grow: 0;
}

/* Panel column heading */
.hd-panel__col-heading {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 1.5rem 0;
  color: var(--nav-text, #1B3A5F);
  border-bottom: 2px solid #eeeeee;
  padding-bottom: 0.8rem;
  text-transform: uppercase;
  display: block;
  width: 100%;
  white-space: nowrap;
}

.hd-panel__col:hover .hd-panel__col-heading {
  border-bottom-color: var(--nav-hover, #FF9933);
}

/* Panel link list */
.hd-panel__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.hd-panel__link {
  font-size: var(--hd-panel-link-size);
  color: #666666;
  text-decoration: none;
  transition: all 0.2s ease;
  display: block;
}

.hd-panel__link:hover {
  color: var(--nav-hover, #FF9933);
  padding-left: 5px;
}

/* ==========================================================================
   4. .hd-panel--mega — mega menu (product categories)
   ========================================================================== */

.hd-panel--mega {
  width: 1300px;
  max-width: 95vw;
  left: 50%;
  transform: translateX(-50%);
  height: 500px;
  min-height: 300px;
  max-height: 500px;
}

.hd-panel--mega .hd-panel__inner {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: flex-start !important;
}

/* Cards container in mega menu */
.hd-panel__cards {
  flex: 0 0 calc(200px * 4 + 16px * 3);
  width: calc(200px * 4 + 16px * 3);
  min-width: calc(200px * 4 + 16px * 3);
  max-width: calc(200px * 4 + 16px * 3);
  margin-left: 0;
  margin-top: 0;
  order: 999;
  display: grid;
  grid-template-columns: repeat(4, 200px);
  gap: 16px;
}

/* Individual card */
.hd-panel__card {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: box-shadow 0.3s ease, transform 0.3s ease;
  text-decoration: none;
  height: 255px;
}

.hd-panel__card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  transform: translateY(-2px);
}

.hd-panel__card-img {
  width: 100%;
  height: 170px;
  object-fit: cover;
}

.hd-panel__card-body {
  padding: 10px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.hd-panel__card-badge {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-color, #E91E8C);
  margin-bottom: 6px;
}

.hd-panel__card-subtitle {
  font-size: 15px;
  font-weight: 700;
  color: var(--heading-primary-color, #1B3A5F);
  line-height: 1.35;
}

.hd-panel__card-subtitle {
  font-size: 15px;
  font-weight: 700;
  color: var(--heading-primary-color, #1B3A5F);
  line-height: 1.35;
}

/* ==========================================================================
   5. .hd-panel--single — single-column dropdown (OEM/ODM, etc.)
   ========================================================================== */

.hd-panel--single {
  width: auto;
  max-width: 260px;
  min-width: 200px;
  height: auto;
  max-height: 500px;
  padding: 1.5rem;
  left: auto;          /* JS alignSingleColumnMenus sets left */
}

.hd-panel--single .hd-panel__col {
  padding: 0;
}

.hd-panel--single .hd-panel__link {
  font-size: var(--hd-panel-link-size);
  padding: 0.5rem 0;
  color: #000;
}

.hd-panel--single .hd-panel__link:hover {
  color: var(--nav-hover, #FF9933);
  padding-left: 5px;
}

/* ==========================================================================
   6. .hd-drawer — mobile/iPad sidebar drawer (<1280px)
   ========================================================================== */

.hd-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  background-color: var(--nav-bg, #FFFEF9);
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 1002;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Renderable on mobile */
@media (max-width: 1279px) {
  .hd-drawer {
    display: block;
  }
}

.hd-drawer.hd-is-open {
  transform: translateX(0);
}

.hd-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem;
  border-bottom: 1px solid var(--nav-border, rgba(0, 0, 0, 0.08));
  background-color: var(--nav-bg, #FFFEF9);
  position: sticky;
  top: 0;
  z-index: 10;
}

.hd-drawer__title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.75rem;
  color: var(--nav-text, #1B3A5F);
  text-transform: uppercase;
}

.hd-drawer__content {
  padding: 1.25rem 0;
}

/* Drawer list */
.hd-drawer__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
}

.hd-drawer__item {
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  display: block;
}

/* Top-level drawer link */
.hd-drawer__link {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  color: var(--nav-text, #1B3A5F);
  text-decoration: none;
  font-size: var(--hd-drawer-link-size);
  font-weight: 600;
  text-transform: uppercase;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hd-drawer__link:hover {
  background-color: rgba(124, 179, 66, 0.1);
  color: var(--nav-hover, #FF9933);
  padding-left: 24px;
}

/* Drawer item with children — flex row for link + toggle */
.hd-drawer__item.menu-item-has-children {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
}

.hd-drawer__item.menu-item-has-children > .hd-drawer__link {
  flex: 1;
  padding-right: 4px;
}

/* Drawer toggle */
.hd-drawer__toggle {
  flex-shrink: 0;
  background: transparent;
  border: none;
  padding: 14px 18px;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hd-drawer__toggle .hd-menu-toggle__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 12px;
  color: var(--nav-text, #1a1a1a);
}

.hd-drawer__toggle .hd-menu-toggle__icon svg {
  display: block;
  width: 16px;
  height: 12px;
}

.hd-drawer__toggle .hd-menu-toggle__icon path {
  stroke: currentColor;
  stroke-width: 7;
  fill: none;
  stroke-linecap: butt;
  stroke-linejoin: miter;
  transition: transform 0.2s ease;
  transform-origin: 50% 50%;
}

/* Accordion open arrow */
.hd-drawer__item.hd-is-expanded .hd-menu-toggle__icon path {
  transform: rotate(180deg);
}

/* Drawer submenu */
.hd-drawer__sub {
  display: none;
  flex: 0 0 100%;
  width: 100%;
  background-color: rgba(0, 0, 0, 0.02);
  padding: 6px 0;
  margin: 0;
  list-style: none;
  overflow: hidden;
  max-height: 0;
}

/* Accordion open state */
.hd-drawer__item.hd-is-expanded > .hd-drawer__sub {
  display: block;
  visibility: visible;
  opacity: 1;
  max-height: 2000px;
  height: auto;
  overflow: visible;
  pointer-events: auto;
}

/* Drawer submenu item */
.hd-drawer__subitem {
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.hd-drawer__sublink {
  display: flex;
  align-items: center;
  padding: 12px 20px 12px 44px;
  font-size: var(--hd-drawer-sub-size);
  font-weight: 500;
  text-transform: none;
  line-height: 1.4;
  color: rgba(27, 58, 95, 0.85);
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease, padding-left 0.2s ease;
}

.hd-drawer__sublink:hover {
  background-color: rgba(124, 179, 66, 0.08);
  color: var(--nav-hover, #FF9933);
  padding-left: 48px;
}

/* Overlay backdrop */
.hd-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1001;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

@media (max-width: 1279px) {
  .hd-overlay {
    display: block;
  }
}

/* JS 加了 .active，双写期两个都认 */
.hd-overlay.active,
.hd-overlay.hd-is-active {
  opacity: 1;
  visibility: visible;
}

/* ==========================================================================
   7. Media queries — unified breakpoint 1280px
   ========================================================================== */

/* Desktop: show horizontal nav, hide hamburger/drawer/overlay */
@media (min-width: 1280px) {
  .hd-header {
    display: flex;
    justify-content: center;
  }

  .hd-header__container {
    flex: 1;
    max-width: 1440px;
    margin: 0;
  }

  .hd-header__nav {
    display: flex;
  }

  .hd-header__hamburger {
    display: none;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
  }

  .hd-drawer {
    display: none;
  }

  .hd-overlay {
    display: none;
  }

  .hd-header__lang {
    display: flex;
    align-items: center;
    width: 140px;
    flex-shrink: 0;
  }

  /* Single-column panel padding-top uniformity */
  .hd-panel--single {
    padding-top: 20px;
  }

  .hd-panel--mega {
    padding-top: 20px;
  }
}

/* Mobile: hide desktop dropdowns unconditionally */
@media (max-width: 1279px) {
  .hd-header__nav .hd-panel,
  .hd-header__nav .hd-panel--mega,
  .hd-header__nav .hd-panel--single {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
  }
}

/* ==========================================================================
   8. Responsive — tablet card adjustments
   ========================================================================== */

@media (max-width: 1024px) {
  .hd-panel--mega {
    width: calc(100vw - 20px);
  }

  .hd-panel__cards {
    flex: 0 0 100%;
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    grid-template-columns: 1fr;
  }

  .hd-panel__card {
    height: auto;
  }
}

/* ==========================================================================
   9. Hover-disable reinforcement (desktop)
      All hover-opening blocked; only .hd-is-open via click opens panels
   ========================================================================== */

@media (min-width: 1280px) {
  .hd-nav__item--has-panel:not(.hd-is-open):hover > .hd-panel,
  .hd-nav__item.menu-item-has-children:not(.hd-is-open):hover > .hd-panel {
    display: none !important;     /* 对抗 WordPress/插件注入的 :hover 规则 */
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }
}

