.water, .lights {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.water {
  --water-matte: url('/assets/moonlit-water-mask.svg');
  mask-image: var(--water-matte);
  mask-size: var(--scene-width) var(--scene-height);
  mask-position: var(--scene-left) var(--scene-top);
  mask-repeat: no-repeat;
}

.ripple {
  position: absolute;
  left: var(--scene-left);
  width: var(--scene-width);
  background: var(--scene-art) 0 var(--ripple-art-y) / var(--scene-width) var(--scene-height) no-repeat;
  /* The moving source is also matted: no shore or boats are carried into the fixed water area. */
  mask-image: var(--water-matte), linear-gradient(transparent, #000 32%, #000 68%, transparent);
  mask-position: 0 var(--ripple-art-y), center;
  mask-size: var(--scene-width) var(--scene-height), 100% 100%;
  mask-repeat: no-repeat;
  mask-composite: intersect;
  opacity: .94;
  animation: harbour-ripple var(--ripple-duration) ease-in-out var(--ripple-delay) infinite;
}

.light {
  position: absolute;
  width: var(--light-size-x);
  height: var(--light-size-y);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  animation-delay: var(--light-delay);
  animation-duration: var(--light-duration);
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
}
.lantern {
  background: radial-gradient(ellipse, rgb(255 235 175 / 72%), rgb(255 174 70 / 43%) 29%, transparent 68%);
  mix-blend-mode: screen;
  animation-name: lantern-flicker;
}
.gate-lantern::before, .gate-lantern::after {
  content: "";
  position: absolute;
  inset: 0;
  animation-duration: inherit;
  animation-delay: inherit;
  animation-iteration-count: inherit;
  animation-timing-function: inherit;
}
.gate-lantern::before {
  background: var(--scene-art) var(--light-art-x) var(--light-art-y) / var(--scene-width) var(--scene-height) no-repeat;
  mask-image: radial-gradient(ellipse 40% 49% at 50% 50%, #000 46%, transparent 100%);
  animation-name: gate-flame;
}
.gate-lantern::after {
  inset: -32%;
  background: radial-gradient(ellipse 36% 39% at center, rgb(255 214 130 / 49%), rgb(255 155 57 / 20%) 49%, transparent 92%);
  mix-blend-mode: screen;
  animation-name: gate-glow;
}
.star {
  background: radial-gradient(circle, #fff 5%, rgb(237 249 255 / 93%) 13%, rgb(178 226 255 / 58%) 27%, rgb(152 209 255 / 19%) 48%, transparent 69%);
  mix-blend-mode: screen;
  animation-name: star-shimmer;
}

.harbour.is-resting :is(.ripple, .light),
.harbour.is-resting .gate-lantern::before,
.harbour.is-resting .gate-lantern::after { animation-play-state: paused; }

@keyframes harbour-ripple {
  0%, 100% {
    transform: translate3d(calc(-.78 * var(--ripple-drift)), calc(-.55 * var(--ripple-lift)), 0) skewX(calc(-.68 * var(--ripple-shear)));
  }
  30% {
    transform: translate3d(var(--ripple-drift), var(--ripple-lift), 0) skewX(var(--ripple-shear));
  }
  57% {
    transform: translate3d(calc(-.22 * var(--ripple-drift)), calc(-.29 * var(--ripple-lift)), 0) skewX(calc(.24 * var(--ripple-shear)));
  }
  79% {
    transform: translate3d(calc(.34 * var(--ripple-drift)), calc(.2 * var(--ripple-lift)), 0) skewX(calc(-.38 * var(--ripple-shear)));
  }
}
@keyframes lantern-flicker {
  0%, 100% { opacity: .12; }
  22% { opacity: .64; }
  43% { opacity: .28; }
  63% { opacity: .54; }
  79% { opacity: .21; }
}
@keyframes gate-flame {
  0%, 100% { filter: brightness(.78); }
  21% { filter: brightness(1.24); }
  42% { filter: brightness(.7); }
  63% { filter: brightness(1.16); }
  81% { filter: brightness(.9); }
}
@keyframes gate-glow {
  0%, 100% { opacity: .12; }
  21% { opacity: .7; }
  42% { opacity: .08; }
  63% { opacity: .55; }
  81% { opacity: .27; }
}
@keyframes star-shimmer {
  0%, 15%, 68%, 100% { opacity: 0; }
  34% { opacity: 1; }
  50% { opacity: .28; }
}

@supports not (mask-composite: intersect) {
  .water { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .water, .lights { display: none; }
  .ripple, .light, .gate-lantern::before, .gate-lantern::after { animation: none !important; }
}
