/* ==========================================================================
   Pookie - Interactive Teddy Bear
   A tribute to Jim Davis's Garfield
   License: GPL-3.0-or-later
   ========================================================================== */

/* ==========================================================================
   1. Reset & Base
   ========================================================================== */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Georgia', 'Palatino Linotype', 'Palatino', serif;
  color: #5C3A1E;
}

/* ==========================================================================
   2. Room Layout
   ========================================================================== */

.room {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 500px;
  overflow: hidden;
}

.room__wall {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 72%;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 232, 204, 0.3) 0px,
      rgba(255, 232, 204, 0.3) 20px,
      transparent 20px,
      transparent 40px
    ),
    linear-gradient(180deg, #FFF5E6 0%, #FFEEDD 100%);
}

.room__baseboard {
  position: absolute;
  top: 72%;
  left: 0;
  width: 100%;
  height: 8px;
  background: #6B4F3A;
  z-index: 2;
}

.room__floor {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 28%;
  background:
    repeating-linear-gradient(
      90deg,
      #8B6B4A 0px,
      #8B6B4A 80px,
      #7D5F42 80px,
      #7D5F42 82px
    ),
    linear-gradient(180deg, #8B6B4A 0%, #7A5E3F 100%);
}

/* ==========================================================================
   3. Furniture - Window
   ========================================================================== */

.room__window {
  position: absolute;
  top: 10%;
  right: 10%;
  width: clamp(100px, 15vw, 180px);
  height: clamp(120px, 20vh, 200px);
  background: #87CEEB;
  border: 8px solid #6B4F3A;
  border-radius: 4px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 4px;
  padding: 2px;
  z-index: 1;
}

.room__window-pane {
  background: linear-gradient(135deg, #87CEEB 0%, #B0E0FF 40%, #87CEEB 100%);
  border: 2px solid #6B4F3A;
  border-radius: 1px;
}

/* Sun in window */
.room__window::after {
  content: '';
  position: absolute;
  top: 12%;
  right: 15%;
  width: 24px;
  height: 24px;
  background: #FFD700;
  border-radius: 50%;
  box-shadow: 0 0 15px 5px rgba(255, 215, 0, 0.4);
  z-index: 1;
}

.room__curtain {
  position: absolute;
  top: 8%;
  width: clamp(30px, 5vw, 50px);
  height: clamp(140px, 24vh, 230px);
  background: #E8967A;
  border-radius: 0 0 8px 8px;
  z-index: 1;
}

.room__curtain--left {
  right: calc(10% + clamp(100px, 15vw, 180px) + 4px);
  transform: skewX(3deg);
}

.room__curtain--right {
  right: calc(10% - clamp(30px, 5vw, 50px) - 4px);
  transform: skewX(-3deg);
}

/* ==========================================================================
   4. Furniture - Bed
   ========================================================================== */

.room__bed {
  position: absolute;
  bottom: 28%;
  left: 5%;
  width: clamp(120px, 18vw, 200px);
  z-index: 1;
}

.room__bed-headboard {
  width: 100%;
  height: clamp(60px, 10vh, 90px);
  background: linear-gradient(180deg, #7A5E3F 0%, #6B4F3A 100%);
  border-radius: 12px 12px 0 0;
  border: 3px solid #5A4030;
  border-bottom: none;
}

.room__bed-blanket {
  width: 110%;
  margin-left: -5%;
  height: clamp(40px, 6vh, 55px);
  background: linear-gradient(180deg, #E8967A 0%, #D4826A 100%);
  border-radius: 0 0 6px 6px;
  border: 2px solid #C07060;
  border-top: none;
  position: relative;
  z-index: 3;
}

/* Blanket pattern */
.room__bed-blanket::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    repeating-linear-gradient(
      45deg,
      transparent 0px,
      transparent 8px,
      rgba(255, 255, 255, 0.1) 8px,
      rgba(255, 255, 255, 0.1) 10px
    );
  border-radius: 0 0 4px 4px;
}

.room__bed-pillow {
  position: absolute;
  top: 15%;
  left: 15%;
  width: 70%;
  height: clamp(20px, 3vh, 30px);
  background: #FFF8F0;
  border-radius: 8px;
  border: 1px solid #E8DDD4;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Sleeping cat under blanket */
.room__cat-ears {
  position: absolute;
  top: 42%;
  left: 55%;
  width: 28%;
  z-index: 4;
}

.room__cat-ears svg {
  width: 100%;
  height: auto;
  display: block;
}

.room__cat-lump {
  position: absolute;
  top: 52%;
  left: 15%;
  width: 75%;
  height: 40%;
  background: linear-gradient(180deg, #E8967A 0%, #D4826A 60%);
  border-radius: 50% 50% 10% 10%;
  border: 2px solid #C07060;
  border-bottom: none;
  z-index: 3;
}

/* Blanket pattern on lump */
.room__cat-lump::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    repeating-linear-gradient(
      45deg,
      transparent 0px,
      transparent 8px,
      rgba(255, 255, 255, 0.1) 8px,
      rgba(255, 255, 255, 0.1) 10px
    );
  border-radius: 50% 50% 10% 10%;
}

/* Zzz speech bubble */
.room__cat-zzz-bubble {
  position: absolute;
  top: 8%;
  right: -10%;
  z-index: 5;
  background: #FFFFFF;
  border: 2px solid #1a1a1a;
  border-radius: 14px;
  padding: 4px 10px 4px 8px;
  display: flex;
  align-items: baseline;
  gap: 1px;
}

/* Speech bubble tail */
.room__cat-zzz-bubble::before {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 20%;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 10px solid #1a1a1a;
}

.room__cat-zzz-bubble::after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 21%;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 8px solid #FFFFFF;
}

.garfield-zzz {
  display: inline-block;
  font-family: 'Georgia', serif;
  font-weight: bold;
  color: #000000;
  animation: zzz-float 2.5s ease-in-out infinite;
}

.garfield-zzz:nth-child(1) {
  font-size: clamp(16px, 2.2vw, 26px);
}

.garfield-zzz--2 {
  font-size: clamp(12px, 1.6vw, 20px);
  animation-delay: 0.4s;
  vertical-align: super;
}

.garfield-zzz--3 {
  font-size: clamp(9px, 1.2vw, 15px);
  animation-delay: 0.8s;
  vertical-align: super;
}

@keyframes zzz-float {
  0%, 100% { opacity: 0.4; transform: translateY(0); }
  50%      { opacity: 1; transform: translateY(-3px); }
}

/* ==========================================================================
   5. Furniture - Shelf
   ========================================================================== */

.room__shelf {
  position: absolute;
  top: 18%;
  left: 15%;
  width: clamp(100px, 14vw, 160px);
  height: 6px;
  background: linear-gradient(180deg, #7A5E3F 0%, #6B4F3A 100%);
  border-radius: 2px;
  z-index: 1;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.room__shelf-book {
  position: absolute;
  bottom: 100%;
  border-radius: 1px 1px 0 0;
}

.room__shelf-book--1 {
  left: 10%;
  width: 12px;
  height: 28px;
  background: #C04040;
}

.room__shelf-book--2 {
  left: 28%;
  width: 10px;
  height: 22px;
  background: #FF8C00;
}

/* Garfield-orange easter egg book */
.room__shelf-book--3 {
  left: 44%;
  width: 14px;
  height: 26px;
  background: #4A7A4A;
}

/* ==========================================================================
   5b. Furniture - Lasagna
   ========================================================================== */

#lasagna {
  position: absolute;
  bottom: 29%;
  right: 12%;
  width: clamp(70px, 10vw, 110px);
  cursor: pointer;
  z-index: 3;
  transition: transform 0.2s ease;
}

#lasagna:hover {
  transform: scale(1.08);
}

#lasagna:active {
  transform: scale(0.95);
}

#lasagna svg {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
}

/* Steam animation */
#lasagna svg path {
  animation: steam 2.5s ease-in-out infinite;
}

