/*
 * Seasonal shapes drifting over the tinted top of the write screen (SeasonDecor.tsx). The CSP
 * forbids inline styles, so each shape's place, size and pace come from nth-child here. Only
 * transform and opacity animate, to stay cheap on phones.
 */
body[class*="season-"] {
  position: relative;
}

.season-decor {
  position: absolute;
  z-index: -1;
  top: 0;
  right: 0;
  left: 0;
  height: 18rem;
  overflow: hidden;
  pointer-events: none;
}

.season-decor-camellia {
  color: #d9485f;
}
.season-decor-plum {
  color: #e889a8;
}
.season-decor-dandelion {
  color: #b3a57f;
}
.season-decor-sakura {
  color: #f0a3bd;
}
.season-decor-leaf {
  color: #7cb86a;
}
.season-decor-rain {
  color: #7fa9d6;
}
.season-decor-fireworks {
  color: #e8a317;
}
.season-decor-cicada {
  color: #6b5a3e;
}
.season-decor-dragonfly {
  color: #d0602f;
}
.season-decor-acorn {
  color: #b5793a;
}
.season-decor-maple {
  color: #e0763a;
}
.season-decor-snow {
  color: #8fb0d0;
}
.season-decor-kagamimochi {
  color: #c9b48a;
}
.season-decor-koinobori {
  color: #e0533d;
}
/* Real carp streamers fly in a family of colors. */
.season-decor-koinobori .season-p:nth-child(3n + 1) {
  color: #3e6fb0;
}
.season-decor-koinobori .season-p:nth-child(3n + 2) {
  color: #3a3a3a;
}
.season-decor-tanabata {
  color: #e6b422;
}
.season-decor-pumpkin {
  color: #e8822a;
}
.season-decor-tree {
  color: #4f8f5a;
}

.season-p {
  position: absolute;
  top: -1.5rem;
  width: 1.25rem;
  height: 1.25rem;
  opacity: 0.8;
  animation: season-fall 11s linear infinite;
}

.season-p svg {
  display: block;
  width: 100%;
  height: 100%;
}

.season-p:nth-child(1) {
  left: 6%;
  animation-delay: -1s;
}
.season-p:nth-child(2) {
  left: 22%;
  width: 1.5rem;
  height: 1.5rem;
  animation-duration: 13s;
  animation-delay: -7s;
}
.season-p:nth-child(3) {
  left: 38%;
  animation-duration: 9s;
  animation-delay: -4s;
}
.season-p:nth-child(4) {
  left: 55%;
  width: 1rem;
  height: 1rem;
  animation-duration: 12s;
  animation-delay: -10s;
}
.season-p:nth-child(5) {
  left: 70%;
  width: 1.5rem;
  height: 1.5rem;
  animation-delay: -2.5s;
}
.season-p:nth-child(6) {
  left: 84%;
  animation-duration: 10s;
  animation-delay: -6s;
}
.season-p:nth-child(7) {
  left: 94%;
  width: 1rem;
  height: 1rem;
  animation-duration: 14s;
  animation-delay: -12s;
}

/* Shapes that stay put rather than cross the page each sit at their own height. */
.season-p:nth-child(odd) {
  --row: 2;
}
.season-p:nth-child(3n) {
  --row: 5;
}
.season-motion-twinkle .season-p,
.season-motion-float .season-p,
.season-motion-swim .season-p,
.season-motion-buzz .season-p {
  top: calc(var(--space-6) + 1.5rem * var(--row, 0));
  animation-timing-function: ease-in-out;
}
.season-motion-twinkle .season-p {
  animation-name: season-twinkle;
  animation-duration: 3.5s;
}
.season-motion-float .season-p {
  animation-name: season-float;
  animation-duration: 3.2s;
}
.season-motion-swim .season-p {
  width: 2rem;
  height: 2rem;
  animation-name: season-swim;
  animation-duration: 4s;
}
.season-motion-buzz .season-p {
  animation-name: season-buzz;
  animation-duration: 2.6s;
  animation-timing-function: linear;
}
.season-motion-rain .season-p {
  width: 0.75rem;
  height: 0.75rem;
  animation-name: season-rain;
  animation-duration: 2.2s;
  animation-timing-function: ease-in;
}
.season-motion-rain .season-p:nth-child(even) {
  animation-duration: 2.8s;
}
.season-motion-rise .season-p {
  top: 17rem;
  animation-name: season-rise;
  animation-timing-function: ease-out;
}

@keyframes season-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0;
  }
  10%,
  70% {
    opacity: 0.8;
  }
  100% {
    transform: translateY(18rem) rotate(260deg);
    opacity: 0;
  }
}

@keyframes season-rain {
  0% {
    transform: translateY(0);
    opacity: 0;
  }
  15%,
  75% {
    opacity: 0.7;
  }
  100% {
    transform: translateY(18rem);
    opacity: 0;
  }
}

@keyframes season-rise {
  0% {
    transform: translate(0, 0) rotate(0deg);
    opacity: 0;
  }
  15%,
  70% {
    opacity: 0.85;
  }
  100% {
    transform: translate(2.5rem, -17rem) rotate(25deg);
    opacity: 0;
  }
}

@keyframes season-twinkle {
  0%,
  100% {
    opacity: 0.2;
  }
  50% {
    opacity: 0.85;
  }
}

@keyframes season-float {
  0%,
  100% {
    transform: translateY(0) rotate(-6deg);
    opacity: 0.85;
  }
  50% {
    transform: translateY(-0.6rem) rotate(6deg);
    opacity: 0.85;
  }
}

@keyframes season-swim {
  0%,
  100% {
    transform: translate(0, 0) rotate(-4deg);
    opacity: 0.85;
  }
  50% {
    transform: translate(1rem, -0.3rem) rotate(4deg);
    opacity: 0.85;
  }
}

/* A cicada sits still, then shrills in a short shiver. */
@keyframes season-buzz {
  0%,
  78%,
  100% {
    transform: translateX(0);
    opacity: 0.85;
  }
  82%,
  90% {
    transform: translateX(-1px) rotate(-3deg);
  }
  86%,
  94% {
    transform: translateX(1px) rotate(3deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .season-decor .season-p {
    animation: none;
    top: calc(var(--space-6) + 2rem * var(--row, 1));
  }
}
