/**
 * 首頁主視覺輪播
 *
 * 第一張投影片預設就是 is-active，JS 失效時等於一張靜態主視覺。
 */

.hero {
  position: relative;
  min-height: min(46rem, 88vh);
  display: flex;
  align-items: center;
  overflow: hidden;
  background: var(--color-second);
}

.hero__stage { position: absolute; inset: 0; }

.hero__slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1.1s var(--ease-out);
}

.hero__slide.is-active { opacity: 1; }

.hero__bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.04);
}

/* Ken Burns 只加在目前顯示的那張，避免背景所有圖都在算動畫 */
.hero__slide.is-active .hero__bg {
  animation: hero-drift 9s linear forwards;
}

@keyframes hero-drift {
  from { transform: scale(1.04) translate3d(0, 0, 0); }
  to   { transform: scale(1.13) translate3d(-1.4%, -1.2%, 0); }
}

/* 漸層讓文字在任何照片上都讀得清楚 */
/*
 * 造形色塊已經提供文字區的對比，漸層只需要輕輕壓一下，
 * 壓太重會讓照片消失——照片是主體。
 */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(100deg, rgba(2, 27, 72, 0.62) 0%, rgba(2, 27, 72, 0.28) 42%, rgba(2, 27, 72, 0) 72%),
    linear-gradient(180deg, rgba(2, 27, 72, 0.28) 0%, transparent 30%);
}

.hero__inner {
  position: relative;
  z-index: 2;
  color: #fff;
  padding-block: var(--space-6);
}

/* ---- 上標籤 ---- */
.hero__eyebrow {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0 0 var(--space-2);
  font-family: var(--font-num);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--color-solar);
}

.hero__eyebrow::before {
  content: "";
  width: 2.6rem;
  height: 2px;
  background: var(--color-solar);
  transform-origin: left;
}

.js-motion .hero__eyebrow::before { transform: scaleX(0); animation: line-in 0.8s var(--ease-out) 0.2s forwards; }

@keyframes line-in { to { transform: scaleX(1); } }

/* ---- 遮罩式標題進場 ----
   對照 vision 站的 slideMask：文字從遮罩下方推上來，比單純淡入有力道。 */
.hero__title { font-size: var(--fs-hero); line-height: 1.12; letter-spacing: 0.02em; color: #fff; }
.hero__title small { display: block; margin-top: var(--space-2); font-size: var(--fs-2xl); font-weight: var(--fw-medium); color: var(--color-solar); }

.mask { display: block; overflow: hidden; }
.mask > span { display: block; }

.js-motion .mask > span {
  transform: translateY(110%);
  animation: mask-in 1s var(--ease-out) forwards;
}

.js-motion .hero__title .mask:nth-of-type(1) > span { animation-delay: 0.25s; }
.js-motion .hero__title .mask:nth-of-type(2) > span { animation-delay: 0.38s; }
.js-motion .hero__title small > span              { animation-delay: 0.52s; }

@keyframes mask-in { to { transform: translateY(0); } }

.hero__lead { margin-top: var(--space-3); max-width: 34rem; color: rgba(255, 255, 255, 0.9); }
.hero__actions { margin-top: var(--space-4); display: flex; gap: var(--space-2); flex-wrap: wrap; }

.js-motion .hero__lead,
.js-motion .hero__actions {
  opacity: 0;
  animation: hero-in 0.9s var(--ease-out) forwards;
}

.js-motion .hero__lead    { animation-delay: 0.62s; }
.js-motion .hero__actions { animation-delay: 0.74s; }

@keyframes hero-in {
  from { opacity: 0; transform: translateY(1.2rem); }
  to   { opacity: 1; transform: none; }
}

/* ---- 目前投影片的說明 ---- */
.hero__caption {
  margin: var(--space-5) 0 0;
  padding-left: 0.9rem;
  border-left: 3px solid var(--color-solar);
  font-size: var(--fs-sm);
  color: rgba(255, 255, 255, 0.82);
  transition: opacity 0.4s var(--ease-out);
}

.hero__caption.is-changing { opacity: 0; }

/* ---- 控制項 ---- */
.hero__controls {
  position: absolute;
  left: 50%;
  bottom: 1.6rem;
  z-index: 3;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  justify-content: flex-end;
}

.hero__arrow {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  line-height: 1;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background-color 0.25s var(--ease-out), transform 0.25s var(--ease-out);
}

.hero__arrow:hover { background: rgba(255, 255, 255, 0.26); transform: scale(1.08); }
.hero__arrow:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

.hero__dots { display: flex; gap: 0.55rem; }

.hero__dot {
  position: relative;
  width: 2.6rem;
  height: 4px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  overflow: hidden;
  transition: background-color 0.25s;
}

.hero__dot:hover { background: rgba(255, 255, 255, 0.5); }
.hero__dot:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }

/* 進度條：目前投影片的剩餘時間 */
.hero__dot-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  background: var(--color-solar);
  transform: scaleX(0);
  transform-origin: left;
}

.hero__dot.is-active .hero__dot-fill {
  animation: dot-progress var(--slide-duration, 7s) linear forwards;
}

.hero__dot.is-paused .hero__dot-fill { animation-play-state: paused; }

@keyframes dot-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---- 捲動提示 ---- */
.hero__scroll {
  position: absolute;
  left: 50%;
  bottom: 5.2rem;
  z-index: 3;
  width: 1.4rem;
  height: 2.2rem;
  margin-left: -0.7rem;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 1rem;
}

.hero__scroll::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0.4rem;
  width: 3px;
  height: 0.45rem;
  margin-left: -1.5px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 2px;
  animation: scroll-hint 1.8s ease-in-out infinite;
}

@keyframes scroll-hint {
  0%, 100% { opacity: 0; transform: translateY(0); }
  40%      { opacity: 1; transform: translateY(0.4rem); }
  80%      { opacity: 0; transform: translateY(0.75rem); }
}

@media (max-width: 800px) {
  .hero { min-height: 34rem; }
  .hero__controls { justify-content: center; bottom: 1.1rem; }
  .hero__arrow { width: 2.2rem; height: 2.2rem; font-size: 1.25rem; }
  .hero__dot { width: 1.8rem; }
  .hero__scroll { display: none; }
  .hero__caption { margin-top: var(--space-3); }
}

/* ---- 減少動態 ---- */
@media (prefers-reduced-motion: reduce) {
  .hero__slide.is-active .hero__bg { animation: none; }
  .js-motion .mask > span { transform: none; animation: none; }
  .js-motion .hero__lead,
  .js-motion .hero__actions { opacity: 1; animation: none; }
  .js-motion .hero__eyebrow::before { transform: scaleX(1); animation: none; }
  .hero__dot.is-active .hero__dot-fill { animation: none; transform: scaleX(1); }
  .hero__scroll { display: none; }
}

/* ---- 保險：JS 失效時把動畫相關的隱藏全部解除 ---- */
.motion-off .mask > span,
.motion-off .hero__lead,
.motion-off .hero__actions { transform: none !important; opacity: 1 !important; animation: none !important; }
.motion-off .hero__eyebrow::before { transform: scaleX(1) !important; animation: none !important; }
