/* ==========================================================================
 * 天策AI (tiancexai.com) 动效与交互质感增强包 v1 (c)
 * 适配范围：首页 #tc-home3 · 商品详情页 #tc-pdp4 · 顶部导航与主题切换
 * 严格保留原有商品封面图 (.h3-art / .p4-art)、角标定位 (.h3-badge) 与分站白标逻辑
 * ========================================================================== */

@property --tc-orbit-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

@property --tc-orbit-rev {
  syntax: "<angle>";
  inherits: false;
  initial-value: 360deg;
}

:root {
  --tc-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --tc-ease-standard: cubic-bezier(0.32, 0.72, 0, 1);
  --tc-ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --tc-dur-hover: 150ms;
  --tc-dur-press: 75ms;
  --tc-dur-spring: 420ms;
  --tc-spot-fill: rgba(15, 122, 85, 0.09);
  --tc-spot-rim: rgba(19, 160, 111, 0.62);
}

@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --tc-ease-spring: linear(
      0, 0.009, 0.035 2.1%, 0.141 4.4%, 0.281 6.7%,
      0.723 12.9%, 0.938 16.7%, 1.017 19.4%, 1.061 22.1%,
      1.072 24.3%, 1.066 27.4%, 1.036 32.8%, 1.009 39.6%,
      0.996 46.9%, 0.993 53.8%, 0.998 69.8%, 1
    );
  }
}

html.dark {
  --tc-spot-fill: rgba(43, 224, 122, 0.13);
  --tc-spot-rim: rgba(43, 224, 122, 0.72);
}

/* ---------- 0. 首屏各大区块错峰丝滑入场（一刷新立刻可见） ---------- */
#tc-home3 .h3-hero {
  animation: tc-sec-enter 460ms var(--tc-ease-out) both;
}

#tc-home3 .h3-tools {
  animation: tc-sec-enter 460ms var(--tc-ease-out) 70ms both;
}

#tc-home3 .h3-pp {
  animation: tc-sec-enter 460ms var(--tc-ease-out) 140ms both;
}

#tc-home3 .h3-sec {
  animation: tc-sec-enter 460ms var(--tc-ease-out) 190ms both;
}

#tc-pdp4 .p4-card {
  animation: tc-sec-enter 420ms var(--tc-ease-out) both;
}

@keyframes tc-sec-enter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.992);
    filter: blur(3px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

/* ---------- 1. 物理弹簧按压反馈（按钮 / 胶囊 / SKU / 支付块） ---------- */
#tc-home3 .h3-btn,
#tc-home3 .h3-btn2,
#tc-home3 .h3-pb,
#tc-home3 .h3-cats button,
#tc-home3 .h3-in button,
#tc-pdp4 .p4-submit,
#tc-pdp4 .p4-sku,
#tc-pdp4 .p4-tile,
#tc-pdp4 .p4-qty button {
  transition:
    transform var(--tc-dur-spring) var(--tc-ease-spring),
    scale var(--tc-dur-spring) var(--tc-ease-spring),
    box-shadow var(--tc-dur-hover) var(--tc-ease-out),
    border-color var(--tc-dur-hover) var(--tc-ease-out),
    background-color var(--tc-dur-hover) var(--tc-ease-out),
    color var(--tc-dur-hover) var(--tc-ease-out);
}

#tc-home3 .h3-btn:hover,
#tc-pdp4 .p4-submit:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -6px rgba(19, 160, 111, 0.58);
}

html.dark #tc-home3 .h3-btn:hover,
html.dark #tc-pdp4 .p4-submit:not(:disabled):hover {
  box-shadow: 0 12px 30px -6px rgba(43, 224, 122, 0.52);
}

/* 主按钮流光扫掠 */
#tc-home3 .h3-btn,
#tc-pdp4 .p4-submit {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

#tc-home3 .h3-btn::after,
#tc-pdp4 .p4-submit::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    105deg,
    transparent 26%,
    rgba(255, 255, 255, 0.34) 50%,
    transparent 74%
  );
  transform: translateX(-120%);
  transition: transform 540ms var(--tc-ease-out);
}

#tc-home3 .h3-btn:hover::after,
#tc-pdp4 .p4-submit:not(:disabled):hover::after {
  transform: translateX(120%);
}

#tc-home3 .h3-btn:active,
#tc-home3 .h3-btn2:active,
#tc-home3 .h3-pb:active,
#tc-home3 .h3-cats button:active,
#tc-home3 .h3-pc:active,
#tc-pdp4 .p4-submit:not(:disabled):active,
#tc-pdp4 .p4-sku:not(:disabled):active,
#tc-pdp4 .p4-tile:not(:disabled):active,
#tc-pdp4 .p4-qty button:not(:disabled):active {
  scale: 0.965;
  transition-duration: var(--tc-dur-press);
}

