:root { --stella-display: "Baskervville", Georgia, "Times New Roman", serif; }

/* The near gate, projected pavement, garden and night sky share one camera. */
.portal-hero {
  --portal-view: 100vh;
  --portal-travel: clamp(440px, 101vh, 1060px);
  --gate-sightline: 61%;
  --court-horizon: 60.5%;
  --court-seam: 60.5%;
  --court-art: url("../assets/observatory-promenade.webp");
  --portrait-scale: 1;
  --crossing: 0;
  --distance: 1;
  position: relative;
  background: #070d18;
}

@supports (height: 100svh) {
  .portal-hero {
    --portal-view: 100svh;
    --portal-travel: clamp(440px, 101svh, 1060px);
  }
}

.portal-hero .hero-stage {
  height: var(--portal-view);
  min-height: 0;
  max-height: none;
  background: #070d18;
  touch-action: pan-y pinch-zoom;
}

.portal-hero .hero-art { background: #070d18; }
.portal-hero .cinema-depth {
  inset: -5%;
  background: #070d18;
  isolation: isolate;
  transform: translate3d(calc(var(--journey, 0) * -4%), calc(var(--journey, 0) * -10%), 0)
             scale(calc(1 + var(--journey, 0) * .31));
  transform-origin: 50% 63%;
}

.portal-hero .cinema-depth picture {
  position: absolute;
  display: block;
  inset: 0;
}

/* The photographic sky also carries a blue nucleus when the orbit canvas is unavailable. */
.portal-hero .cinema-depth picture::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 21% 17% at var(--poster-core-x, 48%) 56%, #b0d8ff51, #617ee928 45%, transparent 100%);
  mix-blend-mode: screen;
}

.portal-hero .galaxy-art {
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 49% 54%;
  filter: saturate(1.08) brightness(1.04);
  transform-origin: 49% 55%;
  transform: none;
}

.portal-companion {
  position: absolute;
  left: 24%;
  top: 25%;
  width: clamp(76px, 8.8vw, 162px);
  height: auto;
  opacity: .52;
  filter: saturate(.65) brightness(.81);
  mix-blend-mode: screen;
  mask-image: radial-gradient(ellipse, #000 15%, rgb(0 0 0 / 72%) 40%, transparent 70%);
  transform: translate(-50%, -50%) rotate(-19deg);
}

.portal-hero.sky-unavailable .galaxy-art { visibility: hidden; }
.portal-hero.sky-unavailable .portal-companion {
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 1;
  mix-blend-mode: normal;
  mask-image: none;
  transform: none;
}

.portal-hero .cinema-depth::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 51% 53%, transparent 46%, rgb(3 7 17 / 35%) 100%);
}

.portal-hero .cinema-stars { z-index: 2; opacity: .60; pointer-events: none; }
.observatory-orbits {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  visibility: hidden;
  pointer-events: none;
  opacity: .77;
}
@media (prefers-reduced-motion: no-preference) {
  /* Compose the opening even while images and the deferred controller are loading. */
  .portal-hero { --distance: 0; --portrait-scale: .31; --actor-x: -2.7vw; --actor-y: -3vh; }
  .portal-hero [data-orbit-renderer] .observatory-orbits { visibility: visible; }
  .portal-hero [data-orbit-renderer] .cinema-depth picture { visibility: hidden; }
  .portal-hero [data-orbit-renderer] .galaxy-art { animation: none; }
  .portal-hero [data-orbit-renderer] .cinema-depth {
    background: radial-gradient(ellipse at 36% 29%, #293347 0%, #182235 37%, #0d1525 71%, #080e1b 100%);
  }
  .portal-hero [data-orbit-renderer] .portal-companion { visibility: hidden; }
}
.portal-hero .hero-art::after {
  z-index: 5;
  background: linear-gradient(90deg, rgb(4 9 19 / 41%), transparent 44%),
              linear-gradient(0deg, rgb(6 12 22 / 79%), transparent 18%),
              linear-gradient(180deg, rgb(5 10 18 / 52%), transparent 19%);
}

.portal-court {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: var(--court-horizon);
  width: max(105%, calc(var(--portal-view) * 1.62));
  aspect-ratio: 3 / 2;
  transform: translate(-50%, calc(0% - var(--court-seam)));
  pointer-events: none;
}

.court-view, .court-scenery, .court-scenery img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.court-view {
  transform-origin: 50% var(--court-seam);
  transform: translate3d(var(--court-x, 0px), var(--court-y, 0px), 0)
             scale(var(--court-scale, 1));
}

.court-scenery img, .has-passage .court-view::after { filter: url("#stella-court-light"); }

@supports (clip-path: inset(1%)) {
  .has-passage .court-scenery { clip-path: inset(0 0 calc(100% - var(--court-seam) - 1px)); }
  /* The same bitmap meets itself at eye level. Only pavement projects towards the viewer. */
  .has-passage .court-view::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--court-art) center / 100% 100% no-repeat;
    clip-path: inset(var(--court-seam) 0 0);
    transform-origin: 50% var(--court-seam);
    transform: matrix3d(1,0,0,0, 0,1,0,var(--floor-projection, 0), 0,0,1,0, 0,0,0,1);
  }
}

