:root {
  --bg: #01040a;
  --cyan: 77, 221, 255;
  --tile-border: rgba(var(--cyan), .72);
  --tile-glow: rgba(var(--cyan), .34);
  --tile-gap: clamp(14px, 1.12vw, 30px);
  --grid-width: min(54.8vw, 1400px);
  --grid-top: clamp(390px, 42.8vh, 560px);
  --ease-premium: cubic-bezier(.2,.74,.24,1);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
html { scroll-behavior: smooth; }
body {
  min-height: 100svh;
  overflow-x: hidden;
  color: #e8f5ff;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: var(--bg); }
.scene__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  user-select: none;
  pointer-events: none;
}
.scene__stars { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.scene__vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, transparent 0%, transparent 66%, rgba(0,3,9,.16) 84%, rgba(0,3,9,.68) 100%),
    radial-gradient(ellipse at center, transparent 35%, rgba(0,2,8,.10) 70%, rgba(0,2,8,.38) 100%);
}

.portal { position: relative; z-index: 2; min-height: 100svh; padding: var(--grid-top) 0 5vh; }
.tiles {
  width: var(--grid-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--tile-gap);
  perspective: 1200px;
}
.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  display: block;
  isolation: isolate;
  overflow: visible;
  border: 1px solid var(--tile-border);
  border-radius: clamp(7px, .45vw, 12px);
  background: rgba(0, 8, 18, .74);
  box-shadow:
    inset 0 0 0 1px rgba(150, 235, 255, .035),
    0 0 10px rgba(0, 177, 255, .08);
  text-decoration: none;
  color: inherit;
  transform: translate3d(0,0,0) scale(1);
  transform-origin: center center;
  transition:
    transform .3s var(--ease-premium),
    border-color .3s ease,
    box-shadow .3s ease,
    filter .3s ease;
  will-change: transform, box-shadow;
  -webkit-tap-highlight-color: transparent;
}
.tile::after {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: 5;
  border-radius: inherit;
  pointer-events: none;
  opacity: .38;
  box-shadow: inset 0 0 18px rgba(56, 217, 255, .10);
  transition: opacity .3s ease, box-shadow .3s ease;
}
.tile__light {
  position: absolute;
  z-index: -1;
  inset: 5% 4% -7%;
  border-radius: 14%;
  background: radial-gradient(ellipse at center, rgba(62, 220, 255, .72), rgba(27, 115, 255, .28) 45%, transparent 72%);
  filter: blur(22px);
  opacity: 0;
  transform: translateY(8px) scale(.94);
  transition: opacity .3s ease, transform .3s var(--ease-premium), filter .3s ease;
  pointer-events: none;
}
.tile__media { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; background: #03101c; }
.tile__media img,
.tile__media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  user-select: none;
  pointer-events: none;
}
.tile__media video { opacity: 0; transition: opacity .16s linear; }
.tile.is-playing .tile__media video { opacity: 1; }
.tile.is-playing .tile__media img { opacity: 0; }

.tile__caption {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18% 4.5% 3.8%;
  text-align: center;
  background: linear-gradient(to bottom, transparent 0%, rgba(0,5,13,.28) 35%, rgba(0,5,13,.84) 100%);
  border-radius: 0 0 inherit inherit;
  pointer-events: none;
}
.tile__title {
  font-size: clamp(12px, .88vw, 23px);
  line-height: 1.02;
  font-weight: 640;
  letter-spacing: -.025em;
  text-shadow: 0 1px 8px rgba(0,0,0,.82), 0 0 12px rgba(111,224,255,.12);
  white-space: nowrap;
}
.tile__subtitle {
  margin-top: clamp(2px, .18vw, 5px);
  font-size: clamp(8px, .55vw, 14px);
  line-height: 1.1;
  color: rgba(205, 228, 244, .72);
  text-shadow: 0 1px 6px rgba(0,0,0,.95);
  white-space: nowrap;
}