/* ---------- 2. Hero 右侧模型星轨舞台：双环反向流光 + 错峰悬浮 + 鼠标微视差 ---------- */
#tc-home3 .h3-hr {
  --px: 0;
  --py: 0;
  overflow: hidden;
  isolation: isolate;
}

#tc-home3 .h3-hr::before {
  content: "";
  position: absolute;
  inset: -20%;
  pointer-events: none;
  background: radial-gradient(
    circle at calc(50% + var(--px) * 24px) calc(50% + var(--py) * 24px),
    rgba(43, 224, 122, 0.22),
    transparent 60%
  );
}

#tc-home3 .h3-ring {
  transition: transform 240ms var(--tc-ease-out);
  transform: translate3d(calc(var(--px) * 6px), calc(var(--py) * 6px), 0);
}

/* 内圈（金色反向流光，9秒一圈） */
#tc-home3 .h3-ring:nth-of-type(1)::after {
  content: "";
  position: absolute;
  inset: -1.5px;
  border-radius: 50%;
  padding: 1.5px;
  background: conic-gradient(
    from var(--tc-orbit-rev),
    transparent 0deg,
    transparent 250deg,
    rgba(245, 196, 81, 0.9) 345deg,
    transparent 360deg
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: tc-orbit-ccw 9s linear infinite;
  pointer-events: none;
}

/* 中圈（翡翠绿正向流光，11秒一圈） */
#tc-home3 .h3-ring:nth-of-type(2) {
  border-color: rgba(255, 255, 255, 0.1);
}

#tc-home3 .h3-ring:nth-of-type(2)::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  padding: 2px;
  background: conic-gradient(
    from var(--tc-orbit-angle),
    transparent 0deg,
    transparent 240deg,
    rgba(43, 224, 122, 0.85) 330deg,
    rgba(224, 177, 60, 0.85) 355deg,
    transparent 360deg
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: tc-orbit-spin 11s linear infinite;
  pointer-events: none;
}

#tc-home3 .h3-core {
  animation: tc-core-breathe 3.6s ease-in-out infinite;
  transform: translate3d(calc(var(--px) * 10px), calc(var(--py) * 10px), 0);
  transition:
    transform 220ms var(--tc-ease-out),
    scale 320ms var(--tc-ease-spring),
    box-shadow 240ms var(--tc-ease-out);
}

#tc-home3 .h3-core:hover {
  scale: 1.08;
}

#tc-home3 .h3-sv {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.65);
  animation: tc-pill-float 3.8s ease-in-out infinite;
  transform: translate3d(calc(var(--px) * -14px), calc(var(--py) * -14px), 0);
  transition:
    transform 220ms var(--tc-ease-out),
    scale 320ms var(--tc-ease-spring),
    background-color 180ms var(--tc-ease-out),
    border-color 180ms var(--tc-ease-out);
}

#tc-home3 .h3-sv:nth-of-type(5) { animation-delay: 0s; }
#tc-home3 .h3-sv:nth-of-type(6) { animation-delay: -0.9s; }
#tc-home3 .h3-sv:nth-of-type(7) { animation-delay: -1.8s; }
#tc-home3 .h3-sv:nth-of-type(8) { animation-delay: -2.7s; }
#tc-home3 .h3-sv:nth-of-type(9) { animation-delay: -3.3s; }

#tc-home3 .h3-sv:hover {
  scale: 1.06;
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(43, 224, 122, 0.7);
}

#tc-home3 .h3-sv i {
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.75);
  animation: tc-dot-pulse 2.2s ease-in-out infinite;
}

@keyframes tc-orbit-spin {
  to { --tc-orbit-angle: 360deg; }
}

@keyframes tc-orbit-ccw {
  to { --tc-orbit-rev: 0deg; }
}

@keyframes tc-core-breathe {
  0%, 100% { box-shadow: 0 0 34px rgba(19, 160, 111, 0.5); }
  50% { box-shadow: 0 0 64px rgba(43, 224, 122, 0.9), 0 0 22px rgba(245, 196, 81, 0.38); }
}

@keyframes tc-pill-float {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -6px; }
}

@keyframes tc-dot-pulse {
  0%, 100% { opacity: 1; scale: 1; }
  50% { opacity: 0.55; scale: 0.8; }
}

/* ---------- 3. 光标跟随聚光灯 + 1.5px 高光追光边框（覆盖全部大卡片与商品卡） ---------- */
#tc-home3 .h3-hero,
#tc-home3 .h3-pc,
#tc-home3 .h3-tc,
#tc-home3 .h3-pp,
#tc-home3 .h3-how {
  position: relative;
  isolation: isolate;
}

#tc-home3 .h3-pc {
  overflow: hidden;
  transition:
    transform var(--tc-dur-spring) var(--tc-ease-spring),
    scale var(--tc-dur-spring) var(--tc-ease-spring),
    border-color 180ms var(--tc-ease-out),
    box-shadow 220ms var(--tc-ease-out);
}

