/* ============================================================
   Hero Showcase v2 — 真實作品裝置牆 + AI 生成敘事
   v2 變更:
   · 放棄 preserve-3d 深度排序(部分瀏覽器與透明度疊加會互相穿透),
     改用平面 transform + 明確 z-index,所有瀏覽器渲染一致
   · 前景卡片轉正、放大,截圖在框內緩慢縱向平移(網站「活」起來)
   · 底部光暈 + 浮動,讓裝置落在場景裡而不是貼補丁
   ============================================================ */

/* 影片壓暗,讓前景作品成為主角 */
.hero-video.loaded { opacity: .32; }
.hero:after {
  background: linear-gradient(120deg, rgba(13,27,42,.82) 0%, rgba(13,27,42,.55) 45%, rgba(6,16,27,.88) 100%);
}

/* ---------- 兩欄版面 ---------- */
@media (min-width: 961px) {
  .hero { padding-top: 104px; padding-bottom: 56px; }
}
.hero .wrap.hero-wrap {
  max-width: 1380px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(36px, 4vw, 60px);
  align-items: center;
}
.hero-copy { min-width: 0; }
.hero h1 { font-size: clamp(30px, 3.4vw, 46px); }
.hero-stats { gap: clamp(20px, 2.4vw, 36px); }

