/* hermes-voice — cinematic dark glass */

:root {
  --bg: #05070a;
  --ink: #e8edf2;
  --ink-dim: #8a94a3;
  --ink-faint: #4a5364;
  --glass: rgba(16, 21, 30, 0.55);
  --glass-edge: rgba(255, 255, 255, 0.08);
  --glass-edge-hi: rgba(255, 255, 255, 0.16);
  --accent: #6fe3d2;
  --accent-dim: rgba(111, 227, 210, 0.35);
  --danger: #ff6b6b;
  --sab: env(safe-area-inset-bottom, 0px);
  --sat: env(safe-area-inset-top, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

body {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
}

/* ambient background */
#bg-grad {
  position: fixed;
  inset: -20%;
  z-index: 0;
  background:
    radial-gradient(ellipse 60% 45% at 50% 30%, rgba(45, 80, 100, 0.20), transparent 70%),
    radial-gradient(ellipse 45% 40% at 25% 85%, rgba(60, 45, 95, 0.14), transparent 70%),
    radial-gradient(ellipse 50% 40% at 80% 75%, rgba(30, 70, 65, 0.12), transparent 70%);
  pointer-events: none;
  animation: drift 26s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(-1.5%, -1%, 0) scale(1); }
  to   { transform: translate3d(1.5%, 1.5%, 0) scale(1.05); }
}

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  backdrop-filter: blur(22px) saturate(1.4);
  border: 1px solid var(--glass-edge);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 12px 40px rgba(0, 0, 0, 0.45);
}

.glass-inset {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--glass-edge);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* ── top bar ── */
.top-bar {
  position: relative;
  z-index: 5;
  margin: calc(10px + var(--sat)) 12px 0;
  padding: 10px 14px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand { display: flex; align-items: baseline; gap: 7px; }
.brand-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.34em;
  background: linear-gradient(180deg, #fff 0%, #9fb2c4 60%, #5d6b7d 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-sub {
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--ink-faint);
  text-transform: uppercase;
}
.conn-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  align-self: center;
  background: var(--ink-faint);
  transition: background 0.4s, box-shadow 0.4s;
}
.conn-dot.on { background: var(--accent); box-shadow: 0 0 8px var(--accent-dim); }
.conn-dot.err { background: var(--danger); }

.top-controls { display: flex; align-items: center; gap: 8px; }

/* mode toggle */
.mode-toggle {
  position: relative;
  display: flex;
  border-radius: 12px;
  padding: 3px;
  overflow: hidden;
}
.mode-btn {
  position: relative;
  z-index: 1;
  border: 0;
  background: transparent;
  color: var(--ink-dim);
  font: 600 11px/1 -apple-system, sans-serif;
  letter-spacing: 0.04em;
  padding: 7px 12px;
  border-radius: 9px;
  cursor: pointer;
  transition: color 0.25s;
  white-space: nowrap;
}
.mode-btn.active { color: var(--ink); }
.mode-pill {
  position: absolute;
  top: 3px; bottom: 3px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid var(--glass-edge-hi);
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
  transition: left 0.28s cubic-bezier(.6,.1,.2,1.2), width 0.28s cubic-bezier(.6,.1,.2,1.2);
}

.icon-btn {
  width: 34px; height: 34px;
  border-radius: 11px;
  color: var(--ink-dim);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color 0.25s, background 0.25s;
}
.icon-btn[aria-pressed="true"] { color: var(--accent); background: rgba(111, 227, 210, 0.10); }

/* ── stage ── */
.stage {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  gap: 4px;
}

.orb-wrap {
  position: relative;
  width: min(62vw, 42vh, 340px);
  aspect-ratio: 1;
  transition: transform 0.6s cubic-bezier(.3,.7,.3,1), width 0.45s cubic-bezier(.3,.7,.3,1);
}
#orb { width: 100%; height: 100%; display: block; }
.orb-hit {
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  cursor: pointer;
}
.orb-hit:active ~ #orb { filter: brightness(1.15); }

.status-line {
  height: 24px;
  display: grid;
  place-items: center;
}
#status-text {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  transition: color 0.4s, opacity 0.3s;
}

/* transcript folded into stage; on desktop it floats right */
.transcript {
  position: absolute;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 1;
  transition: opacity 0.35s, transform 0.35s;
}
.transcript.hidden { opacity: 0; pointer-events: none; transform: translateY(12px); }

.transcript-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  mask-image: linear-gradient(180deg, transparent 0, #000 18px, #000 calc(100% - 6px), transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 18px, #000 calc(100% - 6px), transparent 100%);
}

