/* .page--wait styles removed (using global background) */
.page--wait {
  --wait-fade-duration: 1800ms;
  --wait-fade-ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Font inherits from base.css for consistency */

.wait-wrapper {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 24px;
  text-align: center;
}

/* Simplified content container */
.wait-content {
  width: min(760px, 90vw);
  /* 改用絕對定位的子元素佈局，避免 CTA 出現時影響文字位置 */
  position: relative;
  min-height: 60vh;
}

.page--wait .dev-channel-panel--wait {
  top: max(68px, calc(env(safe-area-inset-top) + 16px));
  left: max(16px, calc(env(safe-area-inset-left) + 12px));
  z-index: 140;
  max-width: min(320px, calc(100vw - 24px));
}

/* Vertical Columns Container */
.wait-cols {
  /* 絕對定位置中，不受 CTA 影響 */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  width: 100%;
  max-width: 1200px;
  height: auto;
  display: flex;
  flex-direction: row-reverse;
  /* Right to Left: Status -> Main -> Sub */
  justify-content: center;
  align-items: center;
  gap: clamp(80px, 15vw, 220px);
  /* 增加間距，確保文字不被擠壓 */
}

/* Col A: Status (Top/Right in vertical logic) */
.wait-col--status {
  writing-mode: vertical-rl;
  text-orientation: upright;
  color: var(--color-text-secondary);
  /* Increased size for Status (Min > 22px) */
  font-size: 24px;
  letter-spacing: 0.25em;
  opacity: 0;
  /* 同步過渡效果 - 與 Main 一致 */
  transition: opacity var(--wait-fade-duration) var(--wait-fade-ease);

  /* 固定定位，防止內容變化導致位移 */
  position: relative;
  min-width: 30px;
  min-height: 250px;
  max-height: 400px;
  white-space: nowrap;
  flex-shrink: 0;
}

.wait-col--status.is-active {
  opacity: 0.7;
}

/* Col B: Main Text (Center) */
.wait-col--main {
  writing-mode: vertical-rl;
  text-orientation: upright;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  min-height: 350px;
  max-height: 500px;
  position: relative;
  /* Containing block for absolute children */
  flex-shrink: 0;
}

/* New: Container for each message group */
.wait-main-group {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  opacity: 0;
  transition: opacity var(--wait-fade-duration) var(--wait-fade-ease);
}

.wait-main-group.is-active {
  opacity: 1;
}

.wait-line {
  /* Significantly increased main text size (Hierarchy adjusted) */
  font-size: clamp(36px, 6vw, 54px);
  color: var(--color-text-primary);
  line-height: 1.6;
  margin: 0;
  /* Opacity & transition are now handled by the parent group */
}

.wait-line--offset {
  margin-top: 48px;
}

/* Col C: Sub Text (Bottom/Left) */
.wait-col--sub {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  /* Natural reading */
  color: var(--color-text-secondary);
  /* Increased size for Sub text (Min > 22px -> 28px) */
  font-size: 26px;
  /* 稍微縮小，避免擠壓 */
  opacity: 0;
  letter-spacing: 0.1em;
  /* 同步過渡效果 - 與 Main 一致 */
  transition: opacity var(--wait-fade-duration) var(--wait-fade-ease);

  /* 固定定位，防止內容變化導致位移 */
  position: relative;
  min-width: 30px;
  min-height: 350px;
  max-height: 500px;
  white-space: nowrap;
  flex-shrink: 0;
}

.wait-col--sub.is-active {
  opacity: 0.9;
}

.wait-sub-line {
  display: block;
  margin-left: 12px;
}

.wait-status-text {
  /* Renamed from .wait-status */
  white-space: pre-line;
}

.wait-error {
  margin-top: 20px;
  color: var(--color-error);
  position: absolute;
  bottom: 20px;
  width: 100%;
  text-align: center;
}

.wait-actions {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.wait-actions .btn {
  padding: 10px 22px;
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 55, 0.4);
  background: transparent;
  color: var(--color-text-primary);
  letter-spacing: 0.16em;
  cursor: pointer;
  transition: all 0.3s ease;
}

.wait-actions .btn:hover {
  background: rgba(212, 175, 55, 0.1);
  border-color: rgba(212, 175, 55, 0.8);
}

/* 揭示按鈕 (Reveal Button) - 橫書版本 */
.cta--reveal {
  /* 絕對定位在底部，不影響文字佈局 */
  position: absolute;
  top: calc(50% + 18vh + 4cm);
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;

  opacity: 0;
  visibility: hidden;
  transition: all 0.8s ease-out;

  /* 橫書排版 */
  writing-mode: horizontal-tb;
  padding: 18px 46px;

  /* 樣式覆蓋 */
  background: rgba(10, 10, 14, 0.45);
  border: 1px solid rgba(210, 195, 165, 0.26);
  color: rgba(235, 228, 215, 0.9);
  box-shadow: none;
  font-size: 24px;
  letter-spacing: 0.4em;
  border-radius: 999px;
  /* 圓弧形 */
}

.cta--reveal.is-visible {
  opacity: 1;
  visibility: visible;
  animation: floatReveal 2s ease-out forwards;
}

@keyframes floatReveal {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) translateY(20px) scale(0.95);
  }

  100% {
    opacity: 1;
    transform: translate(-50%, -50%) translateY(0) scale(1);
  }
}