#tc-home3 .h3-pc:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 38px -16px rgba(0, 0, 0, 0.55), 0 0 24px -10px rgba(43, 224, 122, 0.25);
}

#tc-home3 .h3-pc .h3-art {
  transition: transform 360ms var(--tc-ease-spring);
}

#tc-home3 .h3-pc:hover .h3-art {
  transform: scale(1.055) translateY(-1px);
}

@media (hover: hover) and (pointer: fine) {
  #tc-home3 .h3-pc::before,
  #tc-home3 .h3-tc::before,
  #tc-home3 .h3-pp::before,
  #tc-home3 .h3-how::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: -1;
    background: radial-gradient(
      300px circle at var(--mx, 50%) var(--my, 50%),
      var(--tc-spot-fill),
      transparent 70%
    );
    opacity: 0;
    transition: opacity 200ms var(--tc-ease-out);
  }

  #tc-home3 .h3-pc::after,
  #tc-home3 .h3-tc::after,
  #tc-home3 .h3-pp::after,
  #tc-home3 .h3-how::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1.5px;
    pointer-events: none;
    z-index: 3;
    background: radial-gradient(
      210px circle at var(--mx, 50%) var(--my, 50%),
      var(--tc-spot-rim),
      transparent 72%
    );
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 160ms var(--tc-ease-out);
  }

  #tc-home3 .h3-pc:hover::before,
  #tc-home3 .h3-pc:hover::after,
  #tc-home3 .h3-tc:hover::before,
  #tc-home3 .h3-tc:hover::after,
  #tc-home3 .h3-pp:hover::before,
  #tc-home3 .h3-pp:hover::after,
  #tc-home3 .h3-how:hover::before,
  #tc-home3 .h3-how:hover::after {
    opacity: 1;
  }
}

/* ---------- 4. 分类胶囊弹簧滑块 + 商品网格错峰浮现 ---------- */
#tc-home3 #h3-cats {
  position: relative;
  isolation: isolate;
}

#tc-home3 #h3-cats[data-pill-ready="1"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: var(--pill-w, 0px);
  height: var(--pill-h, 0px);
  transform: translate3d(var(--pill-x, 0px), var(--pill-y, 0px), 0);
  border-radius: 99px;
  background: linear-gradient(135deg, #16a06f, #0f7a55);
  box-shadow: 0 6px 18px -5px rgba(15, 122, 85, 0.6);
  z-index: 0;
  pointer-events: none;
  transition:
    transform 360ms var(--tc-ease-spring),
    width 320ms var(--tc-ease-spring),
    height 320ms var(--tc-ease-spring);
}

html.dark #tc-home3 #h3-cats[data-pill-ready="1"]::before {
  background: linear-gradient(135deg, #1aa874, #0f7a55);
  box-shadow: 0 6px 20px -5px rgba(43, 224, 122, 0.45);
}

#tc-home3 #h3-cats[data-pill-ready="1"] button {
  position: relative;
  z-index: 1;
}

#tc-home3 #h3-cats[data-pill-ready="1"] button.on {
  background: transparent !important;
  border-color: transparent !important;
  color: #fff !important;
  font-weight: 700;
}

#tc-home3 #h3-grid > .tc-card-enter {
  animation: tc-card-rise 320ms var(--tc-ease-out) calc(var(--stagger, 0) * 26ms) both;
}

@keyframes tc-card-rise {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
    filter: blur(2.5px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

/* ---------- 5. 详情页 #tc-pdp4 价格数字滚轮跳动 & 选中态高光 ---------- */
#tc-home3 .h3-pr,
#tc-pdp4 .p4-price,
#tc-pdp4 .p4-total,
#tc-pdp4 .p4-fee {
  font-variant-numeric: tabular-nums;
}

#tc-pdp4 .p4-price.tc-price-pop {
  animation: tc-price-roll 240ms var(--tc-ease-out) both;
}

@keyframes tc-price-roll {
  0% {
    opacity: 0.3;
    transform: translateY(6px);
    filter: blur(2.5px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

#tc-pdp4 .p4-sku.on,
#tc-pdp4 .p4-tile.on {
  box-shadow: 0 0 0 1px var(--p-green), 0 8px 22px -10px rgba(43, 224, 122, 0.48);
}

/* ---------- 6. View Transitions 无闪烁明暗主题切换 ---------- */
html.tc-theme-vt *,
html.tc-theme-vt *::before,
html.tc-theme-vt *::after {
  transition: none !important;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 320ms;
  animation-timing-function: var(--tc-ease-out);
}

/* ---------- 7. 系统级减弱动态效果兜底 ---------- */
@media (prefers-reduced-motion: reduce) {
  #tc-home3 *,
  #tc-home3 *::before,
  #tc-home3 *::after,
  #tc-pdp4 *,
  #tc-pdp4 *::before,
  #tc-pdp4 *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scale: none !important;
  }
}
