/* ============================================================
   hero.css — omhere258 首頁主視覺
   ============================================================
   圖層 z-index 總覽
   1  sea-bg        海面星空底圖
   2  canyon-bg     峽谷底圖
   3  celestial-layer  天象切換
   4  water-wrap    水面（山崖下層，兩側被山崖遮擋）
   5  cliff-mid     中景山崖
   7  cliff-fg      前景山崖
   8  star-sparkles 金色星屑（星空＋海面）
   10 boat-wrap     船
   11 vignette      暗角
   999 debug-bar
   ============================================================ */

/* ── Reset & Base ────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  /* smooth 會讓捲動與 JS 視差疊加延遲感，此頁改由原生慣性捲動 */
  scroll-behavior: auto;
}

body {
  background: #050510;
  color: #fff;
  font-family: 'Noto Serif TC', 'Noto Sans TC', 'PingFang TC', serif;
  overflow-x: hidden;
}

/* ── 主視覺 Section & Sticky 容器 ───────────────────────── */
#hero-section {
  position: relative;
  height: 620vh;           /* 拉長捲動；視覺時間軸約 58% 行程跑完，其餘海面停留 */
}

/* 古騰堡：插在 .entry-content 內時仍撐滿視窗寬 */
.entry-content > #hero-section,
.wp-block-post-content > #hero-section,
main > #hero-section {
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

#hero-sticky {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  /* 水面高度：設計稿 215px≈19.91vh；海面段改 translateY 下移，不改變圖像素比例 */
  --hero-water-base: clamp(120px, 19.91vh, 215px);
  --hero-water-h: var(--hero-water-base);
  --hero-water-ty: 0px;
  /* 船：素材 100×166；bottom 略沉入水面帶頂緣 */
  --hero-boat-w: 100px;
  --hero-boat-h: 166px;
  --hero-boat-sink: 18px;
}

/* ── 全幅圖層基底 ───────────────────────────────────────── */
#sea-bg,
#canyon-bg,
#celestial-layer,
#vignette {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ════════════════════════════════════════════════════════════
   背景圖層
════════════════════════════════════════════════════════════ */

/* 第四層：海面星空底圖（BG-2） */
#sea-bg {
  z-index: 1;
  opacity: 0;
  overflow: hidden;
  background-color: #04040f;
}

/* 第三層：峽谷底圖（BG-1） */
#canyon-bg {
  z-index: 2;
  opacity: 1;
  overflow: hidden;
  background-color: #1e1204;
}

/* 金色星屑：覆蓋星空區與海面帶，screen 疊加 */
#star-sparkles {
  position: absolute;
  inset: 0;
  z-index: 8;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
  transition: opacity 0.6s ease;
}

#star-sparkles.is-active {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  #star-sparkles {
    display: none !important;
  }
}

.hero-bg-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  pointer-events: none;
  user-select: none;
}

/* ════════════════════════════════════════════════════════════
   天象切換層
════════════════════════════════════════════════════════════ */
#celestial-layer {
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  will-change: opacity;
  transition: opacity 0.45s ease;
}

/* 抵達海面、尚未互動：桌機各館隱藏；手機 Swiper 整層透明 */
#celestial-layer.awaiting-swipe #celestial-mobile {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#celestial-layer.awaiting-swipe #c-dots,
#celestial-layer.awaiting-swipe #celestial-mobile .swiper-pagination {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* 首次淡入中 */
#celestial-layer.celestial-revealing #celestial-mobile {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 1.1s cubic-bezier(0.45, 0.05, 0.25, 1);
}

#celestial-layer.awaiting-swipe .c-arrow,
#celestial-layer.celestial-revealing .c-arrow,
#celestial-layer.celestial-unlocked .c-arrow {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#celestial-layer.celestial-unlocked #celestial-mobile {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#celestial-layer.celestial-unlocked #c-dots,
#celestial-layer.celestial-unlocked #celestial-mobile .swiper-pagination {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ── 桌機版 ─── */
#celestial-desktop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  user-select: none;
}

#celestial-desktop:active {
  cursor: grabbing;
}

/* 桌機：四館疊在同一視窗，以淡入淡出切換（非橫向硬切） */
#celestial-track {
  position: relative;
  width: 100%;
  height: 100%;
}

.c-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #050510;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 1;
  transition:
    opacity 1.1s cubic-bezier(0.45, 0.05, 0.25, 1),
    visibility 0s linear 1.1s;
}

.c-slide.is-entering {
  visibility: visible;
  opacity: 0;
  z-index: 1;
  transition:
    opacity 1.1s cubic-bezier(0.45, 0.05, 0.25, 1),
    visibility 0s;
}

