/* ==========================================================================
   黄岩智慧园区 · 第二阶段场景动效层
   原则：真实数据、渐进增强、短促反馈、可关闭；不引入外部运行依赖。
   ========================================================================== */
:root {
  --pms-motion-fast: 160ms;
  --pms-motion-base: 320ms;
  --pms-motion-scene: 560ms;
  --pms-motion-ease: cubic-bezier(.22, 1, .36, 1);
  --pms-motion-standard: cubic-bezier(.2, 0, 0, 1);
}

@keyframes pmsReveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pmsRouteEnter {
  from { opacity: .35; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pmsDialogIn {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes pmsFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pmsAgentIn {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pmsSceneScan {
  0% { opacity: 0; transform: translateY(-65%); }
  25% { opacity: .32; }
  100% { opacity: 0; transform: translateY(65%); }
}
@keyframes pmsMapNode {
  0%, 100% { opacity: .58; }
  50% { opacity: 1; }
}
@keyframes pmsBoundary {
  0%, 100% { opacity: .48; }
  50% { opacity: .88; }
}

/* ---------- 管理后台：只动画容器，不逐行动画表格 ---------- */
html.pms-motion-ok .pms-reveal {
  animation: pmsReveal var(--pms-motion-base) var(--pms-motion-ease) backwards;
  animation-delay: var(--pms-reveal-delay, 0ms);
}
html.pms-motion-ok .mask.on { animation: pmsFadeIn var(--pms-motion-fast) ease-out backwards; }
html.pms-motion-ok .mask.on .dlg {
  animation: pmsDialogIn 260ms var(--pms-motion-ease) backwards;
  transform-origin: 50% 42%;
}
html.pms-motion-ok .pms-number { font-variant-numeric: tabular-nums; }

.top .top-btn.pms-motion-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  white-space: nowrap;
}
.pms-motion-toggle::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8fb7ff;
  box-shadow: 0 0 0 3px rgba(104, 165, 255, .12);
}
.pms-motion-toggle[aria-pressed="false"]::before { background: #a7b4c8; box-shadow: none; }

/* 工作台唯一的场景化区域：全景视差 + 低对比空间网格。 */
html.pms-motion-ok .wb-hero { isolation: isolate; }
html.pms-motion-ok .wb-hero::after {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(137, 182, 255, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(137, 182, 255, .08) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(90deg, transparent 20%, #000 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 20%, #000 100%);
}
html.pms-motion-ok .wb-hero-bg {
  inset: -8px;
  transform: translate3d(var(--pms-hero-x, 0px), var(--pms-hero-y, 0px), 0) scale(1.025);
  transition: transform 480ms var(--pms-motion-ease);
  will-change: transform;
}
html.pms-motion-ok .wb-hero-in { z-index: 2; }
html.pms-motion-ok .wb-tile,
html.pms-motion-ok .wb-kpi,
html.pms-motion-ok .kpi {
  transition-property: transform, box-shadow, border-color, background-color;
  transition-duration: var(--pms-motion-fast);
  transition-timing-function: var(--pms-motion-standard);
}
html.pms-motion-ok .wb-ring { will-change: background; }

/* ---------- 智能体：让查询阶段和结果层级更清楚 ---------- */
html.pms-motion-ok .agent-page .msg {
  animation: pmsAgentIn 300ms var(--pms-motion-ease) backwards;
}
html.pms-motion-ok .agent-page .msg.bot .card {
  box-shadow: 0 12px 32px rgba(28, 69, 139, .075), 0 1px 2px rgba(18, 45, 91, .04);
}
html.pms-motion-ok .agent-page .msg.bot .card-head {
  background: linear-gradient(90deg, rgba(47, 107, 255, .045), transparent 62%);
}
html.pms-motion-ok .agent-page .msg.bot .metric {
  animation: pmsReveal 320ms var(--pms-motion-ease) backwards;
}
html.pms-motion-ok .agent-page .msg.bot .metric:nth-child(2) { animation-delay: 45ms; }
html.pms-motion-ok .agent-page .msg.bot .metric:nth-child(3) { animation-delay: 90ms; }
html.pms-motion-ok .agent-page .msg.bot .metric:nth-child(4) { animation-delay: 135ms; }
html.pms-motion-ok .agent-page .msg.loading .dot { animation-timing-function: var(--pms-motion-standard); }

/* ---------- 驾驶舱：三屏转场、一次性扫描、可停止的自动巡屏 ---------- */
.ck-tour {
  --pms-tour-progress: 0%;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid rgba(104, 165, 255, .28);
  border-radius: 15px;
  color: #bcd5f7;
  background: rgba(17, 49, 96, .66);
  font: 11px/1 "Microsoft YaHei UI", sans-serif;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--pms-motion-fast), border-color var(--pms-motion-fast), background var(--pms-motion-fast);
}
.ck-tour::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: conic-gradient(#76a9ff var(--pms-tour-progress), rgba(118, 169, 255, .16) 0);
  box-shadow: inset 0 0 0 3px #102d5a;
}
.ck-tour:hover { color: #fff; border-color: rgba(118, 169, 255, .62); background: rgba(32, 77, 143, .72); }
.ck-tour[aria-pressed="true"] { color: #fff; border-color: #68a5ff; background: rgba(47, 107, 255, .32); }
.ck-tour:focus-visible { outline: 2px solid #8bb6ff; outline-offset: 3px; }

html.pms-motion-ok body[data-view] .view > .panel {
  animation: pmsReveal 400ms var(--pms-motion-ease) backwards;
}
html.pms-motion-ok body[data-view] .view > .panel:nth-child(2) { animation-delay: 45ms; }
html.pms-motion-ok body[data-view] .view > .panel:nth-child(3) { animation-delay: 90ms; }
html.pms-motion-ok body.pms-scene-enter .stage::after {
  content: "";
  position: absolute;
  z-index: 4;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 15%, rgba(92, 141, 255, .04) 42%, rgba(104, 165, 255, .28) 50%, rgba(92, 141, 255, .04) 58%, transparent 85%);
  animation: pmsSceneScan 620ms var(--pms-motion-standard) backwards;
}
html.pms-motion-ok .mk { animation-duration: 420ms; }
html.pms-motion-ok .mk-dot::after { animation: none; }
html.pms-motion-ok .mk.on .mk-dot::after { animation: mkPulse 1.2s ease-out 2; }
html.pms-motion-ok .mk-name { transition-duration: var(--pms-motion-fast); }
html.pms-motion-ok .dock-bar > i,
html.pms-motion-ok .lv-bar > i { transition: width 700ms var(--pms-motion-ease); }

/* Pro 叙事页沿用相同语言；动效只落在真实边界和配套点位。 */
html.pms-motion-ok .view.on > .panel {
  animation: pmsReveal 400ms var(--pms-motion-ease) backwards;
}
html.pms-motion-ok .view.on > .panel:nth-child(2) { animation-delay: 55ms; }
html.pms-motion-ok .map-svg .bl rect,
html.pms-motion-ok .map-svg .ld circle { transition: fill 220ms, stroke 220ms, filter 220ms; }
html.pms-motion-ok .map-svg .bl:hover rect { filter: drop-shadow(0 0 7px rgba(104, 165, 255, .52)); }
html.pms-motion-ok .map-svg > path:nth-of-type(2) { animation: pmsBoundary 5s ease-in-out 2; }
html.pms-motion-ok .map-svg .pt circle { animation: pmsMapNode 2.8s ease-in-out 2; }
html.pms-motion-ok .map-svg .pt circle:nth-child(2) { animation-delay: .45s; }
html.pms-motion-ok .map-svg .pt circle:nth-child(3) { animation-delay: .9s; }

/* Pro 服务闭环：宽屏保持内容密度，避免卡片和饼图被拉成整屏留白。 */
.view.on[data-v="service"] .panel.wide .service-grid {
  flex: 0 0 auto;
  padding: 14px 12px 16px;
}
.view.on[data-v="service"] .service-grid .svc {
  min-height: 128px;
  padding: 18px 16px;
  border: 1px solid rgba(104, 165, 255, .18);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(47, 107, 255, .13), rgba(11, 40, 82, .36));
  transition: border-color 180ms, background 180ms, transform 180ms;
}
.view.on[data-v="service"] .service-grid .svc:hover {
  transform: translateY(-3px);
  border-color: rgba(104, 165, 255, .48);
  background: linear-gradient(145deg, rgba(47, 107, 255, .22), rgba(11, 40, 82, .48));
}
.view.on[data-v="service"] .panel.wide .bd:last-child {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 250px;
}
.view.on[data-v="service"] #chartWork { height: 320px; min-height: 220px; }
.view.on[data-v="service"] .panel:last-child .bd {
  display: flex;
  align-items: center;
  justify-content: center;
}
.view.on[data-v="service"] #chartSat { height: 460px; min-height: 280px; max-height: 100%; }

/* ---------- 低性能、手动关闭和系统减少动态 ---------- */
html.pms-low-motion .wb-hero-bg { transform: none !important; will-change: auto; }
html.pms-low-motion .map-svg > path,
html.pms-low-motion .map-svg .pt circle { animation: none !important; }
html.pms-motion-off *,
html.pms-motion-off *::before,
html.pms-motion-off *::after,
html.reduce-motion *,
html.reduce-motion *::before,
html.reduce-motion *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}
html.pms-motion-off .wb-hero-bg,
html.reduce-motion .wb-hero-bg { transform: none !important; will-change: auto; }
html.pms-motion-off .mk,
html.reduce-motion .mk { opacity: 1 !important; }

@media (max-width: 1500px) {
  .ck-tour { padding: 0 8px; }
  .ck-tour span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .wb-hero-bg { transform: none !important; will-change: auto; }
  .mk { opacity: 1 !important; }
}
