/* =============================================
   cat-animation.css — SD Cat character styles
   ============================================= */

#cat-character {
  position: fixed;
  width: 80px;
  height: 80px;
  z-index: 1000;
  cursor: pointer;
  user-select: none;
  will-change: left, top;
}

.cat-body {
  position: relative;
  width: 80px;
  height: 80px;
}

/* Head */
.cat-head {
  position: absolute;
  width: 54px;
  height: 48px;
  background: #f5c542;
  border-radius: 50% 50% 45% 45%;
  top: 6px;
  left: 13px;
  box-shadow: inset -4px -4px 8px rgba(0,0,0,0.1);
}

/* Ears */
.cat-head::before,
.cat-head::after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  top: -14px;
}
.cat-head::before {
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 18px solid #f5c542;
  left: 4px;
}
.cat-head::after {
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 18px solid #f5c542;
  right: 4px;
}

.ear-inner-left,
.ear-inner-right {
  position: absolute;
  width: 0;
  height: 0;
  top: -9px;
  z-index: 1;
}
.ear-inner-left {
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 10px solid #ffaaaa;
  left: 8px;
}
.ear-inner-right {
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 10px solid #ffaaaa;
  right: 8px;
}

/* Eyes */
.cat-eyes {
  position: absolute;
  top: 16px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  padding: 0 10px;
}
.eye {
  width: 10px;
  height: 10px;
  background: #222;
  border-radius: 50%;
  position: relative;
  animation: blink 4s infinite;
}
.eye::after {
  content: '';
  position: absolute;
  width: 3px;
  height: 3px;
  background: white;
  border-radius: 50%;
  top: 1px;
  right: 1px;
}

/* Nose */
.cat-nose {
  position: absolute;
  top: 28px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #ff8888;
}

/* Mouth */
.cat-mouth {
  position: absolute;
  top: 33px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 6px;
  border-bottom: 2px solid #e07070;
  border-left: 2px solid #e07070;
  border-right: 2px solid #e07070;
  border-radius: 0 0 8px 8px;
}

/* Whiskers */
.whiskers-left,
.whiskers-right {
  position: absolute;
  top: 28px;
}
.whiskers-left { left: -18px; }
.whiskers-right { right: -18px; }
.whisker {
  width: 22px;
  height: 1.5px;
  background: #aaa;
  margin: 3px 0;
  border-radius: 1px;
}

/* Body / Torso */
.cat-torso {
  position: absolute;
  width: 44px;
  height: 36px;
  background: #f5c542;
  border-radius: 40% 40% 50% 50%;
  bottom: 6px;
  left: 18px;
  box-shadow: inset -3px -4px 8px rgba(0,0,0,0.1);
}
.cat-torso::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 20px;
  background: #fff8e7;
  border-radius: 50%;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
}

/* Tail */
.cat-tail {
  position: absolute;
  width: 8px;
  height: 30px;
  background: #f5c542;
  border-radius: 4px 4px 6px 6px;
  bottom: 10px;
  right: 4px;
  transform-origin: bottom center;
  animation: tail-wag 1.2s ease-in-out infinite;
}

/* Legs */
.cat-legs {
  position: absolute;
  bottom: 0;
  left: 16px;
  width: 48px;
  display: flex;
  justify-content: space-between;
}
.leg {
  width: 10px;
  height: 14px;
  background: #f5c542;
  border-radius: 0 0 5px 5px;
}
.leg::after {
  content: '';
  display: block;
  width: 12px;
  height: 6px;
  background: #e8b030;
  border-radius: 0 0 6px 6px;
  margin-top: 8px;
  margin-left: -1px;
}

/* =============================================
   State classes
   ============================================= */

#cat-character.state-walk .leg:nth-child(odd)  { animation: leg-walk-a 0.4s ease-in-out infinite; }
#cat-character.state-walk .leg:nth-child(even) { animation: leg-walk-b 0.4s ease-in-out infinite; }
#cat-character.state-walk .cat-body            { animation: body-bounce 0.4s ease-in-out infinite; }

#cat-character.state-run .leg:nth-child(odd)   { animation: leg-walk-a 0.18s ease-in-out infinite; }
#cat-character.state-run .leg:nth-child(even)  { animation: leg-walk-b 0.18s ease-in-out infinite; }
#cat-character.state-run .cat-body             { animation: body-bounce 0.18s ease-in-out infinite; }
#cat-character.state-run .cat-tail             { animation: tail-run 0.18s ease-in-out infinite; }

#cat-character.state-rest .cat-body            { animation: body-breathe 2s ease-in-out infinite; }
#cat-character.state-rest .eye                 { animation: none; height: 2px; border-radius: 2px; margin-top: 4px; }

/* Flip sprite when moving left */
#cat-character.facing-left .cat-body { transform: scaleX(-1); }

/* =============================================
   Keyframes
   ============================================= */

@keyframes blink {
  0%, 90%, 100% { transform: scaleY(1); }
  95%            { transform: scaleY(0.1); }
}
@keyframes tail-wag {
  0%, 100% { transform: rotate(-20deg); }
  50%       { transform: rotate(20deg); }
}
@keyframes tail-run {
  0%, 100% { transform: rotate(-40deg); }
  50%       { transform: rotate(10deg); }
}
@keyframes leg-walk-a {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-5px); }
}
@keyframes leg-walk-b {
  0%, 100% { transform: translateY(-5px); }
  50%       { transform: translateY(0); }
}
@keyframes body-bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-3px); }
}
@keyframes body-breathe {
  0%, 100% { transform: scaleY(1); }
  50%       { transform: scaleY(1.04); }
}

/* =============================================
   Image-based cat character (.cat-image-character)
   flip 레이어(.cat-image-flip)와 bounce 레이어(.cat-image-bounce)를
   분리하여 transform 충돌 방지
   ============================================= */

.cat-image-character {
  position: fixed;
  width: 80px;
  height: 80px;
  z-index: 999;
  cursor: pointer;
  user-select: none;
  will-change: left, top;
}

.cat-image-character img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  display: block;
}

/* 방향 반전 — flip 레이어에만 scaleX 적용 */
.cat-image-character.facing-left .cat-image-flip {
  transform: scaleX(-1);
}

/* 걷기 — bounce 레이어에 translateY 애니메이션 */
.cat-image-character.state-walk .cat-image-bounce {
  animation: img-cat-bounce 0.4s ease-in-out infinite;
}

/* 달리기 — 더 빠른 bounce */
.cat-image-character.state-run .cat-image-bounce {
  animation: img-cat-bounce 0.18s ease-in-out infinite;
}

/* 쉬기 — 숨쉬기 효과 */
.cat-image-character.state-rest .cat-image-bounce {
  animation: img-cat-breathe 2s ease-in-out infinite;
}

@keyframes img-cat-bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

@keyframes img-cat-breathe {
  0%, 100% { transform: scaleY(1); }
  50%       { transform: scaleY(1.05); }
}

/* Click thought bubble */
.thought-bubble {
  position: absolute;
  top: -44px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border: 2px solid #ddd;
  border-radius: 16px;
  padding: 4px 10px;
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  animation: bubble-pop 2s forwards;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.thought-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid white;
}
@keyframes bubble-pop {
  0%   { opacity: 0; transform: translateX(-50%) scale(0.7); }
  15%  { opacity: 1; transform: translateX(-50%) scale(1); }
  75%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(0.9); }
}