.c-slide.is-active:not(.is-leaving) {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 2;
  transition:
    opacity 1.1s cubic-bezier(0.45, 0.05, 0.25, 1),
    visibility 0s;
}

.c-slide.is-active.is-leaving {
  opacity: 0;
  visibility: visible;
  pointer-events: none;
  z-index: 3;
  transition:
    opacity 1.1s cubic-bezier(0.45, 0.05, 0.25, 1),
    visibility 0s linear 1.1s;
}

#celestial-mobile .swiper-slide {
  position: relative;
  height: 100%;
  overflow: hidden;
  background-color: #050510;
}

/* 天象圖 1920×1080（16:9），依視口比例縮放、不拉伸 */
.celestial-img {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100% - var(--hero-water-h) + var(--hero-water-ty));
  object-fit: contain;
  object-position: center top;
  pointer-events: none;
  user-select: none;
}

/* 館別 logo：桌機維持接近原始尺寸；可點擊者包在 .pavilion-logo-link 內 */
.pavilion-logo-link,
.celestial-logo {
  position: absolute;
  top: clamp(10vh, 23%, 27%);
  left: 50%;
  transform: translateX(-50%);
  width: 520px;
  max-height: 58vh;
  max-width: none;
  z-index: 2;
}

.pavilion-logo-link {
  display: block;
  height: auto;
  text-decoration: none;
  outline: none;
  border: none;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.pavilion-logo-link:focus,
.pavilion-logo-link:focus-visible {
  outline: none;
  box-shadow: none;
}

.pavilion-logo-link .celestial-logo {
  position: static;
  transform: none;
  width: 100%;
  height: auto;
  max-height: 58vh;
  pointer-events: none;
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.6));
}

.celestial-logo {
  height: auto;
  object-fit: contain;
  object-position: center center;
  pointer-events: none;
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.6));
}

#celestial-layer:not(.celestial-unlocked) .pavilion-logo-link {
  pointer-events: none;
  cursor: default;
}

.c-slide:not(.is-active) .pavilion-logo-link,
#celestial-mobile .swiper-slide:not(.swiper-slide-active) .pavilion-logo-link {
  pointer-events: none;
  cursor: default;
}

/* 視口寬於 16:9（一般桌機全螢幕）：寬度填滿，上下微裁切 */
@media (min-aspect-ratio: 16/9) {
  .celestial-img {
    width: 100%;
    height: 100%;
    max-height: calc(100% - var(--hero-water-h) + var(--hero-water-ty));
    object-fit: cover;
    object-position: center top;
  }
}

/* 底部漸層遮罩：銜接水面區 */
.c-slide::after,
#celestial-mobile .swiper-slide::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: calc(var(--hero-water-h) - var(--hero-water-ty));
  background: linear-gradient(
    to bottom,
    transparent 30%,
    rgba(5, 5, 16, 0.3) 60%,
    rgba(5, 5, 16, 0.7) 100%
  );
  pointer-events: none;
  z-index: 1;
}

/* 方向箭頭 */
.c-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.2s, border-color 0.2s;
}

.c-arrow:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.5);
}

/* 桌機海面：左右箭頭呼吸提示（不移動） */
#celestial-layer.arrow-hint-active .c-arrow {
  animation: arrow-hint-breathe 2.8s ease-in-out infinite;
}

@keyframes arrow-hint-breathe {
  0%, 100% {
    transform: translateY(-50%) scale(0.94);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.32);
    box-shadow:
      0 0 10px 3px rgba(255, 255, 255, 0.18),
      0 0 22px 8px rgba(255, 255, 255, 0.08);
  }
  50% {
    transform: translateY(-50%) scale(1.1);
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.62);
    box-shadow:
      0 0 14px 5px rgba(255, 255, 255, 0.38),
      0 0 28px 12px rgba(255, 255, 255, 0.18);
  }
}

.c-arrow-l { left: 20px; }
.c-arrow-r { right: 20px; }

/* 圓點導航 */
#c-dots {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 10;
}

.c-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.28);
  transition: background 0.3s, transform 0.3s;
}

.c-dot.active {
  background: rgba(255, 255, 255, 0.92);
  transform: scale(1.35);
}

/* ── 手機版 Swiper（初始隱藏） ─── */
#celestial-mobile {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
  will-change: transform;
}

#celestial-mobile.swiper-fade .swiper-slide {
  pointer-events: none;
}

#celestial-mobile.swiper-fade .swiper-slide-active {
  pointer-events: auto;
}

#celestial-mobile .swiper-pagination {
  bottom: 18px;
}

