/* ============================================================
   pet.css — 柴犬电子宠物 + 彩蛋弹层 + 彩带 + Toast
   柴犬全部由 CSS 绘制，无图片依赖
   ============================================================ */

/* ============ 宠物容器（fixed 层，靠 transform 在视口内移动） ============ */
.pet {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  user-select: none;
  will-change: transform;
  /* 位置由 JS 的 translate3d 控制，这里不做 transition 以免打架 */
}

.pet__stage {
  position: relative;
  width: 150px;
  height: 168px;
  display: grid;
  place-items: center;
  cursor: grab;
  filter: drop-shadow(0 18px 26px rgba(0, 0, 0, 0.55));
}
/* 站立时给耳朵留出空间（头顶不被裁切） */

.pet__stage:active {
  cursor: grabbing;
}

/* 跟随鼠标时的轻微倾斜（由 JS 通过 --tilt 提供，现已较少使用） */
.pet__stage.is-follow {
  transform: rotate(var(--tilt, 0deg));
}

/* 影子 */
.pet__shadow {
  position: absolute;
  bottom: 44px;
  left: 50%;
  width: 88px;
  height: 13px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(255, 180, 110, 0.26), transparent 72%);
  border-radius: 50%;
  transition: width var(--dur-base) ease, opacity var(--dur-base) ease;
}

/* 整只狗的呼吸/跳跃 */
.pet__dog {
  position: relative;
  width: 118px;
  height: 112px;
  margin-bottom: 22px;
  animation: dogIdle 3.4s var(--ease-in-out) infinite;
  transform-origin: 50% 100%;
  will-change: transform;
}

@keyframes dogIdle {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-4px) scale(1.012, 0.99);
  }
}

/* ---------- 走路：整体上下颠 + 左右微摆，像四条腿在跑 ---------- */
.pet__dog.is-walking {
  animation: dogWalk 0.36s var(--ease-in-out) infinite;
}
@keyframes dogWalk {
  0% {
    transform: translateY(0) rotate(-1.6deg);
  }
  25% {
    transform: translateY(-5px) rotate(0deg);
  }
  50% {
    transform: translateY(0) rotate(1.6deg);
  }
  75% {
    transform: translateY(-5px) rotate(0deg);
  }
  100% {
    transform: translateY(0) rotate(-1.6deg);
  }
}

/* 走路时腿交替抬起 */
.pet__dog.is-walking .dog__legs i:nth-child(1),
.pet__dog.is-walking .dog__legs i:nth-child(4) {
  animation: legStepA 0.36s var(--ease-in-out) infinite;
}
.pet__dog.is-walking .dog__legs i:nth-child(2),
.pet__dog.is-walking .dog__legs i:nth-child(3) {
  animation: legStepB 0.36s var(--ease-in-out) infinite;
}
@keyframes legStepA {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@keyframes legStepB {
  0%, 100% { transform: translateY(-4px); }
  50% { transform: translateY(0); }
}

/* 走路时尾巴摇得更欢 */
.pet__dog.is-walking .dog__tail {
  animation-duration: 0.32s;
}

/* ---------- 朝向翻转（向右走时水平镜像） ---------- */
.pet__dog.is-flip {
  /* 用 --facing 控制，保持内部动画不被覆盖 */
  scale: -1 1;
}

/* 被摸：蹦一下并左右摆头 */
.pet__dog.is-pat {
  animation: dogPat 0.62s var(--ease-spring);
}
@keyframes dogPat {
  0% {
    transform: translateY(0) rotate(0);
  }
  30% {
    transform: translateY(-16px) rotate(-7deg) scale(1.06, 0.94);
  }
  60% {
    transform: translateY(0) rotate(6deg) scale(0.96, 1.05);
  }
  100% {
    transform: translateY(0) rotate(0) scale(1);
  }
}

/* 蹭头（主动撒娇）：整只前倾 */
.pet__dog.is-nuzzle {
  animation: dogNuzzle 1.5s var(--ease-in-out);
}
@keyframes dogNuzzle {
  0%,
  100% {
    transform: translate(0, 0) rotate(0);
  }
  25% {
    transform: translate(-8px, -3px) rotate(-9deg);
  }
  55% {
    transform: translate(6px, -5px) rotate(8deg);
  }
  80% {
    transform: translate(-3px, -1px) rotate(-4deg);
  }
}

/* 敲屏幕 */
.pet__dog.is-knock {
  animation: dogKnock 0.42s var(--ease-in-out) 4;
}
@keyframes dogKnock {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(-11px) rotate(-3deg);
  }
}

