:is(.phase-home-hero, .guide-reader__hero, .pz-footer,.atlas-lead,.alttp-hero,.alttp-search-heading):has(> .phase-atmosphere) {
  position: relative;
  isolation: isolate;
}

.phase-atmosphere {
  --phase-atmosphere-rim: clamp(12px, 1.65vw, 24px);
  position: absolute;
  z-index: -1;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
  color: #EBC268;
}

.phase-atmosphere::before {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 54% 52% at 62% 110%, rgb(217 138 58 / .2), transparent 92%);
  content: "";
}

.phase-atmosphere--switch2::before {
  background: radial-gradient(ellipse 37% 64% at 104% 104%, rgb(124 196 255 / .17), transparent 95%);
}

.phase-atmosphere--footer::before {
  background: radial-gradient(ellipse 62% 62% at 52% 123%, rgb(233 199 131 / .16), transparent 90%);
}

:is(.phase-atmosphere--hearth,.phase-atmosphere--classic)::after {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(114deg, transparent 7%, rgb(235 194 104 / .14) 11%, rgb(235 194 104 / .06) 17%, transparent 23%),
    linear-gradient(114deg, transparent 29%, rgb(235 194 104 / .1) 34%, rgb(235 194 104 / .04) 39%, transparent 44%);
  mask-image: linear-gradient(#000, transparent 77%);
  content: "";
}

.phase-atmosphere__air {
  position: absolute;
  inset: 0;
  display: block;
}
.phase-atmosphere--classic::after { transform: scaleX(-1); }

:is(.phase-atmosphere--hearth,.phase-atmosphere--atlas,.phase-atmosphere--classic) .phase-atmosphere__air {
  inset: auto -8% -15%;
  height: 52%;
  background:
    radial-gradient(ellipse 47% 70% at 26% 53%, rgb(107 163 247 / .11), transparent 85%),
    radial-gradient(ellipse 44% 42% at 78% 68%, rgb(235 194 104 / .16), transparent 82%);
  animation: phase-atlas-mist 30s ease-in-out infinite alternate paused;
}

.phase-atmosphere--switch2 .phase-atmosphere__air {
  inset: 0 -8% -15% 44%;
  background:
    repeating-radial-gradient(ellipse at 89% 148%, transparent 0 27px, #7cc4ff 34px, transparent 43px 63px),
    repeating-radial-gradient(ellipse at 27% 170%, transparent 0 34px, #e8f8ff 44px, transparent 53px 89px);
  opacity: .10;
  mask-image: radial-gradient(ellipse at 100% 100%, #000 13%, transparent 74%);
  animation: phase-atlas-caustics 19s ease-in-out infinite alternate paused;
}

.phase-atmosphere[data-atlas-active] .phase-atmosphere__air { animation-play-state: running; }
@keyframes phase-atlas-mist {
  from { transform: translateX(-3%) scaleY(.97); }
  to { transform: translateX(4%) scaleY(1.09); }
}
@keyframes phase-atlas-caustics {
  from { transform: translateX(-2%) rotate(-3deg); }
  to { transform: translateX(5%) rotate(1deg); }
}

.phase-atmosphere__engraving,
.phase-atmosphere__frieze {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.phase-atmosphere__engraving {
  opacity: .08;
  object-fit: cover;
  mask-image: linear-gradient(90deg, #000, #000 9%, #0005 24%, transparent 39% 63%, #0005 80%, #000);
}

.phase-atmosphere__frieze {
  object-fit: cover;
  object-position: center 52%;
  opacity: .16;
  filter: grayscale(1) sepia(.62) contrast(1.3) brightness(1.35);
  mask-image: linear-gradient(transparent 24%, #000);
}

.phase-atmosphere__sparks {
  position: absolute;
  inset-block: 0;
  display: block;
  width: var(--phase-atmosphere-rim);
  height: 100%;
}

.phase-atmosphere__sparks--left { inset-inline-start: 0; }
.phase-atmosphere__sparks--right { inset-inline-end: 0; }

:is(.phase-home-door-copy,.phase-home-search button,.phase-home-feature-primary,.guide-bar__next,.series-button,.s2-button:not(.s2-button--quiet),.z64-button,.atlas-finder__submit,.alttp-hero-actions button,.pz-search-dialog button[type="submit"]) {
  position: relative;
  isolation: isolate;
}
:is(.phase-home-door-copy,.phase-home-search button,.phase-home-feature-primary,.guide-bar__next,.series-button,.s2-button:not(.s2-button--quiet),.z64-button,.atlas-finder__submit,.alttp-hero-actions button,.pz-search-dialog button[type="submit"])::after {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(116deg, transparent 43%, rgb(255 228 163 / .25) 48%, transparent 54%) 120% 0 / 245% 100%;
  opacity: 0;
  pointer-events: none;
  content: "";
}
.phase-home-portal .phase-home-feature-primary::before {
  position: absolute;
  inset: 5px;
  background:
    linear-gradient(#EBC268 0 0) top left / 8px 1px,
    linear-gradient(#EBC268 0 0) top left / 1px 8px,
    linear-gradient(#EBC268 0 0) bottom right / 8px 1px,
    linear-gradient(#EBC268 0 0) bottom right / 1px 8px;
  background-repeat: no-repeat;
  opacity: .67;
  pointer-events: none;
  content: "";
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  html[data-atlas-running] :is(.phase-home-door-copy,.phase-home-search button,.phase-home-feature-primary,.guide-bar__next,.series-button,.s2-button:not(.s2-button--quiet),.z64-button,.atlas-finder__submit,.alttp-hero-actions button,.pz-search-dialog button[type="submit"]):hover::after {
    animation: phase-atlas-brass 220ms cubic-bezier(.23, 1, .32, 1);
  }
}
@keyframes phase-atlas-brass {
  from { opacity: 0; background-position: 120% 0; }
  38% { opacity: 1; }
  to { opacity: 0; background-position: -20% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .phase-atmosphere .phase-atmosphere__air { animation: none; }
}
@media (max-width: 48rem) {
  .phase-atmosphere { --phase-atmosphere-rim: 11px; }
  .phase-atmosphere__engraving { opacity: .08; }
}

/* In daylight the plate keeps the contours. Motion belongs to its separately framed objects and footer. */
html[data-phase-theme="light"] .phase-atmosphere:not(.phase-atmosphere--footer) :is(.phase-atmosphere__air,.phase-atmosphere__sparks),
html[data-phase-theme="light"] .phase-atmosphere:not(.phase-atmosphere--footer)::before,
html[data-phase-theme="light"] .phase-atmosphere:not(.phase-atmosphere--footer)::after { display: none; }
html[data-phase-theme="light"] .phase-atmosphere:not(.phase-atmosphere--footer) .phase-atmosphere__engraving {
  color: #141418; filter: brightness(0); opacity: .065;
}
html[data-phase-theme="light"] #pz-content :is(.phase-home-hero,.atlas-lead,.alttp-hero,.guide-reader__hero,.alttp-search-heading) > .phase-atmosphere {
  mask-image: none;
}
#pz-content .phase-home-portal :is(.phase-home-door,.phase-home-feature-primary) {
  background-origin: border-box;
}
#pz-content .phase-home-portal .phase-home-door-copy {
  background-image: radial-gradient(ellipse 60% 170% at 112% 120%, transparent 47%, rgb(128 194 255 / .09) 48%, transparent 53%, rgb(128 194 255 / .07) 56%, transparent 61%);
}
