/* HH Living Galaxy 3D — WebGL enhancement with a complete CSS/mobile fallback. */
/* Desktop begins with the semantic CSS solar system in the DOM, but keeps it
   visually unpublished while WebGL prepares. This prevents the old compact
   orbit layout from flashing before the cinematic first frame on refresh. */
@media (min-width: 761px) {
  .hh-h-galaxy[data-living-galaxy="pending"],
  .hh-h-galaxy[data-living-galaxy="loading"] {
    visibility: hidden;
    opacity: 0;
  }

  .hh-h-galaxy.is-webgl-ready,
  .hh-h-galaxy[data-living-galaxy="css-fallback"] {
    visibility: visible;
    opacity: 1;
  }
}

.hh-living-galaxy-canvas,
.hh-living-galaxy-depth,
.hh-living-meteor-layer,
.hh-living-galaxy-status,
.hh-living-warp {
  pointer-events: none;
}

.hh-living-galaxy-canvas {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 2;
  display: block;
  width: 58.5vw;
  height: 100%;
  opacity: 0;
  filter: saturate(1.08) contrast(1.04);
  transition: filter .35s ease;
}

.hh-living-meteor-layer {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 4;
  width: 58.5vw;
  overflow: hidden;
  contain: strict;
}

.hh-living-meteor {
  --meteor-color: #62e8ff;
  --meteor-start-x: -140px;
  --meteor-start-y: 120px;
  --meteor-end-x: 700px;
  --meteor-end-y: 420px;
  --meteor-angle: 22deg;
  --meteor-duration: 2.35s;
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  width: 132px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg,transparent,color-mix(in srgb,var(--meteor-color) 42%,transparent) 48%,var(--meteor-color) 88%,#fff);
  box-shadow: 0 0 7px var(--meteor-color), 0 0 18px color-mix(in srgb,var(--meteor-color) 68%,transparent);
  opacity: 0;
  filter: blur(.15px) saturate(1.3);
  transform-origin: right center;
  animation: hh-living-meteor-flight var(--meteor-duration) cubic-bezier(.18,.52,.24,1) forwards;
  will-change: transform,opacity;
}

.hh-living-meteor::after {
  position: absolute;
  right: -3px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 9px #fff,0 0 21px var(--meteor-color),0 0 38px var(--meteor-color);
  content: "";
  transform: translateY(-50%);
}

.hh-living-meteor.is-far { width: 82px; height: 1px; opacity: .34; filter: blur(.45px); }
.hh-living-meteor.is-mid { width: 132px; height: 2px; }
.hh-living-meteor.is-near { width: 186px; height: 4px; filter: blur(.1px); }

@keyframes hh-living-meteor-flight {
  0% { opacity: 0; transform: translate3d(var(--meteor-start-x),var(--meteor-start-y),0) rotate(var(--meteor-angle)) scaleX(.35); }
  13% { opacity: .94; }
  78% { opacity: .9; }
  100% { opacity: 0; transform: translate3d(var(--meteor-end-x),var(--meteor-end-y),0) rotate(var(--meteor-angle)) scaleX(1); }
}

.hh-h-galaxy.is-webgl-ready .hh-living-galaxy-canvas { opacity: 1; }
.hh-h-galaxy.is-webgl-ready::before,
.hh-h-galaxy.is-webgl-ready::after { display: none !important; }
.hh-h-galaxy.is-webgl-ready :where(.hh-galaxy-cloud,.hh-galaxy-comet,.hh-galaxy-sun) { display: none !important; }
.hh-h-galaxy.is-webgl-ready .hh-galaxy-orbit::before { display: none !important; }

.hh-living-galaxy-depth {
  position: absolute;
  inset: 0 41.5% 0 0;
  z-index: 1;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 43% 45%, rgba(48,126,255,.13), transparent 22%),
    radial-gradient(ellipse at 19% 73%, rgba(234,49,255,.09), transparent 29%),
    radial-gradient(ellipse at 76% 16%, rgba(43,217,255,.07), transparent 24%);
  mix-blend-mode: screen;
}

.hh-living-galaxy-depth::before,
.hh-living-galaxy-depth::after {
  position: absolute;
  inset: -15%;
  content: "";
  opacity: .5;
  transform: translate3d(var(--galaxy-far-x, 0px), var(--galaxy-far-y, 0px), 0);
  transition: transform .15s ease-out;
}

.hh-living-galaxy-depth::before {
  background-image:
    radial-gradient(circle, rgba(255,255,255,.96) 0 1px, transparent 1.8px),
    radial-gradient(circle, rgba(106,221,255,.8) 0 .8px, transparent 1.5px);
  background-position: 0 0, 47px 71px;
  background-size: 97px 113px, 149px 173px;
  filter: drop-shadow(0 0 3px rgba(135,225,255,.55));
}

