/* ===== Shami — colours, fonts and sizes ===== */
:root {
  --void: #03060d;        /* background */
  --panel: #07122a;       /* panels */
  --cyan: #00e5ff;        /* main accent */
  --blue: #3d7bff;        /* secondary accent */
  --ice: #d6f3ff;         /* main text */
  --dim: #6f8fae;         /* quieter text */
  --line: rgba(0, 229, 255, 0.22);
  --display: "Orbitron", "Eurostile", "Segoe UI", system-ui, sans-serif;
  --mono: "Share Tech Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --level: 0;             /* voice loudness, set by app.js (0 to 1) */
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--void);
  color: var(--ice);
  font-family: var(--mono);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(ellipse at 50% 120%, rgba(61, 123, 255, 0.16), transparent 60%),
    radial-gradient(ellipse at 50% -20%, rgba(0, 229, 255, 0.07), transparent 55%),
    var(--void);
}

button, input { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ===== Knowledge graph ===== */
#graph {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#graph.dragging { cursor: grabbing; }

.hover-tip {
  position: fixed;
  z-index: 5;
  pointer-events: none;
  max-width: 260px;
  padding: 8px 10px;
  background: rgba(7, 18, 42, 0.92);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.35;
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.12);
}
.hover-tip strong { display: block; color: var(--ice); font-weight: normal; font-size: 13px; }
.hover-tip span { color: var(--dim); }

/* ===== Top bar ===== */
.topbar {
  position: fixed;
  z-index: 10;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 18px 12px;
  background: linear-gradient(to bottom, rgba(3, 6, 13, 0.92), rgba(3, 6, 13, 0));
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 22px; height: 22px; }
.brand-mark polygon {
  fill: none; stroke: var(--cyan); stroke-width: 1.6;
  filter: drop-shadow(0 0 4px var(--cyan));
}
.brand-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ice);
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.45);
}

.search { flex: 1; max-width: 360px; margin-left: auto; }
.search input {
  width: 100%;
  padding: 8px 12px;
  background: rgba(7, 18, 42, 0.7);
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
  font-size: 14px;
}
.search input::placeholder { color: var(--dim); }
.search input:focus { border-color: var(--cyan); box-shadow: 0 0 14px rgba(0, 229, 255, 0.25); }

.readouts {
  display: flex; gap: 14px; align-items: baseline;
  font-size: 13px; color: var(--dim);
}
.status-text {
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.24em;
  color: var(--cyan);
}

