/* ============================================================
   乐学堂 · 科学实验室 —— 专属样式
   与 history.css 同构：知识卡 / 想一想 / 速查 / 小诊所 / 打印
   ============================================================ */

/* ---------- 实验室横幅 ---------- */
.textbook-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 16px; padding: 12px 16px;
  background: linear-gradient(135deg, #e8f3f9, #f0faf4);
  border: 1px solid #cfe6f2; border-radius: 14px;
  color: #1d6f8f; font-size: 14px; font-weight: 700;
}
.textbook-banner strong { font-size: 16px; }

/* ---------- 实验室导语 ---------- */
.goal-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.goal-tags span {
  background: color-mix(in srgb, var(--c) 12%, white);
  border: 1px solid color-mix(in srgb, var(--c) 30%, white);
  color: #4a4f63; border-radius: 999px; padding: 3px 10px;
  font-size: 12.5px; font-weight: 700;
}

/* ---------- 知识点卡 ---------- */
.kcard {
  --c: #4d96ff;
  position: relative;
  background: var(--card); border-radius: 18px; padding: 18px 18px 16px;
  border: 1px solid var(--line); border-top: 4px solid var(--c);
  box-shadow: 0 4px 16px rgba(40, 54, 85, .035); overflow-wrap: anywhere;
  margin-bottom: 20px;
}
.kcard.learned { background: #f4fcf7; }
.khead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-right: 40px; }
.ktitle { font-size: 21px; font-weight: 900; }
.khead-gap { flex: 1; }
.kcard .say { width: 32px; height: 32px; }
.learn-btn {
  position: absolute; top: 12px; right: 12px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid #dfe5f0; background: #f5f8fc;
  font-size: 17px; font-weight: 900; color: #fff; line-height: 1;
}
.learn-btn.on { background: #2fbf71; border-color: #2fbf71; }
.k-overview { margin-top: 12px; font-size: 15.5px; line-height: 1.75; color: #4a4f63; }

/* ---------- 小节 ---------- */
.ksec { display: flex; align-items: flex-start; gap: 10px; margin-top: 12px; }
.ksec > :last-child { min-width: 0; flex: 1; }
.seclabel {
  flex: 0 0 26px; height: 26px; margin-top: 2px;
  background: #e4eefb; color: #2b5f8f; border-radius: 8px;
  font-size: 13px; font-weight: 900; display: grid; place-items: center;
}
.klist { list-style: none; display: grid; gap: 5px; }
.kli {
  display: block; width: 100%; text-align: left;
  border: none; background: none; padding: 2px 0;
  font-size: 14.5px; line-height: 1.7; color: #4a4f63; font-weight: 600;
}
.kli:hover { color: #2b5f8f; }
.klist.mis .kli { color: #7a5327; }

/* ---------- 想一想 ---------- */
.mex { display: grid; gap: 6px; }
.mex-q, .mex-steps, .mex-a {
  display: block; width: 100%; text-align: left; border: none;
  padding: 8px 12px; border-radius: 12px;
  font-size: 14.5px; line-height: 1.7; font-weight: 600;
}
.mex-q { background: #e8f4fb; color: #1d6f8f; }
.mex-steps { background: #f8f9fc; color: #5a5570; }
.mex-a { background: #e9f9f0; color: #187749; font-weight: 800; }

.krecite {
  margin-top: 12px; background: #eaf6fd; border-radius: 12px;
  padding: 9px 12px; font-size: 14px; font-weight: 800; color: #1d6f8f;
}

/* ---------- 科学速查 ---------- */
.formula-card {
  --c: #b5893a;
  background: var(--card); border-radius: 18px; padding: 16px 18px;
  border: 1px solid var(--line); border-left: 5px solid var(--c);
  margin-bottom: 16px; box-shadow: 0 4px 16px rgba(40, 54, 85, .035); overflow-wrap: anywhere;
}
.phead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.phead h3 { font-size: 17px; font-weight: 900; }
.frows { display: grid; gap: 6px; margin-top: 10px; }
.frow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border: 1.5px solid var(--line); background: #fafbfe;
  border-radius: 10px; padding: 7px 12px; text-align: left;
}
.frow:active { transform: scale(.98); }
.frow b { font-size: 15px; font-weight: 900; color: #2b5f8f; }
.frow span { font-size: 15px; font-weight: 700; color: #4a4f63; font-variant-numeric: tabular-nums; }
.pnote {
  margin-top: 10px; background: #f0f7fb; border-radius: 12px;
  padding: 9px 12px; font-size: 13.5px; line-height: 1.7; color: #4a5f6d; font-weight: 600;
}

/* ---------- 科学小诊所 ---------- */
.mistake-card {
  --c: #c2557d;
  position: relative;
  display: grid; gap: 8px;
  background: var(--card); border-radius: 18px; padding: 20px 16px 14px;
  border: 1px solid var(--line); border-top: 4px solid var(--c);
  box-shadow: 0 4px 16px rgba(40, 54, 85, .035); overflow-wrap: anywhere;
}
.unit-tag {
  position: absolute; top: -12px; left: 14px;
  color: #fff; font-size: 12px; font-weight: 800;
  border-radius: 999px; padding: 3px 12px; box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
}
.mist-row {
  display: flex; align-items: flex-start; gap: 8px;
  border: none; background: none; text-align: left;
  font-size: 14.5px; line-height: 1.7; font-weight: 600; padding: 2px 4px;
}
.mist-mark { flex-shrink: 0; }
.wrong-row-text { color: #a4453f; text-decoration: line-through; text-decoration-color: #e4b6b2; text-decoration-thickness: 2px; }
.right-row-text { color: #187749; font-weight: 700; }

/* ---------- 打印 ---------- */
@media print {
  .study-course .study-page { background: #fff; font-size: 13px; }
  #app > header, .sidebar, .toolbar, .textbook-banner, .skip-link,
  .say, .learn-btn, .goal-tags { display: none !important; }
  .study-shell { display: block; padding: 0; }
  .study-content { padding: 0; }
  .unit-head { border: 1px solid #ccc; box-shadow: none; }
  .kcard, .formula-card, .mistake-card { box-shadow: none; break-inside: avoid; page-break-inside: avoid; }
  .wgrid { grid-template-columns: 1fr; display: block; }
  .kcard, .mistake-card { margin-bottom: 12px; }
  .unit-banner, .fig { break-inside: avoid; page-break-inside: avoid; }
}

/* ============================================================
   动画与视觉增强（科学实验室专属）
   ============================================================ */

/* ---------- 单元横幅 ---------- */
.unit-banner { margin: 4px 0 14px; border-radius: 14px; overflow: hidden; }
.unit-banner svg { width: 100%; height: auto; display: block; }
.unit-banner:hover svg { transform: translateY(-1px); transition: transform .3s ease; }

/* 横幅装饰粒子漂浮 */
@keyframes bnFloat {
  0%, 100% { transform: translateY(0); opacity: .6; }
  50% { transform: translateY(-10px); opacity: .9; }
}
.bn-float { animation: bnFloat 3.2s ease-in-out infinite; transform-origin: center; }
.bn-float.bn-d2 { animation-duration: 4.1s; animation-delay: .6s; }
.bn-float.bn-d3 { animation-duration: 5s; animation-delay: 1.2s; }

/* 横幅齿轮旋转 */
@keyframes bnSpin { to { transform: rotate(360deg); } }
.bn-gear { transform-origin: center; animation: bnSpin 8s linear infinite; }

/* ---------- 知识点卡入场动画 ---------- */
@keyframes kFadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.kcard, .formula-card, .mistake-card, .unit-head {
  animation: kFadeUp .42s ease both;
}
.kcard:nth-child(2) { animation-delay: .04s; }
.kcard:nth-child(3) { animation-delay: .08s; }
.kcard:nth-child(4) { animation-delay: .12s; }
.kcard:nth-child(5) { animation-delay: .16s; }
.kcard:nth-child(6) { animation-delay: .20s; }

/* ---------- 图示悬浮效果 ---------- */
.fig {
  transition: transform .28s ease, box-shadow .28s ease, border-color .28s ease;
}
.fig:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(40, 54, 85, .08);
  border-color: #c7d4ec;
}
.fig:hover .fig-svg { transform: scale(1.005); transition: transform .35s ease; }

/* ---------- 图示内元素微动画 ---------- */
/* 太阳光芒旋转 */
@keyframes sunPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .7; }
}
.fig-svg [data-anim="sun"] circle,
.fig-svg [data-anim="sun"] line { animation: sunPulse 2.4s ease-in-out infinite; }

/* 水波流动 */
@keyframes waveMove {
  from { transform: translateX(0); }
  to { transform: translateX(-40px); }
}

/* 蒸发水汽上升 */
@keyframes vaporRise {
  0% { opacity: 0; transform: translateY(6px); }
  40% { opacity: .8; }
  100% { opacity: 0; transform: translateY(-14px); }
}

/* 口诀框脉冲提示 */
.krecite {
  background: linear-gradient(90deg, #eaf6fd, #eef7ee, #eaf6fd);
  background-size: 200% 100%;
  animation: kreciteShine 5s ease infinite;
}
@keyframes kreciteShine {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* ---------- 想一想区块悬浮 ---------- */
.mex-q:hover { background: #d9ecf7; }
.mex-a:hover { background: #d6f3e2; }
.mex-steps:hover { background: #eef0f7; }

/* ---------- 已掌握卡片微光 ---------- */
.kcard.learned {
  background: linear-gradient(180deg, #f4fcf7, #fff);
  border-top-color: #2fbf71;
}
.kcard.learned::after {
  content: '✓ 已掌握';
  position: absolute; top: 12px; right: 56px;
  font-size: 11.5px; font-weight: 800; color: #2fbf71;
  background: #e9f9f0; border-radius: 999px; padding: 2px 9px;
}

/* ---------- 减少动画偏好 ---------- */
.sci-demo-stage { overflow-x: auto; margin: 12px 0; border-radius: 12px; }
.sci-demo-stage .fig-svg { min-width: 560px; }
.sci-demo-stage:focus-visible { outline: 3px solid #4d96ff; outline-offset: 3px; }
.sci-scroll-hint { display: none; }
@media (max-width: 700px) {
  .sci-scroll-hint { display: block; color: #4a5f6d; font-size: 14px; line-height: 1.6; }
}
.fig:has(.sci-demo-stage):hover { transform: none; }
.fig:has(.sci-demo-stage):hover .fig-svg { transform: none; }
.fig .sci-observation {
  margin: 12px 0; padding: 12px 16px; border-left: 4px solid #2f9bd6;
  border-radius: 4px 12px 12px 4px; background: #eaf6fd; color: #204d68;
  font-size: 17px; line-height: 1.8; font-weight: 700;
}
.sci-motion-controls { margin: 12px 0; padding: 12px; border-radius: 12px; background: #f2f7fc; }
.sci-motion-controls[hidden] { display: none; }
.sci-motion-status, .fig .sci-model-note { margin: 8px 0; color: #4a5f6d; font-size: 15px; line-height: 1.75; }
.sci-motion-controls .fig-ctrl { margin: 0; }
.fig:has(.sci-demo-stage) .fig-btn { font-size: 15px; min-height: 40px; }
.fig .fig-btn:disabled { opacity: .5; cursor: default; transform: none; }
.sci-demo-sources { color: #4a5f6d; font-size: 14px; line-height: 1.8; }
.sci-demo-sources summary { cursor: pointer; }
.sci-demo-sources a { display: block; padding: 4px 0; }
@media print { .sci-motion-controls, .sci-demo-sources, .fig:has(.sci-demo-stage) .fig-ctrl { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .kcard, .formula-card, .mistake-card, .unit-head,
  .bn-float, .bn-gear, .krecite, .fig {
    animation: none !important;
    transition: none !important;
  }
}