#lasagna svg path:nth-child(even) {
  animation-delay: 0.8s;
}

@keyframes steam {
  0%, 100% { opacity: 0.2; transform: translateY(0); }
  50%      { opacity: 0.6; transform: translateY(-4px); }
}

/* ==========================================================================
   6. Pookie Container
   ========================================================================== */

#pookie-container {
  position: absolute;
  width: 160px;
  height: auto;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 10;
  transition: filter 0.15s ease;
}

#pookie-container svg {
  width: 100%;
  height: auto;
  display: block;
}

#pookie-container.dragging {
  cursor: grabbing;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.25));
}

#pookie-container:focus {
  outline: 3px dashed #E8967A;
  outline-offset: 4px;
  border-radius: 8px;
}

/* SVG arm transitions for hug */
#pookie-left-arm {
  transition: transform 0.3s ease-in-out;
  transform-origin: 66px 140px;
  transform-box: fill-box;
}

#pookie-right-arm {
  transition: transform 0.3s ease-in-out;
  transform-origin: 66px 140px;
  transform-box: fill-box;
}

.hugging #pookie-left-arm {
  transform: rotate(35deg);
}

.hugging #pookie-right-arm {
  transform: rotate(-35deg);
}

/* Eye blink during hug */
#pookie-left-eye,
#pookie-right-eye {
  transition: transform 0.1s ease;
  transform-origin: center;
}

.hugging #pookie-left-eye,
.hugging #pookie-right-eye {
  animation: blink 0.3s ease-in-out 0.15s;
}

/* ==========================================================================
   7. Welcome Message
   ========================================================================== */

.welcome {
  position: absolute;
  top: 3%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  background: rgba(255, 245, 230, 0.9);
  padding: 12px 28px;
  border-radius: 16px;
  border: 2px solid #E8967A;
  z-index: 20;
  transition: opacity 0.5s ease;
  max-width: 90%;
}

.welcome__title {
  font-size: clamp(1.4rem, 3.5vw, 2.2rem);
  color: #8B4513;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.6);
  margin-bottom: 4px;
}

