/* The living scene of the hero, in the visual language of the Shomahmudoff Account sign-in scene
   (saas/platform/auth static/css/scene.css, task P11-07): a twinkling starfield with a soft crimson glow
   behind the hero, and in front of it a constellation of the ecosystem. The account (a key) sits in the
   middle, InfraCanvas (a board block) is linked to it with a solid line, and the dashed rings are the
   services still to come (unnamed on purpose). A crimson pulse travels between the account and
   InfraCanvas and, one after another, out to the coming services.

   CSS and SVG only: no script, no inline style (CSP). Only opacity, transform and stroke-dashoffset
   animate. Decorative: aria-hidden, never focusable, sizes fixed by the viewBox so nothing shifts.
   Still under prefers-reduced-motion; hidden in forced-colors and print. Colours are mixed from the Qizil
   tokens, so both themes follow the theme switch; the two marks (static/scene/*.svg, copied from auth)
   use the Qizil crimson family. */

:root {
  --scene-star: color-mix(in srgb, var(--q-fg) 26%, transparent);
  --scene-accent: color-mix(in srgb, var(--q-accent) 70%, transparent);
  --scene-glow: color-mix(in srgb, var(--q-accent) 12%, transparent);
  --scene-halo: color-mix(in srgb, var(--q-accent) 16%, transparent);
}
:root[data-theme="dark"] {
  --scene-star: color-mix(in srgb, var(--q-fg) 55%, transparent);
  --scene-glow: color-mix(in srgb, var(--q-accent) 22%, transparent);
  --scene-halo: color-mix(in srgb, var(--q-accent) 26%, transparent);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --scene-star: color-mix(in srgb, var(--q-fg) 55%, transparent);
    --scene-glow: color-mix(in srgb, var(--q-accent) 22%, transparent);
    --scene-halo: color-mix(in srgb, var(--q-accent) 26%, transparent);
  }
}

/* ---------- starfield behind the hero ---------- */

.scene {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  contain: strict;
}
.scene__glow,
.scene__stars {
  position: absolute;
  inset: 0;
}
.scene__glow {
  background:
    radial-gradient(60% 70% at 78% 50%, var(--scene-glow), transparent 70%),
    radial-gradient(50% 40% at 10% 110%, var(--scene-glow), transparent 70%);
  animation: scene-breathe 9s ease-in-out infinite alternate;
}
.scene__stars {
  inset: -2rem;
  opacity: 0.6;
  animation: scene-twinkle 5.5s ease-in-out infinite alternate;
}
.scene__stars--a {
  background-image:
    radial-gradient(circle at 8% 14%, var(--scene-star) 0 1px, transparent 1.6px),
    radial-gradient(circle at 34% 62%, var(--scene-star) 0 1.2px, transparent 1.8px),
    radial-gradient(circle at 71% 27%, var(--scene-star) 0 0.9px, transparent 1.5px),
    radial-gradient(circle at 88% 81%, var(--scene-star) 0 1.1px, transparent 1.7px),
    radial-gradient(circle at 52% 93%, var(--scene-star) 0 0.8px, transparent 1.4px);
  background-size: 230px 210px;
}
.scene__stars--b {
  background-image:
    radial-gradient(circle at 19% 41%, var(--scene-star) 0 1.3px, transparent 1.9px),
    radial-gradient(circle at 63% 9%, var(--scene-star) 0 0.9px, transparent 1.5px),
    radial-gradient(circle at 81% 55%, var(--scene-star) 0 1px, transparent 1.6px),
    radial-gradient(circle at 42% 84%, var(--scene-star) 0 1.1px, transparent 1.7px);
  background-size: 310px 290px;
  animation-duration: 7.5s;
  animation-delay: -2.5s;
}
.scene__stars--c {
  background-image:
    radial-gradient(circle at 27% 21%, var(--scene-star) 0 1.6px, transparent 2.3px),
    radial-gradient(circle at 74% 70%, var(--scene-star) 0 1.4px, transparent 2.1px),
    radial-gradient(circle at 92% 12%, var(--scene-star) 0 1px, transparent 1.6px),
    radial-gradient(circle at 6% 77%, var(--scene-star) 0 1.2px, transparent 1.8px);
  background-size: 410px 370px;
  animation-duration: 9.5s;
  animation-delay: -5s;
}
.scene__stars--accent {
  opacity: 0;
  background-image:
    radial-gradient(circle at 23% 31%, var(--scene-accent) 0 1.8px, transparent 2.6px),
    radial-gradient(circle at 79% 64%, var(--scene-accent) 0 1.5px, transparent 2.3px);
  background-size: 560px 520px;
  animation: scene-pulse 6s ease-in-out infinite;
}

/* ---------- the constellation ---------- */