/* ---------- AI BUILD 列 ---------- */
.ai-build-bar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 18px; padding: 10px 16px;
  border: 1px solid rgba(0,212,255,.25); border-radius: 10px;
  background: rgba(6,16,27,.55);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  font-size: 13px; white-space: nowrap; overflow: hidden;
}
.ai-build-led {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: #2ee87e; box-shadow: 0 0 10px #2ee87e;
  animation: ai-led 1.6s ease-in-out infinite;
}
@keyframes ai-led { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.ai-build-label {
  font-family: 'Orbitron', sans-serif; font-size: 10px;
  letter-spacing: 3px; color: #00d4ff; flex: none;
}
.ai-build-prompt {
  color: rgba(255,255,255,.78);
  overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.ai-caret {
  width: 7px; height: 15px; flex: none; background: #00d4ff;
  animation: ai-caret .9s steps(1) infinite;
}
@keyframes ai-caret { 50% { opacity: 0; } }

/* ---------- 舞台(平面堆疊,不用 preserve-3d) ---------- */
.hero-showcase {
  position: relative; z-index: 2;
  animation: showcase-float 7s ease-in-out infinite alternate;
}
@keyframes showcase-float { from { transform: translateY(-5px); } to { transform: translateY(5px); } }

.showcase-stage {
  position: relative;
  height: clamp(330px, 29vw, 426px);
  /* 只保留極輕的整體傾斜 + 滑鼠視差,perspective 直接寫在 transform 內 */
  transform: perspective(1600px) rotateX(calc(1.5deg + var(--my, 0deg))) rotateY(calc(-4deg + var(--mx, 0deg)));
  transition: transform .3s ease-out;
}
/* 底部光暈:把裝置「放進」場景 */
.showcase-stage::before {
  content: ""; position: absolute; z-index: 0;
  left: 4%; right: -2%; bottom: -30px; height: 70px;
  background: radial-gradient(ellipse at center, rgba(0,212,255,.22), rgba(0,212,255,0) 70%);
  filter: blur(22px);
  pointer-events: none;
}

.bframe {
  position: absolute; inset: 0; margin: 0;
  border-radius: 12px; overflow: hidden;
  background: #0b1520;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 26px 60px rgba(0,0,0,.5), 0 0 0 1px rgba(0,212,255,.06);
  transition: transform .8s cubic-bezier(.22,1,.36,1), opacity .8s ease, filter .8s ease;
  will-change: transform, opacity;
  cursor: pointer;
}
/* 平面堆疊:z-index 決定遮蓋,前景完全不透明,絕不互相穿透 */
.bframe.pos-front {
  transform: translate(0, 0) scale(1);
  opacity: 1; z-index: 3; filter: none;
  box-shadow: 0 34px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(0,212,255,.1), 0 0 50px rgba(0,212,255,.08);
}
.bframe.pos-mid {
  transform: translate(40px, -22px) scale(.92);
  opacity: .5; z-index: 2; filter: saturate(.55) brightness(.6);
}
.bframe.pos-back {
  transform: translate(78px, -44px) scale(.85);
  opacity: .26; z-index: 1; filter: saturate(.4) brightness(.42);
}

/* 瀏覽器外框 */
.bframe-bar {
  position: relative; z-index: 5;
  display: flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px;
  background: #101c2a; border-bottom: 1px solid rgba(255,255,255,.08);
}
.bframe-bar .bd { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.bd.r { background: #ff5f57; } .bd.y { background: #febc2e; } .bd.g { background: #28c840; }
.bframe-url {
  margin-left: 10px; flex: 1; min-width: 0;
  font-style: normal; font-size: 11.5px; letter-spacing: .4px; text-align: center;
  color: rgba(255,255,255,.55); background: rgba(255,255,255,.06);
  border-radius: 6px; padding: 4px 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bframe-body {
  position: relative; height: calc(100% - 34px);
  background: #0b1520; overflow: hidden;
}
/* 預設(無 JS 時的 fallback):cover 靜態顯示 */
.bframe-body img {
  position: relative; z-index: 2; display: block;
  width: 100%; height: 100%;
  object-fit: cover; object-position: top center;
}
/* JS 量好尺寸後啟用:截圖緩慢縱向平移,模擬瀏覽網站
   --panY / --pan-dur 由 JS 依圖高計算 */
.bframe-body img.panning {
  position: absolute; top: 0; left: 50%;
  width: auto; height: auto; max-width: none;
  object-fit: fill;
  transform: translate(-50%, 0);
  animation: bf-pan var(--pan-dur, 10s) ease-in-out 1.6s infinite alternate;
}
@keyframes bf-pan {
  from { transform: translate(-50%, 0); }
  to   { transform: translate(-50%, var(--panY, 0px)); }
}
/* 非前景卡片暫停平移,省 GPU */
.bframe:not(.pos-front) .bframe-body img.panning { animation-play-state: paused; }

/* skeleton 佔位(位於截圖下層,只在 build 揭示過程露出) */
.bframe-skeleton {
  position: absolute; inset: 0; z-index: 1;
  padding: 8% 7%; display: flex; flex-direction: column; gap: 7%;
}
.bframe-skeleton i {
  display: block; border-radius: 6px;
  background: linear-gradient(100deg, rgba(255,255,255,.05) 35%, rgba(0,212,255,.16) 50%, rgba(255,255,255,.05) 65%);
  background-size: 240% 100%;
  animation: skel 1.4s linear infinite;
}
.bframe-skeleton i:nth-child(1) { height: 16%; width: 55%; }
.bframe-skeleton i:nth-child(2) { height: 8%;  width: 80%; }
.bframe-skeleton i:nth-child(3) { height: 8%;  width: 70%; }
.bframe-skeleton i:nth-child(4) { height: 26%; width: 100%; }
.bframe-skeleton i:nth-child(5) { height: 11%; width: 40%; }
@keyframes skel { to { background-position: -140% 0; } }

/* build 揭示:掃描線由上而下掃過,截圖隨之展開
   (此動畫只在 .building 存在的 1.3 秒內生效,結束後 JS 移除 class,平移接手) */
.bframe.building .bframe-body img {
  animation: bf-reveal 1.15s cubic-bezier(.45,0,.2,1) both;
}
@keyframes bf-reveal {
  from { clip-path: inset(0 0 100% 0); }
  to   { clip-path: inset(0 0 0 0); }
}
.bframe-scan {
  position: absolute; z-index: 3; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, transparent, #00d4ff 30%, #7bdfff 50%, #00d4ff 70%, transparent);
  box-shadow: 0 0 16px rgba(0,212,255,.9);
  opacity: 0; pointer-events: none;
}
.bframe.building .bframe-scan { animation: bf-scan 1.15s cubic-bezier(.45,0,.2,1) both; }
@keyframes bf-scan {
  0%   { top: 0; opacity: 1; }
  92%  { opacity: 1; }
  100% { top: calc(100% - 3px); opacity: 0; }
}

/* 指示條 */
.showcase-dots { display: flex; gap: 8px; justify-content: center; margin-top: 22px; }
.showcase-dots b {
  width: 22px; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,.18); cursor: pointer;
  transition: background .3s, width .3s, box-shadow .3s;
}
.showcase-dots b.on {
  width: 34px; background: #00d4ff;
  box-shadow: 0 0 8px rgba(0,212,255,.6);
}

/* ---------- 響應式 ---------- */
@media (max-width: 960px) {
  .hero .wrap.hero-wrap { grid-template-columns: 1fr; gap: 44px; }
  .hero-showcase { width: 100%; max-width: 560px; margin: 0 auto; }
  .showcase-stage { height: clamp(240px, 54vw, 350px); transform: perspective(1200px) rotateX(1deg) rotateY(-2.5deg); }
  .bframe.pos-mid  { transform: translate(24px, -14px) scale(.93); }
  .bframe.pos-back { transform: translate(46px, -28px) scale(.86); }
}

/* ---------- prefers-reduced-motion:全部降級為淡入淡出 ---------- */
@media (prefers-reduced-motion: reduce) {
  .hero-showcase { animation: none; }
  .showcase-stage { transform: none; transition: none; }
  .bframe { transition: opacity .4s ease; }
  .bframe.pos-front, .bframe.pos-mid, .bframe.pos-back { transform: none; }
  .bframe-body img.panning { animation: none; }
  .bframe.building .bframe-body img { animation: none; clip-path: none; }
  .bframe.building .bframe-scan { animation: none; }
  .ai-build-led, .ai-caret, .bframe-skeleton i { animation: none; }
}
