/* ==========================================================================
   HUD — the look shared by the chat and sign-in pages: type and geometry
   tokens, backdrop, controls and the orb. A page opts in with
   <html class="hud" data-theme="dark">. Its colours live in tokens.css.
   ========================================================================== */

html.hud[data-theme="dark"] {
  color-scheme: dark;

  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-prose: var(--font-ui);
  --font-display: "Space Grotesk", var(--font-ui);

  --text-md: 15.5px;

  --radius: 12px;
  --radius-sm: 6px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --control-h: 36px;
  --control-h-sm: 32px;
  --nav-height: 60px;
  --column: 780px;

  --duration: 220ms;
  --ease: cubic-bezier(0.22, 0.8, 0.3, 1);
}

/* ------------------------------------------------------------------ backdrop
   The root paints the page colour, so the lights below can sit behind the content
   without a stacking context on the stage. One there would trap the chat drawers
   underneath their scrim, which is appended to <body>. */

html.hud body { background: transparent; }

.hud-stage { position: relative; }

/* Two soft lights, and a faint grid that fades out towards the edges. */
.hud-stage::before,
.hud-stage::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
.hud-stage::before {
  background:
    radial-gradient(60% 45% at 50% -5%, color-mix(in srgb, var(--accent) 17%, transparent), transparent 70%),
    radial-gradient(45% 40% at 85% 105%, color-mix(in srgb, var(--accent-two) 20%, transparent), transparent 70%);
}
.hud-stage::after {
  background-image:
    linear-gradient(var(--rule) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.45;
  -webkit-mask-image: radial-gradient(75% 65% at 50% 40%, #000, transparent 75%);
  mask-image: radial-gradient(75% 65% at 50% 40%, #000, transparent 75%);
}

/* ------------------------------------------------------------------ controls */

.btn {
  border-radius: var(--radius-pill);
  background: transparent;
  font-weight: var(--weight-medium);
}
.btn:hover { border-color: var(--accent); }
.btn:disabled:hover { border-color: var(--rule); }
.btn-ghost { border-color: transparent; }
.btn-ghost:hover { border-color: var(--rule-strong); background: var(--accent-wash); }
.btn-block { background: var(--accent-wash); }

.tag { border-radius: var(--radius-pill); padding: 1px var(--space-2); background: transparent; }
.mark { border-radius: 50%; }
.mark-ok { box-shadow: 0 0 8px var(--status-ok); }
.mark-warn { box-shadow: 0 0 8px var(--status-warn); }

input, select, textarea { background: var(--paper-sunken); }
select option { background: var(--paper-raised); color: var(--ink); }
::-webkit-scrollbar-thumb { border-radius: var(--radius-pill); }

.btn.btn-primary {
  color: var(--ink-inverse);
  background: linear-gradient(135deg, var(--accent), var(--accent-two));
  border: none;
  box-shadow: 0 0 18px var(--accent-glow);
}
.btn.btn-primary:hover { background: linear-gradient(135deg, var(--accent-strong), var(--accent-two)); }
.btn.btn-primary:disabled {
  color: var(--ink-faint);
  background: var(--paper-raised);
  box-shadow: none;
}

/* -------------------------------------------------------------------- toasts */

.toast {
  background: var(--glass-strong);
  border-color: var(--rule-strong);
  border-left-color: var(--accent);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* ------------------------------------------------------------------- the orb
   One element, sized by --orb. The state lives on <html data-core>, so every orb
   on the page breathes, spins or speaks together. */

.orb {
  --orb: 160px;
  --spin: 14s;
  position: relative;
  display: block;
  flex: none;
  width: var(--orb);
  height: var(--orb);
  border-radius: 50%;
  isolation: isolate;
  animation: orb-breathe 6s ease-in-out infinite;
}
/* the logo, in a glowing disc */
.orb::before {
  content: '';
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: #000 url("/static/img/logo-mark.png") center / cover no-repeat;
  box-shadow:
    0 0 0 1px var(--rule-strong),
    0 0 calc(var(--orb) * 0.22) var(--accent-glow);
}
/* soft halo */
.orb::after {
  content: '';
  position: absolute;
  inset: -12%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-wash) 30%, transparent 68%);
  pointer-events: none;
}
/* two orbiting arcs */
.orb i {
  position: absolute;
  inset: 1%;
  border-radius: 50%;
  border: 1px solid var(--rule);
  border-top-color: var(--accent);
  animation: orb-turn calc(var(--spin) * 0.7) linear infinite;
}
.orb i + i {
  inset: -6%;
  border-top-color: transparent;
  border-bottom-color: var(--accent-two);
  animation-direction: reverse;
  animation-duration: var(--spin);
}

.orb-mini { --orb: 34px; }
.orb-mini::before { inset: 7%; }
.orb-mini i { inset: -3%; }
.orb-mini i + i { display: none; }

html[data-core="thinking"] .orb,
html[data-core="working"] .orb { --spin: 2.2s; animation-duration: 2s; }
html[data-core="speaking"] .orb { --spin: 5s; animation: orb-speak 0.9s ease-in-out infinite; }
html[data-core="listening"] .orb { --spin: 8s; animation: orb-breathe 2.4s ease-in-out infinite; }
html[data-core="listening"] .orb::after { animation: orb-ripple 1.8s ease-out infinite; }

@keyframes orb-turn { to { transform: rotate(360deg); } }
@keyframes orb-breathe { 50% { transform: scale(1.045); } }
@keyframes orb-speak {
  0%, 100% { transform: scale(1); }
  35% { transform: scale(1.1); }
  65% { transform: scale(0.97); }
}
@keyframes orb-ripple {
  from { transform: scale(0.85); opacity: 1; }
  to { transform: scale(1.35); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html.hud[data-theme="dark"] { --duration: 0ms; }
  .orb, .orb::before, .orb::after, .orb i { animation: none !important; }
}
