/* ============================================================
   固执小铺 · iOS 手感动效层
   点击回弹（果冻） / 页面推进过渡 / 弹性弹窗 / 卡片浮入
   只动 transform、opacity，不触发重排，滚动不掉帧
   ============================================================ */

:root {
  /* 果冻感的来源：y 值 > 1，冲过终点再弹回来 */
  --ios-spring: cubic-bezier(.34, 1.56, .64, 1);
  --ios-spring-soft: cubic-bezier(.26, 1.30, .38, 1);
  --ios-ease: cubic-bezier(.22, 1, .36, 1);
  --ios-ease-in: cubic-bezier(.4, 0, 1, 1);
}

/* 去掉安卓/微信里那层灰色方块高亮，换成我们自己的回弹 */
html { -webkit-tap-highlight-color: transparent; }

/* ---------------- 1. 页面进场（iOS 推进感） ---------------- */
@keyframes iosPageFade { from { opacity: 0 } to { opacity: 1 } }

@keyframes iosHeaderIn {
  from { opacity: 0; transform: translate3d(0, -14px, 0) }
  to   { opacity: 1; transform: translate3d(0, 0, 0) }
}

/* 桌面：内容从下方轻轻浮起 */
@keyframes iosMainIn {
  from { opacity: 0; transform: translate3d(0, 16px, 0) scale(.988) }
  to   { opacity: 1; transform: none }
}

/* 手机：从右侧推进来（和 iOS 页面跳转一个方向） */
@keyframes iosMainInMobile {
  from { opacity: .35; transform: translate3d(30px, 0, 0) scale(.982) }
  to   { opacity: 1; transform: none }
}

body { animation: iosPageFade .26s var(--ios-ease) backwards; }
body > .site-header { animation: iosHeaderIn .5s var(--ios-spring) backwards; }
body > #main { animation: iosMainIn .52s var(--ios-spring-soft) backwards; }

@media (max-width: 768px) {
  body > #main { animation-name: iosMainInMobile; animation-duration: .46s; }
}

/* ---------------- 2. 页面离场 ---------------- */
body.ios-leaving { animation: none; cursor: progress; }

body.ios-leaving > .site-header,
body.ios-leaving > #main {
  opacity: 0;
  transition: opacity .15s linear, transform .19s var(--ios-ease-in);
  will-change: opacity, transform;
}
body.ios-leaving > #main { transform: translate3d(-16px, 0, 0) scale(.984); }
body.ios-leaving > .site-header { transform: translate3d(0, -10px, 0); }

/* ---------------- 3. 卡片 / 列表浮入 ---------------- */
@keyframes iosRise {
  from { opacity: 0; transform: translate3d(0, 20px, 0) scale(.958) }
  to   { opacity: 1; transform: none }
}

.ios-rise {
  animation: iosRise .54s var(--ios-spring) backwards;
  animation-delay: calc(var(--ios-i, 0) * 46ms + 30ms);
}

/* ---------------- 4. 弹窗 / 面板：弹簧弹出 ---------------- */
@keyframes iosPopIn {
  0%   { opacity: 0; transform: translate3d(0, -20px, 0) scale(.93) }
  58%  { opacity: 1; transform: translate3d(0, 3px, 0) scale(1.014) }
  100% { opacity: 1; transform: none }
}

@keyframes iosSheetUp {
  0%   { opacity: 0; transform: translate3d(0, 30px, 0) scale(.955) }
  60%  { opacity: 1; transform: translate3d(0, -3px, 0) scale(1.008) }
  100% { opacity: 1; transform: none }
}

@keyframes iosDropIn {
  from { opacity: 0; transform: translate3d(0, -9px, 0) scale(.95) }
  to   { opacity: 1; transform: none }
}

/* 顶部搜索弹窗 */
.search-modal-body { animation: iosPopIn .46s var(--ios-spring) both; }

/* 店铺客服面板 */
.cs-panel.cs-show { animation: iosSheetUp .46s var(--ios-spring) both; transform-origin: bottom right; }

/* 顶栏下拉菜单 */
.header-user-menu,
.nav-dropdown-menu { transform-origin: top center; }
.header-user-dropdown.open .header-user-menu { animation: iosDropIn .34s var(--ios-spring) both; }
.nav-dropdown:hover .nav-dropdown-menu { animation: iosDropIn .3s var(--ios-spring) both; }