.msg {
  max-width: 88%;
  font-size: 13.5px;
  line-height: 1.5;
  padding: 9px 13px;
  border-radius: 15px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  user-select: text;
  -webkit-user-select: text;
}
.msg.user {
  align-self: flex-end;
  background: rgba(111, 227, 210, 0.10);
  border: 1px solid rgba(111, 227, 210, 0.18);
  color: #d7f5ef;
  border-bottom-right-radius: 5px;
}
.msg.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-edge);
  color: var(--ink);
  border-bottom-left-radius: 5px;
}
.msg.meta {
  align-self: center;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  background: transparent;
  border: 0;
  padding: 0 4px;
  text-transform: uppercase;
}

/* ── layout: mobile default — transcript above bottom bar ── */
.transcript {
  left: 12px; right: 12px;
  bottom: calc(96px + var(--sab));
  height: 34vh;
}
body.transcript-open .orb-wrap { transform: translateY(-16vh) scale(0.62); }
body.transcript-open .status-line { transform: translateY(-15vh); transition: transform 0.5s cubic-bezier(.3,.7,.3,1); }
.status-line { transition: transform 0.5s cubic-bezier(.3,.7,.3,1); }

/* desktop: transcript as right rail, orb stays centered */
@media (min-width: 900px) {
  .transcript {
    left: auto;
    right: 24px;
    top: 90px;
    bottom: calc(24px + var(--sab));
    width: 340px;
    height: auto;
  }
  body.transcript-open .orb-wrap { transform: translateX(-160px) scale(0.94); }
  body.transcript-open .status-line { transform: translateX(-160px); }
}

/* ── bottom bar / PTT ── */
.bottom-bar {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 0 0 calc(18px + var(--sab));
  min-height: calc(86px + var(--sab));
}

/* persona selector */
.persona-pill {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
}
.persona-btn {
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  font: 600 10.5px/1 -apple-system, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.25s, background 0.25s, box-shadow 0.25s;
  white-space: nowrap;
}
.persona-btn.active {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.10);
  box-shadow: 0 0 14px rgba(111, 227, 210, 0.10), 0 1px 0 rgba(255,255,255,0.08) inset;
}

.ptt-btn {
  position: relative;
  border-radius: 999px;
  padding: 17px 44px;
  color: var(--ink);
  font: 600 13px/1 -apple-system, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.15s, background 0.3s, border-color 0.3s, opacity 0.3s;
  border: 1px solid var(--glass-edge-hi);
}
.ptt-btn.rec {
  background: rgba(111, 227, 210, 0.13);
  border-color: rgba(111, 227, 210, 0.45);
  transform: scale(1.05);
  box-shadow: 0 0 32px rgba(111, 227, 210, 0.18), 0 12px 40px rgba(0,0,0,0.45);
}
.ptt-btn.hidden { opacity: 0; pointer-events: none; }
.ptt-label { position: relative; z-index: 1; }
.ptt-ring {
  position: absolute; inset: -1px;
  border-radius: inherit;
  pointer-events: none;
}
.ptt-btn.rec .ptt-ring { animation: pttPulse 1.6s ease-out infinite; border: 1px solid rgba(111,227,210,0.5); }
@keyframes pttPulse {
  from { transform: scale(1); opacity: 0.7; }
  to   { transform: scale(1.28); opacity: 0; }
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(110px + var(--sab));
  transform: translateX(-50%);
  z-index: 20;
  border-radius: 13px;
  padding: 10px 18px;
  font-size: 12.5px;
  color: var(--ink);
  max-width: 82vw;
  text-align: center;
  transition: opacity 0.3s, transform 0.3s;
}
.toast.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(8px); }

.hidden { }

/* small phones: tighten the top bar so nothing clips */
@media (max-width: 480px) {
  .top-bar { padding: 8px 10px; gap: 6px; }
  .brand-sub { display: none; }
  .brand-name { font-size: 12px; letter-spacing: 0.22em; }
  .mode-btn { padding: 6px 9px; font-size: 10px; }
  .icon-btn { width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0; }
  /* with transcript open, park the status readout just under the top bar */
  body.transcript-open .status-line {
    position: fixed;
    top: calc(64px + var(--sat));
    left: 0; right: 0;
    transform: none;
    z-index: 4;
  }
  body.transcript-open .orb-wrap { transform: translateY(-17vh) scale(0.55); }
}

@media (prefers-reduced-motion: reduce) {
  #bg-grad { animation: none; }
}