/* 吃东西 */
.pet__dog.is-eat {
  animation: dogEat 0.3s var(--ease-in-out) 6;
}
@keyframes dogEat {
  0%,
  100% {
    transform: scale(1, 1);
  }
  50% {
    transform: scale(1.05, 0.93) translateY(3px);
  }
}

/* ---------- 身体 ---------- */
.dog {
  position: absolute;
  inset: 0;
}

.dog__body {
  position: absolute;
  left: 20px;
  bottom: 14px;
  width: 74px;
  height: 52px;
  border-radius: 46% 46% 42% 42% / 52% 52% 48% 48%;
  background: linear-gradient(160deg, #F4B26A 0%, #E09048 58%, #C8763A 100%);
  box-shadow: inset -6px -8px 14px rgba(140, 70, 25, 0.32), inset 6px 6px 12px rgba(255, 224, 186, 0.4);
  z-index: 2;
}
/* 腹部浅色绒毛（露在身体下沿，与白袜子衔接） */
.dog__body::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 42px;
  height: 16px;
  transform: translateX(-50%);
  border-radius: 40% 40% 46% 46%;
  background: linear-gradient(180deg, rgba(242, 220, 190, 0.5), rgba(250, 240, 222, 0.85));
}

/* 尾巴：柴犬标志性的卷尾，从身体右侧翘起 */
.dog__tail {
  position: absolute;
  right: 2px;
  bottom: 40px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 10px solid #E09048;
  border-left-color: transparent;
  border-top-color: transparent;
  /* 只留右下弧线，形成向上卷起的粗尾巴 */
  transform: rotate(-32deg);
  transform-origin: 50% 50%;
  animation: tailWag 0.75s var(--ease-in-out) infinite;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.18));
  z-index: 0;
}
@keyframes tailWag {
  0%,
  100% {
    transform: rotate(-38deg);
  }
  50% {
    transform: rotate(-14deg);
  }
}
.pet__dog.is-pat .dog__tail,
.pet__dog.is-eat .dog__tail {
  animation-duration: 0.22s;
}
.pet__dog.is-nuzzle .dog__tail {
  animation-duration: 0.3s;
}

