/* style.css —— 温暖治愈风（奶油色/暖黄）+ 三段式布局 + 动画 */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #fdf3dd;
  --card: #fff8ec;
  --ink: #5b4636;
  --ink-light: #8a7561;
  --accent: #f4a259;
  --accent-deep: #e07b39;
  --pink: #f3b8c4;
  --shadow: 0 6px 18px rgba(120, 84, 48, 0.16);
}

html, body { height: 100%; }

body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden; /* 单屏不滚动 */
}

.hidden { display: none !important; }

.page { height: 100vh; display: flex; flex-direction: column; }

/* ============ 领养页 ============ */

#adopt-page { align-items: center; justify-content: center; }

.adopt-wrap { width: min(680px, 92vw); text-align: center; }

.adopt-title { font-size: 26px; margin-bottom: 6px; }
.adopt-subtitle { color: var(--ink-light); margin-bottom: 18px; }

.pet-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.pet-cell {
  position: relative;
  background: var(--card);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 6px 4px 4px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

/* 每张卡片自带的拉票气泡：悬浮在该卡片正上方 */
.cell-bubble {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 2px solid #f0dcae;
  border-radius: 14px;
  padding: 7px 13px;
  font-size: 13.5px;
  color: var(--ink);
  box-shadow: var(--shadow);
  white-space: nowrap;
  z-index: 6;
  animation: bubble-in 0.25s ease;
  pointer-events: none;
}
.cell-bubble::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: #fff;
  filter: drop-shadow(0 2px 0 #f0dcae);
}

.pet-cell svg { width: 100%; height: auto; display: block; }
.pet-cell .pet-cell-name { font-size: 12px; color: var(--ink-light); }

.pet-cell:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.pet-cell.selected {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  background: #fff1d9;
}
.pet-cell.selected .pet-cell-name { color: var(--accent-deep); font-weight: bold; }

.adopt-form { display: flex; gap: 10px; justify-content: center; }

.adopt-form input {
  width: 260px;
  font-size: 16px;
  padding: 10px 14px;
  border: 2px solid #e8d9bd;
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  outline: none;
}
.adopt-form input:focus { border-color: var(--accent); }

.hint { margin-top: 10px; font-size: 13px; color: #d9534f; min-height: 18px; }

.trait-line { min-height: 20px; margin-bottom: 14px; color: var(--ink-light); font-size: 14px; }

.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}

/* ============ 按钮 ============ */

.btn {
  font-family: inherit;
  font-size: 16px;
  padding: 10px 22px;
  border: none;
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s, background 0.12s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-deep); }
.btn.small { font-size: 14px; padding: 6px 14px; }

/* ============ 主页：三段式 ============ */

.top-bar {
  height: 58px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: var(--card);
  border-bottom: 2px solid #f0e3c8;
}

.pet-name { font-size: 20px; font-weight: bold; }
.pet-species { flex: 1; color: var(--ink-light); font-size: 15px; }

.stage {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.action-bar {
  height: 84px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  background: var(--card);
  border-top: 2px solid #f0e3c8;
}
.action-bar .btn { font-size: 17px; padding: 11px 26px; }

/* ============ 宠物展示 ============ */

.pet-display {
  width: min(52vh, 400px);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.pet-breath { animation: breathe 3s ease-in-out infinite; }
.pet-breath svg { width: 100%; height: auto; display: block; }

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}

/* ============ 生肖专属待机小动作（可被互动动画临时覆盖） ============ */

.pet-display.anim-hop { animation: hop 3.4s ease-in-out infinite; }
@keyframes hop {
  0%, 62%, 100% { transform: translateY(0); }
  70% { transform: translateY(-14px); }
  78% { transform: translateY(0); }
  86% { transform: translateY(-8px); }
  94% { transform: translateY(0); }
}

.pet-display.anim-sway { animation: sway 4s ease-in-out infinite; }
@keyframes sway {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-2.5deg); }
  75% { transform: rotate(2.5deg); }
}

.pet-display.anim-nod { animation: nod 3.6s ease-in-out infinite; }
@keyframes nod {
  0%, 70%, 100% { transform: translateY(0); }
  78% { transform: translateY(5px); }
  86% { transform: translateY(0); }
  93% { transform: translateY(4px); }
}

.pet-display.anim-scratch { animation: scratch 3.8s ease-in-out infinite; }
@keyframes scratch {
  0%, 60%, 100% { transform: rotate(0deg); }
  66% { transform: rotate(-3deg) translateX(-2px); }
  72% { transform: rotate(2deg) translateX(2px); }
  78% { transform: rotate(-3deg) translateX(-2px); }
  84% { transform: rotate(2deg) translateX(2px); }
  90% { transform: rotate(0deg); }
}

