/* =================================
    CSS 變數定義 (根據 Linear 設計系統)
================================= */
:root {
  /* 顏色系統 */
  --white: #ffffff;
  --black: #000000;
  --bg-primary: #0d0e10;
  --menu-text-primary: #ffffff;
  --menu-text-secondary: #a1a1aa;
  --menu-text-tertiary: #71717a;
  --menu-text-hover: #ffffff;

  /* Header 相關變數 */
  --header-height: 64px;
  --header-bg: rgba(13, 14, 16, 0.8);
  --header-bg-mobile: rgba(13, 14, 16, 0.95);
  --header-border: rgba(255, 255, 255, 0.1);
  --header-blur: 20px;
  --navbar-height: 64px;

  /* 層級管理 */
  --layer-header: 1000;
  --layer-dialog-mobile: 1000;
  --dvh-mobile: 1vh;

  /* 頁面佈局 */
  --page-max-width: 1200px;
  --page-padding-left: 24px;
  --page-padding-right: 24px;

  /* 字體系統 */
  --font-family-primary: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-size-body: 14px;
  --line-height-relaxed: 1.6;

  /* 文字樣式 */
  --text-small-size-mobile: 14px;
  --text-small-line-height-mobile: 1.4;
  --text-small-letter-spacing-mobile: -0.01em;
  --title-size-mobile: 16px;
  --title-line-height-mobile: 1.5;
  --title-letter-spacing-mobile: -0.02em;

  /* 圓角系統 */
  --radius-4: 4px;
  --radius-6: 6px;
  --radius-8: 8px;
  --radius-12: 12px;

  /* 動畫系統 */
  --speed-quickTransition: 0.16s;
  --ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);

  /* 陰影系統 */
  --shadow-stack-low: 0 1px 3px rgba(0, 0, 0, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.24);

  /* 按鈕系統 */
  --button-height: 32px;
  --button-icon-size: 16px;
  --button-font-size: 13px;
  --button-corner-radius: var(--radius-8);
  --button-padding: 0 12px;
  --button-gap: 8px;

  /* 游標系統 */
  --cursor-pointer: pointer;

  /* 滾動條相關 */
  --removed-body-scroll-bar-size: 0px;
}

/* =================================
           全域重置樣式
           ================================= */
/* 以下三個勿刪，在個別網頁中測試navbar時可以使用 */
/* * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        html {
            scroll-behavior: smooth;
            font-size: 16px;
        }

        body {
            font-family: var(--font-family-primary);
            line-height: var(--line-height-relaxed);
            color: var(--menu-text-primary);
            font-size: var(--font-size-body);
            font-weight: var(--font-weight-normal);
            overflow-x: hidden;
            background: var(--bg-primary);
            background-attachment: fixed;
            background-position: center;
            background-size: cover;
            padding-top: var(--navbar-height);
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            text-rendering: optimizeLegibility;
            color: var(--white);
            min-height: 100vh;
        } */

/* =================================
           主要頭部樣式
           ================================= */
.main-header {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  isolation: isolate;
  position: fixed;
  top: 0;
  inset-inline: 0;
  margin-inline: auto;
  z-index: var(--layer-header);
  transform: translateX(
    calc(-1 * var(--removed-body-scroll-bar-size, 0px) / 2)
  );
  -webkit-backdrop-filter: blur(var(--header-blur));
  backdrop-filter: blur(var(--header-blur));
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
}

.main-header:before {
  content: "";
  position: absolute;
  pointer-events: none;
  inset: 0;
  background: linear-gradient(180deg, var(--bg-primary) 0, transparent 100%);
}

/* =================================
           導航容器樣式
           ================================= */
.nav-container {
  height: 100%;
  display: flex;
  align-items: center;
}

@media (max-width: 768px) {
  .nav-container {
    flex-direction: column;
  }
}

.nav-wrapper {
  position: relative;
  height: var(--header-height);
  width: 100%;
  max-width: var(--page-max-width);
  padding-left: var(--page-padding-left);
  padding-right: var(--page-padding-right);
  margin-inline: auto;
  display: flex;
  align-items: center;
}

.nav-wrapper > div {
  width: 100%;
}

/* =================================
           導航列表樣式
           ================================= */
.nav-list {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--header-height);
  margin-bottom: 0px;
}

@media (max-width: 768px) {
  .nav-list {
    justify-content: flex-start;
    gap: 16px;
  }
}

/* =================================
           導航項目樣式
           ================================= */
.nav-item {
  list-style: none;
  white-space: nowrap;
  margin: 0;
}

.logo-item {
  flex: 1 1;
  color: var(--menu-text-primary);
  display: flex;
  justify-content: flex-start;
}

.logo-link {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: 100%;
  border-radius: 6px;
  height: 32px;
  padding: 0 8px;
  margin-left: -8px;
}

/* =================================
           通用連結樣式
           ================================= */
.nav-link {
  text-decoration: none;
  cursor: pointer;
}

.nav-anchor {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  height: 32px;
  font-size: 13px;
  font-weight: var(--font-weight-medium);
  color: var(--menu-text-tertiary);
  border-radius: var(--radius-8);
  background: transparent;
  transition: var(--speed-quickTransition) var(--ease-out-quad);
  transition-property: color, background;
  --anchor-glass-bg: hsla(0, 0%, 100%, 0.08);
}

/* =================================
           按鈕重置樣式
           ================================= */
