/* ============================================
   ProductNavMenu - 多層級玻璃透明下拉選單
   ============================================ */

.pnav {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 100;
  font-family: 'Manrope', 'Noto Sans TC', sans-serif;
}

/* --- 觸發器 (Logo 按鈕) --- */
.pnav__trigger {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0.5rem 1rem 0.5rem 1.1rem;
  border-radius: 50px;
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: default;
  transition: background 0.2s ease, border-color 0.2s ease;
  user-select: none;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.pnav:hover .pnav__trigger,
.pnav.pnav--open .pnav__trigger {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.25);
}

.pnav__zh {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.85);
}

.pnav__divider {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: #CF2D52;
  border-radius: 1px;
  margin: 0 0.5rem;
  vertical-align: middle;
}

.pnav__en {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.5);
}

.pnav__chevron {
  margin-left: 0.4rem;
  color: rgba(255, 255, 255, 0.4);
  transition: transform 0.2s ease;
}

.pnav:hover .pnav__chevron,
.pnav.pnav--open .pnav__chevron {
  transform: rotate(180deg);
}

/* --- 下拉面板（通用） --- */
.pnav__dropdown {
  position: absolute;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  /* 關閉時有延遲，讓游標有時間移到子選單 */
  transition: opacity 0.18s ease 0.12s, visibility 0.18s ease 0.12s;

  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  background: rgba(18, 18, 18, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0.4rem 0;
  min-width: 200px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
}

/* L1：觸發器下方 */
.pnav__l1 {
  top: calc(100% + 0.5rem);
  left: 0;
}

/* Hover bridge：觸發器與 L1 之間的透明橋接區域 */
.pnav__l1::before {
  content: '';
  position: absolute;
  top: -0.7rem;
  left: 0;
  width: 100%;
  height: 0.7rem;
}

/* L2/L3：父項右側 */
.pnav__l2,
.pnav__l3 {
  top: -0.4rem;
  left: calc(100% + 0.4rem);
}

/* Hover bridge：防止游標從父項到子選單時因 gap 而關閉 */
.pnav__l2::before,
.pnav__l3::before {
  content: '';
  position: absolute;
  top: 0;
  left: -1rem;
  width: 1rem;
  height: 100%;
}

/* --- 顯示邏輯 --- */
.pnav:hover > .pnav__l1,
.pnav.pnav--open > .pnav__l1 {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  /* 開啟時無延遲 */
  transition-delay: 0s;
}

.pnav__item--has-children:hover > .pnav__dropdown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

/* --- 選單項目 --- */
.pnav__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.55rem 1rem;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.85rem;
  text-decoration: none;
  cursor: default;
  transition: background 0.12s ease, color 0.12s ease;
  position: relative;
  white-space: nowrap;
}

.pnav__item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.95);
}

/* 可點擊的連結 */
a.pnav__item {
  cursor: pointer;
}

a.pnav__item:hover {
  background: rgba(175, 0, 54, 0.15);
  color: #fff;
}

/* 群組標題連結（產品總覽 — 可點擊但也有子選單） */
.pnav__group-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  flex: 1;
}

.pnav__group-link:hover {
  color: rgba(255, 255, 255, 0.95);
}

/* 當前頁面高亮 */
.pnav__item--active {
  color: #CF2D52 !important;
}

.pnav__item--active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: #CF2D52;
  border-radius: 0 2px 2px 0;
}

/* 有子選單的項目 — 箭頭 */
.pnav__arrow {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  color: rgba(255, 255, 255, 0.3);
  transition: color 0.12s ease;
}

.pnav__item--has-children:hover > .pnav__arrow {
  color: rgba(255, 255, 255, 0.6);
}

/* 鎖定的項目（內部專區） */
.pnav__item--locked {
  color: rgba(255, 255, 255, 0.4);
}

.pnav__item--locked:hover {
  color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.04);
}

.pnav__lock-icon {
  width: 12px;
  height: 12px;
  margin-right: 0.4rem;
  opacity: 0.5;
}

/* 分隔線 */
.pnav__separator {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 0.3rem 0.75rem;
}

/* L2 群組標題樣式（hover 時的父層高亮） */
.pnav__item--has-children.pnav__item--parent-active {
  background: rgba(255, 255, 255, 0.05);
}

/* --- 手機版 (≤768px) --- */
@media (max-width: 768px) {
  .pnav {
    top: 0.75rem;
    left: 0.75rem;
  }

  .pnav__trigger {
    padding: 0.4rem 0.7rem 0.4rem 0.9rem;
  }

  .pnav__zh {
    font-size: 0.8rem;
  }

  .pnav__en {
    display: none;
  }

  .pnav__divider {
    display: none;
  }

  /* L1 改為全螢幕 overlay */
  .pnav__l1 {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 0;
    padding: 4.5rem 1rem 2rem;
    overflow-y: auto;
    min-width: unset;
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
  }

  /* 取消 hover 顯示，改為 JS toggle */
  .pnav:hover > .pnav__l1 {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  .pnav.pnav--open > .pnav__l1 {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  /* L2/L3 改為 inline accordion */
  .pnav__l2,
  .pnav__l3 {
    position: static;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    display: none;
    padding-left: 1rem;
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    min-width: unset;
    border-radius: 0;
  }

  .pnav__l2::before,
  .pnav__l3::before {
    display: none;
  }

  /* Accordion 展開 */
  .pnav__item--expanded > .pnav__dropdown {
    display: block;
  }

  .pnav__item--has-children:hover > .pnav__dropdown {
    display: none;
  }

  .pnav__item--expanded:hover > .pnav__dropdown {
    display: block;
  }

  .pnav__item {
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
  }

  /* 行動版箭頭旋轉 */
  .pnav__item--expanded > .pnav__arrow {
    transform: rotate(90deg);
  }

  /* 行動版關閉按鈕 */
  .pnav__mobile-close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 101;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }

  .pnav.pnav--open .pnav__mobile-close {
    opacity: 1;
    pointer-events: auto;
  }
}

/* 桌面版隱藏手機按鈕 */
@media (min-width: 769px) {
  .pnav__mobile-close {
    display: none;
  }
}
