/* ═══════════════════════════════════════════════════════════════
   楓橋美語 Maple Bridge — 全站動效系統 animations.css
   原則：只用 transform / opacity；支援 prefers-reduced-motion；
        沿用 style.css 既有 class 與設計變數，僅作漸進增強。
   ═══════════════════════════════════════════════════════════════ */

/* ── 動效設計變數 ─────────────────────────────────────────────── */
:root {
  --motion-fast: 180ms;
  --motion-base: 320ms;
  --motion-slow: 600ms;
  --ease-out:   cubic-bezier(.22, 1, .36, 1);
  --ease-brand: cubic-bezier(.2, .8, .2, 1);
}

/* ── 進場 reveal（IntersectionObserver 加上 .is-visible）────────── */
[data-reveal] {
  opacity: 0;
  transform: translate3d(0, 28px, 0);
  transition:
    opacity var(--motion-slow) var(--ease-out),
    transform var(--motion-slow) var(--ease-out);
  will-change: opacity, transform;
}
[data-reveal].is-visible { opacity: 1; transform: translate3d(0, 0, 0); }

[data-reveal="fade-left"]  { transform: translate3d(-28px, 0, 0); }
[data-reveal="fade-right"] { transform: translate3d(28px, 0, 0); }
[data-reveal="zoom"]       { transform: scale(.96); }
[data-reveal="zoom"].is-visible { transform: scale(1); }

/* ── stagger：群組逐項浮現 ───────────────────────────────────── */
[data-stagger] > * {
  opacity: 0;
  transform: translate3d(0, 24px, 0);
  transition:
    opacity var(--motion-slow) var(--ease-out),
    transform var(--motion-slow) var(--ease-out);
  transition-delay: calc(var(--i, 0) * 90ms);
  will-change: opacity, transform;
}
[data-stagger].is-visible > * { opacity: 1; transform: translate3d(0, 0, 0); }

/* ── 內頁 page-hero：文字分層進場 + 極淡光暈 ───────────────────── */
.page-hero { position: relative; overflow: hidden; }
.page-hero > * { position: relative; z-index: 1; }
.page-hero::after {
  content: "";
  position: absolute;
  inset: auto -10% -40% -10%;
  height: 70%;
  z-index: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,.13), transparent 58%);
  transform: translate3d(0, 12px, 0);
  pointer-events: none;
  animation: heroGlow 7s var(--ease-brand) infinite alternate;
}
@keyframes heroGlow {
  from { transform: translate3d(-2%, 12px, 0) scale(1);    opacity: .55; }
  to   { transform: translate3d(2%,  0,   0) scale(1.04);  opacity: .8; }
}
/* 實際 markup 使用 .en（小標）/ h1 / .lead（描述）/ .breadcrumb */
.page-hero .en,
.page-hero h1,
.page-hero .lead,
.page-hero .breadcrumb {
  opacity: 0;
  transform: translate3d(0, 18px, 0);
  animation: heroTextIn var(--motion-slow) var(--ease-out) forwards;
}
.page-hero .en         { animation-delay: 80ms; }
.page-hero h1          { animation-delay: 160ms; }
.page-hero .lead       { animation-delay: 260ms; }
.page-hero .breadcrumb { animation-delay: 360ms; }
@keyframes heroTextIn {
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

/* ── 首頁 #hero：背景 Ken Burns + 文字分層進場 ─────────────────── */
#hero { position: relative; overflow: hidden; }
#hero .hero-bg img {
  transform: scale(1);
  animation: kenburnsHero 9s var(--ease-brand) forwards;
  will-change: transform;
}
@keyframes kenburnsHero { to { transform: scale(1.06); } }

#hero .badge,
#hero .hero-text h1,
#hero .hero-text .subtitle,
#hero .hero-text > p:not(.subtitle),
#hero .hero-buttons {
  opacity: 0;
  transform: translate3d(0, 22px, 0);
  animation: heroTextIn 700ms var(--ease-out) forwards;
}
#hero .badge                       { animation-delay: 100ms; }
#hero .hero-text h1                { animation-delay: 220ms; }
#hero .hero-text .subtitle         { animation-delay: 300ms; }
#hero .hero-text > p:not(.subtitle){ animation-delay: 380ms; }
#hero .hero-buttons                { animation-delay: 480ms; }