/* 四条短腿：从身体下沿露出，形成坐姿 */
.dog__legs {
  position: absolute;
  left: 26px;
  bottom: 2px;
  width: 62px;
  display: flex;
  justify-content: space-between;
  z-index: 1;
}
.dog__legs i {
  width: 15px;
  height: 19px;
  border-radius: 7px 7px 9px 9px;
  background: linear-gradient(180deg, #E79B54 30%, #C8763A 100%);
  box-shadow: inset -2px -3px 5px rgba(120, 60, 20, 0.3);
}
/* 前爪的浅色脚背（柴犬的白袜子） */
.dog__legs i:nth-child(2),
.dog__legs i:nth-child(3) {
  background: linear-gradient(180deg, #E79B54 34%, #FBF0DC 100%);
}

/* ---------- 头 ---------- */
/* 注意：head 必须比 body 层级更高，否则身体会盖住口鼻 */
.dog__head {
  position: absolute;
  left: 14px;
  top: 0;
  width: 88px;
  height: 80px;
  transform-origin: 50% 90%;
  animation: headBob 3.4s var(--ease-in-out) infinite;
  z-index: 3;
}
@keyframes headBob {
  0%,
  100% {
    transform: rotate(0);
  }
  50% {
    transform: rotate(-2.5deg);
  }
}
.pet__dog.is-pat .dog__head {
  animation: headHappy 0.62s var(--ease-spring);
}
@keyframes headHappy {
  0%,
  100% {
    transform: rotate(0);
  }
  40% {
    transform: rotate(-12deg);
  }
  75% {
    transform: rotate(8deg);
  }
}

/* 脸盘 */
.dog__face {
  position: absolute;
  inset: 0;
  border-radius: 48% 48% 46% 46% / 52% 52% 50% 50%;
  background: linear-gradient(165deg, #F7BA74 0%, #E79B54 60%, #CE7C3C 100%);
  box-shadow: inset -6px -8px 14px rgba(140, 70, 25, 0.3), inset 6px 6px 12px rgba(255, 228, 192, 0.42);
  overflow: hidden;
}
/* 柴犬标志性的白色脸颊面罩（只覆盖下半张脸中央，压在五官之下） */
.dog__face::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 48px;
  height: 34px;
  transform: translateX(-50%);
  border-radius: 50% 50% 48% 48% / 62% 62% 40% 40%;
  background: linear-gradient(180deg, rgba(255, 249, 238, 0.98), rgba(246, 226, 200, 0.92));
  z-index: 1;
}

/* 耳朵：柴犬的三角立耳 */
.dog__ear {
  position: absolute;
  top: -10px;
  width: 28px;
  height: 30px;
  /* 用 clip-path 裁出尖角三角形，比圆角更像立耳 */
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
  border-radius: 4px 4px 6px 6px;
  background: linear-gradient(175deg, #F2AC63, #C8763A);
  transition: transform var(--dur-base) var(--ease-spring);
  z-index: 2;
}
.dog__ear--l {
  left: -2px;
  transform: rotate(-13deg);
}
.dog__ear--r {
  right: -2px;
  transform: rotate(13deg) scaleX(-1);
}
/* 耳廓内侧的浅色绒毛 */
.dog__ear::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 13px;
  height: 17px;
  transform: translateX(-50%);
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
  background: rgba(150, 82, 40, 0.42);
}
/* 被摸时耳朵塌下来 */
.pet__dog.is-pat .dog__ear--l {
  transform: rotate(-42deg) translateY(4px);
}
.pet__dog.is-pat .dog__ear--r {
  transform: rotate(42deg) translateY(4px);
}
.pet__dog.is-nuzzle .dog__ear--l {
  transform: rotate(-30deg);
}
.pet__dog.is-nuzzle .dog__ear--r {
  transform: rotate(30deg);
}

/* 眼睛 */
.dog__eye {
  position: absolute;
  top: 33px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2A1B10;
  z-index: 5;
  /* 目光跟随鼠标时轻微偏移 */
  transform: translate(var(--look-x, 0px), var(--look-y, 0px));
  transition: height var(--dur-fast) ease, transform 0.25s var(--ease-out);
}
/* 眨眼：内层负责纵向压缩，外层负责目光偏移，互不覆盖 */
.dog__eye::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: inherit;
  transform-origin: 50% 50%;
  animation: blinkInner 5.2s var(--ease-in-out) infinite;
}
.dog__eye--l {
  left: 22px;
}
.dog__eye--r {
  right: 22px;
}
@keyframes blinkInner {
  0%,
  92%,
  100% {
    transform: scaleY(1);
  }
  95% {
    transform: scaleY(0.1);
  }
}
.pet__dog.is-pat .dog__eye,
.pet__dog.is-eat .dog__eye {
  height: 4px;
  border-radius: 4px;
}
.pet__dog.is-pat .dog__eye::before,
.pet__dog.is-eat .dog__eye::before,
.pet__dog.is-nuzzle .dog__eye::before {
  animation: none;
}

/* 口鼻：位于白色面罩中央 */
.dog__muzzle {
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%);
  width: 40px;
  height: 30px;
  z-index: 3;
}
/* 鼻梁处的一点阴影，让口鼻更立体 */
.dog__muzzle::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -4px;
  transform: translateX(-50%);
  width: 20px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(190, 150, 105, 0.28), transparent 70%);
}
.dog__nose {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: 13px;
  height: 9px;
  border-radius: 50% 50% 46% 46%;
  background: #3A2614;
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.35);
  transition: transform var(--dur-fast) var(--ease-spring);
  z-index: 4;
}
.pet__dog.is-eat .dog__nose {
  animation: noseTwitch 0.3s ease-in-out 6;
}
@keyframes noseTwitch {
  0%,
  100% {
    transform: translateX(-50%) scale(1);
  }
  50% {
    transform: translateX(-50%) scale(1.24, 0.88);
  }
}
/* 微笑嘴 */
.dog__mouth {
  position: absolute;
  left: 50%;
  top: 9px;
  transform: translateX(-50%);
  width: 20px;
  height: 9px;
  border-bottom: 2.4px solid #4A3120;
  border-radius: 0 0 50% 50%;
  transition: all var(--dur-fast) ease;
  z-index: 5;
}
.pet__dog.is-pat .dog__mouth,
.pet__dog.is-eat .dog__mouth {
  width: 26px;
  height: 14px;
  border-bottom-width: 3px;
  background: radial-gradient(ellipse at 50% 90%, rgba(255, 120, 130, 0.5), transparent 60%);
}
/* 张嘴吐舌（高兴） */
.pet__dog.is-pat .dog__mouth::after,
.pet__dog.is-eat .dog__mouth::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 7px;
  transform: translateX(-50%);
  width: 13px;
  height: 9px;
  border-radius: 0 0 50% 50%;
  background: #FF8A93;
}

