/* 轻量动效层（2026-11-24）
   只做位移 / 透明度 / 阴影，不改布局；系统开启「减少动态效果」时全部关闭。 */

@media (prefers-reduced-motion: no-preference) {
  :root {
    --motion-ease: cubic-bezier(.2, .7, .2, 1);
  }

  html { scroll-behavior: smooth; }

  @keyframes motion-rise {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  @keyframes motion-pop {
    0%   { opacity: 0; transform: scale(.92); }
    100% { opacity: 1; transform: scale(1); }
  }
  @keyframes motion-slide-down {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  @keyframes motion-dot-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .45); }
    50%      { box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); }
  }

  /* 页面主体：标题、卡片入场 */
  main.container > .page-head,
  main.container > .alert,
  main.container > .card,
  main.container > .stack > .card,
  main.container > .challenge-grid > .challenge-card,
  main.container .stat-grid .stat {
    animation: motion-rise .42s var(--motion-ease) both;
  }

  /* 卡片 / 数字错开一点，避免整页同时跳出来 */
  main.container .stat-grid .stat:nth-child(2) { animation-delay: .04s; }
  main.container .stat-grid .stat:nth-child(3) { animation-delay: .08s; }
  main.container .stat-grid .stat:nth-child(4) { animation-delay: .12s; }
  main.container .challenge-grid > .challenge-card:nth-child(2) { animation-delay: .04s; }
  main.container .challenge-grid > .challenge-card:nth-child(3) { animation-delay: .08s; }
  main.container .challenge-grid > .challenge-card:nth-child(4) { animation-delay: .12s; }

  .stat-grid .stat-num {
    animation: motion-pop .45s var(--motion-ease) both;
  }

  /* 悬停：挑战卡轻微上浮；普通卡片只加深阴影，不位移 */
  .challenge-card,
  .team-card,
  .stat-link,
  .deadline-card {
    transition: transform .2s var(--motion-ease),
                box-shadow .2s var(--motion-ease),
                border-color .2s var(--motion-ease);
  }
  .challenge-card:hover,
  .team-card:hover,
  .stat-link:hover,
  .deadline-card:hover {
    transform: translateY(-2px);
  }

  /* 表格行、列表项：淡入式高亮 */
  .table tbody tr,
  .missing-list li {
    transition: background-color .16s ease, transform .16s ease;
  }
  .table tbody tr:hover {
    background-color: rgba(56, 189, 248, .07);
  }
  .missing-list li:hover {
    background-color: rgba(56, 189, 248, .05);
    transform: translateX(2px);
  }

  /* 按钮：按下回弹 */
  .btn:active {
    transform: translateY(1px) scale(.995);
  }

  /* 消息红点呼吸 */
  .msg-dot:not(.hidden) {
    animation: motion-dot-pulse 2.4s ease-in-out infinite;
  }

  /* 输入聚焦：柔和光圈 */
  input:focus,
  select:focus,
  textarea:focus {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
    transition: box-shadow .18s ease, border-color .18s ease;
  }

  /* 考试系统 */
  .exam-countdown-bar {
    animation: motion-slide-down .35s var(--motion-ease) both;
  }
  .exam-item-card {
    animation: motion-rise .4s var(--motion-ease) both;
  }
  .exam-file-chip {
    transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
  }
  .exam-file-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(55, 48, 163, .12);
  }
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes motion-bar-grow {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
  }
  @keyframes motion-shimmer {
    0%   { transform: translateX(-110%); }
    55%  { transform: translateX(110%); }
    100% { transform: translateX(110%); }
  }
  @keyframes motion-gradient-text {
    0%   { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
  }
  @keyframes motion-sheen {
    from { transform: translateX(-130%) skewX(-12deg); opacity: 0; }
    35%  { opacity: .55; }
    to   { transform: translateX(130%) skewX(-12deg); opacity: 0; }
  }
  @keyframes motion-glow-line {
    0%, 100% { opacity: .45; }
    50%      { opacity: 1; }
  }

  /* 进度条：从 0 长出 + 一道流光 */
  .progress {
    position: relative;
    overflow: hidden;
  }
  .progress .bar-fill,
  .progress > span {
    position: relative;
    display: block;
    height: 100%;
    border-radius: inherit;
    transform-origin: left center;
    animation: motion-bar-grow .9s var(--motion-ease) both;
    overflow: hidden;
  }
  .progress .bar-fill::after,
  .progress > span::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .5), transparent);
    animation: motion-shimmer 2.8s ease-in-out infinite;
    pointer-events: none;
  }
  .read-progress i {
    transition: width .18s ease;
  }

  /* 数字：等宽数字 + 轻微呼吸，配合 JS 的滚动计数 */
  .stat-num,
  .summary-metric .num,
  .ctf-stat .num,
  .exam-stat .num,
  .exam-clock,
  .score-summary .num,
  .acc-meta {
    font-variant-numeric: tabular-nums;
    transition: color .25s ease, text-shadow .25s ease;
  }
  .stat:hover .stat-num,
  .summary-metric:hover .num {
    text-shadow: 0 0 18px rgba(37, 99, 235, .28);
  }

  /* 文字：页面主标题渐变流光，副标题轻微上浮 */
  @supports (background-clip: text) or (-webkit-background-clip: text) {
    /* V2.8：原来用 #0f172a 深色渐变，深底上几乎看不见；改为浅色流光 */
    .page-head h1 {
      background-image: linear-gradient(90deg, #f2f9ff, #7dd3fc 28%, #a3e635 52%, #e6f6ff 78%, #f2f9ff);
      background-size: 200% 100%;
      -webkit-background-clip: text;
      background-clip: text;
      color: transparent;
      animation: motion-gradient-text 12s linear infinite;
    }
  }
  main.container > .page-head .muted {
    animation: motion-rise .5s var(--motion-ease) .08s both;
  }
  .section-head h2::before {
    animation: motion-glow-line 3.2s ease-in-out infinite;
  }

  /* 卡片：悬停流光扫过 + 彩色边光 */
  .stat,
  .summary-card,
  .challenge-card,
  .ctf-stat {
    position: relative;
    overflow: hidden;
  }
  .stat::after,
  .summary-card::after,
  .challenge-card::after,
  .ctf-stat::after {
    content: "";
    position: absolute;
    top: -30%;
    bottom: -30%;
    left: 0;
    width: 38%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
    pointer-events: none;
    opacity: 0;
    transform: translateX(-130%) skewX(-12deg);
  }
  .stat:hover,
  .summary-card:hover,
  .ctf-stat:hover {
    border-color: rgba(37, 99, 235, .28);
    box-shadow: 0 12px 28px rgba(37, 99, 235, .12);
  }
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes motion-topbar-flow {
    0%   { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
  }
  @keyframes motion-nav-flow {
    0%   { background-position: 0% 50%; }
    100% { background-position: 150% 50%; }
  }
  @keyframes motion-btn-shine {
    from { transform: translateX(-160%) skewX(-18deg); }
    to   { transform: translateX(160%) skewX(-18deg); }
  }
  @keyframes motion-bg-drift {
    0%, 100% { background-position: 0% 0%, 100% 0%; }
    50%      { background-position: 6% 3%, 94% 4%; }
  }

  /* 顶栏底部流动光带 */
  .topbar {
    position: relative;
  }
  .topbar::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #2563eb, #06b6d4, #10b981, transparent);
    background-size: 200% 100%;
    animation: motion-topbar-flow 9s linear infinite;
    pointer-events: none;
    opacity: .85;
  }

  /* 导航当前页：渐变色缓慢流动 */
  .nav a.active {
    background-image: linear-gradient(120deg, var(--brand, #2563eb), #0891b2 55%, var(--brand, #2563eb));
    background-size: 160% 100%;
    animation: motion-nav-flow 7s ease-in-out infinite;
  }

  /* 主按钮：悬停一道高光扫过 */
  .btn {
    position: relative;
    overflow: hidden;
  }
  .btn-primary {
    position: relative;
    overflow: hidden;
  }
  .btn-primary::after {
    content: "";
    position: absolute;
    top: -40%;
    bottom: -40%;
    left: 0;
    width: 32%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .55), transparent);
    transform: translateX(-160%) skewX(-18deg);
    pointer-events: none;
  }

  /* 页面背景：极淡的双光晕缓慢漂移 */
  body.role-teacher,
  body.role-student {
    background-image:
      radial-gradient(1100px 520px at 8% -8%, rgba(34, 211, 238, .055), transparent 62%),
      radial-gradient(900px 480px at 100% 0%, rgba(163, 230, 53, .035), transparent 60%);
    background-repeat: no-repeat;
    background-attachment: fixed;
    animation: motion-bg-drift 26s ease-in-out infinite;
  }

  /* 页面切换顶部加载条 */
  #motion-page-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    z-index: 9999;
    background: linear-gradient(90deg, #2563eb, #06b6d4, #10b981);
    box-shadow: 0 0 10px rgba(37, 99, 235, .55);
    opacity: 0;
    transition: width .45s ease, opacity .2s ease;
    pointer-events: none;
  }
  #motion-page-bar.is-on {
    opacity: 1;
  }
}

