/*
 * OUTSPACE STUDIOS — Animated page hero (v1)
 * Brings the homepage "planet + orbit" language to the top of every inner page.
 * Injected by assets/js/page-hero.js into any  <section class="inner-hero" data-scene="…">.
 * Everything is decorative (aria-hidden), honours prefers-reduced-motion and has a pause control.
 */

.inner-hero.has-scene { isolation: isolate; background-color: #09090d; }
/* The old single static ring is replaced by the live scene */
.inner-hero.has-scene:after { display: none; }
.inner-hero.has-scene > .wrap { position: relative; z-index: 3; }

/* ───────────── Drifting grid + aurora ───────────── */
.ph-grid {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 72px 72px;
  -webkit-mask-image: linear-gradient(90deg, #000, transparent 85%);
  mask-image: linear-gradient(90deg, #000, transparent 85%);
  animation: ph-grid-drift 28s linear infinite;
}
@keyframes ph-grid-drift { to { background-position: 72px 72px, 72px 72px; } }

.ph-aurora {
  position: absolute; inset: -20% -10% -20% 30%; z-index: 0; pointer-events: none;
  background:
    radial-gradient(40% 50% at 70% 40%, rgba(111,82,255,.34), transparent 70%),
    radial-gradient(30% 40% at 40% 70%, rgba(92,124,255,.18), transparent 70%),
    radial-gradient(24% 30% at 85% 80%, rgba(255,74,13,.10), transparent 70%);
  filter: blur(8px);
  animation: ph-aurora 16s ease-in-out infinite alternate;
}
@keyframes ph-aurora {
  from { transform: translate3d(-3%, -2%, 0) scale(1); opacity: .85; }
  to   { transform: translate3d(4%, 3%, 0) scale(1.08); opacity: 1; }
}

/* ───────────── Ghost keyword ───────────── */
.ph-ghost {
  position: absolute; z-index: 1; pointer-events: none; user-select: none;
  left: 0; bottom: -.14em; white-space: nowrap; line-height: .8;
  font-size: clamp(120px, 22vw, 340px); font-weight: 600; letter-spacing: -.07em; text-transform: uppercase;
  color: transparent; -webkit-text-stroke: 1px rgba(255,255,255,.07);
  animation: ph-ghost-slide 60s linear infinite alternate;
}
@keyframes ph-ghost-slide { from { transform: translate3d(-4%, 0, 0); } to { transform: translate3d(-34%, 0, 0); } }

/* ───────────── Scene ───────────── */
.ph-scene {
  position: absolute; z-index: 2; pointer-events: none;
  right: max(2%, calc((100vw - 1500px) / 2)); top: 50%;
  width: min(46vw, 640px); aspect-ratio: 1.22;
  transform: translateY(-46%) translate3d(0, var(--ph-scroll, 0px), 0);
  opacity: var(--ph-fade, 1);
  --ph-unit: clamp(70px, 8.2vw, 124px);
}
.ph-glow {
  position: absolute; inset: -8%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(113,82,255,.46), rgba(113,82,255,.13) 55%, transparent 74%);
  animation: ph-breathe 7s ease-in-out infinite;
}
@keyframes ph-breathe { 0%,100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.07); opacity: 1; } }

.ph-stars {
  position: absolute; inset: 0; opacity: .85;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 22%, #b7a6ff 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 78%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 71% 14%, #ff4a0d 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 62%, #b7a6ff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 52% 92%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 8% 56%, #ff4a0d 50%, transparent 51%),
    radial-gradient(1px 1px at 94% 30%, #b7a6ff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 40% 8%, #fff 50%, transparent 51%);
  animation: ph-twinkle 5s ease-in-out infinite alternate;
}
@keyframes ph-twinkle { from { opacity: .3; } to { opacity: .95; } }

/* Tilted plane; JS adds pointer parallax through --tx/--ty/--rx/--ry */
.ph-sys {
  position: absolute; inset: 0;
  transform: translate3d(var(--tx, 0px), var(--ty, 0px), 0) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) rotate(-14deg);
}
.ph-ring {
  position: absolute; left: 50%; top: 50%; border-radius: 50%;
  width: calc(var(--rw) * 100%); height: calc(var(--rh) * 100%);
  transform: translate(-50%, -50%);
  border: 1px solid rgba(190,175,255,.3);
}
.ph-ring.r1 { --rw: .46; --rh: .32; border-color: rgba(190,175,255,.42); }
.ph-ring.r2 { --rw: .76; --rh: .58; border-color: rgba(190,175,255,.24); }
.ph-ring.r3 { --rw: .94; --rh: .8;  border-color: rgba(190,175,255,.16); border-style: dashed; }