.constellation {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.constellation .link {
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
}
.constellation .link--live {
  stroke: var(--q-border-strong);
}
.constellation .link--soon {
  stroke: var(--q-border-strong);
  stroke-dasharray: 3 6;
  opacity: 0.8;
}
.constellation .link--faint {
  stroke: var(--q-border);
  stroke-dasharray: 2 7;
}
.constellation .node {
  fill: var(--q-bg);
  stroke: var(--q-border-strong);
  stroke-width: 1.5;
}
.constellation .node--hub-outer {
  fill: none;
  stroke: var(--q-border);
}
.constellation .node--soon {
  stroke-dasharray: 3 4;
  animation: node-arrive 8s ease-out infinite;
}
.constellation .node--s2 {
  animation-delay: -6s;
}
.constellation .node--s3 {
  animation-delay: -4s;
}
.constellation .node--s4 {
  animation-delay: -2s;
}
.constellation .halo {
  fill: var(--scene-halo);
  stroke: none;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}
.constellation .halo--live {
  animation: halo-live 6.4s ease-in-out infinite;
}
.constellation .halo--hub {
  animation: halo-hub 6.4s ease-in-out infinite;
}
.constellation .pulse {
  fill: none;
  stroke: var(--q-accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 6 194;
  stroke-dashoffset: 6;
}
.constellation .pulse--live {
  animation: pulse-live 3.2s ease-in-out infinite alternate;
}
.constellation .pulse--soon {
  stroke-width: 2.5;
  opacity: 0;
  animation: pulse-soon 8s ease-in infinite;
}
.constellation .pulse--s2 {
  animation-delay: -6s;
}
.constellation .pulse--s3 {
  animation-delay: -4s;
}
.constellation .pulse--s4 {
  animation-delay: -2s;
}
.constellation .sparkle {
  fill: var(--scene-accent);
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: sparkle 5s ease-in-out infinite;
}
.constellation .sparkle--2 {
  animation-delay: -1.8s;
}
.constellation .sparkle--3 {
  animation-delay: -3.4s;
}
.constellation .label {
  fill: var(--q-muted);
  font-family: var(--q-font-mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-anchor: middle;
  text-transform: uppercase;
}

/* ---------- motion ---------- */

@keyframes scene-twinkle {
  from {
    opacity: 0.2;
  }
  to {
    opacity: 1;
  }
}
@keyframes scene-pulse {
  0%,
  100% {
    opacity: 0;
  }
  45%,
  55% {
    opacity: 1;
  }
}
@keyframes scene-breathe {
  from {
    opacity: 0.7;
  }
  to {
    opacity: 1;
  }
}
/* From the account (0) to InfraCanvas (100) and back (alternate): the dash is 6 units long. */
@keyframes pulse-live {
  from {
    stroke-dashoffset: 6;
  }
  to {
    stroke-dashoffset: -100;
  }
}
/* Arrival at InfraCanvas is at half of the 6.4s cycle, back at the account at its start and end. */
@keyframes halo-live {
  0%,
  35%,
  65%,
  100% {
    opacity: 0;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes halo-hub {
  0%,
  100% {
    opacity: 0.9;
    transform: scale(1);
  }
  15%,
  85% {
    opacity: 0;
    transform: scale(0.92);
  }
}
/* One pulse per coming service every 8s, staggered by 2s: out in the first 30%, then it fades. */
@keyframes pulse-soon {
  0% {
    stroke-dashoffset: 6;
    opacity: 0;
  }
  4% {
    opacity: 0.75;
  }
  28% {
    opacity: 0.75;
  }
  30% {
    stroke-dashoffset: -100;
    opacity: 0;
  }
  100% {
    stroke-dashoffset: -100;
    opacity: 0;
  }
}
@keyframes node-arrive {
  0%,
  26%,
  48%,
  100% {
    stroke: var(--q-border-strong);
  }
  32% {
    stroke: var(--q-accent);
  }
}
@keyframes sparkle {
  0%,
  100% {
    opacity: 0;
    transform: scale(0.4) rotate(0deg);
  }
  50% {
    opacity: 0.85;
    transform: scale(1) rotate(45deg);
  }
}

/* Still under reduced motion: the pulse rests halfway to InfraCanvas, both halos softly lit. */
@media (prefers-reduced-motion: reduce) {
  .scene *,
  .constellation * {
    animation: none !important;
    transition: none !important;
  }
  .scene__stars {
    opacity: 0.6;
  }
  .scene__stars--accent {
    opacity: 0.8;
  }
  .constellation .pulse--live {
    stroke-dashoffset: -47;
  }
  .constellation .halo--live,
  .constellation .halo--hub {
    opacity: 0.5;
  }
  .constellation .sparkle {
    opacity: 0.6;
  }
}

@media (forced-colors: active) {
  .scene,
  .constellation .pulse,
  .constellation .halo,
  .constellation .sparkle {
    display: none;
  }
}
@media print {
  .scene,
  .hero__visual {
    display: none;
  }
}