.portal-light {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse 57% 64% at 36% 24%, rgb(181 194 211 / 9%), transparent 84%),
              radial-gradient(ellipse 31% 17% at 51% 61%, rgb(218 205 188 / 5%), transparent 86%);
}

.portal-gate-mount {
  position: absolute;
  z-index: 4;
  top: var(--gate-sightline);
  left: 50%;
  width: clamp(calc(var(--portal-view) * 1.24), 92%, calc(var(--portal-view) * 1.98));
  aspect-ratio: 3 / 2;
  transform: translate(-50%, -66%);
  pointer-events: none;
}

.portal-gate {
  display: block;
  width: 100%;
  height: 100%;
  visibility: inherit;
  filter: url("#stella-stone-light");
  transform-origin: 50% 66%;
  transform: translate3d(var(--gate-x, 0px), var(--gate-y, 0px), 0)
             scale(var(--gate-scale, 1));
}
.has-passage .portal-gate { visibility: var(--gate-visibility, visible); }

.portal-subject {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  transform-origin: 50% var(--gate-sightline);
  transform: translate3d(var(--actor-x, 0px), var(--actor-y, 0px), 0)
             scale(var(--portrait-scale));
}

.portal-hero .character-wrap {
  --portrait-width: min(calc(var(--portal-view) * 1.12), 88vw);
  --portrait-center: 72.5%;
  z-index: auto;
  inset: clamp(84px, calc(var(--portal-view) * .084), 118px) auto auto calc(var(--portrait-center) - var(--portrait-width) / 2);
  width: var(--portrait-width);
  height: auto;
  aspect-ratio: 1522 / 2175;
  transition: none;
  transform: none;
}

.portal-hero .character-wrap::before {
  content: "";
  position: absolute;
  left: 44%;
  bottom: -1%;
  width: 26%;
  height: 2.7%;
  background: radial-gradient(ellipse 16% 24% at 41% 62%, rgb(14 18 27 / 87%), rgb(21 24 32 / 48%) 45%, transparent),
              radial-gradient(ellipse 48% 49% at 57% 66%, rgb(23 30 42 / 48%), transparent);
}

.portal-hero .character-wrap picture { position: relative; display: block; }

.portal-hero .stella-character {
  object-fit: contain;
  object-position: center top;
  filter: none;
  mask-image: none;
}

.portal-hero .hero-inner {
  width: min(89%, 1680px);
  align-items: center;
  padding: 5% 0 0;
}

.portal-hero .hero-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: clamp(.875rem, 1.9vh, 1.5rem);
  width: auto;
  max-width: none;
  pointer-events: none;
  transform: translate3d(calc(var(--crossing) * -1.4vw), calc(var(--crossing) * -1.4vh), 0);
}

