/**
 * spa.css - SPA 架构核心样式
 * 用途：定义单页应用的容器、转场容器和固定背景层
 */

/* === SPA 主体 === */
.spa-app {
  position: relative;
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
}

/* === 固定背景层（永不销毁） === */
#global-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* === 视图容器（动态内容） === */
#app-container {
  position: relative;
  width: 100%;
  min-height: 100vh;
  z-index: 1;
}

/* === 页面特定样式覆盖 === */
/* 确保每个视图的 .page 容器充满整个视口 */
#app-container>.page {
  min-height: 100vh;
}

/* === 頁面特定樣式 === */
body.page--index .page-nav {
  display: none;
}

/* === 导航栏和语言切换的层级 === */
.page-nav {
  z-index: 100;
}

/* === 語言切換按鈕 === */
.lang-switch {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 101;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(210, 195, 165, 0.25);
  border-radius: 50%;
  background: rgba(10, 10, 14, 0.5);
  backdrop-filter: blur(4px);
  color: rgba(235, 228, 215, 0.8);
  font-family: "Noto Serif TC", serif;
  font-size: 14px;
  font-weight: 300;
  letter-spacing: 0.05em;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 300ms ease, color 300ms ease, background 300ms ease, transform 300ms ease;
}

.lang-switch:hover {
  color: rgba(245, 238, 226, 0.95);
  border-color: rgba(230, 215, 185, 0.5);
  background: rgba(30, 28, 26, 0.7);
  transform: scale(1.05);
}

.lang-switch:active {
  transform: scale(0.98);
}

/* 首頁隱藏語言切換（可選：移除此區塊以始終顯示） */
/* body.page--index .lang-switch {
  opacity: 0;
  pointer-events: none;
  transition: opacity 400ms ease;
}

body.page--index:hover .lang-switch {
  opacity: 1;
  pointer-events: auto;
} */

@media (max-width: 768px) {
  .lang-switch {
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    font-size: 14px;
  }

  html[lang="zh-TW"] .lang-switch {
    font-size: 15px;
  }
}

/* === Ink morph overlay (text formation) === */
.ink-morph-overlay {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 600ms ease;
  mix-blend-mode: screen;
}

.ink-morph-overlay.is-active {
  opacity: 1;
}

.ink-morph-canvas {
  width: 100%;
  height: 100%;
  display: block;
  filter: blur(0.2px);
}

/* Standard transition for other elements */
.ink-morph-target {
  opacity: 0;
  filter: blur(10px);
  transition: opacity 900ms ease, filter 1400ms ease;
}

/* Slower transition for CTA (text duration 4000ms + 500ms) */
.cta.ink-morph-target {
  transition: opacity 4500ms ease, filter 1400ms ease;
}

/* Slower transition specifically for Hero Text */
.hero__title.ink-morph-target {
  transition: opacity 4800ms ease, filter 1400ms ease;
}

.hero__line.ink-morph-target {
  transition: opacity 4000ms ease, filter 1400ms ease;
}

.ink-morph-target.reveal {
  transition: opacity 900ms ease, filter 1400ms ease, visibility 0s linear 0s;
}

/* Ensure Hero Text keeps slow transition even with .reveal class */
.hero__title.ink-morph-target.reveal {
  transition: opacity 4800ms ease, filter 1400ms ease, visibility 0s linear 0s;
}

.hero__line.ink-morph-target.reveal {
  transition: opacity 4000ms ease, filter 1400ms ease, visibility 0s linear 0s;
}

.cta.ink-morph-target.reveal {
  transition: opacity 4500ms ease, filter 1400ms ease;
}

.ink-morph-target.is-visible {
  opacity: 1;
  filter: blur(0);
}

.ink-morph-target.ink-morph-dispersing {
  opacity: 0;
  filter: blur(14px);
  transition: opacity 600ms ease, filter 900ms ease;
}

/* === 响应式适配 === */
@media (max-width: 768px) {
  #app-container {
    overflow-x: hidden;
  }
}

/* 转场效果已移除 */