/* 无障碍：键盘聚焦始终可见（不依赖动画开关） */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--brand, #2563eb);
  outline-offset: 2px;
}


/* 2026-11-26: 去掉卡片悬停流光/位移/阴影，修复鼠标离开时白框闪一下 */
.stat::after, .summary-card::after, .challenge-card::after, .ctf-stat::after { content: none !important; }
.challenge-card, .team-card, .stat-link, .deadline-card { transition: none !important; }
.challenge-card:hover, .team-card:hover, .stat-link:hover, .deadline-card:hover { transform: none !important; }
.stat:hover, .summary-card:hover, .ctf-stat:hover { box-shadow: none !important; border-color: inherit !important; }


/* 2026-11-28：收敛常驻动效（顶栏流光/导航流动/标题流光/背景漂移/进度条流光/扫描线），
   保留入场动画、数字滚动和页面加载条。想恢复某项，删掉对应选择器即可。 */
.topbar::after,
.live-strip::after,
.ctf-hero::before,
.card.ctf-hero::before,
.section-head h2::before,
.page-head h1,
.nav a.active,
body.role-teacher,
body.role-student {
  animation: none !important;
}
.topbar::after,
.live-strip::after,
.ctf-hero::before,
.card.ctf-hero::before {
  opacity: 0 !important;
}
.progress .bar-fill::after,
.progress > span::after {
  display: none !important;
}

/* 高对比度 / 不支持渐变文字时，标题不能是透明色 */
@supports not ((background-clip: text) or (-webkit-background-clip: text)) {
  .student-hero h1,
  .role-teacher .page-head h1 {
    color: var(--ink) !important;
    background: none !important;
  }
}
