/**
 * @file navbar.css
 * @responsibility 負責星簇全域導覽列之桌機端橫向佈局與行動端漢堡選單遮罩防禦
 */

/* ==========================================
 * 全域導覽列本體 (桌機端基準樣式)
 * ========================================== */
.studio-navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 70px; /* 固定高度，防止被內容撐開變形 */
  background: rgba(11, 7, 28, 0.45); /* 透明星空底色 */
  backdrop-filter: blur(12px); /* 毛玻璃特效 */
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(164, 140, 255, 0.08);
  z-index: 1000;
  box-sizing: border-box;
}

/* 限制內部最大寬度並居中 */
.navbar-container {
  max-width: 1200px;
  height: 100%;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between; /* 確保 Logo 在左、選單在右 */
  align-items: center;
}

/* Logo 漸層字體與相容性修復 */
.logo {
  font-size: 1.5rem;
  font-weight: 700;
  text-decoration: none;
  background: linear-gradient(45deg, var(--text-stellar-white, #ffffff), var(--accent-star-glow, #a48cff));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 1px;
}

/* 桌機端導覽頁籤容器 */
.nav-menu {
  display: flex;
  align-items: center;
  gap: 2rem;
}

/* 頁籤超連結樣式 (防禦瀏覽器藍色預設字體) */
.nav-link {
  color: var(--text-stellar-white, #ffffff);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: color 0.3s ease;
}

.nav-link:hover {
  color: var(--accent-star-glow, #a48cff);
}

/* 漢堡按鈕本體 (桌機端絕對隱藏) */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 24px;
  height: 18px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 1002;
}

.menu-toggle .bar {
  width: 100%;
  height: 2px;
  background-color: #ffffff; /* 確保手機端看得到白線 */
  border-radius: 2px;
  transition: all 0.3s ease-in-out;
}

/* ==========================================
 * 行動端響應式斷點防禦 (Mobile RWD Matrix < 768px)
 * ========================================== */
@media (max-width: 768px) {
  .navbar-container {
    padding: 0 1.5rem; /* 縮減手機端邊距 */
  }

  /* 解鎖漢堡按鈕顯示 */
  .menu-toggle {
    display: flex;
  }

  /* 強制將原本橫向的 nav-menu 改造為滿版滑入遮罩 */
  .nav-menu {
    position: fixed;
    top: 0;
    right: -100%; /* 預設完全退回外太空 (螢幕右側外) */
    width: 260px;  /* 寬度固定為 260px，精緻的側邊欄質感 */
    height: 100vh;
    background: rgba(11, 7, 28, 0.98) !important; /* 加上 !important 強制覆蓋桌機透明度 */
    backdrop-filter: blur(20px);
    border-left: 1px solid rgba(164, 140, 255, 0.15);
    
    flex-direction: column; /* 轉為縱向排列 */
    justify-content: flex-start;
    align-items: flex-start;
    padding: 6rem 2rem 2rem 2rem; /* 頂部留空留給 Logo 與關閉按鈕空間 */
    gap: 2rem;
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1001;
    box-sizing: border-box;
  }

  /* 當激活狀態機觸發時，滑入螢幕 */
  .nav-menu.active {
    right: 0;
  }

  /* 行動端頁籤樣式微調 */
  .nav-link {
    font-size: 1.1rem;
    width: 100%;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(164, 140, 255, 0.05); /* 新增下劃線增加層次感 */
    color: #ffffff !important; /* 阻斷預設藍色 */
  }

  /* 漢堡按鈕轉化成「X」動畫控制 */
  .menu-toggle.active .bar:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
    background-color: var(--accent-star-glow, #a48cff);
  }
  
  .menu-toggle.active .bar:nth-child(2) {
    opacity: 0;
  }
  
  .menu-toggle.active .bar:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
    background-color: var(--accent-star-glow, #a48cff);
  }
}

/* ==========================================================================
   多國語言切換按鈕全域樣式 (Language Switch Button Matrix)
   ========================================================================== */

.lang-btn {
  background: rgba(164, 140, 255, 0.05); /* 星簇主題紫極淡微光底色 */
  color: var(--text-stellar-white, #ffffff);
  border: 1px solid rgba(164, 140, 255, 0.2); /* 霧面紫半透明邊框 */
  border-radius: 6px;
  
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-sizing: border-box;
  
  /* ✦ 桌機端關鍵定錨 ✦ */
  /* 使用 margin-left: auto 會強行吃掉左側所有剩餘空間，將自己與右側的頁籤一起推至最右邊 */
  margin-left: auto; 
  margin-right: 2rem; /* 與右側導覽頁籤保持 2rem 的黃金社交距離 */
  
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1002; /* 確保高於畫布，防止點擊穿透死鎖 */
}

/* 按鈕懸停狀態機 (Hover Resonance) */
.lang-btn:hover {
  color: #ffffff;
  background: rgba(164, 140, 255, 0.15);
  border-color: rgba(164, 140, 255, 0.6);
  box-shadow: 0 0 12px rgba(164, 140, 255, 0.3); /* 霓虹共振發光 */
  transform: translateY(-1px);
}

.lang-btn:active {
  transform: translateY(1px);
}

/* ==========================================================================
   行動端多國語言位置防禦 (Mobile Responsive Override < 768px)
   ========================================================================== */
@media (max-width: 768px) {
  .lang-btn {
    /* ✦ 手機端關鍵重置 ✦ */
    /* 當進入手機模式時，右側頁籤變為 fixed 側邊欄，此時我們必須改變外層的推擠關係 */
    margin-left: auto;  /* 繼續保持靠右 */
    margin-right: 1.5rem; /* 留出空間給最右邊的漢堡按鈕，防止重疊死鎖 */
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
    
    /* 防禦控制：確保在 HTML 順序不變的前提下，視覺上依然能完美卡在漢堡選單左側 */
    display: inline-block;
  }
  
  /* 確保手機端漢堡鍵永遠待在最右側文件流 */
  .menu-toggle {
    margin-left: 0;
  }
}