/* ============================================
 * loading.css —— Dynamic Island · 高级加载动效
 * 启动页（Splash + 真实进度）/ 顶部进度条 / 灵动岛激活脉冲
 *
 * 设计规范落地：
 *   · 仅动画 transform / opacity；进度用 transform: scaleX + origin:left
 *   · --lp-ease-out 进入退出 / --lp-ease-in-out 屏幕内形变 / hover ease 150ms
 *   · 微交互 120ms / 标准 200ms / 整页 280ms；退出 240ms（快于进入 280ms）
 *   · 入场初始态 scale(0.95)；模糊 ≤ 20px
 *   · hover 包在 @media (hover: hover) and (pointer: fine)
 *   · reduced-motion 下循环动画以负 delay 暂停在好看的帧，保留 opacity
 * 兼容既有 CSP：外链样式（style-src 'self'），无任何外部资源。
 * ============================================ */

:root {
  --lp-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --lp-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --lp-dur-micro: 120ms;
  --lp-dur-ui: 200ms;
  --lp-dur-page: 280ms;
}

/* ============ 启动页 Splash ============ */
#lpSplash {
  --p: 0;
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  background: radial-gradient(ellipse at 50% 32%, #1a1a26 0%, #0a0a10 62%, #000 100%);
  opacity: 1;
  will-change: transform, opacity;
  transition: opacity 240ms var(--lp-ease-out), transform 240ms var(--lp-ease-out);
}
#lpSplash.lp-gone { opacity: 0; transform: scale(0.96); pointer-events: none; }