#celestial-mobile .swiper-pagination-bullet {
  background: rgba(255, 255, 255, 0.4);
  opacity: 1;
}

#celestial-mobile .swiper-pagination-bullet-active {
  background: #fff;
  transform: scale(1.3);
}

/* ════════════════════════════════════════════════════════════
   山崖圖層
════════════════════════════════════════════════════════════ */

/* 共用：以高度 fit 視口，寬度隨素材比例；超出視口兩側由 #hero-sticky 裁切，不在此層內裁切 */
.cliff {
  position: absolute;
  top: 0;
  bottom: 0;
  height: 100%;
  width: auto;
  max-width: none;
  overflow: visible;
  pointer-events: none;
  opacity: 1;
}

/* 變形原點在靠螢幕外側；y 軸放在 42%，放大時上下都擴張，且向下略多於向上 */
.cliff-l {
  left: 0;
  transform-origin: left 42%;
}

.cliff-r {
  right: 0;
  left: auto;
  transform-origin: right 42%;
}

.cliff-img {
  display: block;
  height: 100%;
  width: auto;
  max-width: none;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.cliff-l .cliff-img {
  object-position: left top;
}

.cliff-r .cliff-img {
  object-position: right top;
}

/* ── 中景山崖（z: 5）Left-2 / Right-2 ─── */
.cliff-mid {
  z-index: 5;
}

/* ── 前景山崖（z: 7）Left-1 / Right-1 ─── */
.cliff-fg {
  z-index: 7;
}

/* ════════════════════════════════════════════════════════════
   水面層
   WebGL renderer canvas / fallback img 皆由 JS 注入 #water-wrap。
   JS 設定的 inline style：
     position: absolute; bottom: 0; left: 0;
     width: 100%; height: 215px; pointer-events: none;
════════════════════════════════════════════════════════════ */
#water-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--hero-water-h);
  z-index: 4;
  transform: translateY(var(--hero-water-ty));
  will-change: transform;
}

/* Three.js 自動插入的 canvas（JS 再追加 inline style，此規則作備援） */
#water-wrap canvas {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100% !important;
  height: var(--hero-water-h) !important;
  pointer-events: none;
  display: block;
}

/* Fallback img（無 WebGL 時） */
#water-wrap img.water-fallback {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--hero-water-h);
  object-fit: fill;
  pointer-events: none;
  display: block;
}

/* ════════════════════════════════════════════════════════════
   海面抵達：LOGO + 滑動提示（z: 12）
════════════════════════════════════════════════════════════ */
#sea-arrival {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 2.5vh, 28px);
  padding: 8vh 24px calc(var(--hero-water-h) - var(--hero-water-ty) + 48px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  text-align: center;
}

#sea-arrival.is-visible {
  pointer-events: none;
}

.hero-logo {
  display: block;
  width: min(560px, 78vw);
  max-width: none;
  max-height: min(210px, 26vh);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 24px rgba(0, 0, 0, 0.45));
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.celestial-swipe-hint {
  font-size: clamp(0.8rem, 1.6vw, 0.95rem);
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.72);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
  transition: opacity 0.4s ease;
}

.hint-text--desktop {
  display: none;
}

/* 觸發天象後：LOGO 立刻淡出（z 高於天象層，須快於星象淡入） */
#sea-arrival.hint-dismissed .hero-logo {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease-out, visibility 0s linear 0.18s;
}

#sea-arrival.hint-dismissed .celestial-swipe-hint {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0s linear 0.28s;
}

/* ── 操作提示光點（上拉 scroll／左右滑） ───────────────── */
.hint-pulse {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  box-shadow:
    0 0 12px 4px rgba(255, 255, 255, 0.38),
    0 0 26px 10px rgba(255, 255, 255, 0.2);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.hint-pulse.is-active {
  opacity: 1;
  visibility: visible;
}

.hint-pulse.is-dismissed {
  opacity: 0 !important;
  visibility: hidden !important;
  animation: none !important;
}

/* 進站：綁在 #boat-wrap 內，船 hull 正下方 */
.hint-pulse--scroll {
  position: absolute;
  left: 50%;
  bottom: -20px;
  z-index: 2;
}

.hint-pulse--scroll.is-active {
  animation: hint-pulse-drag-up 2.8s ease-in-out infinite;
}

/* 海面：緊接提示文字下方（flex 子項，避免沉到畫面底部看不見） */
.hint-pulse--sea {
  position: relative;
  left: auto;
  margin-top: 10px;
  z-index: 2;
}

.hint-pulse--sea.is-active {
  animation: hint-pulse-drag-lr 2.8s ease-in-out infinite;
}

#sea-hint-pulse.is-dismissed {
  opacity: 0 !important;
  visibility: hidden !important;
}

