/* 解压小站 · 场景与角色动效 */

.relax-scene {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.02fr .98fr;
  gap: 10px;
  min-height: 430px;
  margin-top: 8px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #eef5ea 0%, #f6f1e4 62%, #f3ecdd 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), var(--shadow-soft);
}
.relax-scene.is-night { background: linear-gradient(180deg, #dde5e3 0%, #e7e2d4 70%, #e2dbcb 100%); }

/* ---------- 分层背景 ---------- */
.scene-layer { position: absolute; inset: 0; pointer-events: none; will-change: transform; }
.scene-far {
  background:
    radial-gradient(420px 260px at 24% 16%, rgba(255, 246, 214, .95), transparent 72%),
    radial-gradient(360px 240px at 84% 6%, rgba(206, 232, 206, .9), transparent 74%);
  transform: translate3d(calc(var(--px, 0) * 10px), calc(var(--py, 0) * 6px), 0);
  transition: transform .4s cubic-bezier(.22, .8, .2, 1);
}
.scene-mid {
  background-image:
    repeating-linear-gradient(0deg, rgba(31, 48, 42, .028) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(31, 48, 42, .022) 0 1px, transparent 1px 4px);
  opacity: .7;
  transform: translate3d(calc(var(--px, 0) * 18px), calc(var(--py, 0) * 10px), 0);
  transition: transform .5s cubic-bezier(.22, .8, .2, 1);
}
.scene-near {
  background:
    radial-gradient(150px 46px at 26% 88%, rgba(90, 130, 96, .16), transparent 72%),
    radial-gradient(190px 54px at 74% 94%, rgba(90, 130, 96, .12), transparent 74%);
  transform: translate3d(calc(var(--px, 0) * 30px), calc(var(--py, 0) * 16px), 0);
  transition: transform .6s cubic-bezier(.22, .8, .2, 1);
}
.is-night .scene-far::after {
  content: '';
  position: absolute;
  right: 13%;
  top: 11%;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 32%, #fff9e6, #e6dcc3);
  box-shadow: 0 0 46px rgba(255, 248, 227, .75);
}

/* ---------- 角色 ---------- */
.chr-wrap {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 18px 10px 6px;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.chr-wrap:focus-visible .chr { filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0)) drop-shadow(0 2px 6px rgba(47, 99, 83, .35)); }
.chr { height: 384px; width: auto; max-width: 100%; overflow: visible; }

.chr-plant {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: chrBreathe 4.4s cubic-bezier(.45, 0, .55, 1) infinite;
}
@keyframes chrBreathe {
  0%, 100% { transform: translateY(0) scaleY(1); }
  50% { transform: translateY(-3px) scaleY(1.018); }
}

.chr-eyes {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: chrBlink 5.6s cubic-bezier(.5, 0, .5, 1) infinite;
}
@keyframes chrBlink {
  0%, 89%, 100% { transform: scaleY(1); }
  91.5%, 94% { transform: scaleY(.08); }
}

.chr-shadow { transform-box: fill-box; transform-origin: 50% 50%; animation: chrShadow 4.4s cubic-bezier(.45, 0, .55, 1) infinite; }
@keyframes chrShadow {
  0%, 100% { transform: scaleX(1); opacity: .13; }
  50% { transform: scaleX(.96); opacity: .1; }
}

.chr-flower { transform-box: fill-box; transform-origin: 50% 100%; animation: chrFlower 6s cubic-bezier(.45, 0, .55, 1) infinite; }
@keyframes chrFlower {
  0%, 100% { transform: rotate(-1.6deg); }
  50% { transform: rotate(1.6deg); }
}

.chr-wrap.is-petting .chr-plant { animation: chrSquash .5s cubic-bezier(.34, 1.56, .64, 1); }
.chr-wrap.is-petting .chr-eyes { animation: none; transform: scaleY(.15); }
@keyframes chrSquash {
  0% { transform: scale(1, 1); }
  28% { transform: scale(1.06, .93); }
  58% { transform: scale(.97, 1.025); }
  100% { transform: scale(1, 1); }
}

/* 入夜：睡着 */
.is-sleep .chr-eyes { animation: none; transform: scaleY(.07); }
.is-sleep .chr-plant { animation-duration: 6.4s; }
.is-sleep .chr-flower { animation-duration: 8s; }

/* ---------- 粒子 / 光环 / 气泡 ---------- */
.chr-fx { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.chr-particle {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: chrFly .95s cubic-bezier(.16, 1, .3, 1) forwards;
}
@keyframes chrFly {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.4); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(var(--sc, 1)); }
}
.p-drop { background: radial-gradient(circle at 34% 32%, #e4f4ff, #7fb3c9); box-shadow: 0 0 6px rgba(127, 179, 201, .6); }
.p-spark { background: radial-gradient(circle at 34% 32%, #fff8dc, #e5b45b); box-shadow: 0 0 8px rgba(229, 180, 91, .7); }
.p-heart { background: radial-gradient(circle at 34% 32%, #fbe0d2, #e8834e); box-shadow: 0 0 6px rgba(232, 131, 78, .55); }

.chr-ring {
  position: absolute;
  left: 50%;
  top: 54%;
  width: 130px;
  height: 130px;
  margin: -65px 0 0 -65px;
  border-radius: 50%;
  border: 2px solid rgba(229, 180, 91, .85);
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}
.chr-ring.is-on { animation: chrRing 1.3s cubic-bezier(.16, 1, .3, 1) forwards; }
@keyframes chrRing {
  0% { opacity: .95; transform: scale(.35); }
  70% { opacity: .45; }
  100% { opacity: 0; transform: scale(2.7); }
}

.chr-bubble {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translate(-50%, 8px);
  max-width: 82%;
  padding: 6px 13px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffdf7;
  color: var(--ink-2);
  font-size: 12.5px;
  white-space: nowrap;
  box-shadow: var(--shadow-soft);
  opacity: 0;
  transition: opacity .22s cubic-bezier(.22, .8, .2, 1), transform .22s cubic-bezier(.34, 1.56, .64, 1);
  z-index: 4;
}
.chr-bubble.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 右侧面板 ---------- */
.relax-panel {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 13px;
  padding: 22px 22px 22px 4px;
}
.rp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.rp-title { display: grid; gap: 2px; }
.rp-title b { font-family: var(--serif); font-size: 20px; }
.rp-title span { font-size: 12px; color: var(--muted); }
.rp-mute {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .7);
  color: var(--ink-2);
  border-radius: 99px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .18s cubic-bezier(.34, 1.56, .64, 1), background .18s;
}
.rp-mute:hover { transform: translateY(-1px); background: #fff; }

.rp-stages { display: flex; flex-wrap: wrap; gap: 6px; }
.rp-stages span {
  font-size: 11px;
  padding: 1px 9px;
  border-radius: 99px;
  background: rgba(31, 48, 42, .06);
  color: var(--muted);
  transition: background .3s, color .3s;
}
.rp-stages span.is-on { background: var(--green-soft); color: var(--green-deep); font-weight: 600; }

.rp-progress { display: grid; gap: 6px; }
.rp-bar { height: 9px; border-radius: 99px; background: rgba(31, 48, 42, .08); overflow: hidden; }
.rp-bar i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--green), var(--honey));
  transition: width .42s cubic-bezier(.16, 1, .3, 1);
}
.rp-exp { font-size: 12px; color: var(--muted); }
.rp-exp b { color: var(--ink); font-size: 14px; }

.rp-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.rp-act {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 12px 6px 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .82);
  color: var(--ink);
  cursor: pointer;
  transition: transform .2s cubic-bezier(.34, 1.56, .64, 1), box-shadow .2s, background .2s;
}
.rp-act::after { content: ''; position: absolute; inset: -8px; }
.rp-act:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 12px 20px -14px rgba(31, 48, 42, .5); background: #fff; }
.rp-act:active:not(:disabled) { transform: translateY(0) scale(.97); }
.rp-act:disabled { opacity: .42; cursor: not-allowed; }
.rpa-ico { color: var(--green); display: inline-flex; }
.rp-act:nth-child(2) .rpa-ico { color: var(--honey); }
.rp-act:nth-child(3) .rpa-ico { color: var(--peach); }
.rp-act b { font-size: 12.5px; font-weight: 600; }
.rpa-exp { font-size: 11px; color: var(--muted); }

.rp-flags { display: flex; flex-wrap: wrap; gap: 6px; }
.rp-flags span {
  font-size: 11px;
  color: var(--muted);
  background: rgba(31, 48, 42, .05);
  border-radius: 99px;
  padding: 1px 9px;
}
.rp-flags span.is-on { background: var(--green-soft); color: var(--green-deep); }

.rp-tip { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
.rp-tip b { color: var(--green-deep); font-size: 14px; }

/* 入口卡里的迷你角色 */
.fb-relax-entry .fre-pet { width: 54px; display: grid; place-items: center; flex: none; }
.fb-relax-entry .fre-pet svg { width: 50px; height: auto; display: block; }
.fb-relax-entry .fre-pet .chr-plant { animation-duration: 5s; }

@media (max-width: 900px) {
  .relax-scene { grid-template-columns: 1fr; min-height: 0; }
  .relax-panel { padding: 4px 18px 20px; }
  .chr-wrap { padding-top: 18px; }
  .chr { height: 300px; }
}

@media (prefers-reduced-motion: reduce) {
  .chr-plant, .chr-eyes, .chr-shadow, .chr-flower { animation: none !important; }
  .scene-layer { transition: none; }
  .chr-particle { animation-duration: .01s; }
}

/* 状态与反馈细节 */
.chr-drops circle { animation: chrDrop 3.4s cubic-bezier(.45, 0, .55, 1) infinite; }
.chr-drops g:nth-child(2) circle { animation-delay: .7s; }
.chr-drops g:nth-child(3) circle { animation-delay: 1.3s; }
@keyframes chrDrop {
  0%, 100% { transform: translateY(0); opacity: .85; }
  50% { transform: translateY(-1.6px); opacity: 1; }
}

.chr-ripple {
  position: absolute;
  left: 50%;
  top: 56%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  border: 2px solid rgba(127, 168, 184, .8);
  animation: chrRipple .85s cubic-bezier(.16, 1, .3, 1) forwards;
  pointer-events: none;
  z-index: 3;
}
@keyframes chrRipple {
  0% { opacity: .9; transform: scale(.35); }
  100% { opacity: 0; transform: scale(3.1); }
}

.chr-float {
  position: absolute;
  left: 50%;
  top: 16%;
  transform: translate(-50%, 0);
  font-size: 15px;
  font-weight: 700;
  color: #C8893B;
  text-shadow: 0 2px 8px rgba(255, 255, 255, .95);
  animation: chrFloat 1.5s cubic-bezier(.16, 1, .3, 1) forwards;
  pointer-events: none;
  z-index: 5;
}
@keyframes chrFloat {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(.9); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -48px) scale(1.06); }
}

/* ---------- 树形态 ---------- */
.chr-tree .chr-plant {
  animation: chrSway 5.4s cubic-bezier(.45, 0, .55, 1) infinite;
  transform-box: fill-box;
  transform-origin: 50% 100%;
}
@keyframes chrSway {
  0%, 100% { transform: rotate(-.6deg); }
  50% { transform: rotate(.7deg); }
}

.chr-canopy {
  transform-box: fill-box;
  transform-origin: 50% 92%;
  animation: chrCanopy 4.8s cubic-bezier(.45, 0, .55, 1) infinite;
}
@keyframes chrCanopy {
  0%, 100% { transform: rotate(-.9deg) translateY(0); }
  50% { transform: rotate(.9deg) translateY(-2px); }
}

.chr-fruit {
  transform-box: fill-box;
  transform-origin: 50% 0%;
  animation: chrFruitSwing 3.4s cubic-bezier(.45, 0, .55, 1) infinite;
  animation-delay: calc(var(--i, 0) * -.45s);
}
@keyframes chrFruitSwing {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

.chr-tree.is-sleep .chr-plant { animation-duration: 7s; }

/* ---------- 演示 / 预览面板 ---------- */
.relax-demo {
  position: absolute;
  left: 14px;
  top: 12px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.rd-toggle {
  border: 1px dashed var(--line-strong);
  background: rgba(255, 255, 255, .72);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.8;
  padding: 1px 10px;
  border-radius: 99px;
  cursor: pointer;
  transition: color .2s, background .2s, border-color .2s;
}
.rd-toggle:hover { color: var(--ink-2); background: #fff; }
.relax-demo.is-open .rd-toggle { color: var(--green-deep); border-color: var(--green); background: var(--green-mist); border-style: solid; }

.rd-panel {
  background: rgba(255, 253, 247, .97);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 10px 12px;
  display: grid;
  gap: 8px;
  min-width: 236px;
  animation: rdIn .22s cubic-bezier(.16, 1, .3, 1);
}
@keyframes rdIn { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

.rd-row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.rd-row > span { font-size: 11.5px; color: var(--muted); width: 28px; flex: none; }
.rd-row button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  font-size: 11.5px;
  padding: 2px 9px;
  cursor: pointer;
  color: var(--ink-2);
  transition: background .18s, color .18s, border-color .18s, transform .18s;
}
.rd-row button:hover { transform: translateY(-1px); }
.rd-row button.is-on { background: var(--green); color: #f6f1e4; border-color: var(--green); }

.rd-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px dashed var(--line);
  padding-top: 6px;
}
.rd-reset {
  border: 0;
  background: none;
  color: var(--peach-deep);
  font-size: 11.5px;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.rp-preview {
  margin: 0;
  font-size: 12px;
  color: var(--peach-deep);
  display: flex;
  align-items: center;
  gap: 5px;
}

@media (max-width: 900px) {
  .relax-demo { top: 10px; right: 10px; }
  .rd-panel { min-width: 0; }
}