.btn-reset {
  color: #e6e6e6;
  cursor: var(--cursor-pointer);
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.dropdown-trigger {
  position: relative;
  isolation: isolate;
}

/* =================================
           按鈕區域樣式
           ================================= */
.button-group {
  flex: 1 1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.button-item {
  display: flex;
  align-items: center;
  justify-content: center;
}

.button-item a,
.button-item span {
  width: 100%;
}

/* =================================
           主要按鈕樣式
           ================================= */
.btn-primary {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  max-width: 100%;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  text-shadow: none;
}

.btn-style {
  font-weight: var(--font-weight-medium);
  font-size: var(--button-font-size);
  line-height: var(--button-height);
  height: var(--button-height);
  gap: var(--button-gap);
  padding: var(--button-padding);
  border-radius: var(--button-corner-radius);
  transition: 0.16s var(--ease-out-quad);
  transition-property: border, background-color, color, box-shadow, opacity,
    filter, transform;
}

.btn-small {
  --button-height: 32px;
  --button-icon-size: 16px;
  --button-font-size: 13px;
  --button-corner-radius: var(--radius-8);
  --button-padding: 0 12px;
  --button-gap: 8px;
  --kbd-offset: -5px;
  --kbd-size: 18px;
}

.btn-invert {
  background: #e6e6e6;
  border: 1px solid #e6e6e6;
  color: var(--bg-primary);
  box-shadow: var(--shadow-stack-low);
}

/* =================================
            手機選單樣式
        ================================= */
.mobile-menu {
  display: none;
}

.mobile-menu.mobile-menu {
  margin-left: 8px;
}

@media (max-width: 768px) {
  .mobile-menu {
    display: block;
  }
}

/* =================================
           響應式隱藏類別
           ================================= */
@media (max-width: 640px) {
  .hide-on-mobile,
  [data-hide="mobile"] {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .hide-on-tablet,
  [data-hide="tablet"] {
    display: none !important;
  }
}

@media (max-width: 1024px) {
  .hide-on-laptop,
  [data-hide="laptop"] {
    display: none !important;
  }
}

@media not (any-hover: hover) {
  .show-on-hover,
  [data-show="hover"] {
    display: none !important;
  }
}

/* =================================
           登入狀態控制
           ================================= */
html.logged-in [data-hide="logged-in"],
html:not(.js) button[data-rmiz-btn-open],
html:not(.logged-in) [data-show="logged-in"] {
  display: none;
}

/* 以下為手機板選單樣式設定 */
/* 動畫設定 */
@keyframes mobile-menu-fade-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 減少動畫偏好設定 */
@media (prefers-reduced-motion: no-preference) {
  .mobile-menu-dialog[data-state="open"] {
    animation: mobile-menu-fade-in 0.18s ease both;
  }
}

/* 手機版顯示 */
@media (max-width: 768px) {
  .mobile-menu-dialog {
    display: flex;
    flex-direction: column;
  }
}

/* 主要選單容器 */
.mobile-menu-dialog {
  outline: none;
  display: none;
  flex-grow: 1;
  overflow-y: auto;
  position: fixed;
  top: calc(var(--header-height) + 1px);
  inset-inline: 0;
  height: calc(100 * var(--dvh-mobile) - 1px);
  padding-inline: 24px;
  padding-block: 32px;
  background: var(--header-bg-mobile);
  -webkit-backdrop-filter: blur(var(--header-blur));
  backdrop-filter: blur(var(--header-blur));
  z-index: var(--layer-dialog-mobile);
}

/* 視覺隱藏元素 */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* 選單區塊標題 */
.menu-section-title {
  font-size: var(--text-small-size-mobile);
  line-height: var(--text-small-line-height-mobile);
  letter-spacing: var(--text-small-letter-spacing-mobile);
  color: var(--menu-text-tertiary);
  font-weight: var(--font-weight-medium);
  display: block;
  margin-bottom: 20px;
}

/* 選單列表 */
.menu-list {
  list-style-type: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
}

.menu-list li {
  margin: 0;
}

/* 重置列表樣式 */
.reset-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* 選單連結 */
.menu-link {
  text-decoration: none;
  cursor: pointer;
  display: block;
  padding: 8px 0;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.menu-link:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.menu-link:focus {
  outline: 2px solid var(--menu-text-primary);
  outline-offset: 2px;
}

/* 選單項目文字 */
.menu-item-text {
  font-size: var(--title-size-mobile);
  line-height: var(--title-line-height-mobile);
  letter-spacing: var(--title-letter-spacing-mobile);
  font-weight: var(--font-weight-medium);
  color: var(--menu-text-primary);
  transition: color 0.2s ease;
}

.menu-link:hover .menu-item-text {
  color: var(--menu-text-hover);
}

/* 間距元素 */
.menu-spacer {
  display: block;
  width: 1px;
  height: 1px;
  min-width: 1px;
  min-height: 1px;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  margin-top: calc(var(--height, 0px) - 1px);
  margin-left: calc(var(--width, 0px) - 1px);
}

/* 選單區塊容器 */
.menu-section {
  margin-bottom: 32px;
}

.menu-section:last-child {
  margin-bottom: 0;
}

/* 觸控優化 */
/* 當裝置「無法進行 hover 互動」時套用的樣式 */
@media (hover: none) {
  .menu-link {
    padding: 12px 0;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* 高對比模式支援 */
@media (prefers-contrast: high) {
  .menu-section-title {
    color: var(--menu-text-primary);
  }

  .menu-link {
    border: 1px solid transparent;
  }

  .menu-link:focus {
    border-color: var(--menu-text-primary);
  }
}
