/* ========================================
   🎨 全面優化的視覺風格 CSS
   採用 Glassmorphism + 現代化設計
   ======================================== */

* {
  box-sizing: border-box;
  user-select: none;
}

html,
body {
  margin: 0;
  height: 100%;
  color: #fff;
  background: #000000;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, Noto Sans TC;
  overflow: hidden;
}

.page-container {
  position: relative;
  width: 100vw;
  height: 100vh;
}

/* ========================================
   📍 側邊欄區域
   ======================================== */
.sidebar {
  position: fixed;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
}

.sidebar .stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
  width: 420px;
  margin-left: 25%;
}

.nav-section {
  width: 100%;
}

.nav-section .nav-btn {
  display: inline-flex;
  touch-action: manipulation;
}

.nav-section .panel,
.nav-section.open .nav-btn {
  display: none;
}

.nav-section.open .panel {
  display: flex;
}

/* ========================================
   🔘 主要按鈕設計 - Glassmorphism 風格
   ======================================== */
.nav-btn {
  position: relative;
  background: linear-gradient(
    135deg,
    rgba(53, 53, 53, 0.8) 0%,
    rgba(30, 30, 35, 0.9) 100%
  );
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #b8b8c0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50px;
  padding: 14px 32px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

/* 按鈕內部光澤效果 */
.nav-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 100%
  );
  transition: left 0.6s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.nav-btn:hover::before {
  left: 100%;
}

.nav-btn:hover {
  color: #ffffff;
  background: linear-gradient(
    135deg,
    rgba(55, 58, 70, 0.9) 0%,
    rgba(40, 42, 54, 0.95) 100%
  );
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateX(6px) scale(1.02);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 0 20px rgba(255, 255, 255, 0.05),
    0 0 0 1px rgba(255, 255, 255, 0.1);
}

.nav-btn:active {
  transform: translateX(6px) scale(0.98);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3), inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.nav-btn.active {
  background: linear-gradient(
    135deg,
    rgba(50, 52, 64, 0.95) 0%,
    rgba(35, 37, 45, 1) 100%
  );
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4),
    inset 0 0 20px rgba(255, 255, 255, 0.03),
    0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* ========================================
   🎯 顏色圓點設計
   ======================================== */
.dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-right: 15px;
  display: inline-block;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-btn:hover .dot {
  transform: scale(1.1) rotate(10deg);
}

/* ========================================
   📋 面板設計 - 優化的 Glassmorphism
   ======================================== */
.color-panel,
.text-panel {
  position: relative;
  background: rgba(35, 35, 40, 0.5);
  backdrop-filter: blur(5px);
  border-radius: 24px;
  padding: 28px 32px;
  color: #fff;
  font-size: 18px;
  line-height: 1.6;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  flex-direction: column;
  gap: 16px;
  animation: panelSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  overflow: hidden;
}

/* 面板內部光暈效果 */
.color-panel::before,
.text-panel::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.05) 0%,
    transparent 70%
  );
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.color-panel:hover::before,
.text-panel:hover::before {
  opacity: 1;
}

.color-panel p,
.text-panel p {
  margin: 0;
}

/* ========================================
   📝 面板標題和描述
   ======================================== */
.color-title,
.panel-title {
  font-weight: 800;
  color: #ffffff;
  font-size: 20px;
  margin-bottom: 12px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  letter-spacing: 0.3px;
}

.color-desc,
.panel-desc {
  font-weight: 400;
  font-size: 17px;
  color: #d4d4d8;
  line-height: 1.8;
}

.color-desc span {
  color: #fff;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

#currentColorDesc {
  font-weight: 300;
  opacity: 0.95;
}

/* ========================================
   ❌ 關閉按鈕設計
   ======================================== */
.panel-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.panel-close:hover {
  transform: scale(1.1) rotate(90deg);
}

.panel-close:active {
  transform: scale(1) rotate(90deg);
}

.panel-close svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* ========================================
   🎨 顏色選擇器區域
   ======================================== */
.palette-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
}

.chip {
  padding: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-indent: -9999px;
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3),
    inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

/* 各種顏色的色片 */
.chip[title="黑色"] {
  background: #070707;
}
.chip[title="銀色"] {
  background: silver;
}
.chip[title="金色"] {
  background: #8d6c44;
}
.chip[title="深藍色"] {
  background: #0c1625;
}
.chip[title="橘色"] {
  background: #81240d;
}

/* 色片 hover 效果 */
.chip:hover {
  transform: scale(1.05) translateY(-2.5px);
  border-color: rgba(255, 255, 255, 0.2);
}

/* 活動色片效果 */
.chip.active {
  border-color: #ffffff;
  transform: scale(1.05);
}

/* 色片按壓效果 */
.chip:active {
  transform: scale(1.05);
}

/* 色片脈動動畫 */
.chip.active::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  animation: chipPulse 2s ease-in-out infinite;
}

@keyframes chipPulse {
  0%,
  100% {
    transform: scale(0.85);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.1);
    opacity: 0;
  }
}

/* ========================================
   ✨ 動畫效果
   ======================================== */
@keyframes panelSlideIn {
  0% {
    opacity: 0;
    transform: translateY(-25px) scale(0.8);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fadeIn {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

/* ========================================
   📺 查看器和容器
   ======================================== */
.viewer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#three-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  transition: opacity 0.5s ease;
}

#three-container canvas {
  display: block;
  image-rendering: auto;
}

/* ========================================
   ⏳ 載入畫面
   ======================================== */
#loading-screen {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 5;
}

.spinner {
  width: 70px;
  height: 70px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 24px;
}

