/* =====================================================================
   TeachAny 增强层 enhance.css
   作用：优化交互、教学动画、学习记录、导航（清新明亮主题）
   依赖：styles.css（同目录 grade3/）
   ===================================================================== */

/* ---------- 1. 基础交互优化 ---------- */
:root {
  --ta-primary: #4299e1;
  --ta-primary-dark: #3182ce;
  --ta-secondary: #48bb78;
  --ta-accent: #ed8936;
  --ta-shadow: 0 8px 24px rgba(66,153,225,.18);
}

* { -webkit-tap-highlight-color: transparent; }

body { scroll-behavior: smooth; }

a, button, .choice-item, .progress-step { outline: none; }
:focus-visible {
  outline: 3px solid rgba(66,153,225,.55);
  outline-offset: 2px;
  border-radius: 8px;
}

/* 按下时的回弹反馈 */
.btn:active, .choice-item:active, .progress-step:active {
  transform: scale(.96) !important;
}
.choice-item {
  position: relative;
  overflow: hidden;
  user-select: none;
}
/* 点击波纹 */
.ta-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(66,153,225,.35);
  transform: scale(0);
  animation: ta-ripple .6s ease-out;
  pointer-events: none;
}
@keyframes ta-ripple {
  to { transform: scale(3); opacity: 0; }
}

/* 选项被选中/正确/错误 的微动效 */
.choice-item.correct {
  animation: ta-pop .35s ease;
}
@keyframes ta-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ---------- 2. 教学动画关键帧 ---------- */
@keyframes ta-fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes ta-pop-in {
  0%   { opacity: 0; transform: scale(.8); }
  70%  { opacity: 1; transform: scale(1.05); }
  100% { transform: scale(1); }
}
@keyframes ta-slide-left {
  from { opacity: 0; transform: translateX(-24px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes ta-float {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-8px); }
}
@keyframes ta-pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(72,187,120,.5); }
  100% { box-shadow: 0 0 0 14px rgba(72,187,120,0); }
}
@keyframes ta-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes ta-check {
  0%   { transform: scale(0) rotate(-30deg); opacity: 0; }
  60%  { transform: scale(1.2) rotate(8deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* 滚动入场（由 enhance.js 添加 .ta-reveal-init / .ta-reveal-in） */
.ta-reveal-init {
  opacity: 0;
  transform: translateY(16px);
}
.ta-reveal-in {
  opacity: 1 !important;
  transform: none !important;
  transition: opacity .5s ease, transform .5s ease;
}

.ta-float { animation: ta-float 3s ease-in-out infinite; }
.ta-pop-in { animation: ta-pop-in .5s ease both; }
.ta-slide-left { animation: ta-slide-left .5s ease both; }

/* 进度步骤完成勾 */
.progress-step.done .num::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ta-secondary);
  color: #fff;
  border-radius: 50%;
  font-size: 14px;
  animation: ta-check .4s ease;
}
.progress-step.done .num { color: transparent; }

/* ---------- 3. 面包屑导航 ---------- */
.ta-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 13px;
  color: #718096;
  background: rgba(255,255,255,.6);
  border-bottom: 1px solid #e2e8f0;
}
.ta-breadcrumb a { color: var(--ta-primary); text-decoration: none; font-weight: 600; }
.ta-breadcrumb a:hover { text-decoration: underline; }
.ta-breadcrumb .sep { color: #cbd5e0; }
.ta-breadcrumb .cur { color: #2d3748; font-weight: 600; }

/* ---------- 4. 上下课导航 ---------- */
.ta-lesson-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  max-width: 1000px;
  margin: 8px auto 40px;
  padding: 0 20px;
}
.ta-lesson-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 18px;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  text-decoration: none;
  transition: all .25s ease;
}
.ta-lesson-nav a:hover { border-color: var(--ta-primary); transform: translateY(-3px); box-shadow: var(--ta-shadow); }
.ta-lesson-nav .nav-dir { font-size: 12px; color: #a0aec0; }
.ta-lesson-nav .nav-name { font-size: 16px; font-weight: 700; color: #2d3748; }
.ta-lesson-nav .nav-next { text-align: right; align-items: flex-end; }
.ta-lesson-nav a.disabled { opacity: .45; pointer-events: none; }

/* ---------- 5. 学习记录浮窗 ---------- */
.ta-record-btn {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #4299e1, #9f7aea);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(66,153,225,.45);
  z-index: 9998;
  transition: transform .2s ease;
}
.ta-record-btn:hover { transform: scale(1.08) rotate(8deg); }
.ta-record-btn .ta-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 22px; height: 22px;
  padding: 0 5px;
  border-radius: 11px;
  background: #fc8181;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}

.ta-record-panel {
  position: fixed;
  right: 22px;
  bottom: 90px;
  width: 320px;
  max-width: calc(100vw - 44px);
  max-height: 70vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(45,55,72,.25);
  z-index: 9999;
  padding: 20px;
  transform: translateY(20px) scale(.96);
  opacity: 0;
  pointer-events: none;
  transition: all .25s ease;
}
.ta-record-panel.open { transform: none; opacity: 1; pointer-events: auto; }
.ta-record-panel h3 { margin: 0 0 14px; font-size: 18px; color: #2d3748; display: flex; align-items: center; gap: 8px; }
.ta-record-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid #edf2f7; font-size: 14px; }
.ta-record-row:last-of-type { border-bottom: none; }
.ta-record-row .k { color: #718096; }
.ta-record-row .v { font-weight: 700; color: #2d3748; }
.ta-progress-mini {
  height: 10px; border-radius: 6px; background: #edf2f7; overflow: hidden; margin: 6px 0 14px;
}
.ta-progress-mini > i {
  display: block; height: 100%;
  background: linear-gradient(90deg, #4299e1, #48bb78);
  border-radius: 6px; transition: width .5s ease;
}
.ta-record-actions { display: flex; gap: 10px; margin-top: 12px; }
.ta-record-actions button {
  flex: 1; padding: 10px; border: none; border-radius: 10px; font-weight: 600; cursor: pointer; font-size: 14px;
}
.ta-btn-done { background: #48bb78; color: #fff; }
.ta-btn-done:hover { background: #38a169; }
.ta-btn-reset { background: #edf2f7; color: #718096; }
.ta-btn-reset:hover { background: #e2e8f0; }

/* ---------- 6. Toast 提示 ---------- */
.ta-toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%) translateY(20px);
  background: #2d3748;
  color: #fff;
  padding: 12px 22px;
  border-radius: 30px;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: all .3s ease;
}
.ta-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.ta-toast.success { background: #38a169; }
.ta-toast.error { background: #e53e3e; }

/* ---------- 7. 彩带（答对时） ---------- */
.ta-confetti {
  position: fixed;
  width: 10px; height: 14px;
  z-index: 10001;
  pointer-events: none;
  border-radius: 2px;
  animation: ta-fall .9s ease-in forwards;
}
@keyframes ta-fall {
  to { transform: translateY(160px) rotate(540deg); opacity: 0; }
}

/* ---------- 8. 数字滚动 ---------- */
.ta-count {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .ta-reveal-init { opacity: 1 !important; transform: none !important; }
}