@media (orientation: landscape) {
  .portal-hero .hero-copy { position: relative; isolation: isolate; }
  .portal-hero .hero-copy::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: -66% -45% -65% -66%;
    background: radial-gradient(ellipse at 50% 51%, rgb(3 7 14 / 75%) 8%, rgb(3 7 14 / 53%) 42%, transparent 74%);
    opacity: calc(.93 - var(--distance) * .16);
  }
}

.portal-hero .hero-edition {
  --neon-rest: 0 1px 2px #071325b3, 0 0 .08em #def5ffb3, 0 0 .28em #79cfff85, 0 0 .55em #3aa8ff55;
  --neon-peak: 0 1px 2px #071325b3, 0 0 .20em #f0fcff, 0 0 .47em #8bdcffdf, 0 0 .92em #43bfffaa;
  display: block;
  margin: 0;
  font: 500 clamp(.875rem, 1.05vw, 1.0625rem)/1.45 var(--sans);
  text-transform: none;
  letter-spacing: .015em;
  color: #fff;
  text-shadow: var(--neon-rest);
}

.portal-hero .hero-copy h1 {
  --neon-edge: -.5px -.5px .6px #f5fdff, .5px .5px .6px #e7f8ff;
  --neon-rest: var(--neon-edge), 0 0 .04em #dcf5ff, 0 0 .10em #b6e8ffbb,
    0 0 .22em #81d7ff94, 0 0 .46em #4bbdff70, 0 0 .85em #269fe849;
  --neon-peak: var(--neon-edge), 0 0 .075em #f1fcff, 0 0 .18em #c9f2ff,
    0 0 .42em #83defff0, 0 0 .82em #51c8ffd4, 0 0 1.55em #259ffb9c;
  margin: 0;
  color: #f5fcff;
  font: 400 clamp(4rem, min(7.5vw, 14vh), 8.5rem)/.99 var(--stella-display);
  letter-spacing: -.035em;
  text-transform: none;
  text-shadow: var(--neon-rest);
  animation: none;
}

.portal-hero .hero-copy h1 > span {
  position: relative;
  display: block;
  width: fit-content;
  white-space: nowrap;
  color: inherit;
}
.portal-hero .hero-copy h1 > span + span {
  margin-block-start: .035em;
  font-size: .9em;
  --spark-x: 57%;
  --spark-y: 17%;
  --spark-delay: 1s;
  --small-spark-x: 98%;
  --small-spark-y: 43%;
  --small-spark-delay: 3.8s;
}