@media (hover:hover) and (pointer:fine) {
  .tile:hover,
  .tile:focus-visible {
    z-index: 20;
    transform: translate3d(0,-10px,28px) scale(1.035) rotateX(.4deg);
    border-color: rgba(140, 239, 255, .99);
    box-shadow:
      0 20px 42px rgba(0, 0, 0, .54),
      0 0 19px rgba(72, 222, 255, .60),
      0 0 53px rgba(20, 143, 255, .34),
      inset 0 0 24px rgba(89, 222, 255, .21);
    filter: brightness(1.06) saturate(1.08);
    outline: none;
  }
  .tile:hover .tile__light,
  .tile:focus-visible .tile__light {
    opacity: .9;
    transform: translateY(17px) scale(1.095);
    filter: blur(31px);
  }
  .tile:hover::after,
  .tile:focus-visible::after {
    opacity: 1;
    box-shadow: inset 0 0 29px rgba(98, 230, 255, .34);
  }
}

.tile.is-pressed {
  transform: translate3d(0,-4px,12px) scale(1.018);
  border-color: rgba(122, 234, 255, .96);
  box-shadow: 0 10px 28px rgba(0,0,0,.45), 0 0 24px rgba(43,189,255,.30);
}
.tile.is-pressed .tile__light { opacity: .45; transform: translateY(9px) scale(1.02); }

/* Tablet landscape / compact desktop */
@media (max-width: 1199px) and (orientation: landscape) {
  :root { --grid-width: min(58vw, 920px); --grid-top: clamp(340px, 40vh, 460px); --tile-gap: clamp(12px, 1.2vw, 20px); }
  .tile__title { font-size: clamp(11px, 1.05vw, 17px); }
  .tile__subtitle { font-size: clamp(7px, .66vw, 11px); }
}

/* Tablet portrait: keep the two planets + logo fully visible at the top, then 2 columns */
@media (max-width: 1024px) and (orientation: portrait) {
  .scene__video { height: auto; aspect-ratio: 16 / 9; object-fit: contain; object-position: center top; }
  .scene__vignette { background: linear-gradient(to bottom, transparent 0%, rgba(0,3,9,.05) 35%, rgba(0,3,9,.45) 54%, rgba(0,3,9,.82) 100%); }
  .portal { padding-top: clamp(360px, 46.5vw, 500px); padding-bottom: max(42px, env(safe-area-inset-bottom)); }
  .tiles { width: min(78vw, 720px); grid-template-columns: repeat(2, minmax(0,1fr)); gap: clamp(14px, 2.2vw, 22px); }
  .tile__title { font-size: clamp(13px, 2vw, 18px); }
  .tile__subtitle { font-size: clamp(9px, 1.25vw, 12px); }
}

/* iPhone / small phones */
@media (max-width: 600px) {
  .scene__video { height: auto; aspect-ratio: 16 / 9; object-fit: contain; object-position: center top; }
  .portal { padding-top: clamp(205px, 57vw, 260px); padding-bottom: max(34px, env(safe-area-inset-bottom)); }
  .tiles { width: min(86vw, 420px); grid-template-columns: 1fr; gap: 18px; }
  .tile { border-radius: 10px; }
  .tile__caption { padding-bottom: 4.6%; }
  .tile__title { font-size: clamp(16px, 4.55vw, 20px); }
  .tile__subtitle { font-size: clamp(10px, 2.85vw, 13px); }
}

@media (max-width: 390px) {
  .portal { padding-top: 218px; }
  .tiles { width: 88vw; }
}

@media (prefers-reduced-motion: reduce) {
  .scene__video { display: none; }
  .scene { background: #01040a url('assets/background/planet-logo-glow-poster.jpg') center top / cover no-repeat; }
  .tile, .tile__light, .tile::after { transition: none !important; }
  .scene__stars { display: none; }
}

/* --------------------------------------------------------------------------
   Fullscreen section gateway + authorization
   -------------------------------------------------------------------------- */
body.gateway-open { overflow: hidden; }
.tile.is-launching { z-index: 30; }

.gateway {
  position: fixed;
  inset: 0;
  z-index: 1000;
  visibility: hidden;
  pointer-events: none;
}
.gateway.is-open {
  visibility: visible;
  pointer-events: auto;
}
.gateway__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 2, 8, .72);
  opacity: 0;
  transition: opacity .42s ease;
  backdrop-filter: blur(10px);
}
.gateway.is-expanding .gateway__backdrop { opacity: 1; }

