/* ============================================================
   电影级焕新展示（Reveal Compare）
   - 揭幕动画：柔和光影 + 渐变遮罩揭示效果图
   - 一键前后切换：300ms 交叉淡化，画面位置不动
   - 沉浸式全屏：滚轮 / 双指缩放、拖拽、前后切换
   与 global.css 的设计令牌保持一致（米色 / 铜色 / 墨绿）
   ============================================================ */

.rv-wrap {
  background: #FFFFFF;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(48, 54, 48, .06), 0 10px 30px -18px rgba(48, 54, 48, .28);
}

/* ---------- 舞台 ---------- */
.rv-stage {
  position: relative;
  width: 100%;
  height: 0;
  overflow: hidden;
  background: #121513;
  isolation: isolate;
}

.rv-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

.rv-img--after {
  z-index: 2;
  /* 播放前隐藏，避免"先看到结果图再被裁掉"的闪烁 */
  clip-path: inset(0 100% 0 0);
  transition: opacity 300ms ease;
}

.rv-stage.is-done .rv-img--after { clip-path: inset(0 0 0 0); }

.rv-img--before {
  z-index: 1;
  opacity: 1;
  transition: opacity 300ms ease;
}

/* 切到「改造前」：上层效果图淡出，位置不变 */
.rv-stage.is-before .rv-img--after { opacity: 0; }
.rv-fs.is-before .rv-img--after { opacity: 0; }

/* ---------- 揭幕动画 ---------- */
.rv-stage.is-playing .rv-img--after {
  will-change: clip-path, opacity;
  animation: rv-reveal 1800ms cubic-bezier(.22, .61, .36, 1) 120ms both;
}

@keyframes rv-reveal {
  from { clip-path: inset(0 100% 0 0); }
  to   { clip-path: inset(0 0 0 0); }
}

/* 柔光带：随揭示边缘从左扫到右，克制、低亮度 */
.rv-glow {
  position: absolute;
  top: -10%;
  bottom: -10%;
  left: 0;
  width: 42%;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 246, 232, .16) 45%,
    rgba(255, 255, 255, .30) 52%,
    rgba(255, 246, 232, .14) 60%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: translateX(-45%);
}

.rv-stage.is-playing .rv-glow {
  animation: rv-glow 1400ms ease-out 160ms both;
}

@keyframes rv-glow {
  0%   { opacity: 0;   transform: translateX(-45%); }
  22%  { opacity: .9; }
  78%  { opacity: .55; }
  100% { opacity: 0;   transform: translateX(268%); }
}

/* 收尾轻微提亮，避免动画结束瞬间"跳" */
.rv-stage.is-playing .rv-img--after { animation-name: rv-reveal; }

/* 降级：仅交叉淡入 */
.rv-stage.is-fade .rv-img--after { clip-path: none; opacity: 0; }
.rv-stage.is-fade.is-done .rv-img--after { clip-path: none; opacity: 1; }
.rv-stage.is-fade.is-playing .rv-img--after {
  will-change: opacity;
  animation: rv-fade 620ms ease both;
}
.rv-stage.is-fade.is-playing .rv-glow { animation: none; }

@keyframes rv-fade {
  from { opacity: 0; clip-path: none; }
  to   { opacity: 1; clip-path: none; }
}

/* ---------- 加载态 ---------- */
.rv-loading {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #121513;
  color: rgba(247, 243, 236, .72);
  font-size: 13px;
  letter-spacing: .04em;
  transition: opacity 260ms ease;
}

.rv-loading.is-hidden { opacity: 0; pointer-events: none; }

.rv-spin {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(247, 243, 236, .22);
  border-top-color: #AD8663;
  animation: rv-spin 900ms linear infinite;
}

@keyframes rv-spin { to { transform: rotate(360deg); } }