/* === 小螢幕優化（600px 以下）：改為橫書 === */
@media (max-width: 600px) {
  .wait-wrapper {
    padding: 30px 16px;
  }

  .wait-content {
    width: min(95vw, 400px);
    min-height: 50vh;
  }

  .wait-cols {
    flex-direction: column;
    gap: 32px;
  }

  .wait-col--status {
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    font-size: 18px;
    min-width: auto;
    min-height: auto;
    text-align: center;
  }

  .wait-col--main {
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    min-height: auto;
    max-height: none;
  }

  .wait-main-group {
    position: relative;
    flex-direction: column;
  }

  .wait-line {
    font-size: clamp(24px, 6vw, 36px);
    text-align: center;
  }

  .wait-line--offset {
    margin-top: 14px;
  }

  .wait-col--sub {
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    font-size: 18px;
    min-width: auto;
    min-height: auto;
    text-align: center;
  }

  .wait-sub-line {
    margin-left: 0;
    margin-top: 8px;
  }

  /* 揭示按鈕調整 */
  .cta--reveal {
    top: auto;
    bottom: 15vh;
    padding: 14px 36px;
    font-size: 20px;
  }

  .page--wait .dev-channel-panel--wait {
    top: auto;
    bottom: calc(env(safe-area-inset-bottom) + 16px);
    left: calc(env(safe-area-inset-left) + 12px);
    max-width: min(92vw, 340px);
  }
}

/* === 超小螢幕（375px 以下） === */
@media (max-width: 375px) {
  .wait-wrapper {
    padding: 24px 12px;
  }

  .wait-cols {
    gap: 24px;
  }

  .wait-col--status {
    font-size: 16px;
  }

  .wait-line {
    font-size: clamp(20px, 5.5vw, 28px);
  }

  .wait-line--offset {
    margin-top: 10px;
  }

  .wait-col--sub {
    font-size: 16px;
  }

  .cta--reveal {
    bottom: 12vh;
    padding: 12px 28px;
    font-size: 18px;
  }
}

/* === Touch Device Adaptive Layout (Phone + Tablet) === */
@media (hover: none) and (pointer: coarse) and (max-width: 1366px),
  (max-width: 1024px) and (max-height: 1366px) {
  .wait-wrapper {
    padding: calc(24px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom));
  }

  .wait-content {
    width: min(92vw, 860px);
    min-height: min(66vh, 640px);
  }

  .wait-cols {
    width: min(92vw, 900px);
    gap: clamp(28px, 6vw, 88px);
  }

  .wait-col--status {
    font-size: clamp(18px, 2.3vw, 28px);
    min-height: clamp(170px, 28vh, 270px);
    max-height: none;
  }

  .wait-col--main {
    min-height: clamp(230px, 42vh, 430px);
    max-height: none;
  }

  .wait-line {
    font-size: clamp(26px, 4.5vw, 46px);
  }

  .wait-line--offset {
    margin-top: clamp(16px, 2.8vh, 30px);
  }

  .wait-col--sub {
    font-size: clamp(18px, 2.3vw, 28px);
    min-height: clamp(230px, 42vh, 430px);
    max-height: none;
  }

  .cta--reveal {
    top: auto;
    bottom: calc(env(safe-area-inset-bottom) + clamp(64px, 12vh, 116px));
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 36px;
    font-size: clamp(18px, 2.4vw, 24px);
    letter-spacing: 0.28em;
  }

  .wait-error {
    bottom: calc(env(safe-area-inset-bottom) + clamp(118px, 18vh, 208px));
    font-size: clamp(14px, 2.1vw, 20px);
  }

  html[lang="zh-TW"] .page--wait .wait-error {
    font-size: clamp(16px, 2.4vw, 22px);
  }

  .wait-actions {
    position: fixed;
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom) + clamp(58px, 9vh, 84px));
    transform: translateX(-50%);
    z-index: 120;
  }
}

/* === Short Touch Landscape: switch to horizontal reading flow === */
@media (hover: none) and (pointer: coarse) and (max-height: 560px),
  (max-height: 560px) and (max-width: 1024px) and (orientation: landscape) {
  .wait-wrapper {
    padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  }

  .wait-content {
    width: min(96vw, 900px);
    min-height: min(72vh, 420px);
  }

  .wait-cols {
    flex-direction: column;
    gap: 16px;
    width: min(94vw, 900px);
  }

  .wait-col--status {
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    font-size: clamp(14px, 2vw, 18px);
    min-height: auto;
    min-width: auto;
    text-align: center;
  }

  .wait-col--main {
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    min-height: auto;
    max-height: none;
    width: 100%;
  }

  .wait-main-group {
    position: relative;
    width: 100%;
    height: auto;
  }

  .wait-line {
    font-size: clamp(20px, 3.2vw, 30px);
    line-height: 1.65;
    text-align: center;
  }

  .wait-line--offset {
    margin-top: 6px;
  }

  .wait-col--sub {
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    font-size: clamp(13px, 1.8vw, 17px);
    min-height: auto;
    min-width: auto;
    text-align: center;
  }

  .wait-sub-line {
    margin-left: 0;
    margin-top: 6px;
  }

  .cta--reveal {
    bottom: calc(env(safe-area-inset-bottom) + 56px);
    padding: 10px 24px;
    font-size: clamp(15px, 1.9vw, 18px);
  }

  .wait-error {
    bottom: calc(env(safe-area-inset-bottom) + 96px);
    font-size: 13px;
  }

  html[lang="zh-TW"] .page--wait .wait-col--status {
    font-size: clamp(16px, 2.2vw, 20px);
  }

  html[lang="zh-TW"] .page--wait .wait-col--sub {
    font-size: clamp(15px, 2vw, 19px);
  }

  html[lang="zh-TW"] .page--wait .cta--reveal {
    font-size: clamp(16px, 2.1vw, 20px);
  }

  html[lang="zh-TW"] .page--wait .wait-error {
    font-size: 14px;
  }

  .wait-actions {
    bottom: calc(env(safe-area-inset-bottom) + 72px);
  }
}

/* Utilities */
.hidden {
  display: none !important;
}