.gateway__stage {
  --origin-x: 0px;
  --origin-y: 0px;
  --origin-scale-x: .25;
  --origin-scale-y: .25;
  --origin-radius: 10px;
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 1px solid rgba(var(--cyan), .76);
  border-radius: var(--origin-radius);
  background: #020812;
  transform-origin: center center;
  transform: translate3d(var(--origin-x), var(--origin-y), 0) scale(var(--origin-scale-x), var(--origin-scale-y));
  box-shadow: 0 0 24px rgba(52, 214, 255, .25), 0 24px 80px rgba(0,0,0,.7);
  transition:
    transform .62s var(--ease-premium),
    border-radius .62s var(--ease-premium),
    border-color .62s ease,
    box-shadow .62s ease;
}
.gateway.is-expanding .gateway__stage {
  transform: translate3d(0,0,0) scale(1,1);
  border-radius: 0;
  border-color: rgba(var(--cyan), .24);
  box-shadow: none;
}

.gateway__visual {
  --gateway-media-gap: clamp(12px, 1.5vw, 24px);
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #020812;
}

/*
  The media gets its own viewport-safe frame. This is deliberately separate
  from the fullscreen stage: the stage fills the display, while the square
  1080×1080 tile animation is always fitted INSIDE the visible viewport.
  This prevents the old cover-like crop on wide desktop displays and also
  respects iPhone/iPad safe areas.
*/
.gateway__media-frame {
  position: absolute;
  top: max(var(--gateway-media-gap), env(safe-area-inset-top));
  right: max(var(--gateway-media-gap), env(safe-area-inset-right));
  bottom: max(var(--gateway-media-gap), env(safe-area-inset-bottom));
  left: max(var(--gateway-media-gap), env(safe-area-inset-left));
  overflow: hidden;
  display: grid;
  place-items: center;
}
.gateway__image,
.gateway__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  padding: 0;
  object-fit: contain !important;
  object-position: center center !important;
  user-select: none;
  pointer-events: none;
}
.gateway__video { opacity: 1; }
.gateway__visual-shade {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 45%, rgba(0,0,0,.08) 0%, rgba(0,0,0,.2) 42%, rgba(0,3,10,.72) 100%),
    linear-gradient(to bottom, rgba(0,4,10,.08), rgba(0,4,10,.35));
  opacity: .2;
  transition: opacity .55s ease .18s;
}
.gateway.is-auth-visible .gateway__visual-shade { opacity: .48; }

