/* 50-components.mnav.css */
/* ========== Mobile 基礎（≤991px） ========== */
/* 抽屜本體 */
.mnav {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--mnav-top, 56px);
  max-height: calc(100dvh - var(--mnav-top, 56px));
  overflow: auto;
  background: #fff;
  border-top: 1px solid #eee;
  transform: translateY(-8px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
  z-index: 1000;
}
.mnav.is-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.mnav[hidden] {
  display: none !important;
}

/* 抽屜遮罩 */
.mnav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: saturate(120%) blur(2px);
  z-index: 999;
}
.mnav-backdrop[hidden] {
  display: none !important;
}

/* 階層列表與項目 */
.mnav-l1,
.mnav-l2,
.mnav-l3 {
  list-style: none;
  margin: 0;
  padding: 0;
}
.mnav-l1 > li {
  border-bottom: 1px solid #f2f2f2;
}

.mnav-link {
  display: block;
  padding: 14px 16px;
  text-decoration: none;
  color: #222;
  font-weight: 600;
}
.mnav-head {
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  background: #fff;
  border: 0;
  color: #222;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
/* 手機：箭頭 */
.mnav-head::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid #555;
  border-bottom: 2px solid #555;
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
}
.mnav-head[aria-expanded="true"]::after {
  transform: rotate(45deg);
}

/* 手機：次層容器與縮排 */
.mnav-l2,
.mnav-l3 {
  background: #fafafa;
}
.mnav-l2[hidden],
.mnav-l3[hidden] {
  display: none !important;
}
.mnav-l2 > li > .mnav-sublink,
.mnav-l2 > li > .mnav-head {
  padding-left: 28px;
}
.mnav-l3 > li > .mnav-sublink,
.mnav-l3 > li > .mnav-head {
  padding-left: 44px;
}

.mnav-sublink {
  display: block;
  padding: 12px 16px;
  text-decoration: none;
  color: #333;
  font-weight: 500;
}
.mnav-sublink:hover {
  background: #f3f3f3;
}

/* 抽屜 topbar（標題 + X） */
.mnav-topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #eee;
  z-index: 1;
}
.mnav-title {
  font-size: 16px;
  font-weight: 700;
  color: #222;
}
.mnav-close {
  border: 0;
  background: transparent;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
}
.mnav-close svg {
  display: block;
}

/* 目前頁（可選） */
.mnav a.is-active {
  color: #2c295a;
  font-weight: 700;
}

/* ========== Desktop 共用（≥992px） ========== */
@media (min-width: 992px) {
  /* 隱藏手機元件 */
  .mnav-toggle,
  .mnav-topbar {
    display: none !important;
  }

  /* 導覽常駐：不再是抽屜；允許下拉溢出 */
  .mnav {
    position: relative;
    top: auto;
    max-height: none;
    transform: none;
    opacity: 1;
    pointer-events: auto;
    border-top: 0;
    box-shadow: none;
    overflow: visible;
  }

  /* 第一層橫排置中 */
  .mnav-l1 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
    padding: 12px 16px;
    background: #fff;
  }
  .mnav-l1 > li {
    position: relative;
    border: 0;
  }

  /* 大項樣式（連結/按鈕統一） */
  .mnav-link,
  .mnav-head {
    padding: 8px 8px;
    background: transparent;
    border: 0;
    color: #222;
    font-weight: 600;
    cursor: pointer;
  }
  /* 桌機：隱藏箭頭 */
  .mnav-head::after {
    display: none;
  }

  /* 下拉（非 mega 的預設樣式） */
  .mnav-l2 {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    min-width: 260px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 8px 0;
    display: none;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
    z-index: 3100;
  }
  .mnav-l2 > li > .mnav-sublink,
  .mnav-l2 > li > .mnav-head {
    padding: 10px 14px;
    background: #fff;
    color: #333;
    font-weight: 500;
  }
  .mnav-l2 > li > .mnav-sublink:hover {
    background: #f7f7f7;
  }

  /* 第三層：往右展開 */
  .mnav-l3 {
    position: absolute;
    top: 0;
    left: 100%;
    min-width: 240px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 10px;
    padding: 8px 0;
    display: none;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
    z-index: 3100;
  }

  /* 觸發顯示 */
  .mnav-l1 > li.has-sub:hover > .mnav-l2,
  .mnav-l1 > li.has-sub:focus-within > .mnav-l2 {
    display: block !important;
  }
  .mnav-l2 > li.has-sub:hover > .mnav-l3,
  .mnav-l2 > li.has-sub:focus-within > .mnav-l3 {
    display: block !important;
  }

  /* 桌機不需要灰底 */
  .mnav-l2,
  .mnav-l3 {
    background: #fff;
  }
}
