/* ===========================================================================
   ORBITAL BEING — 2D orbital disc prototype
   Mobile-first (390 × 844). Two themes share one structure:
     body[data-theme="neon"]  — Variation A, Original Neon Orbital
     body[data-theme="quiet"] — Variation B, Quiet Orbital
   All theme differences live in the CSS variables just below.
   Motion / layout numbers live in src/config.js — not here.
   ======================================================================== */

/* ----- Theme variables ---------------------------------------------------- */

body[data-theme='neon'] {
  --bg0: #08080f;                       /* deepest background */
  --bg-occlude: #0a0a13;                /* disc that hides rings behind the being */
  --app-bg:
    radial-gradient(120% 55% at 50% -5%, rgba(122, 102, 224, 0.16), transparent 62%),
    radial-gradient(95% 42% at 88% 102%, rgba(255, 122, 132, 0.10), transparent 60%),
    linear-gradient(180deg, #0c0c18 0%, #08080f 55%, #0a0a13 100%);
  --ink: #f1effa;
  --muted: #9d9ab5;
  --accent: #b9a7ff;
  --title-grad: linear-gradient(92deg, #ff8fb3 0%, #c2a6ff 48%, #8fb1ff 100%);
  --being-a: #ffc09a;                   /* being gradient start (head/shoulder) */
  --being-b: #ff8fa8;                   /* being gradient end */
  --being-glow: rgba(255, 145, 140, 0.5);
  --ring-color: #a3a8ff;
  --ring-alpha: 0.34;
  --spark: #cfd3ff;
  --star-alpha: 0.8;
  --chrome-bg: rgba(21, 21, 37, 0.72);
  --chrome-border: rgba(255, 255, 255, 0.09);
  --panel-bg: rgba(19, 19, 34, 0.72);
  --focus-ring: #cdb8ff;
  --sat: 1;                             /* planet saturation */
  --glow-theme: 1;                      /* theme glow multiplier */
}

body[data-theme='quiet'] {
  --bg0: #0a0a0c;
  --bg-occlude: #0c0c0e;
  --app-bg:
    radial-gradient(110% 50% at 50% -5%, rgba(212, 182, 122, 0.07), transparent 60%),
    linear-gradient(180deg, #101013 0%, #0a0a0c 60%, #0c0c0e 100%);
  --ink: #ece9e2;
  --muted: #94918e;
  --accent: #d9c6a0;
  --title-grad: linear-gradient(92deg, #e9cf9f 0%, #f2e8d4 55%, #cfc0e2 100%);
  --being-a: #eec19b;
  --being-b: #d5a3b5;
  --being-glow: rgba(238, 190, 160, 0.32);
  --ring-color: #d6c49f;
  --ring-alpha: 0.22;
  --spark: #e2d5b8;
  --star-alpha: 0.45;
  --chrome-bg: rgba(19, 19, 21, 0.78);
  --chrome-border: rgba(255, 255, 255, 0.07);
  --panel-bg: rgba(19, 18, 16, 0.8);
  --focus-ring: #e3d3ab;
  --sat: 0.58;
  --glow-theme: 0.45;
}

/* combined glow: theme dial × LOOK.glow from config.js (set by app.js) */
body { --glow-total: calc(var(--glow-theme, 1) * var(--glow-cfg, 1)); }

/* ----- Base ---------------------------------------------------------------- */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg0);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI',
    Roboto, 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--app-bg);
}

@media (min-width: 500px) {
  #app { box-shadow: 0 0 90px rgba(0, 0, 0, 0.55); }
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 14px;
}

/* ----- Top bar -------------------------------------------------------------- */

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 2px;
}

.top-bar__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.4px solid color-mix(in srgb, var(--being-a) 55%, transparent);
  display: grid;
  place-items: center;
}

.icon-btn svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: var(--being-a);
  stroke-width: 1.7;
  stroke-linecap: round;
}

.pill-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: 999px;
  background: var(--chrome-bg);
  border: 1px solid var(--chrome-border);
  font-size: 13px;
  color: var(--ink);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.pill-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
}

