/* =========================================================================
   糖糖 · 陪伴小猫 + 光标
   —— 右下角一只会呼吸、会眨眼、会打盹的小猫，点一下会说话；
      桌面端外加一圈跟着鼠标走的光。
   和其它页面的关系：不占文档流，全部 fixed；手机上小一号；
   `prefers-reduced-motion` 下不演动画，只留一个能点的头像。
   ========================================================================= */

/* ------------------------------------------------------------ 小猫本体 */
.pet {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 850;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;          /* 只有按钮和气泡接管点击 */
  transition: opacity .35s var(--ease), transform .35s var(--ease);
}
/* 首页开场的纸还没散、手机抽屉拉开时，先别露头 */
body.is-intro .pet,
body.nav-open .pet { opacity: 0; transform: translateY(10px) scale(.9); pointer-events: none; }
/* 正在填表 / 输密码时让开 */
.pet.is-away { opacity: 0; transform: translateY(14px) scale(.9); pointer-events: none; }

.pet_btn {
  pointer-events: auto;
  position: relative;
  width: 64px; height: 64px;
  padding: 0;
  border-radius: 50%;
  display: grid; place-items: center;
  background:
    radial-gradient(120% 120% at 30% 18%, #fffefd 0%, #fff5f6 52%, #ffe1e8 100%);
  border: 1px solid rgba(255, 152, 172, .62);
  box-shadow:
    0 10px 26px -12px rgba(200, 80, 105, .38),
    0 2px 8px rgba(200, 80, 105, .10),
    inset 0 1px 0 rgba(255, 255, 255, .9);
  transition: transform .35s var(--ease), box-shadow .35s var(--ease);
  animation: petBob 4.4s ease-in-out infinite;
}
.pet_btn:hover {
  transform: translateY(-2px);
  box-shadow:
    0 16px 34px -14px rgba(200, 80, 105, .46),
    0 2px 8px rgba(200, 80, 105, .12),
    inset 0 1px 0 rgba(255, 255, 255, .9);
}
.pet_btn:active { transform: translateY(0) scale(.96); }
.pet_btn:focus-visible {
  outline: 2px solid var(--rose-ink);
  outline-offset: 3px;
}

/* 身后那圈光：呼吸感，比阴影更像「活的」 */
.pet_halo {
  position: absolute; inset: -7px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 176, 193, .34), transparent 68%);
  animation: petHalo 4.4s ease-in-out infinite;
  pointer-events: none;
}

.pet_cat { width: 46px; height: 46px; display: block; overflow: visible; }
/* SVG 的 transform-origin 默认对着视口，得先换成「自己的框」 */
.pet_cat .pet_ear { transform-box: fill-box; transform-origin: 50% 100%; }
.pet_cat .pet_ear--l { animation: petEar 7s ease-in-out infinite; }
.pet_cat .pet_ear--r { animation: petEar 7s ease-in-out .18s infinite; }
.pet_cat .pet_tail { transform-box: fill-box; transform-origin: 0% 100%; animation: petTail 3.4s ease-in-out infinite; }
/* 眨眼：睁眼/闭眼两组交替，占空比很小，看着像偶尔眨一下 */
.pet_cat .pet_shut { opacity: 0; }
.pet_cat .pet_open { animation: petBlinkOpen 6.4s linear infinite; }
.pet_cat .pet_shut { animation: petBlinkShut 6.4s linear infinite; }

/* 静置久了打盹：眼睛闭着，呼吸慢下来 */
.pet.is-sleep .pet_open { opacity: 0; animation: none; }
.pet.is-sleep .pet_shut { opacity: 1; animation: none; }
.pet.is-sleep .pet_btn { animation-duration: 6.6s; }
.pet.is-sleep .pet_tail { animation-duration: 5.6s; }

/* 点一下：蹦一下 */
.pet.is-hop .pet_cat { animation: petHop .72s cubic-bezier(.3, .8, .3, 1); }
.pet.is-hop .pet_btn { animation: none; }