.welcome__subtitle {
  font-size: clamp(0.8rem, 1.8vw, 1rem);
  color: #A0704C;
  font-style: italic;
}

/* ==========================================================================
   8. Footer
   ========================================================================== */

.footer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  text-align: center;
  padding: 8px 16px;
  background: rgba(107, 79, 58, 0.85);
  color: #FFF5E6;
  font-size: clamp(0.65rem, 1.2vw, 0.8rem);
  z-index: 20;
}

.footer__tribute {
  margin-bottom: 2px;
}

.footer__tribute em {
  font-style: italic;
}

.footer__license a {
  color: #F5DEB3;
  text-decoration: underline;
}

.footer__license a:hover {
  color: #FFD700;
}

/* ==========================================================================
   9. Hug Animation
   ========================================================================== */

@keyframes pookie-hug {
  0%   { transform: translate(var(--px, 0px), var(--py, 0px)) scale(1, 1); }
  12%  { transform: translate(var(--px, 0px), var(--py, 0px)) scale(1.18, 0.85); }
  28%  { transform: translate(var(--px, 0px), var(--py, 0px)) scale(0.92, 1.08); }
  44%  { transform: translate(var(--px, 0px), var(--py, 0px)) scale(1.06, 0.96); }
  65%  { transform: translate(var(--px, 0px), var(--py, 0px)) scale(0.98, 1.02); }
  100% { transform: translate(var(--px, 0px), var(--py, 0px)) scale(1, 1); }
}

@keyframes pookie-wobble {
  0%, 100% { transform: translate(var(--px, 0px), var(--py, 0px)) rotate(0deg); }
  25%  { transform: translate(var(--px, 0px), var(--py, 0px)) rotate(-4deg); }
  75%  { transform: translate(var(--px, 0px), var(--py, 0px)) rotate(4deg); }
}

@keyframes blink {
  0%, 100% { transform: scaleY(1); }
  40%, 60% { transform: scaleY(0.1); }
}

#pookie-container.hugging {
  animation: pookie-hug 0.6s ease-in-out;
}

#pookie-container.wobbling {
  animation: pookie-wobble 0.4s ease-in-out;
}

/* ==========================================================================
   10. Heart Particles
   ========================================================================== */

.heart {
  position: absolute;
  width: 18px;
  height: 18px;
  pointer-events: none;
  z-index: 15;
  animation: heart-float var(--heart-duration, 1s) ease-out forwards;
}

.heart::before,
.heart::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 28px;
  background: var(--heart-color, #FF6B8A);
  border-radius: 50px 50px 0 0;
}

.heart::before {
  transform: rotate(-45deg);
  transform-origin: 100% 100%;
}

.heart::after {
  left: 9px;
  transform: rotate(45deg);
  transform-origin: 0 100%;
}

@keyframes heart-float {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(var(--heart-scale, 1)) rotate(var(--heart-rot, 0deg));
  }
  100% {
    opacity: 0;
    transform: translate(var(--heart-dx, 0px), var(--heart-dy, -150px)) scale(0.2) rotate(var(--heart-rot, 0deg));
  }
}

/* ==========================================================================
   11. Speech Bubble (Easter Egg)
   ========================================================================== */

.speech-bubble {
  position: absolute;
  background: #FFF5E6;
  border: 2px solid #8B4513;
  border-radius: 16px;
  padding: 8px 14px;
  font-size: 0.9rem;
  color: #8B4513;
  font-weight: bold;
  white-space: normal;
  max-width: 320px;
  text-align: center;
  line-height: 1.4;
  z-index: 25;
  pointer-events: none;
  animation: bubble-appear 3s ease-in-out forwards;
}

.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 10px solid #8B4513;
}

@keyframes bubble-appear {
  0%   { opacity: 0; transform: translateY(10px) scale(0.8); }
  15%  { opacity: 1; transform: translateY(0) scale(1); }
  75%  { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-10px) scale(0.9); }
}

/* ==========================================================================
   12. Accessibility - Screen Reader
   ========================================================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   13. Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  #pookie-container.hugging {
    animation: none;
    opacity: 0.7;
    transition: opacity 0.3s ease;
  }

  #pookie-container.wobbling {
    animation: none;
  }

  .heart {
    display: none;
  }

  .hugging #pookie-left-eye,
  .hugging #pookie-right-eye {
    animation: none;
  }

  .speech-bubble {
    animation: none;
    opacity: 1;
  }
}

/* ==========================================================================
   14. Responsive
   ========================================================================== */

@media (max-width: 768px) {
  #pookie-container {
    width: 120px;
  }

  .welcome {
    padding: 8px 18px;
  }

  .room__curtain {
    display: none;
  }
}

@media (max-width: 480px) {
  #pookie-container {
    width: 100px;
  }

  .welcome {
    padding: 6px 14px;
    border-radius: 12px;
  }

  .room__bed {
    display: none;
  }

  .room__shelf {
    display: none;
  }

  .footer {
    font-size: 0.6rem;
    padding: 6px 10px;
  }
}