/* dev-only theme switch */
.theme-chip {
  width: 27px;
  height: 27px;
  border-radius: 50%;
  border: 1px solid var(--chrome-border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  opacity: 0.65;
}

/* ----- Title ----------------------------------------------------------------- */

.title-block {
  text-align: center;
  margin-top: 2px;
}

.app-title {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--title-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.app-subtitle {
  margin: 4px 0 0;
  font-size: 12.5px;
  letter-spacing: 0.03em;
  color: var(--muted);
}

/* ----- Orbital viewport -------------------------------------------------------- */

.orbit-viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.orbit-viewport, .orbit-viewport * { touch-action: none; }
.orbit-viewport.is-dragging { cursor: grabbing; }

.orbit-viewport:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -4px;
  border-radius: 26px;
}

/* stars */
.stars {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.star {
  position: absolute;
  width: var(--s, 1.5px);
  height: var(--s, 1.5px);
  border-radius: 50%;
  background: rgba(226, 226, 250, var(--star-alpha));
  animation: twinkle var(--tw, 4s) ease-in-out var(--twd, 0s) infinite alternate;
  opacity: 0.3;
}

body[data-theme='quiet'] .star--extra { display: none; }

@keyframes twinkle {
  from { opacity: 0.14; }
  to { opacity: 0.7; }
}

/* orbital paths */
.orbit-rings {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
}

.ring {
  fill: none;
  stroke: var(--ring-color);
  stroke-width: 1;
  opacity: calc(var(--ring-alpha) * var(--ring-cfg, 1));
}

.ring--inner {
  opacity: calc(var(--ring-alpha) * var(--ring-cfg, 1) * 0.6);
  stroke-dasharray: 1 6;
}

/* drifting lights riding the paths */
.spark-layer {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

.spark {
  position: absolute;
  left: -1.5px;
  top: -1.5px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--spark);
  box-shadow: 0 0 calc(7px * var(--glow-total)) var(--spark);
}

body[data-theme='quiet'] .spark--dim { display: none; }

/* soft disc that hides ring lines passing behind the being */
.being-backdrop {
  position: absolute;
  z-index: 12;
  width: calc(var(--being-d, 132px) * 1.7);
  height: calc(var(--being-d, 132px) * 1.7);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, var(--bg-occlude) 0%, var(--bg-occlude) 36%, transparent 70%);
  pointer-events: none;
}

/* planet layer must NOT create a stacking context — planets interleave
   with the being (z-index 50) to pass in front of and behind it */
.planet-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* ----- Planets ------------------------------------------------------------------ */

.planet {
  position: absolute;
  left: var(--cx, 50%);
  top: var(--cy, 47%);
  width: var(--d);
  height: var(--d);
  pointer-events: auto;
  will-change: transform, opacity, filter;
}

.planet__inner {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.34s ease, opacity 0.34s ease;
}

.planet.is-leaving { pointer-events: none; }
.planet.is-leaving .planet__inner,
.planet.is-entering .planet__inner {
  transform: scale(0.4);
  opacity: 0;
}

.planet__sphere {
  --c-hi: color-mix(in oklab, var(--c) 58%, white);
  --c-lo: color-mix(in oklab, var(--c) 42%, black);
  position: relative;
  display: grid;
  place-items: center;
  width: var(--d);
  height: var(--d);
  border-radius: 50%;
  background: radial-gradient(circle at 33% 28%,
    var(--c-hi) 0%, var(--c) 46%, var(--c-lo) 79%, #07070d 100%);
  box-shadow:
    inset -6px -9px 16px rgba(0, 0, 0, 0.42),
    inset 4px 6px 10px rgba(255, 255, 255, 0.14),
    0 0 calc(22px * var(--glow-total)) color-mix(in srgb, var(--c) 50%, transparent),
    0 0 calc(54px * var(--glow-total)) color-mix(in srgb, var(--c) 20%, transparent);
  filter: saturate(var(--sat));
}

.planet__icon {
  width: 40%;
  height: 40%;
  fill: none;
  stroke: color-mix(in srgb, white 84%, var(--c));
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.planet__label {
  position: absolute;
  top: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  color: color-mix(in srgb, var(--c) 48%, white);
  text-shadow: 0 0 calc(9px * var(--glow-total)) color-mix(in srgb, var(--c) 60%, transparent);
  opacity: var(--lbl, 1);
}

.planet.is-selected .planet__sphere::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--c) 65%, white);
  opacity: 0.55;
}

.planet:focus-visible {
  outline: none;
}