/* 品牌标记：灵动岛形状 + 呼吸光圈 */
.lp-mark { position: relative; width: 96px; height: 34px; display: grid; place-items: center; }
.lp-mark > span {
  width: 92px; height: 32px; border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.02) 45%, rgba(0,0,0,.16));
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255,255,255,.17);
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; gap: 5px;
  overflow: hidden;
}
.lp-mark i { width: 5px; height: 5px; border-radius: 50%; background: rgba(255,255,255,.5); will-change: transform, opacity; }
.lp-mark i:nth-child(1) { background: #5cacff; animation: lpDot 1.1s var(--lp-ease-in-out) infinite; }
.lp-mark i:nth-child(2) { background: #c44dff; animation: lpDot 1.1s var(--lp-ease-in-out) -0.16s infinite; }
.lp-mark i:nth-child(3) { background: #4ade80; animation: lpDot 1.1s var(--lp-ease-in-out) -0.32s infinite; }
@keyframes lpDot {
  0%, 100% { opacity: .3; transform: scale(0.8); }
  50%      { opacity: 1;  transform: scale(1.3); }
}

.lp-mark::before, .lp-mark::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 92px; height: 32px; margin: -16px 0 0 -46px; border-radius: 16px;
  border: 1px solid rgba(255,255,255,.16);
  will-change: transform, opacity;
  animation: lpRing 2.2s var(--lp-ease-out) infinite;
}
.lp-mark::after { animation-delay: -1.1s; }
@keyframes lpRing {
  0%   { transform: scale(0.85); opacity: 0; }
  30%  { opacity: 0.8; }
  100% { transform: scale(2.6); opacity: 0; }
}

/* 品牌字：入场 scale(0.95) → 1 */
.lp-word {
  display: flex; flex-direction: column; align-items: center; gap: 5px; margin-top: 6px;
  animation: lpEnter 280ms var(--lp-ease-out) both;
}
.lp-title { font-size: 15px; font-weight: 600; letter-spacing: .3em; text-indent: .3em; color: #f2f2f7; }
.lp-sub { font-size: 10.5px; letter-spacing: .18em; color: rgba(235,235,245,.45); }
@keyframes lpEnter {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

/* 真实进度条 */
.lp-bar {
  --p: 0;
  position: relative; width: min(210px, 58vw); height: 2px; border-radius: 2px;
  background: rgba(255,255,255,.12); overflow: hidden;
}
.lp-bar > i {
  position: absolute; inset: 0; border-radius: 2px;
  transform: scaleX(var(--p)); transform-origin: left center;
  background: linear-gradient(90deg, #5cacff, #c44dff);
  transition: transform 200ms var(--lp-ease-out);
  will-change: transform;
}
.lp-bar::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 40px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent);
  will-change: transform;
  animation: lpShimmer 1.5s linear infinite;
}
@keyframes lpShimmer {
  from { transform: translate3d(-50px, 0, 0); }
  to   { transform: translate3d(240px, 0, 0); }
}
.lp-pct { font-size: 10px; font-variant-numeric: tabular-nums; color: rgba(235,235,245,.45); letter-spacing: .1em; }
.lp-stage { font-size: 11.5px; color: rgba(235,235,245,.8); min-height: 15px; }

/* ============ 顶部进度条 ============ */
#lpTop {
  --p: 0;
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 9998;
  pointer-events: none;
  background: rgba(255,255,255,.07);
  opacity: 0;
  transition: opacity var(--lp-dur-ui) var(--lp-ease-out);
  will-change: opacity;
}
#lpTop.lp-on { opacity: 1; }
#lpTop > i {
  position: absolute; inset: 0; display: block;
  transform: scaleX(var(--p)); transform-origin: left center;
  background: linear-gradient(90deg, #5cacff, #c44dff);
  transition: transform 180ms var(--lp-ease-out), opacity 180ms var(--lp-ease-out);
  will-change: transform;
}
/* 头部亮点：与进度条同 duration / 同 easing */
#lpTop > b {
  position: absolute; top: 0; left: 0; width: 28px; height: 2px;
  background: linear-gradient(90deg, transparent, #fff);
  border-radius: 0 2px 2px 0;
  transform: translate3d(calc(var(--p) * (100vw - 28px)), 0, 0);
  transform-origin: left center;
  opacity: 0.9;
  transition: transform 180ms var(--lp-ease-out), opacity 180ms var(--lp-ease-out);
  will-change: transform;
}
/* 收尾：冲到 100% 后淡出 */
#lpTop.lp-done > i,
#lpTop.lp-done > b { opacity: 0; }
#lpTop.lp-done { background: transparent; }

/* ============ 灵动岛激活脉冲（等待/进行中） ============ */
/* 活动开始时给岛一圈向外扩散的微光，强化"有事发生"的感知 */
.island.lp-pulse::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  will-change: box-shadow, opacity;
  animation: lpIslandPulse 850ms var(--lp-ease-out);
}
@keyframes lpIslandPulse {
  0%   { opacity: 1; box-shadow: 0 0 0 0 rgba(255,255,255,.34); }
  100% { opacity: 0; box-shadow: 0 0 0 14px rgba(255,255,255,0); }
}

/* 紧凑态活动进行中：传感器呼吸（循环，ease-in-out） */
.island.lp-live .sensor-dot {
  animation: lpSensorBreathe 1.9s var(--lp-ease-in-out) infinite;
  will-change: transform, opacity;
}
@keyframes lpSensorBreathe {
  0%, 100% { opacity: 0.7; transform: scale(0.94); }
  50%      { opacity: 1;  transform: scale(1.06); }
}

/* ============ Hover（仅精确指针设备） ============ */
@media (hover: hover) and (pointer: fine) {
  .island:hover { filter: brightness(1.06); transition: filter 150ms ease; }
}

/* ============ 减弱动态 ============ */
@media (prefers-reduced-motion: reduce) {
  /* 去transform / 缩放；循环动画负 delay 停在好看的帧；保留 opacity */
  #lpSplash.lp-gone { transform: none; }
  .lp-word { animation: none; opacity: 1; transform: none; }
  .lp-mark i { animation: none; opacity: .8; transform: none; }
  .lp-mark::before,
  .lp-mark::after { animation: none; opacity: .5; }
  .lp-bar::after { animation: none; }
  .island.lp-pulse::after { animation: none; opacity: 0; }
  .island.lp-live .sensor-dot { animation: none; opacity: 1; transform: none; }
  .lp-bar > i, #lpTop > i, #lpTop > b { transition-duration: 1ms !important; }
  #lpSplash, #lpTop { transition-duration: 120ms !important; }
}