/* 客服气泡逐条冒出 */
@keyframes iosBubbleIn {
  from { opacity: 0; transform: translate3d(0, 10px, 0) scale(.94) }
  to   { opacity: 1; transform: none }
}
.cs-msg { animation: iosBubbleIn .38s var(--ios-spring) backwards; }

/* ---------------- 5. 侧滑菜单：弹性滑入 + 逐项浮现 ---------------- */
@media (max-width: 768px) {
  .mobile-nav.mobile-nav--shown { transition: transform .46s var(--ios-spring); }
  .mobile-nav-backdrop.mobile-nav--shown.is-open { transition: opacity .3s var(--ios-ease); }
}

@keyframes iosMenuRowIn {
  from { opacity: 0; transform: translate3d(22px, 0, 0) }
  to   { opacity: 1; transform: none }
}

.mobile-nav.mobile-nav--shown.open .mobile-nav-inner > * {
  animation: iosMenuRowIn .42s var(--ios-spring) backwards;
}
.mobile-nav.mobile-nav--shown.open .mobile-nav-inner > *:nth-child(1) { animation-delay: .05s }
.mobile-nav.mobile-nav--shown.open .mobile-nav-inner > *:nth-child(2) { animation-delay: .09s }
.mobile-nav.mobile-nav--shown.open .mobile-nav-inner > *:nth-child(3) { animation-delay: .13s }
.mobile-nav.mobile-nav--shown.open .mobile-nav-inner > *:nth-child(4) { animation-delay: .17s }
.mobile-nav.mobile-nav--shown.open .mobile-nav-inner > *:nth-child(5) { animation-delay: .21s }
.mobile-nav.mobile-nav--shown.open .mobile-nav-inner > *:nth-child(6) { animation-delay: .25s }
.mobile-nav.mobile-nav--shown.open .mobile-nav-inner > *:nth-child(7) { animation-delay: .29s }
.mobile-nav.mobile-nav--shown.open .mobile-nav-inner > *:nth-child(n+8) { animation-delay: .32s }

/* ---------------- 6. 顶栏：滚动时轻轻收一下 ---------------- */
body > .site-header {
  transition: transform .36s var(--ios-ease), box-shadow .34s var(--ios-ease), background .3s ease, border-radius .34s var(--ios-ease);
}
body.ios-scrolled > .site-header {
  transform: translate3d(0, -3px, 0) scale(.988);
  box-shadow: 0 16px 40px rgba(31, 38, 135, .17), 0 2px 8px rgba(15, 23, 42, .06), var(--glass-inset);
}

/* ---------------- 7. 骨架屏：一束光扫过 ---------------- */
@keyframes iosShimmer {
  0%   { transform: translate3d(-120%, 0, 0) }
  100% { transform: translate3d(120%, 0, 0) }
}
.sk-card { position: relative; overflow: hidden; }
.sk-card::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; width: 60%;
  background: linear-gradient(100deg, rgba(255,255,255,0) 0%, rgba(255,255,255,.72) 50%, rgba(255,255,255,0) 100%);
  animation: iosShimmer 1.5s ease-in-out infinite;
  pointer-events: none;
}

/* ---------------- 8. 通用：元素刚插入时的轻弹（供 JS 调用） ---------------- */
@keyframes iosSoftPop {
  0%   { opacity: 0; transform: scale(.92) }
  60%  { opacity: 1; transform: scale(1.018) }
  100% { opacity: 1; transform: none }
}
.ios-pop { animation: iosSoftPop .42s var(--ios-spring) backwards; }

/* ---------------- 9. 尊重「减弱动态效果」 ---------------- */
@media (prefers-reduced-motion: reduce) {
  body,
  body > .site-header,
  body > #main,
  .ios-rise,
  .ios-pop,
  .search-modal-body,
  .cs-panel.cs-show,
  .cs-msg,
  .header-user-dropdown.open .header-user-menu,
  .nav-dropdown:hover .nav-dropdown-menu,
  .sk-card::after,
  .mobile-nav.mobile-nav--shown.open .mobile-nav-inner > * {
    animation: none !important;
  }
  body.ios-leaving > .site-header,
  body.ios-leaving > #main,
  body > .site-header,
  body.ios-scrolled > .site-header,
  .mobile-nav.mobile-nav--shown {
    transition: none !important;
  }
}
