/* ============================================================
   創藝裝璜工程公司 — 前沿動效層 (motion.css)
   獨立於 style.css，只做視覺增強，不覆蓋現有佈局
   手機 / prefers-reduced-motion 自動降級
   ============================================================ */

:root {
  --m-ease: cubic-bezier(.16, 1, .3, 1);
  --m-ease-soft: cubic-bezier(.4, 0, .2, 1);
  --m-gold: #e2bd7d;
}

/* ---------- 1. 頂部捲動進度條 ---------- */
.m-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  z-index: 1200;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: linear-gradient(90deg, #c8a05f, #f3ddb0 55%, #d9b271);
  box-shadow: 0 0 14px rgba(226, 189, 125, .55);
  pointer-events: none;
  will-change: transform;
}

/* ---------- 2. Hero 極光 + 滑鼠光暈 ---------- */
.m-aurora {
  position: absolute;
  inset: -35%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(34% 30% at 24% 30%, rgba(226, 189, 125, .20), transparent 62%),
    radial-gradient(30% 28% at 78% 22%, rgba(120, 150, 255, .15), transparent 62%),
    radial-gradient(36% 32% at 62% 84%, rgba(255, 150, 170, .10), transparent 62%);
  filter: blur(46px);
  opacity: .85;
  animation: mAurora 20s ease-in-out infinite alternate;
  will-change: transform;
}
@keyframes mAurora {
  0%   { transform: translate3d(-2.5%, -1.5%, 0) scale(1); }
  100% { transform: translate3d(3.5%, 2.5%, 0) scale(1.15); }
}
.m-spot {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(520px circle at var(--mx, 70%) var(--my, 40%), rgba(255, 255, 255, .10), transparent 62%);
  opacity: 0;
  transition: opacity .5s ease;
}
.hero:hover .m-spot { opacity: 1; }

/* ---------- 3. Hero 標題逐行揭幕 ---------- */
.m-line {
  display: block;
  overflow: hidden;
  padding-bottom: .14em;
  margin-bottom: -.14em;
}
.m-line-i {
  display: inline-block;
  transform: translateY(115%);
  opacity: 0;
  will-change: transform, opacity;
}
.hero.m-ready .m-line-i { animation: mLineUp 1s var(--m-ease) forwards; }
.hero.m-ready .m-line:nth-child(1) .m-line-i { animation-delay: .06s; }
.hero.m-ready .m-line:nth-child(2) .m-line-i { animation-delay: .18s; }
@keyframes mLineUp {
  to { transform: translateY(0); opacity: 1; }
}

/* ---------- 4. 導覽底線 + 目前區塊標示（桌機） ---------- */
@media (min-width: 769px) {
  .main-nav a:not(.nav-cta) { position: relative; }
  .main-nav a:not(.nav-cta)::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -7px;
    height: 1.5px;
    background: currentColor;
    opacity: .9;
    transform: scaleX(0);
    transform-origin: 100% 50%;
    transition: transform .45s var(--m-ease);
  }
  .main-nav a:not(.nav-cta):hover::after,
  .main-nav a.is-current::after {
    transform: scaleX(1);
    transform-origin: 0 50%;
  }
  .main-nav a.is-current { opacity: 1; }
}

/* ---------- 5. 按鈕光澤掃過 ---------- */
.btn { position: relative; overflow: hidden; }
.btn::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: -120%;
  width: 55%;
  z-index: 0;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .38), transparent);
  transform: skewX(-18deg);
  transition: left .7s var(--m-ease);
  pointer-events: none;
}
.btn:hover::before { left: 145%; }
.btn-outline::before,
.btn-outline-dark::before {
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .16), transparent);
}

/* ---------- 6. 卡片 3D 傾斜（桌機） ---------- */
@media (hover: hover) and (pointer: fine) {
  .m-tilt {
    transform: perspective(1000px) rotateX(var(--m-rx, 0deg)) rotateY(var(--m-ry, 0deg)) translate3d(0, var(--m-ty, 0px), 0) !important;
    transition: transform .55s var(--m-ease), box-shadow .3s ease, border-color .3s ease !important;
  }
  .m-tilt:hover { --m-ty: -6px; }
}

