/* ATLAS — space console. The black-hole canvas IS the page; chrome and chat float in the scene. */

:root {
  --bg: #04060e;
  --ink: #eef2fb;
  --ink-soft: rgba(238, 242, 251, 0.74);
  --ink-mute: rgba(238, 242, 251, 0.52);

  --line: rgba(190, 205, 255, 0.14);
  --line-strong: rgba(190, 205, 255, 0.3);
  --field: rgba(9, 13, 26, 0.55);

  --cyan: #9fd8ff;     /* live / listening / primary action — low saturation, reads as energized white */
  --violet: #c4b8ff;   /* thinking */
  --online: #74e0a6;
  --offline: #e6817b;

  --z-bg: 0;
  --z-scene: 10;

  --ease-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Exo 2", system-ui, -apple-system, sans-serif;
  overflow: hidden;                 /* the scene is fixed; only the transcript scrolls */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ── the reactive scene ── */
.viz {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: var(--z-bg);
  cursor: pointer;                  /* tap the orb to talk */
  touch-action: manipulation;
}

/* overlay: transparent to clicks except where there's a real control, so empty space hits the orb */
.scene {
  position: fixed;
  inset: 0;
  z-index: var(--z-scene);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
  pointer-events: none;
}

/* ── top bar ── */
.bar {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
}
.logo {
  font-size: 17px;
  color: var(--cyan);
  text-shadow: 0 0 14px rgba(159, 216, 255, 0.7);
}
.title {
  font-family: "Chakra Petch", "Exo 2", sans-serif;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.42em;
  padding-left: 2px;
}
.spacer { flex: 1; }

.state {
  font-family: "Chakra Petch", "Exo 2", sans-serif;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: color 0.3s var(--ease-quart), border-color 0.3s var(--ease-quart), box-shadow 0.35s var(--ease-quart);
}
.state.listening { color: var(--cyan); border-color: rgba(159, 216, 255, 0.42); box-shadow: 0 0 18px -4px var(--cyan); }
.state.thinking  { color: var(--violet); border-color: rgba(196, 184, 255, 0.42); }
.state.speaking  { color: #eef4ff; border-color: rgba(234, 241, 255, 0.5); box-shadow: 0 0 20px -4px rgba(234, 241, 255, 0.6); }

.conn {
  font-size: 10px;
  line-height: 1;
  color: var(--online);
  text-shadow: 0 0 10px rgba(116, 224, 166, 0.6);
  transition: color 0.3s, text-shadow 0.3s;
}
.conn.off { color: var(--offline); text-shadow: 0 0 10px rgba(230, 129, 123, 0.55); }

/* ── transcript: sits at the bottom of the orb's zone and dissolves upward into space ── */
.stagezone { position: relative; min-height: 0; }
.log {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(680px, 92vw);
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px 4px 14px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 72px);
          mask-image: linear-gradient(to bottom, transparent 0, #000 72px);
  scrollbar-width: thin;
  scrollbar-color: rgba(190, 205, 255, 0.22) transparent;
}
.log::-webkit-scrollbar { width: 8px; }
.log::-webkit-scrollbar-thumb { background: rgba(190, 205, 255, 0.2); border-radius: 8px; }
.log::-webkit-scrollbar-track { background: transparent; }

.msg {
  max-width: 82%;
  line-height: 1.55;
  font-size: 15px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  opacity: 0;
  transform: translateY(8px);
  animation: rise 0.42s var(--ease-expo) forwards;
}
.msg.cj {
  align-self: flex-end;
  text-align: right;
  color: var(--ink-soft);
}
.msg.atlas {
  align-self: flex-start;
  color: var(--ink);
  text-shadow: 0 0 22px rgba(159, 216, 255, 0.16);   /* spoken from the orb */
}
@keyframes rise { to { opacity: 1; transform: none; } }

.cursor {
  display: inline-block;
  width: 7px;
  height: 1.05em;
  margin-left: 3px;
  transform: translateY(2px);
  background: var(--cyan);
  border-radius: 1px;
  box-shadow: 0 0 8px var(--cyan);
  animation: blink 1.1s steps(1, end) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ── dock: hint + composer, seated on a soft scrim so input stays legible over the scene ── */
.dock {
  pointer-events: none;
  padding: 0 16px max(18px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 8%, rgba(4, 6, 14, 0.82) 42%, transparent);
}
.hint {
  pointer-events: none;
  margin: 0 auto 12px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-mute);
  transition: opacity 0.5s var(--ease-quart), transform 0.5s var(--ease-quart);
}
.hint.gone { opacity: 0; transform: translateY(6px); }

.composer {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(680px, 92vw);
  margin: 0 auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--field);
  -webkit-backdrop-filter: blur(10px);
          backdrop-filter: blur(10px);
  transition: border-color 0.25s var(--ease-quart), box-shadow 0.3s var(--ease-quart);
}
.composer:focus-within {
  border-color: var(--line-strong);
  box-shadow: 0 0 30px -12px var(--cyan);
}

#text {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  padding: 8px 6px;
}
#text::placeholder { color: rgba(238, 242, 251, 0.56); }

.mic, .send {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: transform 0.18s var(--ease-quart), color 0.2s, border-color 0.2s, box-shadow 0.25s, background 0.2s;
}
.mic:hover, .send:hover { color: var(--ink); border-color: var(--line-strong); transform: translateY(-1px); }
.mic:active, .send:active { transform: translateY(0) scale(0.95); }
.send { color: var(--cyan); }
.send:hover { box-shadow: 0 0 20px -6px var(--cyan); }
.send:disabled { opacity: 0.4; cursor: default; transform: none; box-shadow: none; }

.mic.live {
  color: #07101e;
  background: var(--cyan);
  border-color: var(--cyan);
  animation: micpulse 1.6s ease-out infinite;
}
@keyframes micpulse {
  0%   { box-shadow: 0 0 0 0 rgba(159, 216, 255, 0.5); }
  100% { box-shadow: 0 0 0 16px rgba(159, 216, 255, 0); }
}

/* ── focus / a11y ── */
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 10px; }
.composer:focus-within :focus-visible { outline-offset: 2px; }

/* ── responsive ── */
@media (max-width: 560px) {
  .bar { padding: 14px 16px; }
  .title { letter-spacing: 0.3em; }
  .msg { max-width: 88%; font-size: 14.5px; }
  .mic, .send { width: 40px; height: 40px; }
}

/* ── reduced motion: kill choreography, keep state legible ── */
@media (prefers-reduced-motion: reduce) {
  .msg { animation: none; opacity: 1; transform: none; }
  .cursor { animation: none; }
  .mic.live { animation: none; }
  .hint, .state, .conn, .mic, .send, .composer { transition-duration: 0.001ms; }
}