/* ------------------------------------------------------------ 说话的气泡 */
.pet_bubble {
  pointer-events: none;
  position: relative;
  max-width: min(74vw, 250px);
  padding: 11px 34px 11px 14px;
  border-radius: 16px 16px 5px 16px;
  background: #fffdfc;
  border: 1px solid rgba(255, 170, 186, .55);
  box-shadow: 0 18px 40px -20px rgba(180, 70, 95, .45), 0 2px 6px rgba(180, 70, 95, .07);
  font-size: 13.5px;
  line-height: 1.68;
  color: var(--ink-2);
  text-align: left;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(.92);
  transform-origin: 100% 100%;
  transition:
    opacity .22s var(--ease),
    transform .34s cubic-bezier(.2, .9, .3, 1.16),
    visibility .3s;
}
.pet.is-open .pet_bubble { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }
/* 气泡尾巴：指向小猫 */
.pet_bubble::after {
  content: '';
  position: absolute;
  right: 10px; bottom: -7px;
  width: 15px; height: 8px;
  background: #fffdfc;
  border-right: 1px solid rgba(255, 170, 186, .55);
  border-bottom: 1px solid rgba(255, 170, 186, .55);
  border-radius: 0 0 3px 0;
  transform: skewX(28deg);
}
.pet_text { margin: 0; white-space: pre-wrap; }
.pet_text::after {
  content: '';
  display: inline-block;
  width: 1px; height: 1em;
  margin-left: 1px;
  vertical-align: -2px;
  background: var(--rose);
  animation: petCaret .9s steps(1) infinite;
}
.pet.is-typed .pet_text::after { display: none; }

.pet_close {
  position: absolute;
  top: 6px; right: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--ink-3);
  font-size: 15px; line-height: 1;
  transition: background .2s, color .2s;
}
.pet_close:hover { background: var(--pink-mist); color: var(--rose-ink); }
.pet_close:focus-visible { outline: 2px solid var(--rose-ink); outline-offset: 1px; }

.pet_chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pet_chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 170, 186, .6);
  background: var(--pink-mist);
  color: var(--rose-ink);
  font-size: 12px;
  line-height: 1.7;
  transition: background .2s, color .2s, border-color .2s;
}
.pet_chip:hover { background: var(--rose); border-color: var(--rose); color: #fff; }

/* ------------------------------------------------------------ 小猫的小动作 */
@keyframes petBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}
@keyframes petHalo {
  0%, 100% { opacity: .55; transform: scale(1); }
  50%      { opacity: .95; transform: scale(1.06); }
}
@keyframes petTail {
  0%, 100% { transform: rotate(-7deg); }
  50%      { transform: rotate(9deg); }
}
@keyframes petEar {
  0%, 86%, 100% { transform: rotate(0deg); }
  90%           { transform: rotate(-7deg); }
  94%           { transform: rotate(4deg); }
}
@keyframes petBlinkOpen {
  0%, 92%, 96%, 100% { opacity: 1; }
  93%, 95%           { opacity: 0; }
}
@keyframes petBlinkShut {
  0%, 92%, 96%, 100% { opacity: 0; }
  93%, 95%           { opacity: 1; }
}
@keyframes petHop {
  0%   { transform: translateY(0) scale(1); }
  35%  { transform: translateY(-9px) scale(1.06, .95); }
  62%  { transform: translateY(0) scale(.97, 1.03); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes petCaret { 50% { opacity: 0; } }

/* ------------------------------------------------------------ 小屏 */
@media (max-width: 899px) {
  .pet { right: max(12px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); }
  .pet_btn { width: 54px; height: 54px; }
  .pet_cat { width: 40px; height: 40px; }
  .pet_bubble { max-width: min(72vw, 232px); font-size: 13px; padding: 10px 32px 10px 12px; }
}

/* ------------------------------------------------------------ 关掉动效 */
@media (prefers-reduced-motion: reduce) {
  .pet_btn, .pet_halo { animation: none; }
  .pet_cat .pet_ear, .pet_cat .pet_tail,
  .pet_cat .pet_open, .pet_cat .pet_shut { animation: none; }
  .pet_cat .pet_shut { opacity: 0; }
  .pet.is-hop .pet_cat { animation: none; }
  .pet_bubble { transition: opacity .2s; transform: none; }
  .pet.is-open .pet_bubble { transform: none; }
}