/* Planet (same violet world as the homepage) */
.ph-planet {
  position: absolute; left: 50%; top: 50%; z-index: 5;
  width: calc(var(--ph-unit) * 1.5); aspect-ratio: 1;
  transform: translate(-50%, -50%) rotate(14deg);
  filter: drop-shadow(0 0 26px rgba(126,94,255,.5));
}
.ph-body {
  position: absolute; inset: 3%; border-radius: 50%; overflow: hidden;
  background:
    radial-gradient(ellipse at 30% 24%, rgba(255,255,255,.88) 0, rgba(221,211,255,.35) 9%, transparent 24%),
    radial-gradient(ellipse at 66% 68%, rgba(31,18,75,.95) 0, transparent 42%),
    radial-gradient(ellipse at 38% 42%, #b5a0ff 0%, #7053c9 24%, #34205f 53%, #100d22 76%);
  box-shadow: inset -18px -12px 28px rgba(0,0,0,.72), inset 8px 5px 16px rgba(255,255,255,.22), 0 0 34px rgba(134,104,255,.4);
  animation: ph-planet-glow 6s ease-in-out infinite;
}
.ph-body:before {
  content: ""; position: absolute; inset: -8%; border-radius: 50%; mix-blend-mode: screen; opacity: .7;
  background:
    repeating-linear-gradient(162deg, transparent 0 13px, rgba(224,213,255,.13) 14px 17px, transparent 18px 29px),
    radial-gradient(ellipse at 72% 34%, rgba(181,152,255,.36), transparent 36%);
  animation: ph-bands 18s linear infinite;
}
.ph-body:after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: linear-gradient(105deg, rgba(255,255,255,.24), transparent 34% 65%, rgba(0,0,0,.45));
}
@keyframes ph-planet-glow { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.14); } }
@keyframes ph-bands { to { transform: translate3d(7%, 5%, 0); } }

.ph-moon { position: absolute; inset: -20%; animation: ph-spin 24s linear infinite; }
.ph-moon:after {
  content: ""; position: absolute; left: 8%; top: 44%; width: 18%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #fff 0, #b7a1ff 28%, #6546d8 62%, #21133e 100%);
  box-shadow: 0 0 18px 5px rgba(156,126,255,.55);
}
@keyframes ph-spin { to { transform: rotate(360deg); } }

.ph-ripple {
  position: absolute; inset: 3%; border-radius: 50%; border: 1px solid rgba(173,151,255,.5); opacity: 0;
  animation: ph-ripple 5s ease-out infinite;
}
.ph-ripple:nth-of-type(2) { animation-delay: 2.5s; }
@keyframes ph-ripple { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(3.2); opacity: 0; } }

