/* ==========================================================================
   Gence tech 精視科技 - 全站統一工控光學網格與視覺節奏主題引擎 (Global Theme Engine)
   職責：集中統一管理全站所有頁面的背景漸層、光學校驗坐標方格子 (4rem x 4rem) 與邊框分隔線
   若要調整全站網格深淺、尺寸、色調或羽化，只需在此處微調，全站所有頁面立即同步生效！
   ========================================================================== */

:root {
  --bg-alt: linear-gradient(to bottom, #f1f5f9 0%, #ffffff 40%, #ffffff 60%, #f1f5f9 100%);
  --grid-line: rgba(148, 163, 184, 0.45);
  --grid-size: 4rem 4rem;
  --border-alt: rgba(226, 232, 240, 0.8);
  --grid-mask: radial-gradient(ellipse 70% 60% at 50% 50%, #000 40%, transparent 100%);

  --video-hero-bg: linear-gradient(180deg, rgba(3, 18, 55, 0.85) 0%, rgba(7, 32, 86, 0.75) 100%);
  --video-hero-border: rgba(59, 130, 246, 0.3);
  --video-hero-blur: 12px;
  --video-hero-py: 2rem;
}

.tech-grid-section {
  position: relative;
  background: var(--bg-alt) !important;
  overflow: hidden;
}

.tech-grid-section::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: var(--grid-size);
  -webkit-mask-image: var(--grid-mask);
  mask-image: var(--grid-mask);
  pointer-events: none;
  z-index: 0;
}

.tech-grid-section > * {
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   影片浮水印 (參數統一由 data/watermark-config.js 設定，js/watermark.js 自動掛載)
   - 字級用容器寬度百分比 (cqw)，卡片與全螢幕比例一致
   - 忽隱忽現：wm-breathe 呼吸動畫
   ========================================================================== */
.protected-asset:has(> video) {
  container-type: inline-size;
}

.protected-asset > video {
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.video-watermark {
  position: absolute;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: var(--wm-opacity, 0.16);
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.video-watermark span {
  display: block;
  white-space: nowrap;
  user-select: none;
  color: var(--wm-color, #fff);
  font-weight: var(--wm-weight, 800);
  letter-spacing: var(--wm-spacing, 0.12em);
  font-size: calc(var(--wm-size, 6.5) * 1cqw);
  text-shadow: var(--wm-shadow, 0 0 10px rgba(0,0,0,.95), 0 1px 4px rgba(0,0,0,.9));
  transform: translate(var(--wm-x, 0%), var(--wm-y, 0%)) rotate(var(--wm-rotate, -12deg));
}

/* 瀏覽器原生全螢幕 (桌機 / iPad / Android) */
.protected-asset:fullscreen,
.protected-asset:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  aspect-ratio: auto !important;
  background-color: #000 !important;
}

.protected-asset:fullscreen video,
.protected-asset:-webkit-full-screen video,
.protected-asset.pseudo-fs video {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
}

/* iPhone 等不支援容器全螢幕的裝置：改用滿版覆蓋模式，浮水印同樣保留 */
.protected-asset.pseudo-fs {
  position: fixed !important;
  inset: 0;
  z-index: 99999 !important;
  width: 100vw !important;
  height: 100dvh !important;
  aspect-ratio: auto !important;
  background: #000 !important;
  border-radius: 0 !important;
}

body.pseudo-fs-active { overflow: hidden; }
body.pseudo-fs-active header,
body.pseudo-fs-active #floating-dock { display: none !important; }

/* iPhone 自訂影片控制列 (取代原生控制列，讓放大後浮水印不消失) */
.vc-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 10px max(8px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0,0,0,.7), rgba(0,0,0,0));
  color: #fff;
  font-size: 12px;
}
.vc-bar button {
  background: none; border: 0; color: #fff;
  font-size: 18px; min-width: 36px; height: 36px; cursor: pointer;
}
.vc-time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.vc-seek { flex: 1; min-width: 0; accent-color: #fff; }

.pseudo-fs-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  z-index: 30;
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

/* ==========================================================================
   頁尾官方 QR Code 點擊放大燈箱 (預設隱藏，僅在點擊 #lightbox-footer-qr 時彈出)
   ========================================================================== */
#lightbox-footer-qr {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(2, 6, 23, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#lightbox-footer-qr:target {
  display: flex;
}

#lightbox-footer-qr .lightbox-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 34px;
  height: 34px;
  border-radius: 9999px;
  background: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: all 0.2s ease;
}

#lightbox-footer-qr .lightbox-close:hover {
  background: #005bb5;
  border-color: #60a5fa;
}
