.theme-switch {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.theme-switch .theme-auto {
  position: absolute;
  z-index: 2;
  top: calc(100% + 9px);
  right: 0;
  min-height: 36px;
  padding: 5px 11px;
  white-space: nowrap;
  border: 1px solid #aacade;
  border-radius: 9px;
  background: #f4faff;
  color: #194568;
  box-shadow: 0 5px 16px #041c3733;
  font: 600 11px var(--font);
}

.theme-switch .theme-auto:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.theme-switch :focus-visible {
  outline: 2px solid #28bfe7;
  outline-offset: 3px;
}

#scene-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The page palette is independent of the time of day. */
.night-mode .landscape-day {
  opacity: 1;
}

.night-mode:not(.theme-night-photo) .landscape-day {
  filter: brightness(.74) saturate(.88) hue-rotate(7deg);
}

.night-mode .landscape-night {
  opacity: 0;
}

.night-mode.theme-night-photo .landscape-night {
  opacity: 1;
}

.scene-alternate {
  opacity: 0;
  pointer-events: none;
}

.night-mode .scene-alternate[data-night-src].is-ready,
:root:not(.night-mode) .scene-alternate[data-day-src].is-ready {
  opacity: 1;
}

/* Give single-image illustrations the same lighting cue as the paired scenes. */
.night-mode :where(main img:not(.scene-alternate, .hero-landscape, [src$="/logo.webp"], [src$=".svg"], :has(> .scene-alternate) > img)) {
  filter: brightness(.86) saturate(.92);
}

.giving-checkout-photo {
  position: relative;
  overflow: hidden;
  height: clamp(104px, 17vw, 162px);
  margin-bottom: 23px;
  border-radius: 13px;
  background: #183e63;
}

.giving-checkout-photo > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 55% 49%;
}

.community-scene > .scene-alternate,
.final-section > .scene-alternate {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.community-scene > .scene-alternate {
  object-position: 66% 51%;
}

.final-section > .scene-alternate {
  object-position: 50% 72%;
}

/* Full-size overlays reuse the crop of their daytime image. */
.scene-media,
.tour-media {
  position: relative;
  display: block;
  min-width: 0;
}

.scene-media > .scene-alternate,
.tour-media > .scene-alternate,
.departure-art > .scene-alternate,
.trailer-poster > .scene-alternate,
.product-screen > .scene-alternate,
.giving-photo > .scene-alternate {
  position: absolute;
  inset: 0;
}

.ed-feature-media {
  overflow: hidden;
  border-radius: 18px;
  box-shadow: 0 15px 45px #153c6120;
  background: var(--ed-deep);
}

.ed-feature-media > img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.giving-next-media .scene-alternate {
  box-shadow: none;
}

.community-scene--formazione > .scene-alternate,
.community-scene--lezioni > .scene-alternate {
  object-position: 66% 50%;
}

.tour-media {
  z-index: -2;
  height: 100%;
  width: 100%;
}

.tour-media > img {
  display: block;
}

/* Relight composited props and illustrations without changing their geometry. */
.night-mode :is(.metrix-cloud, .community-jet, .tour-layer-plane) {
  filter: brightness(.87) saturate(.93) hue-rotate(5deg);
}

.night-mode .final-plane {
  filter: drop-shadow(0 35px 30px #0005) brightness(.73) saturate(.93);
}

.night-mode .hero-companion img {
  filter: brightness(.91) saturate(.93) drop-shadow(0 16px 13px #0632583a);
}

.night-mode .metrix-character img {
  filter: brightness(.96) saturate(.92) drop-shadow(0 20px 20px #2b80b129);
}

.night-mode .community-mascot img {
  filter: brightness(.96) saturate(.92) drop-shadow(0 6px 12px #15508b29);
}

.night-mode :is(.tour-layer-metrix, .product-welcome img, .edu-hero-image[src$=".svg"]) {
  filter: brightness(.92) saturate(.94);
}

.night-mode .edu-app-coach img {
  filter: brightness(.93) saturate(.94) drop-shadow(0 6px 8px #000a2470);
}

/* Referenced hardware, screenshots and marks keep high contrast over both photographs. */
.night-mode :is(.giving-display img, .edu-regolo img, .edu-vor img, .edu-vor > svg,
                 .edu-app-diagram > svg, .product-route, .feature-method-route > svg) {
  filter: brightness(.96) saturate(.95);
}

.night-mode :is(img[src$="/logo.webp"], .entry-slice, .loading-mark img) {
  filter: brightness(1.04) saturate(.96);
}

.ed-route-art {
  position: relative;
  z-index: 0;
}

.ed-route-art::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(120deg, #071c35dd, #062a49a8), url("assets/v63/planning-night.webp") center / cover;
  opacity: 0;
  pointer-events: none;
}

.night-mode .ed-route-art::after {
  opacity: 1;
}

.scene-intro :is(.hero-landscape, .scene-alternate) {
  transition: none;
}

.scene-intro-reveal {
  --scene-fade-duration: 4.5s;
  --scene-fade-easing: cubic-bezier(.35, 0, .28, 1);
}

@media (prefers-reduced-motion: no-preference) {
  .scene-intro-reveal:not(.reduced-motion) .ambient-toggle::before {
    transition-duration: .85s;
  }

  :root:not(.reduced-motion, .scene-intro) .ed-route-art::after {
    transition: opacity var(--scene-fade-duration, .72s) var(--scene-fade-easing, ease);
  }

  :root:not(.reduced-motion, .scene-intro) :is(.hero-landscape, .scene-alternate) {
    transition:
      opacity var(--scene-fade-duration, .72s) var(--scene-fade-easing, ease),
      filter var(--scene-fade-duration, .72s) var(--scene-fade-easing, ease);
  }

  :root:not(.reduced-motion, .scene-intro) :is(.departure-art, .topic-visual) > img {
    transition: transform .8s, opacity var(--scene-fade-duration, .72s) var(--scene-fade-easing, ease);
  }

  :root:not(.reduced-motion) :is(.hero-companion img, .metrix-character img, .community-mascot img,
       .tour-layer-metrix, .tour-layer-plane, .metrix-cloud, .community-jet, .final-plane,
       .product-welcome img, .edu-hero-image[src$=".svg"], .edu-app-coach img, .giving-display img,
       .edu-regolo img, .edu-vor img, .edu-vor > svg, .edu-app-diagram > svg, .product-route,
       .feature-method-route > svg, img[src$="/logo.webp"], .entry-slice, .loading-mark img) {
    transition: filter var(--scene-fade-duration, .72s) var(--scene-fade-easing, ease);
  }

  :root:not(.reduced-motion, .scene-intro) :where(main img:not(.scene-alternate, .hero-landscape, [src$="/logo.webp"], [src$=".svg"], :has(> .scene-alternate) > img)) {
    transition: filter var(--scene-fade-duration, .72s) var(--scene-fade-easing, ease);
  }
}

@media (max-width: 760px) {
  .community-scene > .scene-alternate {
    height: min(64vw, 320px);
    object-position: 73% 47%;
  }
}

@media (max-width: 720px) {
  .final-section > .scene-alternate {
    object-position: 65% 50%;
  }
}
