/* ============================================================
   before-after.css — 「点击看前后」对比图组件
   背景：用户定调「有意思、生动的交互玩法」——点击图片，从
         before 变为 after；图风格为色彩生动的国风插画。
   设计意图：两图同构图叠放，点击整卡切换（淡入交叉），
             角标「前/后」随状态翻转；点击本身就是学习动作
             （元末荒村→洪武春耕、工地→宫城）。
   约束：依赖 base.css 令牌；两图尺寸必须一致（同构图生成）。
   ============================================================ */

.ba-wrap {
  position: relative;
  margin: 0 0 calc(var(--sp) * 3);
  border-radius: 12px;
  overflow: hidden;
  border: 3px solid var(--zhu);
  box-shadow: 0 10px 30px rgba(120, 60, 30, 0.25);
  cursor: ew-resize;
  user-select: none;
  touch-action: none;
  -webkit-user-select: none;
}
.ba-wrap:focus-visible { outline: 3px solid var(--qing); outline-offset: 3px; }

.ba-img {
  display: block;
  width: 100%;
  height: auto;
  transition: opacity .45s ease;
}
.ba-img.ba-after { position: absolute; inset: 0; clip-path: inset(0 50% 0 0); }

/* 角标：左 before / 右 after 双标签，分割拖动时交叉淡出 */
.ba-tag {
  position: absolute;
  top: calc(var(--sp) * 1.8);
  left: calc(var(--sp) * 1.8);
  display: inline-flex;
  align-items: center;
  gap: .4em;
  font-family: var(--font-serif);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .12em;
  color: #fff8ea;
  background: var(--zhu);
  border-radius: 6px;
  padding: .25em .8em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: opacity .25s ease;
}
.ba-tag-r {
  left: auto;
  right: calc(var(--sp) * 1.8);
  background: var(--qing);
}
.ba-wrap.show-after .ba-tag:not(.ba-tag-r) { opacity: .25; }
.ba-wrap:not(.show-after) .ba-tag-r { opacity: .25; }
@media (max-width: 760px) { .ba-tag, .ba-tag-r { font-size: 12.5px; } }

/* 提示气泡：点我切换 */
.ba-divider {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 0;
  z-index: 3;
  cursor: ew-resize;
}
.ba-divider::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: -1.5px;
  width: 3px;
  background: #fff8ea;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}
.ba-knob {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff8ea;
  color: var(--zhu);
  display: grid;
  place-items: center;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.45);
}
.ba-knob .icon { width: 1.3em; height: 1.3em; stroke-width: 2.6; }

.ba-hint {
  position: absolute;
  bottom: calc(var(--sp) * 1.8);
  right: calc(var(--sp) * 1.8);
  display: inline-flex;
  align-items: center;
  gap: .45em;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: #3a2f24;
  background: rgba(255, 248, 234, 0.92);
  border-radius: 999px;
  padding: .3em 1em;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  animation: ba-bounce 2.4s ease-in-out infinite;
}
@keyframes ba-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* 说明文字（图外） */
.ba-cap {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  text-align: center;
  padding: calc(var(--sp) * 1.2);
}

@media (prefers-reduced-motion: reduce) {
  .ba-hint { animation: none; }
  .ba-img { transition: none; }
}