/* ---------- 角标（动画结束后出现） ---------- */
.rv-badges {
  position: absolute;
  inset: 12px 12px auto 12px;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  opacity: 0;
  transition: opacity 300ms ease 120ms;
  pointer-events: none;
}

.rv-stage.is-done .rv-badges { opacity: 1; }

.rv-badge {
  font-size: 10px;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 999px;
  color: #fff;
  background: rgba(18, 21, 19, .55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.rv-badge--after { background: rgba(173, 134, 99, .92); }

/* ---------- 全屏按钮 ---------- */
.rv-fs-btn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  background: rgba(18, 21, 19, .52);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #F7F3EC;
  font-size: 12px;
  cursor: pointer;
  transition: background 200ms ease, transform 200ms ease;
}

.rv-fs-btn:hover { background: rgba(18, 21, 19, .72); }
.rv-fs-btn:active { transform: scale(.97); }

/* ---------- 切换条 ---------- */
.rv-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid rgba(48, 54, 48, .07);
  background: #FBF8F3;
}

.rv-seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: #FFFFFF;
  box-shadow: inset 0 0 0 1px rgba(48, 54, 48, .08);
}

.rv-seg-btn {
  min-width: 84px;
  padding: 9px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #8A8C81;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: color 220ms ease, background 220ms ease, box-shadow 220ms ease;
}

.rv-seg-btn.is-on {
  background: #AD8663;
  color: #FFFFFF;
  box-shadow: 0 4px 12px -4px rgba(173, 134, 99, .55);
}

.rv-replay {
  border: 0;
  background: transparent;
  color: #8E6A4B;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 6px;
  cursor: pointer;
  transition: opacity 200ms ease;
}

.rv-replay:hover { opacity: .72; }
.rv-replay[disabled] { opacity: .35; cursor: default; }

/* ============================================================
   沉浸式全屏
   ============================================================ */
.rv-fs {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  background: #0B0D0C;
  opacity: 0;
  transition: opacity 240ms ease;
}

.rv-fs.is-open { opacity: 1; }

.rv-fs-top {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  color: rgba(247, 243, 236, .82);
  font-size: 13px;
}

.rv-fs-close {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid rgba(247, 243, 236, .18);
  border-radius: 999px;
  background: rgba(255, 255, 255, .05);
  color: inherit;
  font-size: 13px;
  cursor: pointer;
}

.rv-fs-close:hover { background: rgba(255, 255, 255, .1); }

.rv-fs-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.rv-fs-stage.is-dragging { cursor: grabbing; }

.rv-fs-canvas {
  position: absolute;
  inset: 0;
  transform-origin: center center;
  will-change: transform;
}

.rv-fs-canvas .rv-img { object-fit: contain; }

.rv-fs-bottom {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 16px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
}

.rv-fs-seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .07);
  box-shadow: inset 0 0 0 1px rgba(247, 243, 236, .14);
}

.rv-fs-seg .rv-seg-btn { color: rgba(247, 243, 236, .66); }
.rv-fs-seg .rv-seg-btn.is-on { color: #fff; background: #AD8663; }

.rv-fs-hint {
  color: rgba(247, 243, 236, .38);
  font-size: 11px;
  text-align: center;
}

body.rv-lock { overflow: hidden; }

/* ---------- 减少动态效果 / 小屏 ---------- */
@media (prefers-reduced-motion: reduce) {
  .rv-img,
  .rv-badges,
  .rv-fs { transition-duration: 1ms !important; }
  .rv-stage.is-playing .rv-img--after,
  .rv-stage.is-playing .rv-glow { animation: none !important; }
  .rv-stage.is-fade.is-playing .rv-img--after { animation: rv-fade 200ms ease both !important; }
}

@media (max-width: 640px) {
  .rv-bar { padding: 10px 12px; }
  .rv-seg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 86px;
    min-height: 40px;
    padding: 0 18px;
    font-size: 13px;
  }
  .rv-fs-btn { padding: 10px 14px; font-size: 11px; }
}