@media (prefers-reduced-motion: no-preference) {
  .is-cinema-running .portal-hero { --light-play-state: running; }
  .portal-hero .hero-copy h1,
  .portal-hero .hero-edition {
    animation: stella-sky-neon 3s ease-in-out -.3s infinite;
    animation-play-state: var(--light-play-state, paused);
  }
  /* Anchor each glint to a stroke of the lettering, clear of the spaces between words. */
  .portal-hero .hero-copy h1 > span::before,
  .portal-hero .hero-copy h1 > span::after {
    content: "";
    position: absolute;
    left: var(--spark-x, 16.5%);
    top: var(--spark-y, 15%);
    width: .43em;
    aspect-ratio: 1;
    pointer-events: none;
    opacity: 0;
    --ray: #fff 12%, #dcf7ff 42%, #8cdcffac 68%, transparent 100%;
    background: radial-gradient(circle, #fff 0 5%, #d9f8ff 9%, #7ed7ff55 21%, transparent 44%),
                radial-gradient(ellipse 48% 5%, var(--ray)),
                radial-gradient(ellipse 5% 50%, var(--ray));
    filter: drop-shadow(0 0 .035em #90deff);
    animation: stella-letter-spark 5.6s ease-in-out var(--spark-delay, -.34s) infinite;
    animation-play-state: var(--light-play-state, paused);
  }
  .portal-hero .hero-copy h1 > span::after {
    left: var(--small-spark-x, 82.5%);
    top: var(--small-spark-y, 17%);
    width: .28em;
    animation-delay: var(--small-spark-delay, 2.45s);
  }
}
@keyframes stella-sky-neon {
  0%, 100% { text-shadow: var(--neon-rest); }
  50% { text-shadow: var(--neon-peak); }
}
@keyframes stella-letter-spark {
  0%, 2%, 24%, 100% { opacity: 0; transform: translate(-50%, -50%) rotate(-12deg) scale(.3); }
  10% { opacity: 1; transform: translate(-50%, -50%) rotate(4deg) scale(1); }
  15% { opacity: .74; transform: translate(-50%, -50%) rotate(8deg) scale(.78); }
}

.portal-hero .hero-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  gap: .5rem;
  z-index: 6;
  width: min(89%, 1680px);
  bottom: max(2.5%, env(safe-area-inset-bottom));
}

.portal-rewards-link {
  grid-column: 3;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: #eee4cf;
  font: 500 12px/1.4 var(--sans);
  text-shadow: 0 1px 7px #050911;
}

.portal-scroll-hint {
  grid-column: 2;
  display: grid;
  justify-items: center;
  gap: .375rem;
  margin: 0;
  color: #fff5df;
  font: 550 .875rem/1.3 var(--sans);
  white-space: nowrap;
  text-shadow: 0 1px 3px #10131d;
  pointer-events: none;
}
.portal-scroll-touch { display: none; }
.portal-scroll-gesture {
  position: relative;
  width: 18px;
  height: 26px;
}
.portal-scroll-gesture::before, .portal-scroll-gesture::after {
  content: "";
  position: absolute;
  box-sizing: border-box;
}
.portal-scroll-gesture::before {
  inset: 0;
  border: 1.5px solid currentColor;
  border-radius: 9px;
}
.portal-scroll-gesture::after {
  left: 8px;
  top: 5px;
  width: 2px;
  height: 6px;
  border-radius: 1px;
  background: currentColor;
}
@media (hover: none) and (pointer: coarse) {
  .portal-scroll-wheel { display: none; }
  .portal-scroll-touch { display: inline; }
  .portal-scroll-gesture { --gesture-travel: -5px; height: 23px; }
  .portal-scroll-gesture::before { inset: auto 1px 1px; height: 2px; border: 0; border-radius: 1px; background: currentColor; }
  .portal-scroll-gesture::after {
    left: 5px; top: 8px; width: 8px; height: 8px;
    border: solid currentColor; border-width: 1.5px 0 0 1.5px; border-radius: 0;
    background: none; transform: rotate(45deg);
  }
}
@media (prefers-reduced-motion: no-preference) {
  .portal-scroll-gesture::after {
    animation: stella-scroll-nudge 2.5s ease-in-out infinite;
    animation-play-state: var(--light-play-state, paused);
  }
}
@keyframes stella-scroll-nudge {
  0%, 25%, 100% { translate: 0 0; }
  65% { translate: 0 var(--gesture-travel, 5px); }
}

.portal-rewards-link span { color: #ddc08b; font-size: 18px; }
.portal-rewards-link:hover { color: white; }
@media (forced-colors: active) {
  .portal-hero .hero-copy h1,
  .portal-hero .hero-edition { color: CanvasText; text-shadow: none; animation: none; }
  .portal-hero .hero-copy h1 > span::before,
  .portal-hero .hero-copy h1 > span::after { display: none; animation: none; }
  .portal-scroll-hint { color: CanvasText; text-shadow: none; }
  .portal-scroll-gesture { forced-color-adjust: none; color: CanvasText; }
}
.portal-marker {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  .portal-hero .hero-stage:not([data-orbit-renderer]) .cinema-depth picture::after {
    animation: observatory-core-light 6.7s ease-in-out infinite alternate;
    animation-play-state: var(--light-play-state, paused);
  }
  .portal-hero .galaxy-art {
    animation: observatory-sky-drift 28s ease-in-out infinite alternate;
    animation-play-state: paused;
  }
  .is-cinema-running .portal-hero .galaxy-art { animation-play-state: running; }
  .portal-hero.has-passage { height: calc(var(--portal-view) + var(--portal-travel)); }
  .has-passage .hero-stage { position: sticky; top: 0; }
  .has-passage .portal-marker {
    top: calc(var(--portal-travel) + var(--anchor-offset, 0px));
    bottom: auto;
  }
  .is-cinema-running .portal-gate,
  .is-cinema-running .court-view,
  .is-cinema-running .portal-subject { will-change: transform; }
}

@media (prefers-reduced-motion: reduce), (scripting: none) {
  .portal-hero { --distance: 1; --portrait-scale: 1; --actor-x: 0px; --actor-y: 0px; }
  .portal-gate-mount { display: none; }
}

@keyframes observatory-sky-drift {
  from { transform: scale(1.045) rotate(-1.6deg); }
  to { transform: scale(1.085) rotate(2deg); }
}
@keyframes observatory-core-light {
  from { opacity: .43; }
  to { opacity: 1; }
}

@media (orientation: portrait) {
  .portal-hero {
    --gate-sightline: 53%;
    --court-horizon: 55.5%;
    --court-seam: 59%;
    --court-art: url("../assets/observatory-promenade-portrait.webp");
  }
  .portal-court { width: max(108%, calc(var(--portal-view) * .76)); aspect-ratio: 2 / 3; }
  .portal-hero .hero-inner { align-items: end; width: 88%; padding: 0 0 max(96px, 13svh); }
  .portal-hero .cinema-depth picture {
    --poster-core-x: 41%;
    inset: -40% -6% 0 -26%;
    transform: translate3d(calc(var(--journey, 0) * 5%), calc(var(--journey, 0) * 17%), 0);
  }
  .portal-gate-mount { width: min(179vw, calc(var(--portal-view) * 1.48)); }
  .portal-hero .character-wrap {
    --portrait-width: min(calc(var(--portal-view) * .784), 144vw);
    --portrait-center: 62%;
    top: max(68px, calc(var(--portal-view) * .088));
  }
  .portal-hero .galaxy-art { transform-origin: 40% 48%; }
  .portal-companion { left: 19%; top: 18%; width: clamp(58px, 12vw, 105px); }
  .portal-hero .hero-art::after {
    background: linear-gradient(0deg, rgb(5 10 19 / 89%) 0%, rgb(7 13 25 / 69%) 12%, rgb(7 13 25 / 39%) 24%, transparent 43%),
                linear-gradient(90deg, rgb(3 8 18 / 26%), transparent 58%),
                linear-gradient(180deg, rgb(4 8 16 / 36%), transparent 17%);
  }
  .portal-hero .hero-copy h1 { font-size: clamp(3.5rem, min(15.5vw, 10svh), 6.5rem); }
  .portal-hero .hero-bottom { width: 88%; bottom: max(2%, env(safe-area-inset-bottom)); }
}

@media (max-width: 760px) and (max-height: 650px) and (orientation: portrait) {
  .portal-hero .hero-inner { padding-bottom: max(72px, 12svh); }
  .portal-hero .hero-copy h1 { font-size: clamp(42px, 8.8svh, 57px); }
  .portal-hero .hero-copy { gap: .5rem; }
}

@media (orientation: portrait) and (prefers-reduced-motion: no-preference) and (scripting: enabled) {
  .portal-hero { --portrait-scale: .33; --actor-x: 1vw; --actor-y: -2vh; }
}

@media (max-width: 380px) {
  .portal-hero .portal-rewards-link { gap: 7px; font-size: 11px; white-space: nowrap; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .portal-hero .hero-copy h1 { font-size: clamp(42px, 11.4vh, 62px); }
  .portal-hero .hero-inner { padding-top: 8%; }
  .portal-hero .hero-copy { gap: .5rem; }
  .portal-hero .hero-bottom { bottom: max(.4rem, env(safe-area-inset-bottom)); }
  .portal-hero .character-wrap { top: clamp(54px, 13vh, 72px); }
}