.gateway__close {
  position: absolute;
  z-index: 5;
  top: max(18px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  width: 46px;
  height: 46px;
  border: 1px solid rgba(128, 231, 255, .38);
  border-radius: 50%;
  background: rgba(0, 11, 24, .52);
  color: rgba(231, 249, 255, .9);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-6px) scale(.92);
  transition: opacity .3s ease, transform .3s ease, border-color .3s ease, box-shadow .3s ease;
  backdrop-filter: blur(10px);
}
.gateway.is-auth-visible .gateway__close {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.gateway__close:hover,
.gateway__close:focus-visible,
.gateway__close.is-emphasized {
  outline: none;
  border-color: rgba(128, 231, 255, .88);
  box-shadow: 0 0 24px rgba(50, 203, 255, .28);
}

.gateway__auth {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: max(4.5vh, calc(env(safe-area-inset-bottom) + 18px));
  width: min(420px, calc(100vw - max(32px, env(safe-area-inset-left) + env(safe-area-inset-right) + 24px)));
  max-height: min(32dvh, 270px);
  overflow-y: auto;
  padding: 18px 20px 16px;
  border: 1px solid rgba(106, 224, 255, .34);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(3, 17, 31, .46), rgba(0, 8, 20, .34));
  box-shadow:
    0 18px 42px rgba(0,0,0,.34),
    0 0 34px rgba(39, 182, 255, .08),
    inset 0 0 0 1px rgba(191, 244, 255, .02);
  backdrop-filter: blur(18px) saturate(1.08);
  -webkit-backdrop-filter: blur(18px) saturate(1.08);
  opacity: 0;
  transform: translate(-50%, 18px) scale(.97);
  transition: opacity .42s ease, transform .42s var(--ease-premium);
  pointer-events: none;
}
.gateway.is-auth-visible .gateway__auth {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  pointer-events: auto;
}
.gateway__eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
  color: rgba(115, 226, 255, .72);
  margin-bottom: 10px;
}
.gateway__title {
  margin: 0;
  font-size: clamp(27px, 2.1vw, 36px);
  line-height: 1.05;
  letter-spacing: -.035em;
  font-weight: 620;
}
.gateway__text {
  margin: 11px 0 7px;
  color: rgba(211, 233, 245, .74);
  font-size: 14px;
  line-height: 1.45;
}
.gateway__section-name {
  min-height: 17px;
  margin-bottom: 22px;
  color: rgba(122, 229, 255, .9);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .055em;
  text-transform: uppercase;
}
.gateway__form {
  display: grid;
  gap: 12px;
  opacity: 1;
  transition: opacity .25s ease, transform .25s ease;
}
.gateway__form.is-hidden {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  position: absolute;
}
.gateway__field { display: grid; gap: 7px; }
.gateway__field span {
  font-size: 14px;
  letter-spacing: .01em;
  color: rgba(226, 242, 252, .92);
}
.gateway__field input {
  width: 100%;
  height: 46px;
  border: 1px solid rgba(108, 219, 255, .32);
  border-radius: 10px;
  background: rgba(0, 7, 18, .38);
  color: #effaff;
  padding: 0 14px;
  font: inherit;
  outline: none;
  caret-color: rgb(var(--cyan));
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.gateway__field input:focus {
  border-color: rgba(108, 219, 255, .78);
  box-shadow: 0 0 0 3px rgba(48, 190, 255, .09), 0 0 18px rgba(47, 195, 255, .1);
  background: rgba(0, 10, 23, .82);
}
.gateway__submit--hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.gateway__error {
  min-height: 18px;
  color: #ff8f9b;
  font-size: 12px;
  line-height: 1.35;
}

.gateway__loader {
  display: none;
  min-height: 88px;
  padding-top: 2px;
}
.gateway__loader.is-visible { display: block; }
.gateway__loader-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 10px;
  color: rgba(213, 240, 250, .78);
  font-size: 11px;
  letter-spacing: .065em;
  text-transform: uppercase;
}
.gateway__loader-track {
  position: relative;
  height: 7px;
  overflow: hidden;
  border: 1px solid rgba(104, 222, 255, .28);
  border-radius: 99px;
  background: rgba(0, 7, 17, .72);
  box-shadow: inset 0 0 12px rgba(0,0,0,.6);
}
.gateway__loader-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(43, 157, 255, .8), rgba(115, 235, 255, .98));
  box-shadow: 0 0 16px rgba(82, 222, 255, .65);
}
.gateway__loader-status {
  margin-top: 13px;
  color: rgba(195, 227, 241, .68);
  font-size: 12px;
  line-height: 1.45;
}
.gateway__loader.is-complete .gateway__loader-status { color: rgba(160, 238, 213, .88); }

@media (max-width: 900px) {
  .gateway__visual { --gateway-media-gap: clamp(8px, 1.8vw, 16px); }
  .gateway__auth {
    width: min(390px, calc(100vw - 24px));
    max-height: min(34dvh, 250px);
    padding: 16px 18px 14px;
  }
}

@media (max-width: 600px) {
  .gateway__visual { --gateway-media-gap: 8px; }
  .gateway__auth {
    bottom: max(12px, env(safe-area-inset-bottom));
    width: calc(100vw - max(24px, env(safe-area-inset-left) + env(safe-area-inset-right) + 16px));
    max-height: min(35dvh, 245px);
    padding: 14px 16px 12px;
    border-radius: 14px;
  }
  .gateway__close { width: 42px; height: 42px; font-size: 27px; }
}

/* Short landscape screens (phones/tablets): keep the compact login panel in the lower zone
   without covering too much of the expanded tile animation. */
@media (max-height: 560px) and (orientation: landscape) {
  .gateway__visual { --gateway-media-gap: 6px; }
  .gateway__auth {
    width: min(340px, calc(100vw - 86px));
    max-height: min(40dvh, 210px);
    bottom: max(10px, env(safe-area-inset-bottom));
    padding: 12px 14px 10px;
  }
  .gateway__field { gap: 6px; }
  .gateway__field input { height: 38px; }
}


@media (prefers-reduced-motion: reduce) {
  .gateway__stage,
  .gateway__backdrop,
  .gateway__auth,
  .gateway__close,
  .gateway__visual-shade { transition: none !important; }
  .gateway__stage,
  .gateway.is-expanding .gateway__stage { transform: none !important; border-radius: 0 !important; }
}

.gateway__eyebrow,
.gateway__title,
.gateway__text,
.gateway__section-name { display: none !important; }
