/* ============================================
   Orbit diagram — Tajuring distance rings
   The wearer sits in the middle, four rings mark distance.
   One sonar pulse leaves every cycle: each ring flashes as it
   is crossed, people (P) on that ring answer, the object (O)
   echoes back and the wearer feels it. Positions are the
   still composition — motion only adds on top of it.
   ============================================ */

.orbit {
  --orbit-cycle: 7s;
  --orbit-ring-1: var(--color-mocha-5);
  --orbit-ring-2: var(--color-mocha-4);
  --orbit-ring-3: var(--color-mocha-3);
  --orbit-ring-4: var(--color-mocha-2);
  --orbit-ping: var(--color-mocha-6);
  --orbit-wave: var(--color-mocha-4);
  --orbit-user-body: var(--color-mocha-4);
  --orbit-user-head: var(--color-mocha-5);
  --orbit-person-body: var(--color-mocha-2);
  --orbit-person-head: var(--color-mocha-3);
  --orbit-object-box: var(--color-mocha-2);
  --orbit-object-pill: var(--color-mocha-3);
  --orbit-object-line: var(--color-mocha-4);
  --orbit-ink: var(--color-mocha-6);

  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  font-family: var(--font-body);
  letter-spacing: var(--tracking);
}

[data-theme="dark"] .orbit {
  --orbit-ring-1: var(--color-surface-dark);
  --orbit-ring-2: color-mix(in srgb, var(--color-surface-dark) 66%, var(--color-surface-primary));
  --orbit-ring-3: color-mix(in srgb, var(--color-surface-dark) 44%, var(--color-surface-primary));
  --orbit-ring-4: color-mix(in srgb, var(--color-surface-dark) 26%, var(--color-surface-primary));
  --orbit-ping: var(--color-text-primary);
  --orbit-wave: var(--color-surface-dark);
  --orbit-user-body: color-mix(in srgb, var(--color-surface-dark) 72%, var(--color-surface-primary));
  --orbit-user-head: var(--color-surface-dark);
  --orbit-person-body: color-mix(in srgb, var(--color-surface-dark) 24%, var(--color-surface-primary));
  --orbit-person-head: color-mix(in srgb, var(--color-surface-dark) 44%, var(--color-surface-primary));
  --orbit-object-box: color-mix(in srgb, var(--color-surface-dark) 24%, var(--color-surface-primary));
  --orbit-object-pill: color-mix(in srgb, var(--color-surface-dark) 44%, var(--color-surface-primary));
  --orbit-object-line: color-mix(in srgb, var(--color-surface-dark) 72%, var(--color-surface-primary));
  --orbit-ink: var(--color-text-primary);
}

/* ── Rings ───────────────────────────────── */
.orbit__ring {
  fill: none;
  stroke: var(--ring);
  stroke-width: 5;
  animation: orbit-ring-ping var(--orbit-cycle) ease-out infinite;
}

/* Delay = the moment the pulse (5s, linear, radius 557) reaches the ring, minus the rise time */
.orbit__ring--1 { --ring: var(--orbit-ring-1); animation-delay: 1.1s; }
.orbit__ring--2 { --ring: var(--orbit-ring-2); animation-delay: 2.36s; }
.orbit__ring--3 { --ring: var(--orbit-ring-3); animation-delay: 3.6s; }
.orbit__ring--4 { --ring: var(--orbit-ring-4); animation-delay: 4.86s; }

@keyframes orbit-ring-ping {
  0%   { stroke: var(--ring); stroke-width: 5; }
  2%   { stroke: var(--orbit-ping); stroke-width: 10; }
  14%  { stroke: var(--ring); stroke-width: 5; }
  100% { stroke: var(--ring); stroke-width: 5; }
}

/* ── Sonar pulse ─────────────────────────── */
.orbit__wave {
  fill: none;
  stroke: var(--orbit-wave);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  opacity: 0;
  transform: scale(0.02);
  animation: orbit-wave var(--orbit-cycle) linear infinite;
}

.orbit__wave--late {
  stroke-width: 1.5;
  animation-delay: 0.45s;
}

@keyframes orbit-wave {
  0%      { transform: scale(0.02); opacity: 0.6; }
  71.43%  { transform: scale(1); opacity: 0; }
  100%    { transform: scale(1); opacity: 0; }
}

/* ── Orbiting people ─────────────────────── */
.orbit__orbiter {
  transform: rotate(var(--a0));
  animation: orbit-spin var(--orbit-dur) linear infinite;
}