.loading-text {
  font-size: 1.1rem;
  color: #aaa;
  font-weight: 300;
  letter-spacing: 1px;
  animation: loadingPulse 2s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes loadingPulse {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

/* ========================================
   🎬 影片和圖片容器
   ======================================== */
#video-container,
#image-container {
  position: absolute;
  width: 100%;
  height: 100%;
  background: #000;
  transition: opacity 0.5s ease;
  z-index: 1;
}

#feature-video,
#feature-image {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  height: 100%;
}

.scroll-controls {
  position: absolute;
  left: 5%;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 30px;
  z-index: 11;
  opacity: 0; /* 初始隱藏 */
  transition: opacity 0.5s ease; /* 淡入淡出時間 0.5秒，可調整 */
  pointer-events: none; /* 隱藏時不可點擊 */
}

/* ⭐ 顯示狀態 */
.scroll-controls.visible {
  opacity: 1;
  pointer-events: auto; /* 顯示時可以點擊 */
}

/* 滾動按鈕樣式 */
.scroll-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(30, 30, 32, 0.9);
  backdrop-filter: blur(10px);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.scroll-btn:hover {
  background: rgba(73, 73, 73, 0.95);
  transform: scale(1.1) translateY(-2.5px);
}

.scroll-btn:active {
  transform: scale(0.95);
}

.scroll-btn svg {
  width: 24px;
  height: 24px;
  display: block;
}
/* 控制箭頭粗細 */
.scroll-btn svg polyline {
  stroke-width: 2;
}
/* 當按鈕無法再滾動時禁用 */
.scroll-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: scale(1);
}

.scroll-btn:disabled:hover {
  background: rgba(30, 30, 32, 1);
  transform: scale(1.2);
}
/* ===== QR Code Modal 樣式 ===== */
.qr-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.3s ease;
}

.qr-modal-overlay.show {
  display: flex;
}

.qr-modal {
  border-radius: 15px;
  padding: 40px;
  max-width: 420px;
  width: 100%;
  position: relative;
  animation: slideUp 0.4s ease;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background-color: rgba(95, 95, 95, 0.3);
}

.qr-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 35px;
  height: 35px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.qr-modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

.qr-modal-close svg {
  width: 20px;
  height: 20px;
  stroke: #fff;
  stroke-width: 2;
}

.qr-modal-content {
  text-align: center;
}

.qr-modal-title {
  color: #fff;
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 15px 0;
  background: #fff;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.qr-code-container {
  background: white;
  padding: 20px;
  border-radius: 15px;
  display: inline-block;
  margin: 20px 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

#qrcode {
  width: 256px;
  height: 256px;
}

#qrcode img,
#qrcode canvas {
  width: 100%;
  height: 100%;
  image-rendering: crisp-edges;
}

.qr-modal-description {
  color: #b0b0c0;
  font-size: 16px;
  line-height: 1.6;
  margin: 20px 0 0 0;
}

.qr-modal-icon {
  font-size: 40px;
  margin-bottom: 10px;
}

.qr-modal-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
  padding: 12px 20px;
  background: rgba(66, 68, 90, 0.3);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.qr-modal-hint-text {
  color: #b0b0c0;
  font-size: 14px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ========================================
   🎯 額外的微互動和細節優化
   ======================================== */

/* 按鈕點擊漣漪效果 */
.nav-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50px;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.2) 0%,
    transparent 70%
  );
  opacity: 0;
  transform: scale(0);
  transition: all 0.5s ease;
  pointer-events: none;
}

.nav-btn:active::after {
  opacity: 1;
  transform: scale(1);
  transition: all 0s;
}

/* 選中元素的焦點效果 */
.nav-btn:focus-visible,
.chip:focus-visible,
.panel-close:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 4px;
}

/* 禁用按鈕樣式 */
button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* 平滑滾動 */
* {
  scroll-behavior: smooth;
}

/* 文字選擇顏色 */
::selection {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* ========================================
   📱 響應式設計 - 手機版優化
   ======================================== */
@media (max-width: 900px) {
  .sidebar {
    bottom: 20px;
    top: auto;
    left: 0;
    right: 0;
    transform: none;
    position: fixed;
    z-index: 99999;
  }

  .sidebar .stack {
    width: 100%;
    flex-direction: row;
    align-items: end;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    flex-wrap: nowrap;
    margin-left: 0%;
    padding: 0 calc(50vw - 180px);
    scroll-behavior: smooth;
  }

  .sidebar .stack::before {
    content: "";
    display: block;
    width: 8px;
    flex-shrink: 0;
  }

  .sidebar .stack::-webkit-scrollbar {
    display: none;
  }

  .nav-section {
    width: auto !important;
    flex: 0 0 auto;
    scroll-snap-align: center;
  }

  .nav-btn {
    padding: 12px 22px;
    border-radius: 32px;
    font-size: 15px;
  }

  .dot {
    width: 24px;
    height: 24px;
  }

  .text-panel,
  .color-panel {
    width: 360px;
    padding: 24px 28px;
    border-radius: 20px;
  }

  .color-title,
  .panel-title {
    font-size: 17px;
  }

  .color-desc,
  .panel-desc {
    font-size: 15px;
  }

  .chip {
    width: 38px;
    height: 38px;
  }

  .panel-close {
    width: 36px;
    height: 36px;
    top: 12px;
    right: 12px;
  }

  #three-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  #feature-video,
  #feature-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    height: 100%;
  }
  .scroll-controls {
    display: none;
  }
  .qr-modal-overlay {
    display: none;
  }
}