.pet-display.anim-wag { animation: wag 2.6s ease-in-out infinite; }
@keyframes wag {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(2.2deg) translateY(2px); }
  50% { transform: rotate(0deg); }
  75% { transform: rotate(-2.2deg) translateY(2px); }
}

.pet-display.anim-bob { animation: bob 3.2s ease-in-out infinite; }
@keyframes bob {
  0%, 55%, 100% { transform: translateY(0) scale(1); }
  65% { transform: translateY(3px) scale(1.02, 0.985); }
  75% { transform: translateY(0) scale(1); }
  85% { transform: translateY(3px) scale(1.02, 0.985); }
}

/* 摸头时：开心晃动 */
.pet-display.wiggle { animation: wiggle 0.7s ease; }
@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-7deg) scale(1.03); }
  45% { transform: rotate(6deg) scale(1.04); }
  70% { transform: rotate(-4deg) scale(1.02); }
}

/* 喂食时：咀嚼点头 */
.pet-display.eating { animation: chew 0.55s ease-in-out infinite; }
@keyframes chew {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(6px) scale(1.015, 0.985); }
}

/* 开心蹦跳 */
.pet-display.jump { animation: jump 0.6s ease; }
@keyframes jump {
  0%, 100% { transform: translateY(0); }
  35% { transform: translateY(-26px); }
  60% { transform: translateY(0); }
  80% { transform: translateY(-10px); }
}

/* ============ SVG 表情与部件 ============ */

.pet-svg .eye { fill: #4a3728; }
.pet-svg .eyeline { stroke: #4a3728; stroke-width: 3.5; fill: none; stroke-linecap: round; }
.pet-svg .mouth { stroke: #4a3728; stroke-width: 3; fill: none; stroke-linecap: round; }
.pet-svg .mouth-open { fill: #8d5a4a; }
.pet-svg .blush { fill: #f4a3a0; opacity: 0.5; }
.pet-svg .whisker { stroke: #00000055; stroke-width: 2.5; stroke-linecap: round; }
.pet-svg .stripe { stroke: #6b4a2f; stroke-width: 5; fill: none; stroke-linecap: round; }

/* 表情组切换：默认全部隐藏，按 data-expr 显示对应组 */
.pet-svg .expr-idle, .pet-svg .expr-happy, .pet-svg .expr-eating { display: none; }
.pet-svg[data-expr="idle"] .expr-idle { display: inline; }
.pet-svg[data-expr="happy"] .expr-happy { display: inline; }
.pet-svg[data-expr="eating"] .expr-eating { display: inline; }

.pet-svg .only-eating { display: none; }
.pet-svg[data-expr="eating"] .only-eating { display: inline; }

/* ============ 对话气泡 ============ */

.bubble {
  position: absolute;
  top: max(6vh, 40px);
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 2px solid #f0dcae;
  border-radius: 16px;
  padding: 10px 18px;
  font-size: 16px;
  box-shadow: var(--shadow);
  white-space: nowrap;
  animation: bubble-in 0.25s ease;
  z-index: 5;
}
.bubble::after {
  content: "";
  position: absolute;
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  border: 9px solid transparent;
  border-top-color: #fff;
  filter: drop-shadow(0 2px 0 #f0dcae);
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============ 粒子特效 ============ */

.particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 4;
}

.particle {
  position: absolute;
  bottom: 42%;
  font-size: 26px;
  animation: float-up 1.1s ease-out forwards;
}
@keyframes float-up {
  0% { opacity: 0; transform: translateY(0) scale(0.5) rotate(0deg); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-130px) scale(1.25) rotate(18deg); }
}

/* ============ 弹窗 ============ */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(91, 70, 54, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.modal-card {
  background: var(--card);
  border-radius: 18px;
  padding: 24px 28px;
  width: min(380px, 90vw);
  text-align: center;
  box-shadow: 0 10px 30px rgba(91, 70, 54, 0.3);
  animation: bubble-in 0.22s ease;
}
.modal-card .bubble-in { animation: none; }

.modal-card h3 { margin-bottom: 14px; font-size: 19px; }

.modal-card input {
  width: 100%;
  font-size: 16px;
  padding: 9px 12px;
  border: 2px solid #e8d9bd;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
  margin-bottom: 16px;
}
.modal-card input:focus { border-color: var(--accent); }

.modal-actions { display: flex; gap: 12px; justify-content: center; }

.modal-text { color: var(--ink-light); font-size: 14px; margin-bottom: 16px; }

.feed-thumb {
  width: 150px;
  height: 150px;
  object-fit: cover;
  border-radius: 14px;
  border: 3px solid #fff;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.feed-guess { color: var(--ink-light); font-size: 15px; margin-bottom: 10px; }
.feed-comment { font-size: 17px; color: var(--accent-deep); margin-bottom: 14px; }