.orbit__upright {
  transform: rotate(calc(var(--a0) * -1));
  animation: orbit-unspin var(--orbit-dur) linear infinite;
}

.orbit__orbiter--a { --a0: 84deg;  --dir: 1; --orbit-dur: 46s; }
.orbit__orbiter--b { --a0: -8deg;  --dir: 1; --orbit-dur: 58s; }
.orbit__orbiter--c { --a0: 234deg; --dir: 1; --orbit-dur: 58s; }

@keyframes orbit-spin {
  from { transform: rotate(var(--a0)); }
  to   { transform: rotate(calc(var(--a0) + 360deg * var(--dir))); }
}

@keyframes orbit-unspin {
  from { transform: rotate(calc(var(--a0) * -1)); }
  to   { transform: rotate(calc((var(--a0) + 360deg * var(--dir)) * -1)); }
}

.orbit__person {
  animation: orbit-answer var(--orbit-cycle) ease-out infinite;
}

.orbit__orbiter--a .orbit__person { animation-delay: 2.29s; }
.orbit__orbiter--b .orbit__person,
.orbit__orbiter--c .orbit__person { animation-delay: 3.53s; }

@keyframes orbit-answer {
  0%   { transform: scale(1); }
  3%   { transform: scale(1.09); }
  16%  { transform: scale(1); }
  100% { transform: scale(1); }
}

.orbit__person-body { fill: var(--orbit-person-body); }
.orbit__person-head { fill: var(--orbit-person-head); }

.orbit__label {
  fill: var(--orbit-ink);
  font-size: 54px;
  font-weight: var(--weight-regular);
  text-anchor: middle;
  dominant-baseline: central;
}

/* ── Wearer ──────────────────────────────── */
.orbit__user-breath {
  animation: orbit-breath var(--orbit-cycle) ease-out infinite;
}

.orbit__user-buzz {
  animation: orbit-buzz var(--orbit-cycle) linear infinite;
  animation-delay: 1.65s;
}

.orbit__user-body { fill: var(--orbit-user-body); }
.orbit__user-head { fill: var(--orbit-user-head); }

@keyframes orbit-breath {
  0%   { transform: scale(1); }
  4%   { transform: scale(1.04); }
  14%  { transform: scale(1); }
  100% { transform: scale(1); }
}

@keyframes orbit-buzz {
  0%   { transform: translateX(0); }
  2%   { transform: translateX(-4px); }
  4%   { transform: translateX(4px); }
  6%   { transform: translateX(-3px); }
  8%   { transform: translateX(3px); }
  10%  { transform: translateX(-1.5px); }
  12%  { transform: translateX(0); }
  100% { transform: translateX(0); }
}

/* ── Object ──────────────────────────────── */
.orbit__object {
  animation: orbit-object-hit var(--orbit-cycle) ease-out infinite;
  animation-delay: 1.32s;
}

.orbit__object-box  { fill: var(--orbit-object-box); }
.orbit__object-pill { fill: var(--orbit-object-pill); }

.orbit__object-line {
  stroke: var(--orbit-object-line);
  stroke-width: 5;
  stroke-linecap: round;
}

@keyframes orbit-object-hit {
  0%   { transform: scale(1); }
  4%   { transform: scale(1.14); }
  16%  { transform: scale(1); }
  100% { transform: scale(1); }
}

.orbit__object-halo,
.orbit__object-echo {
  fill: none;
  stroke: var(--orbit-wave);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  opacity: 0;
  animation-duration: var(--orbit-cycle);
  animation-iteration-count: infinite;
  animation-timing-function: ease-out;
  animation-delay: 1.6s;
}

.orbit__object-halo { animation-name: orbit-object-halo; }
.orbit__object-echo { animation-name: orbit-object-echo; }

@keyframes orbit-object-halo {
  0%   { transform: scale(1); opacity: 0.55; }
  14%  { transform: scale(1.7); opacity: 0; }
  100% { transform: scale(1.7); opacity: 0; }
}

@keyframes orbit-object-echo {
  0%   { transform: scale(0.1); opacity: 0.5; }
  26%  { transform: scale(1); opacity: 0; }
  100% { transform: scale(1); opacity: 0; }
}

/* ── Off-screen / reduced motion ─────────── */
.orbit.is-offscreen * {
  animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
  .orbit * {
    animation: none !important;
  }
}
