.motion-masthead,
.footer {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  overflow: clip;
}

.motion-masthead::before,
.motion-masthead::after,
.footer::before {
  position: absolute;
  z-index: -1;
  pointer-events: none;
  content: "";
}

.motion-masthead::before {
  right: -14%;
  bottom: -56%;
  width: clamp(32rem, 76vw, 92rem);
  height: clamp(19rem, 39vw, 44rem);
  background: radial-gradient(ellipse at center, #557fa735, transparent 67%);
  animation: masthead-light 25s ease-in-out infinite alternate paused;
}

.motion-masthead::after {
  right: -8%;
  bottom: -39%;
  width: clamp(27rem, 66vw, 80rem);
  height: clamp(16rem, 31vw, 35rem);
  background: repeating-radial-gradient(ellipse at 62% 96%, transparent 0 .86rem, #a0c1e33b .92rem .97rem, transparent 1.03rem 1.45rem);
  mask-image: radial-gradient(ellipse at 66% 65%, #000 16%, #000a 40%, transparent 72%);
  transform: rotate(-12deg);
  animation: masthead-tide 21s ease-in-out infinite alternate paused;
}

.article-intro.motion-masthead::after {
  width: clamp(25rem, 62vw, 70rem);
  right: -14%;
  bottom: -47%;
  opacity: .74;
}

.guide-masthead.motion-masthead::after {
  right: auto;
  left: -12%;
  bottom: -51%;
  transform-origin: 14% 85%;
  background: repeating-radial-gradient(ellipse at 38% 94%, transparent 0 .9rem, #a2b9d138 .96rem 1.01rem, transparent 1.07rem 1.55rem);
  mask-image: radial-gradient(ellipse at 45% 62%, #000 10%, #0008 38%, transparent 70%);
}

.footer::before {
  right: -9%;
  bottom: -7rem;
  width: clamp(29rem, 70vw, 90rem);
  height: 14rem;
  background: repeating-radial-gradient(ellipse at 67% 100%, transparent 0 .78rem, #9fbddc48 .84rem .89rem, transparent .95rem 1.28rem);
  mask-image: linear-gradient(95deg, transparent 12%, #000 76%);
  transform: rotate(-4deg);
  animation: footer-tide 25s ease-in-out infinite alternate paused;
}

.motion-playing .motion-masthead[data-motion-visible]::before,
.motion-playing .motion-masthead[data-motion-visible]::after,
.motion-playing .footer[data-motion-visible]::before {
  animation-play-state: running;
}

@keyframes masthead-light {
  from { transform: translate(4%, 0); }
  to { transform: translate(-13%, -13%) scale(1.12); }
}

@keyframes masthead-tide {
  from { transform: translate(3%, 0) rotate(-12deg); }
  to { transform: translate(-8%, -11%) rotate(-3deg) scaleY(1.12); }
}

@keyframes footer-tide {
  from { transform: translate(3%, 0) rotate(-4deg); }
  to { transform: translate(-14%, -5%) rotate(2deg); }
}

.motion-toggle {
  min-height: 2.75rem;
  padding: .25rem .65rem;
  border: 1px solid #a0beda99;
  border-radius: .35rem;
  background: #183650;
  color: #e6f0f9;
  font: 650 .77rem/1.3 var(--sans);
  cursor: pointer;
}

.motion-masthead .motion-toggle { display: block; margin-block-start: 1.15rem; }
.motion-toggle:hover { background: #26496b; }
.motion-toggle:focus-visible { outline: 2px solid #ffe0b8; outline-offset: 4px; }

@media (max-width: 730px) {
  .motion-masthead::before { right: -64%; bottom: -45%; }
  .motion-masthead::after { right: -43%; bottom: -48%; opacity: .72; }
  .article-intro.motion-masthead::after { right: -55%; }
  .guide-masthead.motion-masthead::after { left: -28%; bottom: -28%; }
}

@media (prefers-reduced-motion: reduce) {
  .motion-masthead::before,
  .motion-masthead::after,
  .footer::before { animation: none; }
  .motion-masthead .motion-toggle,
  .motion-toggle { display: none; }
}

@media print {
  .motion-masthead::before,
  .motion-masthead::after,
  .footer::before,
  .motion-masthead .motion-toggle,
  .motion-toggle { display: none; }
}
