/* Cat mascot: pixel cat roaming beside its house, with a fun-fact bubble above (see js/features/cat-mascot). */
.cat-mascot {
  position: fixed;
  right: 18px;
  bottom: 0;
  width: var(--cat-stage-width, 252px);
  --cat-bubble-bg: #fff1c1;
  --cat-bubble-border: #4a3228;
  --cat-bubble-text: #3b2a24;
  --cat-bubble-shadow: rgba(74, 50, 40, 0.4);
  z-index: 90;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  user-select: none;
}

.cat-mascot[hidden] {
  display: none;
}

.cat-mascot-bubble {
  position: relative;
  align-self: stretch;
  margin-bottom: 9px;
  padding: 8px 11px;
  /* Fixed colors on purpose: the bubble stays the same warm paper in every theme and skin,
     so it never blends into the page and the story text never shows through it. */
  border: 2px solid var(--cat-bubble-border);
  border-radius: 8px;
  background: var(--cat-bubble-bg);
  color: var(--cat-bubble-text);
  box-shadow: 0 3px 0 var(--cat-bubble-shadow);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.cat-mascot-bubble[data-visible="true"] {
  opacity: 1;
  transform: none;
}

.cat-mascot-bubble::after {
  content: '';
  position: absolute;
  right: calc(var(--cat-house-width, 60px) / 2 - 7px);
  bottom: -8px;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--cat-bubble-border);
  border-bottom: 2px solid var(--cat-bubble-border);
  background: var(--cat-bubble-bg);
  transform: rotate(45deg);
}

.cat-mascot-bubble-text {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cat-mascot-stage {
  position: relative;
  height: var(--cat-house-height, 54px);
}

.cat-mascot-scaffold {
  line-height: 0;
}

.cat-mascot-house,
.cat-mascot-bowl,
.cat-mascot-cat {
  position: absolute;
  bottom: 0;
}

.cat-mascot-bowl {
  left: var(--cat-bowl-left, 6px);
  line-height: 0;
}

.cat-mascot-house {
  right: 0;
  line-height: 0;
}

.cat-mascot-house.is-occupied .cat-house-svg {
  filter: drop-shadow(0 0 5px rgba(255, 216, 107, 0.75));
}

.cat-mascot-cat {
  left: 0;
  width: var(--cat-width, 48px);
  line-height: 0;
  transition: opacity 0.3s ease;
}

.cat-mascot-cat.is-inside {
  opacity: 0;
}

.cat-mascot-cat-flip {
  position: relative;
  transform-origin: center;
}

.cat-mascot-cat.is-facing-left .cat-mascot-cat-flip {
  transform: scaleX(-1);
}

.cat-frame {
  display: none;
}

.cat-mascot-cat.is-resting .cat-frame-loaf {
  display: block;
}

.cat-mascot-cat.is-walking .cat-frame-a,
.cat-mascot-cat.is-walking .cat-frame-b {
  display: block;
}

.cat-mascot-cat.is-walking .cat-frame-b {
  position: absolute;
  inset: 0;
  animation: cat-step-b 0.4s steps(1, end) infinite;
}

.cat-mascot-cat.is-walking .cat-frame-a {
  animation: cat-step-a 0.4s steps(1, end) infinite;
}

.cat-mascot-cat.is-eating .cat-frame-eat-a,
.cat-mascot-cat.is-eating .cat-frame-eat-b {
  display: block;
}

.cat-mascot-cat.is-eating .cat-frame-eat-b {
  position: absolute;
  inset: 0;
  animation: cat-step-b 0.7s steps(1, end) infinite;
}

.cat-mascot-cat.is-eating .cat-frame-eat-a {
  animation: cat-step-a 0.7s steps(1, end) infinite;
}

@keyframes cat-step-a {
  0% { visibility: visible; }
  50% { visibility: hidden; }
}

@keyframes cat-step-b {
  0% { visibility: hidden; }
  50% { visibility: visible; }
}

/* Desktop only: no mascot on mobile UI (keep in sync with mobileQuery in config.js). */
@media (max-width: 900px), (hover: none) and (pointer: coarse) {
  .cat-mascot {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cat-mascot-bubble,
  .cat-mascot-cat {
    transition: none;
  }
}
