/* 手機版 — 直向 MP4 底 + desktop 同款 AI 對話框 */

.mobile-page {
  --mobile-bg-w: 1080;
  --mobile-bg-h: 1920;
  --mobile-bg-ar: 1.7778;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

.mobile-page .chat-page {
  background: #0a0604;
  height: 100dvh;
}

.mobile-page .chat-widget {
  --widget-w: min(92vw, 400px);
  z-index: 20;
}

.mobile-page .chat-widget__drag {
  touch-action: none;
}

.mobile-stage.is-debug .mobile-bg-inner,
.chat-page.is-debug .mobile-bg-inner {
  outline: 2px dashed rgba(255, 80, 80, 0.85);
  outline-offset: -2px;
}

.chat-page.is-debug .mobile-bg-inner::after {
  content: attr(data-size);
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(255, 80, 80, 0.9);
  color: #fff;
  font: 12px/1.4 system-ui, sans-serif;
  z-index: 5;
  pointer-events: none;
}

.mobile-bg-scroll {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: #0a0604;
  overscroll-behavior: contain;
}

/* 直向手機：闊度貼滿螢幕，高度跟片比例；唔夠高就拉高避免底部黑邊 */
.mobile-page .mobile-bg-inner {
  position: relative;
  width: 100vw;
  min-height: 100dvh;
  height: max(100dvh, calc(100vw * var(--mobile-bg-ar)));
}

/* 打橫 / 闊螢幕：用原片像素尺寸可捲動（同 desktop 邏輯） */
@media (orientation: landscape), (min-width: 901px) {
  .mobile-page .mobile-bg-inner {
    width: max(100vw, calc(var(--mobile-bg-w) * 1px));
    height: max(100dvh, calc(var(--mobile-bg-h) * 1px));
    min-width: calc(var(--mobile-bg-w) * 1px);
    min-height: calc(var(--mobile-bg-h) * 1px);
  }
}

.mobile-bg-video {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 100%;
  object-fit: fill;
  pointer-events: none;
  background: #0a0604;
}

.mobile-fallback {
  position: fixed;
  left: 50%;
  bottom: calc(16px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 30;
  margin: 0;
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(10, 6, 4, 0.9);
  border: 1px solid rgba(255, 213, 106, 0.45);
  color: rgba(245, 230, 200, 0.85);
  font-size: 12px;
  text-align: center;
}

.mobile-fallback code {
  color: #ffd56a;
}

.mobile-page .chat-panel__foot .chat-actions {
  flex-wrap: wrap;
  gap: 6px;
}

.mobile-page .chat-panel__foot .chat-actions a {
  font-size: 11px;
  padding: 6px 10px;
}

/* 對話為主：WhatsApp / 連結在面板內向下滑才見 */
.mobile-page .chat-panel {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.mobile-page .chat-panel__body {
  flex: 1 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.mobile-page .chat-messages {
  flex: 1 1 auto;
  min-height: 6em;
  overflow: visible;
}

.mobile-page .chat-input-row {
  position: sticky;
  bottom: 0;
  z-index: 2;
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 6px;
  background: linear-gradient(
    to top,
    rgba(255, 248, 235, 1) 65%,
    rgba(255, 248, 235, 0.92) 85%,
    rgba(255, 248, 235, 0)
  );
}

.mobile-page .chat-panel:not(.is-preface) .chat-panel__body::after {
  content: '向下滑 → WhatsApp / 連結';
  flex-shrink: 0;
  padding: 2px 0 4px;
  font-size: 9px;
  font-weight: 600;
  text-align: center;
  color: rgba(90, 64, 32, 0.5);
  pointer-events: none;
}

.mobile-page .chat-panel.is-preface .chat-panel__body::after {
  content: none;
  display: none;
}

.mobile-page .chat-panel__foot {
  flex-shrink: 0;
  margin-top: 0;
  padding: 10px 0 8px;
  border-top: 1px dashed rgba(139, 105, 20, 0.3);
}

.mobile-page .chat-panel__foot::before {
  content: '↓ WhatsApp 及連結';
  display: block;
  margin-bottom: 8px;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  color: rgba(90, 64, 32, 0.65);
  letter-spacing: 0.02em;
}

.mobile-page .chat-panel.is-preface .chat-panel__foot::before {
  content: none;
  display: none;
}
