/* ============================================================================
 * 哈皮点金 精修预览版 - 动效
 * ----------------------------------------------------------------------------
 * 入场、图表生长、表格行展开收起、减少动态效果。
 * 过渡只作用于 transform、opacity，以及颜色、背景色、边框色。
 * ========================================================================= */

/* ------------------------------------------------------------ 大屏入场 */

.enter-panel {
  animation: panelIn var(--dur-enter) var(--ease-out) both;
  animation-delay: var(--d, 0ms);
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ------------------------------------------------------------ 明细页整体淡入 */

body[data-kind] .page {
  animation: pageIn var(--dur-base) var(--ease-out) both;
}

@keyframes pageIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ------------------------------------------------------------ 登录卡片 */

.login-card {
  animation: loginIn var(--dur-login) var(--ease-out) both;
}

@keyframes loginIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ------------------------------------------------------------ 趋势图 */

.chart-svg .t-line {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: drawLine var(--draw-dur, var(--dur-draw)) var(--ease-out) forwards;
}

.chart-svg .t-area {
  opacity: 0;
  animation: fadeIn var(--dur-enter) var(--ease-out) forwards;
  animation-delay: calc(var(--draw-dur, var(--dur-draw)) * 0.55);
}

.chart-svg .t-end-label,
.chart-svg .t-dot-end {
  opacity: 0;
  animation: fadeIn var(--dur-base) var(--ease-out) forwards;
  animation-delay: calc(var(--draw-dur, var(--dur-draw)) * 0.9);
}

.chart-svg .t-bar-daily {
  transform-box: fill-box;
  transform-origin: bottom;
  transform: scaleY(0);
  animation: barGrow var(--dur-enter) var(--ease-out) forwards;
  animation-delay: calc(var(--i, 0) * 15ms);
}

@keyframes drawLine {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes barGrow {
  from {
    transform: scaleY(0);
  }
  to {
    transform: scaleY(1);
  }
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

/* ------------------------------------------------------------ 减少动态效果、审计模式 */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }

  /* 入场和图表直接是最终状态：不靠“0.01ms 的动画”，免得头一帧是空白 */
  .enter-panel,
  .login-card,
  body[data-kind] .page {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .chart-svg .t-line {
    animation: none;
    stroke-dasharray: none;
    stroke-dashoffset: 0;
  }

  .chart-svg .t-area,
  .chart-svg .t-end-label,
  .chart-svg .t-dot-end {
    animation: none;
    opacity: 1;
  }

  .chart-svg .t-bar-daily {
    animation: none;
    transform: none;
  }

  .cell.is-saved .cell-text,
  .day-v.is-saved,
  .spinner {
    animation: none;
  }
}

/* 窗口变化重画时直接显示最终状态，不再演一次 */
.chart-svg.is-static .t-line {
  animation: none;
  stroke-dasharray: none;
  stroke-dashoffset: 0;
}

.chart-svg.is-static .t-area,
.chart-svg.is-static .t-end-label,
.chart-svg.is-static .t-dot-end {
  animation: none;
  opacity: 1;
}

.chart-svg.is-static .t-bar-daily {
  animation: none;
  transform: none;
}