.planet:focus-visible .planet__sphere {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

.planet:active .planet__sphere { transform: scale(0.96); }

/* ----- Central being --------------------------------------------------------------- */

.being {
  position: absolute;
  z-index: 50;
  width: var(--being-d, 132px);
  height: var(--being-d, 132px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
}

.being:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 4px;
  border-radius: 50%;
}

.being__glow {
  position: absolute;
  inset: -20%;
  border-radius: 50%;
  background: radial-gradient(circle,
    color-mix(in srgb, var(--being-b) 26%, transparent) 0%,
    color-mix(in srgb, var(--being-a) 10%, transparent) 40%,
    transparent 68%);
  animation: breathe 5.6s ease-in-out infinite alternate;
}

.being__halo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.being__halo circle:first-child {
  fill: none;
  stroke: color-mix(in srgb, var(--being-a) 50%, transparent);
  stroke-width: 0.7;
  stroke-dasharray: 0.6 5;
  opacity: 0.8;
}

.halo-dot { fill: var(--being-a); opacity: 0.9; }

.being__figure {
  position: absolute;
  inset: 11%;
  width: 78%;
  height: 78%;
  filter: drop-shadow(0 0 calc(11px * var(--glow-total)) var(--being-glow));
  animation: breathe-figure 5.6s ease-in-out infinite alternate;
}

.being:active .being__figure { scale: 0.97; }

@keyframes breathe {
  from { opacity: 0.72; transform: scale(0.985); }
  to { opacity: 1; transform: scale(1.05); }
}

@keyframes breathe-figure {
  from { transform: scale(1); }
  to { transform: scale(1.028); }
}

/* ----- Selection panel ---------------------------------------------------------------- */

.domain-panel {
  position: absolute;
  left: 50%;
  bottom: 10px;
  z-index: 200;
  width: min(350px, calc(100% - 26px));
  padding: 13px 15px 13px;
  border-radius: 22px;
  background: var(--panel-bg);
  border: 1px solid var(--chrome-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transform: translate(-50%, 14px);
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.domain-panel.is-open {
  opacity: 1;
  transform: translate(-50%, 0);
}

.domain-panel__head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.domain-panel__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c, var(--being-a));
  box-shadow: 0 0 calc(9px * var(--glow-total)) var(--c, var(--being-a));
  flex: none;
}

.domain-panel__name {
  margin: 0;
  flex: 1;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.domain-panel__close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--chrome-border);
  display: grid;
  place-items: center;
  flex: none;
}

.domain-panel__close svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.domain-panel__desc {
  margin: 7px 2px 10px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
}

.domain-panel__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip {
  font-size: 11px;
  padding: 5px 11px;
  border-radius: 999px;
  color: color-mix(in srgb, var(--ink) 82%, var(--c, var(--accent)));
  border: 1px solid color-mix(in srgb, var(--c, var(--accent)) 40%, transparent);
  background: color-mix(in srgb, var(--c, var(--accent)) 11%, transparent);
}

/* ----- Focus pill ------------------------------------------------------------------------ */

.focus-row {
  display: flex;
  justify-content: center;
  padding: 4px 0 10px;
}

.focus-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 26px 9px 13px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--being-a) 38%, transparent);
  background: color-mix(in srgb, var(--being-a) 7%, transparent);
}

.focus-orb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--being-a) 60%, transparent);
  background: radial-gradient(circle, var(--being-b) 0 4.5px, transparent 5.5px);
  box-shadow: 0 0 calc(10px * var(--glow-total)) var(--being-glow);
  animation: breathe 4.8s ease-in-out infinite alternate;
}

.focus-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-align: left;
}

.focus-title {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--ink) 70%, var(--being-a));
}

.focus-sub {
  font-size: 11.5px;
  color: var(--muted);
}

/* ----- Bottom navigation ------------------------------------------------------------------ */

.bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin: 0 14px calc(10px + env(safe-area-inset-bottom, 8px));
  padding: 8px 10px;
  border-radius: 26px;
  background: var(--chrome-bg);
  border: 1px solid var(--chrome-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 22px;
  border-radius: 16px;
  color: var(--muted);
}

.nav-btn svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.nav-btn span {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.nav-btn.is-active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  text-shadow: 0 0 calc(10px * var(--glow-total)) color-mix(in srgb, var(--accent) 65%, transparent);
}

.mic-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid var(--chrome-border);
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.09), rgba(18, 18, 32, 0.5));
  display: grid;
  place-items: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.mic-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.6;
  stroke-linecap: round;
}

/* tap acknowledgement for placeholder controls */
@keyframes tap-pulse { 35% { transform: scale(0.93); } }
.did-tap { animation: tap-pulse 0.3s ease; }

/* ----- Misc -------------------------------------------------------------------------------- */

.noscript-msg {
  position: fixed;
  inset: auto 16px 24px;
  padding: 14px;
  border-radius: 14px;
  background: #1a1a28;
  color: #efedf7;
  text-align: center;
  font-size: 14px;
}

/* short phones: tighten the header so the disc keeps room */
@media (max-height: 700px) {
  .app-title { font-size: 24px; }
  .app-subtitle { margin-top: 2px; }
  .focus-row { padding-bottom: 6px; }
}

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

@media (prefers-reduced-motion: reduce) {
  .star,
  .being__glow,
  .being__figure,
  .focus-orb {
    animation: none !important;
  }

  .planet__inner { transition: none; }
  .domain-panel { transition-duration: 0.01s; }
  .did-tap { animation: none; }
}
