/* Homepage globe and its scroll animation. */

body.games-opening-page { overflow-x: clip; }

.games-opening {
  --opening-hero-height: max(700px, calc(100vh - 104px));
  --opening-hero-height: max(700px, calc(100svh - 104px));
  --opening-pin-top: min(var(--opening-header-height, 0px), calc(100svh - var(--opening-hero-height)));
  --opening-travel: clamp(320px, 58svh, 540px);
  position: relative;
  background: #000;
}

.games-hero {
  position: relative;
  isolation: isolate;
  height: var(--opening-hero-height);
  overflow: hidden;
  overflow: clip;
  background: #000;
  color: #fff;
  font-family: 'Manrope', system-ui, sans-serif;
  font-weight: 400;
  line-height: 1.6;
  touch-action: pan-y;
}

.games-hero-copy {
  position: absolute;
  z-index: 2;
  top: clamp(50px, 7vh, 100px);
  left: 50%;
  width: min(1200px, calc(100% - 60px));
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}

#games-hero-title {
  display: grid;
  margin: 0;
  padding: 0;
  color: #fff !important;
  font-family: inherit;
  font-size: clamp(42px, 6.6vw, 96px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.06em;
}

.games-hero-phrase {
  grid-area: 1 / 1;
  align-self: center;
  min-width: 0;
  opacity: 0;
}

.games-hero-phrase:first-child { opacity: 1; }

#games-hero-title,
.games-hero-description,
.games-hero-scroll { overflow-wrap: normal; }

.games-hero-description {
  margin: 22px 0 0;
  font-size: clamp(19px, 2.2vw, 32px);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -.035em;
}