/* ---------- 7. 回到頂部 ---------- */
.m-top {
  position: fixed;
  right: 22px;
  bottom: 24px;
  z-index: 90;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 20, 22, .72);
  color: #f5f5f7;
  border: 1px solid rgba(255, 255, 255, .18);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .28);
  cursor: pointer;
  opacity: 0;
  transform: translateY(16px) scale(.9);
  pointer-events: none;
  transition: opacity .4s var(--m-ease), transform .4s var(--m-ease), background .25s ease;
}
.m-top.show { opacity: 1; transform: none; pointer-events: auto; }
.m-top:hover { background: rgba(20, 20, 22, .92); }
.m-top svg { width: 18px; height: 18px; }
html.theme-dark .m-top {
  background: rgba(245, 245, 247, .92);
  color: #1d1d1f;
  border-color: rgba(0, 0, 0, .12);
}

/* ---------- 8. 區塊標題細節線 ---------- */
.section-head h2 { position: relative; }
.section-head h2::after {
  content: "";
  display: block;
  width: 46px;
  height: 2px;
  margin: 20px auto 0;
  background: linear-gradient(90deg, transparent, var(--m-gold), transparent);
  opacity: .85;
}

/* ---------- 9. 品牌跑馬燈 ---------- */
.m-marquee {
  overflow: hidden;
  background: var(--ink);
  color: var(--white);
  padding: 15px 0;
  white-space: nowrap;
  border-top: 1px solid rgba(255, 255, 255, .06);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.m-marquee-track {
  display: inline-flex;
  align-items: center;
  gap: 28px;
  padding-left: 28px;
  animation: mMarquee 30s linear infinite;
  will-change: transform;
}
.m-marquee-track span {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .04em;
}
.m-marquee-track i {
  font-style: normal;
  color: var(--m-gold);
  font-size: 11px;
}
.m-marquee:hover .m-marquee-track { animation-play-state: paused; }
@keyframes mMarquee { to { transform: translateX(-50%); } }

/* ---------- 10. 手機降級 ---------- */
@media (max-width: 768px) {
  .m-aurora { opacity: .5; filter: blur(40px); }
  .section-head h2::after { margin-top: 16px; width: 38px; }
  .m-top { right: 16px; bottom: 18px; width: 42px; height: 42px; }
  .m-marquee { padding: 12px 0; }
  .m-marquee-track { gap: 20px; padding-left: 20px; }
  .m-marquee-track span { font-size: 13px; }
}

/* ---------- 11. 減少動態 ---------- */
@media (prefers-reduced-motion: reduce) {
  .m-aurora,
  .m-spot,
  .m-progress { display: none !important; }
  .m-line-i { transform: none !important; opacity: 1 !important; animation: none !important; }
  .btn::before { display: none !important; }
  .m-top { transition: none !important; }
  .m-marquee-track { animation: none !important; }
}

/* ---------- 12. 卡片滑鼠聚光（高階質感） ---------- */
.m-spotlight { position: relative; }
.m-spotlight::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity .5s ease;
  background:
    radial-gradient(300px circle at var(--sx, 50%) var(--sy, 50%), rgba(226, 189, 125, .22), rgba(226, 189, 125, .05) 42%, transparent 70%);
}
.m-spotlight:hover::after { opacity: 1; }
.m-spotlight > * { position: relative; z-index: 1; }

/* ---------- 13. 工程流程捲動激活 ---------- */
.process-item {
  transition: transform .5s var(--m-ease), box-shadow .5s var(--m-ease), border-color .5s ease;
}
.process-item::before {
  transition: background .5s ease, color .5s ease, border-color .5s ease, box-shadow .5s ease, transform .5s var(--m-ease);
}
.process-item.m-on::before {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  box-shadow: 0 0 0 6px rgba(226, 189, 125, .22);
  transform: scale(1.06);
}
html.theme-dark .process-item.m-on::before {
  background: var(--accent);
  color: #1d1d1f;
  border-color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  .m-spotlight::after { display: none !important; }
  .process-item::before { transition: none !important; }
}
