#home{position:relative}

#home{
  overflow:visible;
}


/* ---------------------------------------------------------
   CAT CONTAINER
   --------------------------------------------------------- */

.home-cat{
  --cat-width:128px;

  position:absolute;

  /* Cat rests on the top-right edge of the homepage panel */
  right:-9px;
  top:calc(var(--cat-width) * -.511);

  width:var(--cat-width);
  height:calc(var(--cat-width) * 330 / 364);

  /*
   * Keep the mascot above the panel border.
   * No need for extreme z-index values.
   */
  z-index:50;

  pointer-events:none;

  /*
   * Allow ears / tail to extend naturally.
   */
  overflow:visible;
}


/* ---------------------------------------------------------
   CLICK / TOUCH TARGET
   --------------------------------------------------------- */

.home-cat-touch{
  all:unset;

  display:block;
  position:absolute;
  inset:0;

  cursor:pointer;

  pointer-events:auto;
  touch-action:manipulation;

  -webkit-tap-highlight-color:transparent;

  /*
   * IMPORTANT:
   * Do not use clip-path here because the sprite is inside
   * this element and would be visually clipped as well.
   */
  overflow:visible;
}


/* ---------------------------------------------------------
   CAT SPRITE
   --------------------------------------------------------- */

.home-cat-sprite{
  display:block;

  width:100%;
  height:100%;

  background-image:url('/home-cat.svg?v=3');
  background-repeat:no-repeat;

  /*
   * The sprite sheet contains 8 horizontal frames.
   * Keep the original frame geometry.
   */
  background-size:800% 100%;

  background-position:
    calc(var(--cat-frame, 0) * 100% / 7)
    0;

  image-rendering:pixelated;

  transform-origin:50% 56.3%;

  filter:
    drop-shadow(0 1px 1px #080c0880);
}


/* ---------------------------------------------------------
   SLEEPING / BREATHING
   --------------------------------------------------------- */

.home-cat[data-state="sleeping_loop"] .home-cat-sprite{
  animation:
    cat-breathe 4.8s ease-in-out infinite;
}

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

  50%{
    /*
     * Extremely subtle breathing.
     */
    transform:translateY(-1px) scaleY(1.012);
  }
}


/* ---------------------------------------------------------
   HOVER / KEYBOARD FOCUS
   --------------------------------------------------------- */

.home-cat-touch:hover .home-cat-sprite,
.home-cat-touch:focus-visible .home-cat-sprite{
  filter:
    drop-shadow(0 0 2px #efd3a578)
    brightness(1.06);
}

.home-cat-touch:focus-visible{
  outline:1px solid #d8c69e;
  outline-offset:-9px;
}


/* ---------------------------------------------------------
   FLOATING DIALOGUE
   Position itself is controlled by home-cat.js.
   --------------------------------------------------------- */

.home-cat-line{
  position:absolute;

  width:max-content;

  max-width:min(
    290px,
    calc(100vw - 24px)
  );

  font:
    13px/1.7
    'Segoe UI',
    'Microsoft YaHei',
    'PingFang SC',
    sans-serif;

  color:#e7d7b9;

  text-align:right;

  text-shadow:
    0 1px 2px #080b08,
    0 0 4px #080b08,
    1px 0 1px #080b08,
    -1px 0 1px #080b08;

  pointer-events:none;

  opacity:0;

  z-index:60;

  overflow-wrap:anywhere;
  white-space:normal;
}


/* ---------------------------------------------------------
   MOBILE
   --------------------------------------------------------- */


@media(max-width:800px){

  .home-cat{
    --cat-width:100px;
    right:-6px;
  }

  .home-cat-line{
    font-size:12px;

    max-width:min(
      260px,
      calc(100vw - 24px)
    );

    /* Mobile only: move dialogue slightly upward */
    transform:translateY(-8px);
  }
}
 


/* ---------------------------------------------------------
   REDUCED MOTION
   --------------------------------------------------------- */

@media(prefers-reduced-motion:reduce){

  .home-cat-sprite{
    animation:none !important;
  }
}
.home-cat-sprite{
  clip-path: inset(0 0 0 5px);
}