/* ── 按鈕 hover / active / focus-visible ─────────────────────── */
.btn,
.nav-cta,
.footer-cta-btn,
.contact-btn,
.contact-btn--line {
  transition:
    transform var(--motion-fast) var(--ease-out),
    box-shadow var(--motion-fast) var(--ease-out),
    background-color var(--motion-fast) var(--ease-out),
    color var(--motion-fast) var(--ease-out);
}
.footer-cta-btn:hover,
.contact-btn:hover,
.contact-btn--line:hover {
  transform: translate3d(0, -2px, 0);
  box-shadow: 0 10px 24px rgba(0,0,0,.14);
}
.btn:active,
.nav-cta:active,
.footer-cta-btn:active,
.contact-btn:active,
.contact-btn--line:active { transform: scale(.98); }

.btn i,
.nav-cta i,
.footer-cta-btn i { transition: transform var(--motion-fast) var(--ease-out); }
.btn:hover i,
.nav-cta:hover i,
.footer-cta-btn:hover i { transform: translate3d(2px, 0, 0) scale(1.06); }

.btn:focus-visible,
.nav-cta:focus-visible,
.footer-cta-btn:focus-visible,
.contact-btn:focus-visible,
.contact-btn--line:focus-visible {
  outline: 3px solid rgba(204, 22, 22, .35);
  outline-offset: 3px;
}
/* LINE 綠 / 電話紅 專屬光暈 */
.footer-cta-btn--line:hover,
.contact-btn--line:hover { box-shadow: 0 10px 24px rgba(6, 199, 85, .26); }
.footer-cta-btn--phone:hover,
.contact-btn:hover       { box-shadow: 0 10px 24px rgba(204, 22, 22, .20); }

/* ── 通用卡片 hover：motion-card ─────────────────────────────── */
.motion-card {
  transition:
    transform var(--motion-base) var(--ease-out),
    box-shadow var(--motion-base) var(--ease-out);
  will-change: transform;
}
.motion-card:hover {
  transform: translate3d(0, -6px, 0);
  box-shadow: 0 18px 36px rgba(0,0,0,.12);
}
.motion-card .icon,
.motion-card i,
.motion-card svg { transition: transform var(--motion-base) var(--ease-out); }
.motion-card:hover .course-icon-wrap i,
.motion-card:hover .feature-icon i,
.motion-card:hover > .icon i { transform: scale(1.08) rotate(-3deg); }

/* 課程卡 icon */
.course-card .course-icon-wrap {
  transition:
    transform var(--motion-base) var(--ease-out),
    background-color var(--motion-base) var(--ease-out);
}
.course-card:hover .course-icon-wrap {
  transform: scale(1.1) rotate(-5deg);
  background-color: rgba(204, 22, 22, .14);
}
/* 課程標籤 chips */
.course-tag {
  transition:
    transform var(--motion-fast) var(--ease-out),
    background-color var(--motion-fast) var(--ease-out),
    color var(--motion-fast) var(--ease-out);
}
.course-card:hover .course-tag {
  transform: translate3d(0, -1px, 0);
  background-color: rgba(204, 22, 22, .08);
  color: var(--primary);
}

/* about 特色 icon 微互動 */
.feature-item .feature-icon {
  transition:
    transform var(--motion-base) var(--ease-out),
    background-color var(--motion-base) var(--ease-out);
}
.feature-item:hover .feature-icon { transform: scale(1.08) rotate(-4deg); }

/* about 浮動徽章浮現 */
.about-photo-col .about-floating-badge {
  transition:
    opacity var(--motion-slow) var(--ease-out),
    transform var(--motion-slow) var(--ease-out);
  transition-delay: 350ms;
}
.about-photo-col[data-reveal]:not(.is-visible) .about-floating-badge,
.about-photo-col.reveal:not(.visible) .about-floating-badge {
  opacity: 0;
  transform: translate3d(0, 18px, 0) scale(.96);
}
.about-photo-col:hover .about-floating-badge { transform: translate3d(0, -4px, 0); }