/* 腮红 */
.dog__cheek {
  position: absolute;
  top: 47px;
  width: 14px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 130, 120, 0.36);
  filter: blur(2px);
  opacity: 0;
  transition: opacity var(--dur-base) ease;
  z-index: 6;
}
.dog__cheek--l {
  left: 5px;
}
.dog__cheek--r {
  right: 5px;
}
.pet__dog.is-pat .dog__cheek,
.pet__dog.is-nuzzle .dog__cheek,
.pet__dog.is-eat .dog__cheek {
  opacity: 1;
}

/* ---------- 宠物气泡 ---------- */
.pet__bubble {
  position: relative;
  max-width: min(208px, 78vw);
  padding: 11px 15px;
  border-radius: var(--radius-md);
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-soft);
  font-size: var(--fs-xs);
  line-height: 1.7;
  color: var(--ink);
  opacity: 0;
  transform: translateY(10px) scale(0.94);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-spring);
}
.pet__bubble::after {
  content: "";
  position: absolute;
  right: 26px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: var(--glass-bg-strong);
  border-right: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
  transform: rotate(45deg);
}
.pet__bubble.is-show {
  opacity: 1;
  transform: none;
}

/* ---------- 抚摸提示（贴在柴犬脚下方的常驻小标签） ---------- */
.pet__hint {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--fs-tiny);
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  padding: 3px 11px;
  border-radius: var(--radius-full);
  background: rgba(8, 11, 19, 0.78);
  border: 1px solid rgba(255, 184, 112, 0.2);
  white-space: nowrap;
  opacity: 1;
  transition: opacity var(--dur-slow) ease;
}
.pet__hint.is-gone {
  opacity: 0;
}

/* 提示闪烁吸引注意 */
.pet__hint::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  border: 1px solid rgba(255, 184, 112, 0.22);
  animation: hintPulse 2.6s var(--ease-in-out) infinite;
}
@keyframes hintPulse {
  0%,
  100% {
    opacity: 0.2;
    transform: scale(1);
  }
  50% {
    opacity: 0.75;
    transform: scale(1.1);
  }
}