.games-globe,
.games-globe-fallback {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.games-globe-fallback { scale: .9; }

.games-globe canvas {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 400ms ease;
}

.games-globe.is-ready canvas { opacity: 1; }
.games-globe.is-ready .games-globe-fallback { visibility: hidden; }

.games-globe-fallback-earth {
  position: absolute;
  top: 45%;
  left: 50%;
  width: 112%;
  aspect-ratio: 1;
  transform: translateX(-50%);
  border-radius: 50%;
  background: #0055c7 url('assets/game-hero/earth-clouds.webp') 55% 35% / 200% 100%;
  box-shadow: inset -35px -20px 90px #001f74, inset 0 12px 25px #93e9ff, 0 -2px 14px #55b7ed;
}

[data-search-planet] .games-globe-fallback-earth {
  background: #444 var(--planet-preview) 50% 45% / 200% 100%;
  box-shadow: inset -35px -20px 90px rgb(0 0 0 / 75%), inset 0 12px 25px rgb(255 255 255 / 12%);
}

[data-search-planet="mercury"] { --planet-preview: url('assets/game-hero/planets/mercury.jpg'); }
[data-search-planet="venus"] { --planet-preview: url('assets/game-hero/planets/venus.jpg'); }
[data-search-planet="mars"] { --planet-preview: url('assets/game-hero/planets/mars.jpg'); }
[data-search-planet="jupiter"] { --planet-preview: url('assets/game-hero/planets/jupiter.jpg'); }
[data-search-planet="saturn"] { --planet-preview: url('assets/game-hero/planets/saturn.jpg'); }
[data-search-planet="uranus"] { --planet-preview: url('assets/game-hero/planets/uranus.jpg'); }
[data-search-planet="neptune"] { --planet-preview: url('assets/game-hero/planets/neptune.jpg'); }
[data-search-planet="moon"] { --planet-preview: url('assets/game-hero/planets/moon.jpg'); }
[data-search-planet="saturn"] .games-globe-fallback-earth::after {
  content: '';
  position: absolute;
  inset: 22% -29% auto;
  height: 29%;
  border: clamp(9px, 2.4vw, 32px) double #c8aa7b;
  border-radius: 50%;
  transform: rotate(-13deg);
}

.globe-fallback-icon {
  position: absolute;
  top: 60%;
  left: 30%;
  width: clamp(50px, 7vw, 110px);
  height: auto;
  border-radius: 24%;
  transform: rotate(-15deg);
}
.globe-fallback-icon--two { top: 48%; left: 66%; transform: rotate(15deg); }
.globe-fallback-icon--three { top: 80%; left: 79%; transform: rotate(22deg); }

.games-hero-scroll {
  position: absolute;
  z-index: 3;
  bottom: 23px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 44px;
  padding: 4px 16px;
  border-radius: 24px;
  transform: translateX(-50%);
  color: #fff;
  background: rgb(0 12 35 / 55%);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .06em;
  white-space: nowrap;
  text-decoration: none;
}
.games-hero-scroll span:last-child { font-size: 19px; }

.games-hero-scroll:focus-visible { outline: 2px solid #9dd8ff; outline-offset: 5px; }

#puzzle-collections { scroll-margin-top: var(--sticky-header-height); }

@media (prefers-reduced-motion: no-preference) {
  .games-hero-phrase {
    animation: games-hero-phrase 15s linear var(--phrase-delay, -.375s) infinite,
      gradient-shift 5s ease-in-out infinite alternate;
  }
  .games-hero-phrase:nth-child(2) { --phrase-delay: 2.625s; }
  .games-hero-phrase:nth-child(3) { --phrase-delay: 5.625s; }
  .games-hero-phrase:nth-child(4) { --phrase-delay: 8.625s; }
  .games-hero-phrase:nth-child(5) { --phrase-delay: 11.625s; }

  .games-opening.is-enhanced::after {
    content: '';
    display: block;
    height: var(--opening-travel);
  }

  .games-opening.is-enhanced .games-opening-stage {
    position: sticky;
    top: var(--opening-pin-top);
    overflow: clip;
    isolation: isolate;
    background: #000;
  }

  .games-opening.is-enhanced .games-hero {
    opacity: var(--earth-opacity, 1);
    visibility: var(--earth-visibility, visible);
  }

  .games-opening.is-enhanced .games-globe > :is(canvas, .games-globe-fallback) {
    transform: scale(var(--globe-zoom, 1));
    transform-origin: 50% 55%;
  }

  .games-opening.is-enhanced + .artworks-section {
    margin-top: max(-132px, -16svh);
  }

  /* Bring the intro into the end of the Earth fade on phones and desktops. */
  .games-opening.is-enhanced + .artworks-section .home-intro {
    margin-top: calc(-1 * clamp(240px, 34svh, 360px));
  }

  .games-opening.is-enhanced + .artworks-section .home-intro p {
    opacity: var(--intro-reveal, 1);
    transform: translateY(calc(64px * (1 - var(--intro-reveal, 1))));
  }
}

@keyframes games-hero-phrase {
  0%, 20%, 100% { opacity: 0; }
  2.5%, 17.5% { opacity: 1; }
}

@media (max-width: 1100px) and (min-width: 721px) {
  .games-hero-copy { top: 70px; }
}

@media (max-width: 720px) {
  .games-opening {
    --opening-hero-height: max(660px, calc(100vh - 72px));
    --opening-hero-height: max(660px, calc(100svh - 72px));
  }
  .games-hero-copy { top: 60px; width: calc(100% - 32px); }
  #games-hero-title { font-size: clamp(43px, 12.5vw, 76px); line-height: 1.07; }
  .games-hero-phrase > span { display: block; }
  .games-hero-description { margin-top: 18px; font-size: clamp(15px, 4.3vw, 22px); }
  .games-globe-fallback-earth { width: 170%; }
  .globe-fallback-icon { width: 55px; left: 17%; translate: 0 20px; }
  .globe-fallback-icon--two { left: 69%; }
  .globe-fallback-icon--three { left: 85%; }
  .games-hero-scroll { bottom: 13px; left: 18px; transform: none; font-size: 9px; padding-inline: 12px; }
}

@media (min-width: 721px) and (max-height: 800px) {
  .games-hero-copy { top: clamp(36px, 7vh, 70px); }
  #games-hero-title { font-size: clamp(42px, min(6.6vw, 11.3vh), 96px); }
  .games-hero-description { margin-top: min(22px, 3vh); font-size: clamp(16px, 2.2vw, 3.5vh); }
}

@media (max-height: 540px) and (orientation: landscape) {
  .games-hero-copy { top: 24px; }
  #games-hero-title { font-size: clamp(32px, 11vh, 56px); }
  .games-hero-phrase > span { display: inline; }
  .games-hero-description { margin-top: 10px; font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .games-globe canvas { transition: none; }
}