.hh-living-galaxy-depth::after {
  background: conic-gradient(from 18deg at 45% 48%, transparent, rgba(83,47,186,.08), transparent 22%, rgba(10,167,216,.07), transparent 48%, rgba(235,46,178,.06), transparent 72%);
  filter: blur(38px);
  transform: translate3d(var(--galaxy-near-x, 0px), var(--galaxy-near-y, 0px), 0) rotate(-7deg);
}

.hh-living-galaxy-hitlayer {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 14;
  width: 58.5vw;
  pointer-events: none;
}

.hh-h-galaxy.is-webgl-ready .hh-living-galaxy-hitlayer .hh-galaxy-planet {
  left: 0;
  top: 0;
  width: var(--planet-hit-size, 52px);
  min-width: var(--planet-hit-size, 52px);
  max-width: var(--planet-hit-size, 52px);
  height: var(--planet-hit-size, 52px);
  min-height: var(--planet-hit-size, 52px);
  max-height: var(--planet-hit-size, 52px);
  border: 0;
  background: transparent;
  box-shadow: none;
  filter: none;
  offset-path: none;
  animation: none;
  opacity: var(--planet-depth-opacity, .9);
  transform: translate3d(calc(var(--planet-screen-x, 0px) - var(--planet-hit-half, 26px)), calc(var(--planet-screen-y, 0px) - var(--planet-hit-half, 26px)), 0) scale(var(--planet-screen-scale, 1));
  transition: opacity .18s ease, filter .18s ease;
  will-change: transform;
}

.hh-h-galaxy.is-webgl-ready .hh-galaxy-planet::before { display: none; }
.hh-h-galaxy.is-webgl-ready .hh-galaxy-planet::after { display: none; }
.hh-h-galaxy.is-webgl-ready .hh-galaxy-planet > span {
  display: grid;
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(255,255,255,.42);
  border-radius: 50%;
  background: rgba(2,7,17,.36);
  backdrop-filter: blur(5px);
  box-shadow: 0 2px 10px rgba(0,0,0,.5), 0 0 8px color-mix(in srgb,var(--planet-a) 42%,transparent);
  color: #fff;
  font-size: 8px;
  text-shadow: 0 1px 4px #000, 0 0 9px #fff;
}

.hh-h-galaxy.is-webgl-ready .hh-galaxy-planet > em {
  top: calc(100% + 2px);
  border-color: color-mix(in srgb, var(--planet-a) 54%, rgba(255,255,255,.24));
  background: rgba(2,7,17,.88);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 28px rgba(0,0,0,.52), 0 0 24px color-mix(in srgb, var(--planet-a) 28%, transparent);
}

.hh-h-galaxy.is-webgl-ready .hh-galaxy-planet:is(:hover,:focus-visible,.is-active) {
  filter: drop-shadow(0 0 10px var(--planet-a));
  opacity: 1;
  transform: translate3d(calc(var(--planet-screen-x, 0px) - var(--planet-hit-half, 26px)), calc(var(--planet-screen-y, 0px) - var(--planet-hit-half, 26px)), 0) scale(calc(var(--planet-screen-scale, 1) * 1.14));
}

.hh-living-galaxy-status {
  position: absolute;
  left: 18px;
  top: auto;
  bottom: 20px;
  z-index: 16;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid rgba(129,225,255,.22);
  border-radius: 999px;
  background: rgba(3,9,20,.58);
  box-shadow: 0 10px 32px rgba(0,0,0,.24);
  color: #b9c9dd;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .09em;
  backdrop-filter: blur(12px);
}

.hh-living-galaxy-status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #65f6cf;
  box-shadow: 0 0 12px #65f6cf;
}

.hh-living-warp {
  position: fixed;
  inset: 0;
  z-index: 100000;
  overflow: hidden;
  visibility: hidden;
  opacity: 0;
  background: #02040c;
}

.hh-living-warp::before {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 42px 18px #7eeaff, 0 0 110px 56px rgba(125,77,255,.65);
  content: "";
  transform: translate(-50%,-50%);
}

