/* === RESET & BASE === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
}

body {
  background: #f5f0eb;
  color: #2a2a2a;
  font-family: Georgia, 'Times New Roman', serif;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* === STAGE === */
#stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
  padding: 1rem;
}

/* === TYPEWRITER AREA === */
#typewriter-area {
  text-align: center;
  max-width: 800px;
  width: 100%;
}

#typewriter-text {
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  line-height: 1.4;
  padding: 0 1rem;
  min-height: 1.4em;
  white-space: nowrap;
}

/* === CURSOR === */
.cursor {
  animation: blink 0.7s step-end infinite;
}

.cursor.hidden {
  display: none;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* === BUTTON WRAPPER (reserves space to prevent layout shift) === */
#button-wrapper {
  height: 80px;
  margin-top: 2rem;
}

/* === BUTTONS === */
#buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

#buttons button {
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  font-size: clamp(1rem, 2.5vw, 1.1rem);
  color: #2a2a2a;
  background: none;
  border: 1px solid #2a2a2a;
  border-radius: 0;
  padding: 0.6rem 2rem;
  min-width: 100px;
  min-height: 44px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

#btn-yes:hover, #btn-yes:active {
  background: #2e7d32;
  border-color: #2e7d32;
  color: #fff;
}

#btn-yes:focus-visible {
  outline: 2px solid #2e7d32;
  outline-offset: 2px;
}

#btn-no:hover, #btn-no:active {
  background: #c62828;
  border-color: #c62828;
  color: #fff;
}

#btn-no:focus-visible {
  outline: 2px solid #c62828;
  outline-offset: 2px;
}

#buttons button:disabled {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

/* === HIDDEN === */
.hidden {
  display: none !important;
}

/* === PSSST CONTAINER === */
#pssst-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

/* === CAT CONTAINER === */
#cat-container {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 6;
}

#cat-container.visible {
  transform: translateX(-50%) translateY(-10%);
}

#cat-container svg {
  width: clamp(360px, 70vw, 500px);
  height: auto;
  display: block;
  touch-action: none;
}

/* === PET PROMPT === */
#pet-prompt {
  text-align: center;
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  color: #2a2a2a;
  padding-bottom: 0.5rem;
  transition: opacity 0.3s ease;
}

#pet-prompt.dimmed {
  opacity: 0;
}

.bounce-arrow {
  margin-top: 0.5rem;
  font-size: 1.6em;
  line-height: 1;
  animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(10px); }
}

/* On smaller viewports, pull the cat up more so the face is visible */
@media (max-width: 600px) {
  #cat-container.visible {
    transform: translateX(-50%) translateY(-30%);
  }
}

/* === ANIMATIONS === */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.fade-in {
  animation: fadeIn 1.4s ease forwards;
}

.fade-out {
  animation: fadeOut 0.4s ease forwards;
}

/* === PSSST TEXT === */
.pssst-text {
  position: absolute;
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', cursive;
  font-style: italic;
  color: #2a2a2a;
  animation: pssstLife 1.6s ease forwards;
  white-space: nowrap;
}

@keyframes pssstLife {
  /* Pop in */
  0% {
    transform: scale(0) rotate(var(--rot, 0deg));
    opacity: 0;
  }
  10% {
    transform: scale(1.15) rotate(var(--rot, 0deg));
    opacity: 1;
  }
  15% {
    transform: scale(1) rotate(var(--rot, 0deg));
    opacity: 1;
  }
  /* Vibrate */
  20% { transform: translate(2px, -1px) rotate(var(--rot, 0deg)); }
  25% { transform: translate(-2px, 2px) rotate(var(--rot, 0deg)); }
  30% { transform: translate(1px, -2px) rotate(var(--rot, 0deg)); }
  35% { transform: translate(-1px, 1px) rotate(var(--rot, 0deg)); }
  40% { transform: translate(2px, 1px) rotate(var(--rot, 0deg)); }
  45% { transform: translate(-1px, -2px) rotate(var(--rot, 0deg)); }
  50% { transform: translate(1px, 2px) rotate(var(--rot, 0deg)); }
  55% { transform: translate(-2px, -1px) rotate(var(--rot, 0deg)); }
  60% { transform: translate(0, 0) rotate(var(--rot, 0deg)); opacity: 1; }
  /* Fade out */
  100% {
    transform: translate(0, 0) rotate(var(--rot, 0deg));
    opacity: 0;
  }
}

/* === CAT INTERACTION — EYELIDS & SQUINT === */
#eye-left, #eye-right {
  transition: transform 0.3s ease-in-out;
}

#eye-left {
  transform-origin: 70px 118px;
}

#eye-right {
  transform-origin: 130px 118px;
}

#eye-left.squint, #eye-right.squint {
  transform: scaleY(0.55);
}

#eyelid-left, #eyelid-right {
  transition: transform 0.3s ease-in-out;
  transform: translateY(-36px);
}

#eyelid-left.closed, #eyelid-right.closed {
  transform: translateY(0);
}

/* === CAT INTERACTION — HEAD TILT (tracks pointer during petting) === */
#cat-body {
  transform-origin: 100px 200px;
  transition: transform 0.15s ease-out;
}

/* === CAT INTERACTION — WHISKER WIGGLE === */
@keyframes whiskerWiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-3deg); }
  75% { transform: rotate(3deg); }
}

#whiskers-left.wiggling {
  transform-origin: 55px 133px;
  animation: whiskerWiggle 0.4s ease-in-out infinite;
}

#whiskers-right.wiggling {
  transform-origin: 145px 133px;
  animation: whiskerWiggle 0.4s ease-in-out infinite reverse;
}

/* === CAT INTERACTION — EAR WIGGLE === */
@keyframes earWiggle {
  0%, 100% { transform: rotate(0deg); }
  30% { transform: rotate(-4deg); }
  70% { transform: rotate(4deg); }
}

#ear-left.wiggling {
  transform-origin: 58px 90px;
  animation: earWiggle 0.6s ease-in-out infinite;
}

#ear-right.wiggling {
  transform-origin: 142px 90px;
  animation: earWiggle 0.6s ease-in-out infinite;
  animation-delay: 0.15s;
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .cursor {
    animation: none;
    opacity: 1;
  }
}