/* ===== Category filters ===== */
.legend {
  position: fixed;
  z-index: 10;
  top: calc(env(safe-area-inset-top, 0px) + 60px);
  left: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: calc(100% - 36px);
}
.legend button {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px;
  background: rgba(7, 18, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  font-size: 12px;
  color: var(--ice);
  cursor: pointer;
}
.legend button i {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 8px var(--c);
}
.legend button[aria-pressed="false"] { opacity: 0.4; }
.legend button[aria-pressed="false"] i { box-shadow: none; }

/* ===== Note panel ===== */
.note {
  position: fixed;
  z-index: 20;
  top: calc(env(safe-area-inset-top, 0px) + 64px);
  right: 18px;
  width: min(380px, calc(100% - 36px));
  max-height: calc(100% - 260px);
  overflow-y: auto;
  padding: 22px 22px 18px;
  background: rgba(7, 18, 42, 0.97);
  border: 1px solid var(--line);
  border-left: 3px solid var(--note-colour, var(--cyan));
  border-radius: 10px;
  box-shadow: 0 0 40px rgba(0, 229, 255, 0.12);
  transform: translateX(calc(100% + 40px));
  transition: transform 0.35s cubic-bezier(.2, .8, .2, 1);
}
.note.open { transform: none; }
.note-close {
  position: absolute; top: 10px; right: 12px;
  width: 32px; height: 32px;
  background: none; border: 0;
  font-size: 22px; color: var(--dim);
  cursor: pointer;
}
.note-category { margin: 0 0 6px; font-size: 12px; color: var(--note-colour, var(--cyan)); }
.note-title {
  margin: 0 30px 4px 0;
  font-family: var(--display);
  font-weight: 500;
  font-size: 19px;
  line-height: 1.3;
}
.note-date { margin: 0 0 14px; font-size: 12px; color: var(--dim); }
.note-body { margin: 0 0 18px; font-size: 15px; line-height: 1.55; }
.note-subhead { margin: 0 0 8px; font-size: 12px; font-weight: normal; color: var(--dim); }
.note-links { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 6px; }
.note-links button {
  width: 100%; text-align: left;
  padding: 8px 10px;
  background: rgba(0, 229, 255, 0.05);
  border: 1px solid rgba(0, 229, 255, 0.14);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.note-links button:hover { border-color: var(--cyan); }
.note-hint { margin: 0; font-size: 12px; color: var(--dim); }

/* ===== Bottom dock ===== */
.dock {
  position: fixed;
  z-index: 15;
  left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 16px calc(env(safe-area-inset-bottom, 0px) + 14px);
  background: linear-gradient(to top, rgba(3, 6, 13, 0.95) 40%, rgba(3, 6, 13, 0));
  pointer-events: none;
}
.dock > * { pointer-events: auto; }

.transcript {
  width: min(640px, 100%);
  background: rgba(7, 18, 42, 0.78);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.transcript-toggle {
  display: none;
  width: 100%;
  padding: 8px 14px;
  background: none; border: 0;
  text-align: left; font-size: 12px; color: var(--dim);
  cursor: pointer;
}
.messages {
  list-style: none;
  margin: 0;
  padding: 10px 14px;
  max-height: 132px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  line-height: 1.45;
}
.messages li { color: var(--ice); }
.messages li::before { margin-right: 8px; color: var(--dim); }
.messages li.you::before { content: "You"; }
.messages li.shami::before { content: "Shami"; color: var(--cyan); }
.messages li.system { color: var(--dim); font-size: 13px; }

/* ===== The voice core ===== */
.core {
  position: relative;
  width: 96px; height: 96px;
  padding: 0;
  background: none; border: 0; border-radius: 50%;
  cursor: pointer;
}
.core svg { width: 100%; height: 100%; overflow: visible; }
.core .ring circle { fill: none; stroke: var(--cyan); }
.core .ring-outer circle { stroke-width: 3; opacity: 0.85; }
.core .ring-ticks circle { stroke-width: 6; opacity: 0.5; }
.core .ring-inner circle { stroke-width: 1.5; opacity: 0.6; stroke: var(--blue); }
.core .ring { transform-origin: 100px 100px; }
.core .ring-outer { animation: spin 18s linear infinite; }
.core .ring-ticks { animation: spin 40s linear infinite reverse; }
.core .ring-inner { animation: spin 12s linear infinite reverse; }
.core .hex {
  fill: rgba(0, 229, 255, 0.08);
  stroke: var(--cyan); stroke-width: 2.5;
  filter: drop-shadow(0 0 6px var(--cyan));
  transform-origin: 100px 100px;
  transition: transform 0.12s ease-out;
}
.core .hex-dot { fill: var(--ice); }
.core .core-halo { opacity: 0.25; transition: opacity 0.4s; transform-origin: 100px 100px; }

body[data-state="listening"] .core .core-halo { opacity: 0.55; animation: breathe 1.6s ease-in-out infinite; }
body[data-state="listening"] .core .ring-outer { animation-duration: 5s; }
body[data-state="listening"] .core .ring-inner { animation-duration: 4s; }

body[data-state="speaking"] .core .core-halo { opacity: calc(0.45 + var(--level) * 0.5); }
body[data-state="speaking"] .core .hex { transform: scale(calc(1 + var(--level) * 0.18)); }
body[data-state="speaking"] .core .ring-outer { animation-duration: 3s; }

body[data-state="offline"] .core .ring circle,
body[data-state="offline"] .core .hex { stroke: var(--dim); filter: none; }
body[data-state="offline"] .status-text { color: var(--dim); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { transform: scale(1.08); } }

/* ===== Phones ===== */
@media (max-width: 640px) {
  .topbar { gap: 10px; padding-left: 14px; padding-right: 14px; }
  .brand-name { font-size: 15px; letter-spacing: 0.26em; }
  .clock { display: none; }
  .search { max-width: none; }
  .legend { left: 14px; top: calc(env(safe-area-inset-top, 0px) + 56px); }
  .legend button { padding: 4px 9px; font-size: 11px; }

  /* Note becomes a sheet that slides up from the bottom */
  .note {
    top: auto; right: 0; left: 0; bottom: 0;
    width: 100%;
    max-height: 72%;
    border-left: 1px solid var(--line);
    border-top: 3px solid var(--note-colour, var(--cyan));
    border-radius: 16px 16px 0 0;
    background: var(--panel);
    z-index: 30;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
    transform: translateY(105%);
  }

  .transcript-toggle { display: block; }
  .transcript:not(.expanded) .messages { max-height: 52px; }
  .messages { max-height: 40vh; font-size: 13px; }
  .core { width: 84px; height: 84px; }
}

/* ===== Respect "reduce motion" ===== */
@media (prefers-reduced-motion: reduce) {
  .core .ring, .core .core-halo { animation: none !important; }
  .note { transition: none; }
}