.hh-living-warp::after {
  position: absolute;
  inset: -40%;
  background: repeating-conic-gradient(from 0deg at 50% 50%, transparent 0deg 4deg, rgba(168,235,255,.72) 4.4deg, transparent 5deg 9deg);
  content: "";
  mask-image: radial-gradient(circle, transparent 0 4%, #000 9% 42%, transparent 69%);
  transform: scale(.15) rotate(0);
}

.hh-living-warp.is-active {
  visibility: visible;
  opacity: 1;
  pointer-events: none;
  animation: hh-warp-auto-release 520ms steps(1, end) both;
}
.hh-living-warp.is-active::before { animation: hh-warp-core 440ms cubic-bezier(.22,.8,.24,1) both; }
.hh-living-warp.is-active::after { animation: hh-warp-lines 440ms cubic-bezier(.16,.84,.22,1) both; }

@keyframes hh-warp-shell { 0%,100% { opacity: 1; } }
@keyframes hh-warp-auto-release {
  0%, 92% { visibility: visible; opacity: 1; }
  100% { visibility: hidden; opacity: 0; }
}
@keyframes hh-warp-core { 0% { transform: translate(-50%,-50%) scale(.1); } 52% { transform: translate(-50%,-50%) scale(3); } 100% { transform: translate(-50%,-50%) scale(52); opacity: 0; } }
@keyframes hh-warp-lines { 0% { transform: scale(.1) rotate(-12deg); opacity: 0; } 40% { opacity: .9; } 100% { transform: scale(3.4) rotate(10deg); opacity: 0; } }

#authGate[data-motion-level="soft"] .hh-living-galaxy-canvas { filter: saturate(.94) contrast(1.02); }
#authGate[data-motion-level="off"] .hh-living-galaxy-canvas { filter: saturate(.82) brightness(.84); }
#authGate[data-motion-level="off"] .hh-living-galaxy-depth::before,
#authGate[data-motion-level="off"] .hh-living-galaxy-depth::after { transform: none; }

@media (max-width: 1100px) {
  .hh-living-galaxy-canvas,
  .hh-living-galaxy-hitlayer,
  .hh-living-meteor-layer { width: 100vw; opacity: .42; }
  .hh-living-galaxy-depth { inset: 0; opacity: .54; }
  .hh-living-galaxy-status { display: none; }
}

@media (max-width: 760px) {
  html body.home-neon.auth-locked #authGate.hh-neon-gateway {
    align-items: start !important;
    padding: 112px 8px 8px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }
  html body.home-neon.auth-locked #authGate.hh-neon-gateway > .auth-gate-brand { display: none !important; }
  html body.home-neon.auth-locked #authGate.hh-neon-gateway > .auth-gate-card {
    align-self: start !important;
    margin: 0 auto !important;
  }
  html body.home-neon.auth-locked #authGate.hh-neon-gateway > .hh-h-galaxy {
    --galaxy-y: 50%;
    position: fixed !important;
    inset: 0 0 auto !important;
    z-index: 12;
    height: 104px;
    overflow: hidden;
    opacity: 1;
    clip-path: none;
    background: linear-gradient(180deg,rgba(5,9,20,.98),rgba(7,12,25,.9));
    border-bottom: 1px solid rgba(122,220,255,.2);
    box-shadow: 0 12px 34px rgba(0,0,0,.45);
    backdrop-filter: blur(16px);
  }
  .hh-living-galaxy-canvas,
  .hh-living-galaxy-depth,
  .hh-living-meteor-layer,
  .hh-galaxy-cloud,
  .hh-galaxy-comet,
  .hh-galaxy-sun,
  .hh-galaxy-signature { display: none !important; }
  .hh-galaxy-system { inset: 0 !important; width: 100% !important; height: 104px; transform: none !important; }
  .hh-galaxy-orbits {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px 15px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    transform: none;
    pointer-events: auto;
  }
  .hh-galaxy-orbits::-webkit-scrollbar { display: none; }
  .hh-galaxy-orbit { display: contents; }
  .hh-galaxy-orbit::before { display: none; }
  .hh-galaxy-planet,
  .hh-galaxy-planet:nth-of-type(n) {
    position: relative;
    inset: auto;
    flex: 0 0 64px;
    width: 64px;
    min-width: 64px;
    max-width: 64px;
    height: 64px;
    min-height: 64px;
    max-height: 64px;
    offset-path: none;
    animation: none;
    scroll-snap-align: center;
    transform: none;
  }
  .hh-galaxy-planet > em {
    top: auto;
    bottom: -15px;
    display: block;
    max-width: 76px;
    padding: 3px 5px;
    overflow: hidden;
    border: 0;
    background: rgba(3,8,18,.72);
    font-size: 7px;
    opacity: .72;
    text-overflow: ellipsis;
  }
  .hh-galaxy-planet.is-active > em { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .hh-living-galaxy-canvas { display: none; }
  .hh-living-meteor-layer { display: none; }
  .hh-living-warp { display: none; }
  .hh-living-galaxy-depth::before,
  .hh-living-galaxy-depth::after { transform: none !important; transition: none; }
}
