/* QuizSprint 全局动效、渐变光影、平滑微交互与主题过渡 */
:root {
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-smooth: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 键盘可访问焦点环 & 高频控件防误选 */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; }
.btn, .mode-pill, .subject-pill, .top-nav-btn, .admin-sub-btn, .aside-tab-btn, .mode-tile {
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* 顶部极细异步加载条（命中本地 SWR 缓存时不展示，仅真实慢请求出现） */
.top-load-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2.5px;
  z-index: 95;
  pointer-events: none;
  opacity: 0;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--accent), var(--accent-2, var(--accent)));
  transition: transform 0.35s var(--ease-smooth), opacity 0.2s ease;
}
.top-load-bar.is-loading {
  opacity: 1;
  transform: scaleX(0.72);
  transition: transform 2.4s cubic-bezier(0.12, 0.8, 0.25, 1), opacity 0.14s ease;
}
.top-load-bar.is-done {
  opacity: 0;
  transform: scaleX(1);
  transition: transform 0.16s ease, opacity 0.22s ease 0.08s;
}

/* 核心关键帧 */
@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes maskFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes maskFadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes modalPopIn {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes modalPopOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(6px) scale(0.97); }
}
@keyframes menuDropIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes detailReveal {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px) scale(0.96); }
}
@keyframes optOkPop {
  0% { transform: scale(0.992); }
  55% { transform: scale(1.005); }
  100% { transform: scale(1); }
}
@keyframes optWrongShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  55% { transform: translateX(4px); }
  80% { transform: translateX(-2px); }
}
@keyframes barGrowY {
  from { transform: scaleY(0); opacity: 0.4; }
  to { transform: scaleY(1); opacity: 1; }
}
@keyframes immSlideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 弹窗进出 / 菜单 / Toast / 折叠展开 */
.modal-backdrop:not([hidden]) { animation: maskFadeIn 180ms var(--ease-soft); }
.modal-backdrop:not([hidden]) > .modal-card { animation: modalPopIn 240ms var(--ease-smooth); }
.modal-backdrop.modal-closing { animation: maskFadeOut 150ms ease forwards; pointer-events: none; }
.modal-backdrop.modal-closing > .modal-card { animation: modalPopOut 150ms ease forwards; }
.dropdown-menu:not([hidden]) { transform-origin: top right; animation: menuDropIn 160ms var(--ease-smooth); }
.clean-menu:not([hidden]) { transform-origin: top left; }
.toast { animation: toastIn 240ms var(--ease-spring); }
.toast.toast-out { animation: toastOut 210ms ease forwards; pointer-events: none; }
.search-item[open] .search-detail-body,
.sheet-settings[open] > div { animation: detailReveal 220ms var(--ease-smooth); }

/* 柔和渐变进度条、柱状图与主题按钮光影 */
.progress-bar > span, .q-progress-track > span, .imm-progress-fill, .rank-track > span {
  background: linear-gradient(90deg, var(--accent), var(--accent-2, var(--accent)));
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 28%, transparent);
  transition: width 0.42s var(--ease-smooth);
}
.chart-bar.has-val {
  background: linear-gradient(180deg, var(--accent-2, var(--accent)), var(--accent));
}
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2, var(--accent)));
  box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 38%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.bank-workbench {
  background-image: radial-gradient(ellipse at top right, color-mix(in srgb, var(--accent) 8%, color-mix(in srgb, var(--accent-2, var(--accent)) 5%, transparent)), transparent 64%);
}

/* 路由视图进入时柔和淡入（视图随路由整体重挂载，仅触发一次） */
.view-frame, .exam-room-frame, .practice-shell { animation: viewFadeIn 240ms var(--ease-smooth); }

/* 高频控件平滑渐变过渡 & 三栏折叠缓动 */
.btn, .top-nav-btn, .admin-sub-btn, .mode-pill, .subject-pill, .aside-tab-btn,
.view-seg-btn, .sheet-cell, .note-history-item, .dropdown-item, .search-summary, .bank-row {
  transition: background-color 0.22s var(--ease-smooth), border-color 0.22s var(--ease-smooth),
    color 0.22s var(--ease-smooth), box-shadow 0.22s var(--ease-smooth), transform 0.2s var(--ease-smooth);
}
.sheet-cell.current { transition: border-color 0.22s var(--ease-smooth), box-shadow 0.24s var(--ease-smooth); }
.practice-layout { transition: grid-template-columns 0.26s var(--ease-smooth); }
body.is-resizing .practice-layout { transition: none; }

/* 刷题签名交互（仅新回答瞬时反馈、AI气泡、沉浸滑入） */
.q-body-scroll { padding: 2px 6px 6px 4px; }
.ai-msg { animation: viewFadeIn 190ms var(--ease-smooth); }
.q-body-scroll.is-just-answered .answer-box { animation: viewFadeIn 180ms var(--ease-smooth); }
.option-item { transition: border-color 0.18s var(--ease-smooth), background-color 0.18s var(--ease-smooth), transform 0.16s var(--ease-smooth), box-shadow 0.18s var(--ease-smooth); }
.option-item:focus-visible { outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 32%, transparent); }
.option-item.correct:focus-visible { outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok) 32%, transparent); }
.option-item.wrong:focus-visible { outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--bad) 32%, transparent); }
.option-item:active:not(:disabled) { transform: scale(0.99); }
.q-body-scroll.is-just-answered .option-item.correct { animation: optOkPop 240ms var(--ease-smooth); }
.q-body-scroll.is-just-answered .option-item.wrong { animation: optWrongShake 240ms ease; }
body.immersive-mode .immersive-bar { animation: immSlideDown 220ms var(--ease-smooth); }

/* 卡片、趋势条交互过渡（不强制整片透明闪入；悬停位移动效仅限桌面鼠标） */
.mode-tile, .bank-card, .kpi-card.is-clickable {
  transition: transform 0.22s var(--ease-smooth), border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.22s var(--ease-smooth);
}
.mode-tile:active { transform: scale(0.985); }
.mode-tile-icon { transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s var(--ease-smooth); }
.chart-bar.has-val { transition: height 0.24s var(--ease-smooth), opacity 0.14s ease; }

@media (hover: hover) and (pointer: fine) {
  .btn.primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 26%, transparent);
  }
  .option-item:hover:not(:disabled):not(.correct):not(.wrong) { transform: translateX(2px); }
  .order-item:hover, .match-chip:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
  .mode-tile:hover, .bank-card:hover, .kpi-card.is-clickable:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }
  .mode-tile:hover .mode-tile-icon { background: var(--accent-soft); color: var(--accent-fg); transform: scale(1.06); }
}

/* 主动切换外观主题时平滑渐变底色与卡片色 */
html.theme-switching, html.theme-switching body, html.theme-switching .panel,
html.theme-switching .app-topbar, html.theme-switching .app-footer, html.theme-switching .question-box, html.theme-switching .bank-workbench,
html.theme-switching .bank-card, html.theme-switching .mode-tile, html.theme-switching .practice-aside,
html.theme-switching .practice-notes, html.theme-switching .btn, html.theme-switching .kpi-card,
html.theme-switching .modal-card {
  transition: background-color 0.32s ease, color 0.32s ease, border-color 0.32s ease, box-shadow 0.32s ease;
}

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