/* ---------- 亲密度 ---------- */
.pet__stats {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-full);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.pet__meter {
  position: relative;
  width: 96px;
  height: 18px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.pet__meter-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--lamp-deep), var(--lamp-bright), var(--lamp-core));
  box-shadow: 0 0 12px rgba(255, 154, 77, 0.6);
  transition: width var(--dur-slow) var(--ease-out);
}
.pet__meter-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--ink);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
.pet__meter-label b {
  font-weight: 700;
}

.pet__mini-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.09);
  font-size: 14px;
  transition: transform var(--dur-fast) var(--ease-spring), background var(--dur-fast) ease;
}
.pet__mini-btn:hover {
  transform: scale(1.14) rotate(-8deg);
  background: rgba(255, 184, 112, 0.18);
}
.pet__mini-btn:active {
  transform: scale(0.9);
}

/* 升级提示闪光 */
.pet.is-levelup .pet__meter-fill {
  animation: meterFlash 0.9s var(--ease-in-out) 2;
}
@keyframes meterFlash {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.8);
  }
}

/* ============ 彩蛋弹层 ============ */
/* 注意：[hidden] 必须优先级最高，否则 display:grid 会让隐藏的弹层继续拦截点击 */
.overlay[hidden] {
  display: none !important;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 6, 12, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn var(--dur-base) var(--ease-out);
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
}

.overlay__card {
  position: relative;
  width: min(460px, 100%);
  padding: var(--space-6) var(--space-6) var(--space-5);
  text-align: center;
  border-radius: var(--radius-lg);
  animation: cardIn var(--dur-slow) var(--ease-spring);
}
@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(26px) scale(0.94);
  }
}

.overlay__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink-faint);
  font-size: 13px;
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}
.overlay__close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

.overlay__icon {
  font-size: 52px;
  line-height: 1;
  margin-bottom: var(--space-4);
  animation: iconFloat 3s var(--ease-in-out) infinite;
  filter: drop-shadow(0 8px 22px rgba(255, 154, 77, 0.35));
}
@keyframes iconFloat {
  0%,
  100% {
    transform: translateY(0) rotate(-3deg);
  }
  50% {
    transform: translateY(-8px) rotate(3deg);
  }
}

.overlay__title {
  font-size: var(--fs-h3);
  color: var(--ink);
  margin-bottom: var(--space-3);
}
.overlay__text {
  font-size: var(--fs-sm);
  line-height: 1.9;
  color: var(--ink-soft);
  margin-bottom: var(--space-5);
}

/* ============ 彩带 / 星光 ============ */
.confetti {
  position: fixed;
  inset: 0;
  z-index: 95;
  pointer-events: none;
  overflow: hidden;
}
.confetti__piece {
  position: absolute;
  top: -20px;
  border-radius: 2px;
  will-change: transform, opacity;
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  z-index: 110;
  transform: translate(-50%, 20px);
  padding: 11px 20px;
  border-radius: var(--radius-full);
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-soft);
  font-size: var(--fs-xs);
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-spring);
  white-space: nowrap;
  max-width: calc(100vw - 48px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ============ 响应式：窄屏整体缩小 ============ */
/* 关键：不要用 zoom / scale 在 .pet 上，否则会连带缩放 JS 设置的 translate 坐标。
   改为缩小内部的舞台与 UI 尺寸，根元素保持 1:1，坐标系统就不会错乱。 */
@media (max-width: 720px) {
  .pet__stage {
    width: 108px;
    height: 122px;
  }
  .pet__dog {
    scale: 0.72;
    margin-bottom: 12px;
  }
  .pet__shadow {
    bottom: 30px;
    width: 64px;
  }
  .pet__bubble {
    max-width: 156px;
    font-size: var(--fs-tiny);
    padding: 9px 12px;
  }
  .pet__meter {
    width: 66px;
    height: 16px;
  }
  .pet__meter-label {
    font-size: 9px;
  }
  .pet__mini-btn {
    width: 25px;
    height: 25px;
    font-size: 12px;
  }
  .pet__stats {
    padding: 5px 8px;
  }
  .toast {
    bottom: 108px;
  }
}
