/* =================================================== */
/* 首页动效：幽灵猫插画分层 3D 卡片                          */
/* 桌面：指针驱动倾斜 / 移动：陀螺仪 + 拖拽 / 逐层深度视差      */
/* 分层素材由 PSD 自动拆分，见 assets/home-hero/layers.json   */
/* =================================================== */

.hero-art {
  display: block;
  position: relative;
  width: 100%;
  max-width: 560px;
  margin: 1.6rem auto 1rem;
  padding: 0;
  /* 3D 透视放在外层，卡片本身的 rotateX/Y 才有纵深感 */
  perspective: 1000px;
  perspective-origin: 50% 50%;
}

.hero-art__stage {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 22px;
  overflow: hidden;
  /* 与原图背景同色系：图层还没加载/入场时就已是这张卡片的底色，不会露出空框 */
  background: #2c1b4c;
  background-image: linear-gradient(
    180deg,
    #2c1b4c 0%,
    #33205a 30%,
    #412b64 50%,
    #5a4483 70%,
    #7b61ae 87%,
    #a384de 100%
  );
  box-shadow:
    0 18px 44px -18px rgba(58, 24, 90, .55),
    0 0 0 1px rgba(153, 102, 204, .22) inset;
  transform-origin: 50% 50%;
  transform: rotateX(0deg) rotateY(0deg);
  /* 触摸时横向拖拽交给卡片，纵向仍然正常滚动页面 */
  touch-action: pan-y;
  will-change: transform;
  transition: box-shadow .4s ease;
}

.hero-art:hover .hero-art__stage,
.hero-art:focus-within .hero-art__stage {
  box-shadow:
    0 30px 64px -22px rgba(58, 24, 90, .7),
    0 0 0 1px rgba(153, 102, 204, .34) inset;
}

/* 视差层：translate 与入场动画的 transform 互不干扰 */
.hero-art__layer {
  position: absolute;
  opacity: 0;
  translate: 0 0;
  will-change: translate;
}

/* 背景层不参与淡入：卡片一出现就是原来的底色，而不是先露一个空框 */
.hero-art__layer[data-kind="bg"] {
  opacity: 1;
}

.hero-art__stage.is-ready .hero-art__layer {
  animation: hero-in .9s cubic-bezier(.22, .75, .35, 1) both;
  animation-delay: var(--in, 0s);
}

.hero-art__stage.is-ready .hero-art__layer[data-kind="bg"] {
  animation: none;
}

.hero-art__img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 !important;
  max-width: none !important;
  animation-duration: var(--dur, 8s);
  animation-delay: var(--d, 0s);
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
  animation-fill-mode: both;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.hero-art.is-paused .hero-art__img {
  animation-play-state: paused;
}

/* 移动端体感授权（仅 iOS 需要），授权后自动移除 */
.hero-art__hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  translate: -50% 0;
  z-index: 9999;
  margin: 0;
  padding: .38rem .85rem;
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 999px;
  background: rgba(30, 18, 48, .55);
  color: #f2ecff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: .02em;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: background .2s ease, opacity .3s ease;
}

.hero-art__hint:hover {
  background: rgba(46, 28, 72, .75);
}

/* 入场：淡入 + 轻微上浮 */
@keyframes hero-in {
  from { opacity: 0; transform: translateY(16px) scale(.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* 猫：缓慢呼吸浮动 */
@keyframes hero-bob {
  0%, 100% { transform: translateY(0) }
  50%      { transform: translateY(calc(var(--bob, 5px) * -1)) }
}

/* 爱心 / 月亮：更柔的漂浮 */
@keyframes hero-drift {
  0%, 100% { transform: translate(0, 0) }
  33%      { transform: translate(var(--dx, 4px), calc(var(--dy, 6px) * -1)) }
  66%      { transform: translate(calc(var(--dx, 4px) * -1), calc(var(--dy, 6px) * -1 * .4)) }
}

/* 方块：像素闪烁 */
@keyframes hero-twinkle {
  0%, 100% { opacity: 1 }
  50%      { opacity: .35 }
}

/* 线条：极慢漂移 + 呼吸 */
@keyframes hero-sway {
  0%, 100% { transform: translate(0, 0) }
  50%      { transform: translate(var(--dx, 3px), var(--dy, -3px)) }
}

/* 雾：缓慢流动 */
@keyframes hero-fog {
  0%, 100% { opacity: .78; transform: translate(0, 0) scale(1) }
  50%      { opacity: .52; transform: translate(8px, -6px) scale(1.03) }
}

.hero-art__img.k-cat    { animation-name: hero-bob; }
.hero-art__img.k-moon   { animation-name: hero-drift; }
.hero-art__img.k-heart  { animation-name: hero-drift; }
.hero-art__img.k-line   { animation-name: hero-sway; }
.hero-art__img.k-square { animation-name: hero-twinkle; }
.hero-art__img.k-fog    { animation-name: hero-fog; }
.hero-art__img.k-bg     { animation: none; }

/* 无障碍：偏好减少动态时完全静止，也不做倾斜 */
@media (prefers-reduced-motion: reduce) {
  .hero-art__layer,
  .hero-art__img {
    animation: none !important;
  }
  .hero-art__layer { opacity: 1; }
  .hero-art__img { opacity: 1; }
  .hero-art { perspective: none; }
  .hero-art__stage { transform: none !important; }
}

@media screen and (max-width: 44.984em) {
  .hero-art {
    width: 92vw;
    max-width: 92vw;
    margin: 1rem auto .8rem;
  }
  .hero-art__stage { border-radius: 18px; }
}
