/* ============================================================
   loading.css — Loading/Splash 頁專用樣式
   ============================================================ */

/* ── 頁面容器 ── */
.loading-page {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--c-bg-base);
  z-index: var(--z-loading);
  overflow: hidden;
}

/* ── 中央光暈背景 ── */
.loading-page::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%);
  width: 600px;
  height: 600px;
  background: radial-gradient(ellipse, rgba(255, 107, 43, 0.18) 0%, transparent 70%);
  pointer-events: none;
}

/* 次級光暈（底部） */
.loading-page::after {
  content: '';
  position: absolute;
  bottom: -100px;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 300px;
  background: radial-gradient(ellipse, rgba(255, 107, 43, 0.06) 0%, transparent 60%);
  pointer-events: none;
}

/* ── 粒子 canvas ── */
.loading-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* ── 主內容包裝 ── */
.loading-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-6);
  opacity: 0;
  animation: loadingContentIn 0.8s ease 0.1s forwards;
}

@keyframes loadingContentIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Logo 區域 ── */
.loading-logo-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 120px;
  opacity: 0;
  transform: scale(0.75);
  animation: logoReveal 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) 0s forwards;
}

@keyframes logoReveal {
  from { opacity: 0; transform: scale(0.75); }
  to   { opacity: 1; transform: scale(1); }
}

/* Logo 外環光暈 */
.loading-logo-wrap::before {
  content: '';
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255, 107, 43, 0.20) 0%, transparent 70%);
  animation: breathe 3s ease-in-out infinite;
}

/* Logo 圓形背景 */
.loading-logo-bg {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255, 107, 43, 0.15) 0%, rgba(255, 140, 0, 0.08) 100%);
  border: 1.5px solid rgba(255, 107, 43, 0.40);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 40px rgba(255, 107, 43, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: breathe 3s ease-in-out 0.5s infinite;
}

/* Logo 文字（無圖片時） */
.loading-logo-text {
  font-family: var(--font-data);
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 0.05em;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

/* Logo 圖片（有圖時） */
.loading-logo-img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

/* ── 標題文字區 ── */
.loading-brand {
  text-align: center;
  opacity: 0;
  animation: loadingContentIn 0.6s ease 0.7s forwards;
}

.loading-title {
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--c-text-primary);
  letter-spacing: 0.03em;
  line-height: 1.1;
  margin-bottom: var(--sp-2);
}

.loading-title span {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.loading-subtitle {
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── 進度條區域 ── */
.loading-progress-wrap {
  width: 240px;
  opacity: 0;
  animation: loadingContentIn 0.5s ease 1.1s forwards;
}

.loading-progress-track {
  width: 100%;
  height: 3px;
  background: rgba(255, 107, 43, 0.12);
  border-radius: var(--r-full);
  overflow: hidden;
  position: relative;
}

.loading-progress-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--gradient-primary);
  box-shadow: 0 0 12px rgba(255, 107, 43, 0.6);
  width: 0%;
  transition: width 0.1s linear;
  position: relative;
}

/* 進度條閃光 */
.loading-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 40px;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: progressShine 1.5s ease 1.5s infinite;
}

@keyframes progressShine {
  0%   { opacity: 0; transform: translateX(-40px); }
  30%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(40px); }
}

/* 進度百分比 & 文字 */
.loading-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--sp-2);
}

.loading-status-text {
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  letter-spacing: 0.05em;
}

.loading-pct {
  font-size: var(--text-xs);
  font-family: var(--font-data);
  color: var(--c-primary);
  font-weight: 600;
}

/* ── 底部 Powered by ── */
.loading-footer {
  position: absolute;
  bottom: var(--sp-8);
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  animation: loadingContentIn 0.5s ease 2.0s forwards;
  white-space: nowrap;
}

.loading-powered {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  letter-spacing: 0.06em;
}

.loading-powered .polygon-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8247E5;
  box-shadow: 0 0 8px rgba(130, 71, 229, 0.6);
  flex-shrink: 0;
}

/* ── 離場動畫 ── */
.loading-page.fade-out {
  animation: loadingFadeOut 0.5s ease forwards;
}

@keyframes loadingFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; pointer-events: none; }
}

/* ── 版本號（dev 用途） ── */
.loading-version {
  position: absolute;
  bottom: var(--sp-4);
  right: var(--sp-4);
  font-size: 10px;
  color: rgba(255, 255, 255, 0.08);
  font-family: var(--font-data);
  pointer-events: none;
  user-select: none;
}

/* ── RWD 桌機優化 ── */
@media (min-width: 768px) {
  .loading-logo-wrap {
    width: 140px;
    height: 140px;
  }

  .loading-logo-bg {
    width: 120px;
    height: 120px;
  }

  .loading-logo-text {
    font-size: 40px;
  }

  .loading-title {
    font-size: var(--text-4xl);
  }

  .loading-progress-wrap {
    width: 300px;
  }
}