/* 國家卡 hover 景深 + pill */
.country-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: radial-gradient(circle at 20% 20%, rgba(255,255,255,.16), transparent 36%);
  opacity: .5;
  transform: translate3d(-8px, -8px, 0);
  transition:
    opacity var(--motion-base) var(--ease-out),
    transform var(--motion-base) var(--ease-out);
  pointer-events: none;
}
.country-card:hover::before { opacity: .85; transform: translate3d(0, 0, 0); }
.country-card .country-tag {
  transition:
    background-color var(--motion-base) var(--ease-out),
    letter-spacing var(--motion-base) var(--ease-out),
    transform var(--motion-base) var(--ease-out);
}
.country-card:hover .country-tag {
  background-color: rgba(255,255,255,.18);
  letter-spacing: .26em;
  transform: translate3d(0, -2px, 0);
}

/* ── 圖片外層 image-motion：hover zoom + 亮度 ─────────────────── */
.image-motion { overflow: hidden; }
.image-motion img {
  display: block;
  width: 100%;
  transform: scale(1);
  transition:
    transform 700ms var(--ease-out),
    filter 700ms var(--ease-out);
}
.image-motion:hover img { transform: scale(1.04); filter: brightness(1.04) saturate(1.04); }

/* ── 導覽列底線 hover ────────────────────────────────────────── */
.nav-links a::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0;
  transform: translate3d(-50%, 4px, 0) scaleX(.4);
  transition:
    opacity var(--motion-fast) var(--ease-out),
    transform var(--motion-fast) var(--ease-out);
}
.nav-links a:hover::after,
.nav-links a.active::after {
  opacity: 1;
  transform: translate3d(-50%, 0, 0) scaleX(1);
}

/* ── section-title 小標進場（與既有 .reveal 並用）──────────────── */
.section-title.visible .en,
[data-reveal].is-visible .section-kicker {
  animation: kickerIn 520ms var(--ease-out) both;
}
@keyframes kickerIn {
  from { opacity: 0; letter-spacing: .26em; transform: translate3d(0, 8px, 0); }
  to   { opacity: 1; letter-spacing: .2em;  transform: translate3d(0, 0, 0); }
}

/* ── 平滑捲動 / 固定 header 偏移 ─────────────────────────────── */
section[id] { scroll-margin-top: calc(var(--nav-h, 76px) + 12px); }

/* ── contact 電話卡數字進場 ─────────────────────────────────── */
.contact-phone-big.visible .number,
.contact-phone-big.is-visible .number,
[data-reveal].is-visible .contact-phone-big .number {
  animation: numberPop 460ms var(--ease-out) both;
}
@keyframes numberPop {
  from { opacity: 0; transform: scale(.94); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── 地圖 iframe skeleton shimmer → 載入後淡入 ──────────────── */
.contact-map { position: relative; }
.contact-map::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
  pointer-events: none;
}
.contact-map.is-loaded::before { display: none; }
.contact-map iframe {
  opacity: 0;
  transition: opacity 400ms var(--ease-out);
}
.contact-map.is-loaded iframe { opacity: 1; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* ── gallery lightbox ───────────────────────────────────────── */
.gallery-item img { cursor: zoom-in; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms var(--ease-out);
}
.lightbox.is-open { opacity: 1; pointer-events: auto; }
.lightbox img {
  max-width: min(92vw, 1100px);
  max-height: 86vh;
  border-radius: 18px;
  transform: scale(.96);
  transition: transform 240ms var(--ease-out);
}
.lightbox.is-open img { transform: scale(1); }
.lightbox-close {
  position: absolute;
  top: 24px;
  right: 28px;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,.14);
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--motion-fast) var(--ease-out), transform var(--motion-fast) var(--ease-out);
}
.lightbox-close:hover { background: rgba(255,255,255,.28); transform: scale(1.06); }

/* ── 降低動態：完整尊重 prefers-reduced-motion ──────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  html { scroll-behavior: auto; }
  [data-reveal],
  [data-stagger] > * { opacity: 1 !important; transform: none !important; }
  .page-hero::after,
  #hero .hero-bg img { animation: none !important; }
  .page-hero .en,
  .page-hero h1,
  .page-hero .lead,
  .page-hero .breadcrumb,
  #hero .badge,
  #hero .hero-text h1,
  #hero .hero-text .subtitle,
  #hero .hero-text > p:not(.subtitle),
  #hero .hero-buttons {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .about-photo-col .about-floating-badge { opacity: 1 !important; transform: none !important; }
  .contact-map::before { display: none !important; }
  .contact-map iframe { opacity: 1 !important; }
}