/* Satellites ride the rings (positioned by JS) */
.ph-sat, .ph-dot, .ph-card { position: absolute; left: 50%; top: 50%; will-change: transform, opacity; }
.ph-dot {
  width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; z-index: 4;
  background: #9c83ff; box-shadow: 0 0 15px 4px rgba(156,131,255,.55);
}
.ph-dot.is-orange { background: #ff4a0d; box-shadow: 0 0 14px 3px rgba(255,74,13,.55); }
.ph-sat {
  z-index: 8; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 9px 15px 9px 12px; border-radius: 999px;
  font-size: clamp(10px, .95vw, 13px); letter-spacing: .04em; font-weight: 500; color: #f7f6fa;
  background: rgba(22,20,29,.66); border: 1px solid rgba(190,175,255,.28);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 12px 34px rgba(0,0,0,.4);
}
.ph-sat:before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #b6a5ff; box-shadow: 0 0 10px #b6a5ff; flex: none; }
.ph-sat.is-hot:before { background: #ff4a0d; box-shadow: 0 0 10px #ff4a0d; }
.ph-card {
  z-index: 8; width: calc(var(--ph-unit) * .92); padding: 6px; border-radius: 8px;
  background: #211e29; border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 18px 44px rgba(0,0,0,.55);
}
.ph-card img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 4px; background: #2b2734; }

/* ───────────── "Out of orbit" (404) ───────────── */
.ph-scene.is-lost .ph-planet { animation: ph-wobble 9s ease-in-out infinite; }
@keyframes ph-wobble {
  0%,100% { transform: translate(-50%, -50%) rotate(14deg); }
  50%     { transform: translate(-38%, -62%) rotate(34deg); }
}

/* ───────────── Entrance choreography ───────────── */
.js .inner-hero.has-scene .ph-scene { animation: ph-scene-in 1.4s cubic-bezier(.2,.75,.2,1) both .15s; }
@keyframes ph-scene-in { from { opacity: 0; transform: translateY(-40%) scale(.9); } }

/* Headline lines slide up out of a mask */
.ph-line { display: block; overflow: hidden; padding: .04em .12em .14em 0; margin: -.04em -.12em -.14em 0; }
.ph-line-in { display: inline-block; transform: translate3d(0, 112%, 0); will-change: transform; }
.inner-hero.ph-ready .ph-line-in { transform: none; transition: transform 1s cubic-bezier(.2,.75,.2,1); transition-delay: calc(var(--i, 0) * .11s + .12s); }

/* Supporting copy fades up in sequence */
.inner-hero.has-scene .ph-rise { opacity: 0; transform: translate3d(0, 22px, 0); }
.inner-hero.ph-ready .ph-rise { opacity: 1; transform: none; transition: opacity .9s ease, transform .9s cubic-bezier(.2,.75,.2,1); transition-delay: calc(var(--r, 0) * .12s + .35s); }

/* ───────────── Pause control (WCAG 2.2.2) ───────────── */
.ph-pause {
  position: absolute; z-index: 6; right: max(24px, calc((100vw - 1240px) / 2)); bottom: 26px;
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: transparent; border: 1px solid rgba(255,255,255,.3); color: #f7f6fa; opacity: .55;
  font-size: 10px; letter-spacing: -1px; transition: opacity .25s, background .25s;
}
.ph-pause:hover, .ph-pause:focus-visible { opacity: 1; background: rgba(120,85,255,.55); outline: none; }
.inner-hero.is-paused .ph-grid, .inner-hero.is-paused .ph-aurora, .inner-hero.is-paused .ph-ghost,
.inner-hero.is-paused .ph-glow, .inner-hero.is-paused .ph-stars, .inner-hero.is-paused .ph-body,
.inner-hero.is-paused .ph-body:before, .inner-hero.is-paused .ph-moon, .inner-hero.is-paused .ph-ripple,
.inner-hero.is-paused .ph-planet { animation-play-state: paused; }

/* ───────────── Responsive ───────────── */
@media (max-width: 1100px) {
  .ph-scene { width: min(62vw, 520px); right: -6%; opacity: calc(var(--ph-fade, 1) * .8); }
}
@media (max-width: 760px) {
  .ph-scene { width: 96vw; right: -38%; top: auto; bottom: -10%; transform: translate3d(0, var(--ph-scroll, 0px), 0); opacity: calc(var(--ph-fade, 1) * .55); --ph-unit: 60px; }
  .ph-sat { display: none; }
  .ph-pause { bottom: 14px; right: 16px; }
  .ph-ghost { font-size: 34vw; }
}

/* ───────────── Reduced motion: everything settles, nothing loops ───────────── */
@media (prefers-reduced-motion: reduce) {
  .ph-grid, .ph-aurora, .ph-ghost, .ph-glow, .ph-stars, .ph-body, .ph-body:before, .ph-moon, .ph-ripple,
  .ph-scene.is-lost .ph-planet, .js .inner-hero.has-scene .ph-scene { animation: none !important; }
  .ph-line-in, .inner-hero.has-scene .ph-rise { transform: none !important; opacity: 1 !important; transition: none !important; }
  .ph-pause { display: none; }
}
/* No-JS safety: never hide the headline */
html:not(.js) .ph-line-in, html:not(.js) .inner-hero .ph-rise { transform: none; opacity: 1; }