/* 上拉 scroll：到終點後淡出，停留於起點再出現（不滑回） */
@keyframes hint-pulse-drag-up {
  0%, 20% {
    transform: translate(-50%, 0) scale(0.9);
    opacity: 0.48;
  }
  34% {
    transform: translate(-50%, -26px) scale(1.05);
    opacity: 1;
  }
  44% {
    transform: translate(-50%, -26px) scale(1.05);
    opacity: 1;
  }
  50% {
    transform: translate(-50%, -26px) scale(1.05);
    opacity: 0;
  }
  51%, 100% {
    transform: translate(-50%, 0) scale(0.9);
    opacity: 0;
  }
}

/* 手機海面：右→左移動（軌跡置中），終點淡出後於右側起點再出現 */
@keyframes hint-pulse-drag-lr {
  0%, 20% {
    transform: translateX(26px) scale(0.9);
    opacity: 0.48;
  }
  34% {
    transform: translateX(-26px) scale(1.05);
    opacity: 1;
  }
  44% {
    transform: translateX(-26px) scale(1.05);
    opacity: 1;
  }
  50% {
    transform: translateX(-26px) scale(1.05);
    opacity: 0;
  }
  51%, 100% {
    transform: translateX(26px) scale(0.9);
    opacity: 0;
  }
}

/* ════════════════════════════════════════════════════════════
   船（持續浮沉動畫）
════════════════════════════════════════════════════════════ */
#boat-wrap {
  position: absolute;
  bottom: calc(var(--hero-water-h) - var(--hero-boat-sink) - var(--hero-water-ty));
  left: 50%;
  width: var(--hero-boat-w);
  height: var(--hero-boat-h);
  z-index: 10;
  overflow: visible;
  animation: boat-float 5s ease-in-out infinite both;
  will-change: transform;
}

.boat-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  display: block;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35));
  pointer-events: none;
  user-select: none;
}

#boat-sea {
  opacity: 0;
}

/* 浮沉動畫（translateX(-50%) 負責水平置中，translateY 控制上下） */
@keyframes boat-float {
  0%, 100% { transform: translateX(-50%) translateY(0px); }
  50%       { transform: translateX(-50%) translateY(-10px); }
}

/* ════════════════════════════════════════════════════════════
   暗角遮罩（邊緣加深，強化沉浸感）
════════════════════════════════════════════════════════════ */
#vignette {
  z-index: 11;
  pointer-events: none;
  background: radial-gradient(
    ellipse 75% 75% at 50% 50%,
    transparent 45%,
    rgba(0, 0, 0, 0.25) 75%,
    rgba(0, 0, 0, 0.5) 100%
  );
}

/* ════════════════════════════════════════════════════════════
   Debug bar
════════════════════════════════════════════════════════════ */
#debug-bar {
  display: none !important;
}

/* ════════════════════════════════════════════════════════════
   視差段落結束後的頁面底部
════════════════════════════════════════════════════════════ */
#page-end {
  background: #050510;
  color: rgba(255, 255, 255, 0.3);
  text-align: center;
  padding: 80px 24px;
  font-size: 0.85rem;
  line-height: 2.4;
  letter-spacing: 0.12em;
}

/* ════════════════════════════════════════════════════════════
   手機版 RWD（≤ 767px）
════════════════════════════════════════════════════════════ */
@media (min-width: 768px) {
  .hint-text--mobile { display: none; }
  .hint-text--desktop { display: inline; }
  .hint-pulse--sea { display: none !important; }
}

@media (max-width: 767px) {

  /* 隱藏桌機版，顯示 Swiper */
  #celestial-desktop { display: none; }
  #celestial-mobile  { display: block; }

  /* 天象圖（手機）：高度填滿容器，左右超出裁切 */
  .celestial-img {
    width: auto;
    height: 100%;
    max-height: none;
    object-fit: cover;
    object-position: center top;
  }

  .hero-logo {
    width: min(420px, 88vw);
    max-height: min(160px, 22vh);
  }

  .pavilion-logo-link,
  .celestial-logo {
    width: clamp(170px, 56vw, 300px);
    top: clamp(15vh, 32%, 38%);
    max-height: none;
  }

  .pavilion-logo-link .celestial-logo {
    max-height: none;
  }

  /* 浮沉幅度稍減 */
  @keyframes boat-float {
    0%, 100% { transform: translateX(-50%) translateY(0px); }
    50%       { transform: translateX(-50%) translateY(-7px); }
  }
}