/* === Shared CTA Styles (From Index) === */
.cta {
  position: relative;
  border: 1px solid rgba(210, 195, 165, 0.26);
  background: rgba(10, 10, 14, 0.45);
  color: rgba(235, 228, 215, 0.9);
  padding: 14px 46px;
  font-size: clamp(31px, 4.1vw, 41px);
  letter-spacing: 0.24em;
  border-radius: 999px;
  cursor: pointer;
  text-transform: uppercase;
  font-family: "Bakudai", "Noto Serif TC", serif;
  backdrop-filter: blur(2px);
  transition: border-color 300ms ease, color 300ms ease, transform 300ms ease, box-shadow 300ms ease;
  overflow: hidden;
}

html[lang="en-US"] .cta {
  letter-spacing: 0.15em;
}

.cta--vertical {
  position: fixed;
  left: 15.385vw;
  top: 50%;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
  text-orientation: upright;
  padding: 26px 14px;
  letter-spacing: 0.18em;
  z-index: 100;
}

.cta-btn::before {
  content: "";
  position: absolute;
  inset: -20%;
  background: url("../assets/images/115.1.26%20float_ink_speckle_01_2048.png") center/cover no-repeat;
  opacity: 0.12;
  transform: scale(1.1);
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.cta-btn::after {
  content: "";
  position: absolute;
  inset: -30%;
  background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.14), transparent 55%);
  opacity: 0.2;
  pointer-events: none;
}

.cta-label {
  position: relative;
  z-index: 1;
}

.cta-ripple {
  position: absolute;
  inset: -65% -45%;
  background: url("../assets/images/115.1.26%20fx_ink_ring_1024.png") center/contain no-repeat;
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}

.cta:hover {
  color: rgba(245, 238, 226, 0.95);
  transform: translateY(-1px);
  border-color: rgba(230, 215, 185, 0.45);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.cta:active {
  transform: translateY(0) scale(0.98);
}

.cta:focus-visible {
  outline: 2px solid rgba(160, 128, 80, 0.45);
  outline-offset: 6px;
}

.cta:hover .cta-ripple,
.cta:focus-visible .cta-ripple {
  animation: inkRing 1s ease-out;
}

/* Reveal transition logic shared for CTA */
.cta.reveal {
  --reveal-duration: 3600ms;
  --reveal-blur: 12px;
  --reveal-y: 0px;
  transition: opacity var(--reveal-duration, 800ms) ease;
}

/* CTA appear ripple (triggered when CTA becomes visible) */
.cta.is-visible:not(:hover):not(:focus-visible) .cta-ripple {
  animation:
    inkRingAppear 1.8s ease-out,
    inkRingIdle 6.2s ease-out 1.8s infinite;
}

@keyframes inkRing {
  0% {
    opacity: 0.35;
    transform: scale(0.8);
  }

  100% {
    opacity: 0;
    transform: scale(1.6);
  }
}

@keyframes inkRingAppear {
  0% {
    opacity: 0.28;
    transform: scale(0.72);
  }

  55% {
    opacity: 0.18;
    transform: scale(1.15);
  }

  100% {
    opacity: 0;
    transform: scale(1.9);
  }
}

@keyframes inkRingIdle {
  0% {
    opacity: 0;
    transform: scale(0.82);
  }

  22% {
    opacity: 0.2;
    transform: scale(1.12);
  }

  60% {
    opacity: 0.14;
    transform: scale(1.5);
  }

  100% {
    opacity: 0;
    transform: scale(1.9);
  }
}

.cta.is-entering {
  transform: translateY(2px) scale(0.98);
  opacity: 0.8;
}

/* Mobile adjustments shared */
@media (max-width: 768px) {
  .cta {
    padding: 12px 36px;
    font-size: clamp(20px, 4.8vw, 26px);
  }
}

/* Mobile CTA Optimization */
@media (max-width: 480px) {
  /* Vertical CTA becomes horizontal mobile pill button */
  .cta--vertical {
    position: static;
    top: auto;
    left: auto;
    transform: none;
    margin: 0 auto;
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    width: 100%;
    max-width: 280px;
    padding: 14px 20px;
    text-align: center;
    white-space: nowrap;
    z-index: 40;
  }

  .cta--vertical .cta-label {
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    text-align: center !important;
    width: 100%;
    display: block;
  }
}
