/* Peekaboo Farm */

body {
  background: #8fdcff;
}

.stage {
  background: linear-gradient(180deg, #6ccbff 0%, #a6e4ff 45%, #d9f5ff 100%);
}

/* ---------------------------------------------------------------- sky */

.sky {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sun {
  position: absolute;
  top: calc(3vmin + var(--safe-top));
  right: calc(4vmin + var(--safe-right));
  width: 17vmin;
  height: 17vmin;
  max-width: 150px;
  max-height: 150px;
  min-width: 64px;
  min-height: 64px;
  z-index: 1;
}
.sun .rays {
  position: absolute;
  inset: -28%;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(255, 225, 90, 0.75) 0deg 12deg, rgba(255, 225, 90, 0) 12deg 30deg);
  -webkit-mask: radial-gradient(circle, #000 45%, transparent 71%);
  mask: radial-gradient(circle, #000 45%, transparent 71%);
  animation: spin 24s linear infinite;
}
.sun .face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6b0 0%, #ffe14d 40%, #ffc41f 100%);
  box-shadow: 0 0 0 5px rgba(255, 236, 130, 0.55), 0 0 40px 10px rgba(255, 220, 80, 0.55);
}
/* sleepy happy face on the sun */
.sun .face::before {
  content: "";
  position: absolute;
  left: 25%;
  top: 34%;
  width: 50%;
  height: 13%;
  background: radial-gradient(circle closest-side, #7a4a00 85%, transparent 100%) left / 26% 100% no-repeat,
    radial-gradient(circle closest-side, #7a4a00 85%, transparent 100%) right / 26% 100% no-repeat;
}
.sun .face::after {
  content: "";
  position: absolute;
  left: 34%;
  top: 52%;
  width: 32%;
  height: 18%;
  border-bottom: max(3px, 0.9vmin) solid #8a5a00;
  border-radius: 0 0 50% 50%;
}
.sun.bounce {
  animation: sunbounce 0.6s cubic-bezier(0.3, 1.6, 0.5, 1);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes sunbounce {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.22) rotate(-10deg);
  }
  100% {
    transform: scale(1);
  }
}

.cloud {
  position: absolute;
  width: 26vmin;
  height: 9vmin;
  max-width: 230px;
  max-height: 80px;
  border-radius: 999px;
  background: #fff;
  opacity: 0.95;
  box-shadow: inset 0 -0.8vmin 0 rgba(170, 215, 245, 0.55);
  animation: drift 60s linear infinite;
}
.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 50%;
}
.cloud::before {
  width: 45%;
  height: 120%;
  left: 14%;
  bottom: 30%;
}
.cloud::after {
  width: 34%;
  height: 95%;
  left: 50%;
  bottom: 38%;
}
.cloud.c1 {
  top: 6vmin;
  left: 18%;
  animation-duration: 70s;
  animation-delay: -20s;
}
.cloud.c2 {
  top: 15vmin;
  left: 55%;
  transform: scale(0.75);
  animation-duration: 90s;
  animation-delay: -55s;
}
.cloud.c3 {
  top: 3vmin;
  left: 80%;
  transform: scale(0.6);
  animation-duration: 110s;
  animation-delay: -10s;
}
@keyframes drift {
  from {
    translate: -60vw 0;
  }
  to {
    translate: 60vw 0;
  }
}

/* ---------------------------------------------------------------- land */

.land {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------------------------------------------------------------- spots */

.spots {
  position: absolute;
  inset: 0;
}

.spot {
  position: absolute;
  /* --S (px) and left/top are set by game.js */
  width: var(--S);
  height: var(--S);
  --A: calc(var(--S) * 0.62);
  /* animal rest / peek / open positions, as fractions of S (overridden per kind) */
  --rx: 0.5;
  --ry: 0.72;
  --rs: 0.55;
  --px: 0.5;
  --py: 0.42;
  --oy: 0.38;
  --x: var(--rx);
  --y: var(--ry);
  --sc: var(--rs);
}
.spot.peek {
  --x: var(--px);
  --y: var(--py);
}
.spot.open {
  --x: 0.5;
  --y: var(--oy);
  --sc: 1;
}

.spot .body {
  position: absolute;
  inset: 0;
  transform-origin: 50% 97%;
  animation: breathe 3s ease-in-out infinite;
}
.spot .jig {
  position: absolute;
  inset: 0;
  transform-origin: 50% 97%;
}
.spot svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.spot svg.back {
  z-index: 1;
}
.spot svg.front {
  z-index: 3;
}
.spot .clip {
  position: absolute;
  left: calc(var(--S) * -0.2);
  width: calc(var(--S) * 1.4);
  top: calc(var(--S) * -0.4);
  height: calc(var(--S) * 1.8);
  z-index: 2;
  pointer-events: none;
}
.spot.front .clip {
  z-index: 4;
}
/* the pond hides its animal under the water line */
.spot[data-kind="pond"] .clip {
  z-index: 4;
  overflow: hidden;
  height: calc(var(--S) * 1.23);
}

.spot .mover {
  position: absolute;
  width: var(--A);
  height: var(--A);
  left: calc(var(--S) * 0.2);
  top: 0;
  transform: translate(calc((var(--x) * var(--S)) - var(--A) / 2), calc(var(--S) * 0.4 + var(--y) * var(--S) - var(--A) / 2))
    scale(var(--sc));
  transition: transform 0.42s cubic-bezier(0.5, 0, 0.75, 0.3);
  will-change: transform;
}
.spot.peek .mover {
  transition: transform 0.35s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.spot.open .mover {
  transition: transform 0.6s cubic-bezier(0.28, 1.75, 0.45, 1);
}

.spot .animal {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: calc(var(--S) * 0.5);
  line-height: 1;
  transform-origin: 50% 90%;
  filter: drop-shadow(0 calc(var(--S) * 0.015) calc(var(--S) * 0.02) rgba(40, 30, 0, 0.25));
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1, 1);
  }
  50% {
    transform: scale(1.025, 0.975);
  }
}

/* ---- per-kind animal positions ---- */
.spot[data-kind="barn"] {
  --ry: 0.8;
  --rs: 0.58;
  --py: 0.8;
  --oy: 0.4;
}
.spot[data-kind="haystack"] {
  --ry: 0.72;
  --px: 0.64;
  --py: 0.25;
}
.spot[data-kind="bush"] {
  --ry: 0.7;
  --py: 0.26;
}
.spot[data-kind="crate"] {
  --ry: 0.72;
  --py: 0.34;
  --oy: 0.34;
}
.spot[data-kind="tree"] {
  --ry: 0.5;
  --px: 0.6;
  --py: 0.08;
  --oy: 0.4;
}
.spot[data-kind="pond"] {
  --ry: 1.08;
  --py: 0.77;
  --oy: 0.47;
}

/* ---- moving parts of the hiding objects (SVG units == % of spot) ---- */
.spot svg .door,
.spot svg .half,
.spot svg .lid {
  transform-box: fill-box;
  transition: transform 0.35s cubic-bezier(0.3, 1.45, 0.5, 1);
}
.spot svg .door-l {
  transform-origin: 0% 50%;
}
.spot svg .door-r {
  transform-origin: 100% 50%;
}
.spot.peek svg .door-l,
.spot.peek svg .door-r {
  transform: scaleX(0.72);
}
.spot.open svg .door-l,
.spot.open svg .door-r {
  transform: scaleX(-0.42);
}

.spot svg .half {
  transform-origin: 50% 100%;
}
.spot.peek svg .half-l {
  transform: translate(-3px, 0) rotate(-3deg);
}
.spot.peek svg .half-r {
  transform: translate(3px, 0) rotate(3deg);
}
.spot.open svg .half-l {
  transform: translate(-15px, 3px) rotate(-12deg);
}
.spot.open svg .half-r {
  transform: translate(15px, 3px) rotate(12deg);
}

.spot svg .lid {
  transform-origin: 0% 100%;
}
.spot.peek svg .lid {
  transform: rotate(-13deg);
}
.spot.open svg .lid {
  transform: translate(-2px, -3px) rotate(-28deg);
}

.spot svg .hay,
.spot svg .leaves {
  transform-box: fill-box;
  transform-origin: 50% 100%;
}
.spot.open svg .hay {
  animation: puff 0.55s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.spot.open svg .leaves {
  animation: rustle 0.6s ease-in-out;
}
.spot svg .ripple {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  opacity: 0;
}
.spot.open svg .ripple {
  animation: ripple 1s ease-out;
}
.spot.open svg .ripple.r2 {
  animation-delay: 0.25s;
}

@keyframes puff {
  0% {
    transform: scale(1, 1);
  }
  30% {
    transform: scale(1.12, 0.84);
  }
  60% {
    transform: scale(0.96, 1.06);
  }
  100% {
    transform: scale(1, 1);
  }
}
@keyframes rustle {
  0%,
  100% {
    transform: rotate(0);
  }
  20% {
    transform: rotate(-4deg);
  }
  45% {
    transform: rotate(4deg);
  }
  70% {
    transform: rotate(-2deg);
  }
}
@keyframes ripple {
  0% {
    transform: scale(0.3);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

/* ---------------------------------------------------------------- hint hand */

.hand {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 64px;
  line-height: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.3s ease;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.25));
}
.hand.show {
  opacity: 1;
  animation: handbob 1s ease-in-out infinite;
}
@keyframes handbob {
  0%,
  100% {
    translate: 0 0;
  }
  50% {
    translate: 0 -18px;
  }
}
