/* ── Pet Companion Overlay ────────────────────────────────────────────────── */

#pet-companion {
  position: fixed;
  bottom: 90px;
  /* Stay inside the 480px content column on any viewport width */
  right: max(12px, calc((100vw - 480px) / 2 + 12px));
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
  user-select: none;
  width: 140px;
}

/* Sit higher in lesson screen to clear the feedback bar + check button */
#pet-companion.pet-in-lesson {
  bottom: 148px;
}

/* On home screen: top-right corner near the greeting */
#pet-companion.pet-on-home {
  bottom: auto;
  top: 68px;
}

.pet-bubble {
  position: absolute;
  /* top + horizontal side set dynamically by _updateBubbleSide() in pet.js */
  top: 152px;
  right: 68px;   /* right edge at x=72px ≈ beak centre; extends LEFT over card info */
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(31,158,149,0.18);
  border-radius: 14px 14px 2px 14px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  color: #2a2320;
  box-shadow: 0 2px 12px rgba(0,0,0,0.11);
  text-align: center;
  line-height: 1.4;
  font-family: 'Vazirmatn', sans-serif;
  white-space: nowrap;
  max-width: 150px;
  opacity: 0;
  transform: scale(0.85);
  transform-origin: right center;
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
  z-index: 1;
}

.pet-bubble.show {
  opacity: 1;
  transform: scale(1);
}

/* ── Happiness bar (inside pet card only) ──────────────────────────────────── */

.pet-happy-bar-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  margin-bottom: 6px;
}

.pet-happy-icon {
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
}

.pet-happy-bar {
  flex: 1;
  height: 5px;
  background: rgba(0,0,0,0.15);
  border-radius: 3px;
  overflow: hidden;
}

.pet-happy-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff6b8a, #ff3366);
  border-radius: 3px;
  transition: width 0.55s cubic-bezier(0.34,1.56,0.64,1);
}

/* ── Floating hearts (full-bar burst) ──────────────────────────────────────── */

.pet-heart {
  position: absolute;
  pointer-events: none;
  font-size: 15px;
  line-height: 1;
  animation: petHeartFloat 1.5s ease-out forwards;
}

@keyframes petHeartFloat {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  60%  { opacity: 0.9; }
  100% { transform: translate(var(--hx, 0px), -170px) scale(0.25); opacity: 0; }
}

/* ── Seed treat ─────────────────────────────────────────────────────────────── */

.pet-treat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 4px 0 8px;
}

.pet-seed {
  font-size: 32px;
  line-height: 1;
  cursor: grab;
  user-select: none;
  animation: seedBounce 2s ease-in-out infinite;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.18));
}

.pet-seed:active { cursor: grabbing; }

@keyframes seedBounce {
  0%, 100% { transform: translateY(0) rotate(-5deg) scale(1); }
  50%       { transform: translateY(-5px) rotate(5deg) scale(1.08); }
}

.pet-treat-label {
  font-size: 10.5px;
  color: #9b8d7e;
  font-family: 'Vazirmatn', sans-serif;
}

/* ── Pets collection screen ───────────────────────────────────────────────── */

.pets-intro {
  padding: 10px 16px 0;
  font-size: 13.5px;
  color: #9b8d7e;
  text-align: center;
  line-height: 1.5;
}

.pets-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 14px 16px 32px;
}

.pet-card {
  background: var(--cream);
  border: 2px solid rgba(31,158,149,0.14);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.pet-card-active {
  border-color: var(--turquoise);
  background: linear-gradient(145deg, #e8f7f6, #f4fdfc);
  box-shadow: 0 4px 18px rgba(31,158,149,0.14);
}

.pet-card-locked {
  opacity: 0.6;
}

/* Horizontal row: info panel left, live area right */
.pet-card-live-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
}

/* Transparent placeholder — companion snaps here in JS */
.pet-card-live-area {
  position: relative;   /* allows canvas + zzz to be absolute children */
  width: 140px;
  height: 280px;
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(31,158,149,0.04);
}

/* Locked cards: small emoji box */
.pet-card-live-area--locked {
  height: 72px;
  width: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  filter: grayscale(1) opacity(0.45);
  animation: cardBob 2.4s ease-in-out infinite;
}

@keyframes cardBob {
  0%, 100% { transform: translateY(0) rotate(2deg); }
  50%       { transform: translateY(-6px) rotate(-2deg); }
}

.pet-card-info-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.pet-card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.active-pet-badge {
  background: var(--leaf);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 11px;
  border-radius: 20px;
}

.locked-pet-badge {
  background: #d0cac3;
  color: #6b5f55;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 11px;
  border-radius: 20px;
}

.pet-card-desc {
  font-size: 11.5px;
  color: #9b8d7e;
  line-height: 1.45;
}

.pet-pref-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.pet-pref-btn {
  background: var(--turquoise);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 700;
  font-family: 'Vazirmatn', sans-serif;
  cursor: pointer;
  transition: background 0.18s, opacity 0.18s;
  pointer-events: auto;
}

.pet-pref-btn.off {
  background: #b0a49a;
}

.pet-pref-btn.active {
  background: var(--leaf);
}

/* ── Inactive / sleeping pet card ─────────────────────────────────────────── */

.pet-card-inactive {
  border-color: rgba(31,158,149,0.08);
  background: linear-gradient(145deg, #f5f0eb, #faf7f4);
  opacity: 0.88;
}

.inactive-pet-badge {
  background: #c4b8ae;
  color: #6b5f55;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 11px;
  border-radius: 20px;
}

.pet-card-status {
  /* shared wrapper for all badges */
}

.pet-select-btn {
  background: var(--turquoise);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 700;
  font-family: 'Vazirmatn', sans-serif;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.18s, transform 0.12s;
  pointer-events: auto;
}

.pet-select-btn:active { transform: scale(0.96); }

/* ── Sleeping animation (canvas fills the area; zzz overlays absolutely) ─── */

.sleep-zzz {
  position: absolute;
  top: 16px;
  right: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  z-index: 2;
  pointer-events: none;
}

.sleep-zzz span {
  display: block;
  color: #8aa8be;
  font-weight: 800;
  font-family: 'Vazirmatn', sans-serif;
  animation: petZzz 2.8s ease-in-out infinite;
  opacity: 0;
}

.sleep-zzz span:nth-child(1) { font-size: 10px; animation-delay: 0s; }
.sleep-zzz span:nth-child(2) { font-size: 14px; animation-delay: 0.7s; }
.sleep-zzz span:nth-child(3) { font-size: 18px; animation-delay: 1.4s; }

@keyframes petZzz {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.7); }
  25%  { opacity: 1; }
  100% { opacity: 0; transform: translate(8px, -28px) scale(1.1); }
}

/* ── Sleep tooltip on click ───────────────────────────────────────────────── */

.pet-sleep-tip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30,30,30,0.82);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Vazirmatn', sans-serif;
  padding: 5px 12px;
  border-radius: 10px;
  white-space: nowrap;
  pointer-events: none;
  animation: tipFade 1.8s ease-out forwards;
  z-index: 10;
}

@keyframes tipFade {
  0%   { opacity: 0; transform: translateX(-50%) translateY(4px); }
  15%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  75%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}
