/* 首頁背景預告片：index.html 頁首直接載入（全站網域都會載，但只有 html.home-trailer-on＝測試站才顯示任何東西）。
   透明度 token 在 theme.css。 */
html:not(.home-trailer-on) .home-trailer-btn,
html:not(.home-trailer-motion) .home-trailer-nav-toggle { display: none !important; }
.home-trailer-bg {
  position: fixed; inset: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: 0; pointer-events: none;
  opacity: var(--home-trailer-opacity, 0.38);
}
.home-trailer-btn i { font-size: 0.85em; }

.home-trailer-toggle {
  position: fixed; left: 20px; bottom: 20px; z-index: 890;
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.55rem 1rem; border-radius: var(--radius-pill, 999px);
  border: 1px solid var(--border-gold); color: var(--accent-gold);
  background: var(--fx-nav-bg); box-shadow: var(--shadow-rest);
  backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px);
  font: 500 0.75rem/1 'Noto Sans TC', sans-serif; letter-spacing: 1px; cursor: pointer;
  transition: border-color 0.3s, background 0.3s;
}
.home-trailer-toggle:hover { border-color: var(--accent-gold); background: rgba(var(--gold-rgb), 0.14); }
.home-trailer-toggle i { font-size: 0.85em; }

/* 導覽列內的圖示版（只在導覽收合時出現；外觀比照 theme.css 的 .theme-toggle） */
.home-trailer-nav-toggle {
  display: none; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  width: 2.25rem; height: 1.75rem; padding: 0; border-radius: var(--radius-pill, 999px);
  color: var(--accent-gold); font-size: 0.95rem;
  flex-shrink: 0; white-space: nowrap; -webkit-tap-highlight-color: transparent;
  transition: color .2s;
}
.home-trailer-nav-toggle.is-classic { color: var(--text-secondary); }
.home-trailer-nav-toggle:hover { color: var(--accent-gold); }
.home-trailer-nav-toggle:focus-visible { outline: 2px solid var(--accent-gold); outline-offset: 2px; }
/* 只放導覽相關規則（CLS-NAV 規格 §2a）：斷點與全站導覽一致 */
@media (max-width: 1279px) {
  .home-trailer-nav-toggle { display: inline-flex; }
  .home-trailer-toggle { display: none; }
}

.home-trailer-modal {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center; padding: 64px 16px 24px;
  background: rgba(5, 4, 3, 0.9);
  backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px);
}
.home-trailer-modal[hidden] { display: none; }
.home-trailer-modal video {
  display: block; height: auto; aspect-ratio: 16 / 9; background: #000;
  width: min(100%, 1280px, calc((100vh - 96px) * 16 / 9));
  width: min(100%, 1280px, calc((100dvh - 96px) * 16 / 9));
  border: 1px solid var(--border-gold); border-radius: 16px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.9), 0 0 40px rgba(var(--gold-rgb), 0.12);
}
.home-trailer-modal.is-portrait video {
  aspect-ratio: 9 / 16;
  width: min(100%, calc((100vh - 96px) * 9 / 16));
  width: min(100%, calc((100dvh - 96px) * 9 / 16));
}
.home-trailer-close {
  position: absolute; top: 14px; right: 16px; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border-gold); background: rgba(10, 9, 8, 0.6);
  color: var(--accent-gold); font-size: 26px; line-height: 1; cursor: pointer;
}
.home-trailer-close:hover { border-color: var(--accent-gold); background: rgba(var(--gold-rgb), 0.12); }
html.home-trailer-open { overflow: hidden; }

/* 登入的人按播放後、伺服器確認開始計時前（通常不到 1 秒）：疊在影片中央，隨時可按「直接觀看」跳出 */
.home-trailer-wait { display: none; }
.home-trailer-modal.is-waiting .home-trailer-wait {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  width: min(calc(100% - 32px), 420px); padding: 22px 20px; text-align: center;
  border: 1px solid var(--border-gold); border-radius: 16px; background: rgba(10, 9, 8, 0.82);
}
.home-trailer-wait-text { margin: 0; color: var(--accent-gold); font-size: 0.95rem; letter-spacing: 1px; }
.home-trailer-wait-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* 彩蛋卡（TRAILER-GIFT-SPEC）：播完、伺服器確認後取代影片 */
.home-trailer-gift { display: none; }
.home-trailer-modal.is-gift video { display: none; }
.home-trailer-modal.is-gift .home-trailer-gift {
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  width: min(100%, 520px); padding: 40px 28px 32px;
  border: 1px solid var(--border-gold); border-radius: 16px;
  background: rgba(10, 9, 8, 0.75);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.9), 0 0 40px rgba(var(--gold-rgb), 0.15);
}
.home-trailer-gift-icon { font-size: 2.6rem; line-height: 1; }
.home-trailer-gift-title { margin: 4px 0 0; color: var(--accent-gold); font: 700 1.35rem/1.4 'Noto Serif TC', serif; letter-spacing: 1px; }
.home-trailer-gift-sub { margin: 0; color: var(--text-primary); font-size: 0.95rem; line-height: 1.7; }
.home-trailer-gift-key { margin: 0; color: var(--text-secondary); font: 0.85rem/1.6 ui-monospace, monospace; letter-spacing: 1px; }
.home-trailer-gift-note { margin: 0; color: var(--accent-rose); font-size: 0.85rem; }
.home-trailer-gift-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 14px; }
.home-trailer-gift-actions .btn:disabled { opacity: 0.5; cursor: wait; }
