/* Interview Assist: a "teleprompter console". Mobile-first: the base styles are for phones; wider screens
   (min-width: 960px) add the desktop layout. Low-glare dark surface, big high-contrast "say" text,
   teal = live / what to say, amber = thinking. */

:root {
  --bg: #0b0e12;
  --surface: #12161c;
  --surface-2: #181d25;
  --surface-3: #202733;
  --line: #262e3a;
  --line-strong: #364152;
  --text: #e7ecf2;
  --text-dim: #93a0b1;
  --text-faint: #5f6b7b;
  --live: #2dd4bf;
  --live-soft: #0f2f2b;
  --live-ink: #061a17;
  --say-bg: #0e2421;
  --busy: #f5b544;
  --violet: #a78bfa;
  --danger: #f87171;
  --ok: #4ade80;
  --link: #7dd3fc;

  --font-ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-read: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Cascadia Code", "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;

  --text-say: clamp(1.12rem, 1rem + 0.6vw, 1.45rem);
  --text-body: clamp(0.98rem, 0.94rem + 0.2vw, 1.06rem);
  --tap: 44px; /* minimum touch target */

  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;
  --shadow: 0 12px 40px rgb(0 0 0 / 0.45);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --fast: 140ms;
  --dock-h: calc(70px + env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: radial-gradient(900px 500px at 85% -10%, #10302c33, transparent 60%), var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font-ui);
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
:focus-visible { outline: 2px solid var(--live); outline-offset: 2px; }
[hidden] { display: none !important; }
kbd {
  font: 600 0.72em var(--font-mono); padding: 1px 5px; border-radius: 4px;
  border: 1px solid var(--line); border-bottom-width: 2px; color: var(--text-dim);
}
code { font-family: var(--font-mono); }
.muted { color: var(--text-dim); }
.small { font-size: 0.85em; }
.error { color: var(--danger); }
.spacer { flex: 1; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.wide-only, .brand-name, .wide-label { display: none !important; }

/* ---- controls ------------------------------------------------------------------ */
.primary, .secondary, .ghost {
  min-height: 40px; padding: 8px 14px; border-radius: var(--radius-s); white-space: nowrap;
  transition: background var(--fast), color var(--fast), transform var(--fast);
}
.primary { background: var(--live); color: var(--live-ink); font-weight: 650; }
.primary:hover { background: #5eead4; }
.primary:disabled { opacity: 0.45; cursor: not-allowed; }
.secondary { background: var(--surface-3); border: 1px solid var(--line); }
.secondary:hover { background: #2a3342; }
.ghost { color: var(--text-dim); }
.ghost:hover { color: var(--text); background: var(--surface-2); }
.ghost.danger:hover { color: var(--danger); }
.ghost.small { min-height: 32px; padding: 4px 10px; font-size: 0.85rem; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  min-width: var(--tap); min-height: var(--tap); padding: 0 10px; border-radius: var(--radius-m);
  color: var(--text-dim); font-size: 0.95rem;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
:is(.primary, .secondary, .ghost, .mic, .dock-btn, .icon-btn):active { transform: translateY(1px); }

select, input:not([type="checkbox"]):not([type="range"]), textarea {
  min-height: 40px; padding: 8px 10px; border-radius: var(--radius-s); background: var(--bg); border: 1px solid var(--line);
  font-size: 16px; /* prevents iOS zoom on focus */
}
:is(select, input, textarea):focus { border-color: var(--live); outline: none; }
textarea { resize: vertical; width: 100%; line-height: 1.5; }

.segmented { display: flex; padding: 3px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); }
.segmented button { flex: 1; min-height: 34px; padding: 4px 12px; border-radius: 99px; color: var(--text-dim); font-size: 0.9em; white-space: nowrap; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.segmented.small button { min-height: 30px; padding: 3px 10px; font-size: 0.82em; }
.segmented button[data-mode="deep"].active { color: var(--busy); }
.view-switch button.active { color: var(--live); }

.chip {
  display: inline-flex; gap: 6px; align-items: center; max-width: 280px; min-height: 30px;
  padding: 3px 10px; border-radius: 99px; font-size: 0.8rem;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none;
}
button.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip.active { color: var(--live); border-color: #1f4d47; background: var(--live-soft); }

.badge {
  flex-shrink: 0; padding: 2px 7px; border-radius: 4px; background: var(--surface-3); color: var(--text-dim);
  font: 700 0.66rem var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em;
}
.badge.auto { color: var(--live); background: var(--live-soft); }

.status { font: 600 0.72rem var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); }
.status[data-state="live"] { color: var(--live); }
.status[data-state="busy"] { color: var(--busy); }

/* ---- top bar -------------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 4px;
  padding: max(6px, env(safe-area-inset-top)) 8px 6px;
  border-bottom: 1px solid var(--line); background: rgb(11 14 18 / 0.92); backdrop-filter: blur(8px);
}
.logo {
  display: grid; place-items: center; flex-shrink: 0; width: 30px; height: 30px; border-radius: 8px;
  background: var(--live); color: var(--live-ink); font-weight: 800;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.scenario-picker { flex: 1; min-width: 0; margin-left: 4px; }
.scenario-picker select { width: 100%; padding: 6px 12px; border-radius: 99px; background: var(--surface-2); font-weight: 600; font-size: 15px; }
.topbar .spacer { display: none; }

.mic {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; overflow: hidden;
  min-height: var(--tap); padding: 8px 16px 8px 12px; border-radius: 99px; font-weight: 650;
  background: var(--surface-3); border: 1px solid var(--line);
  transition: background var(--fast), border-color var(--fast);
}
.mic .dot { flex-shrink: 0; width: 12px; height: 12px; border-radius: 50%; background: var(--text-faint); }
.mic.on { background: var(--live-soft); border-color: var(--live); color: var(--live); }
.mic.on .dot { background: var(--live); animation: pulse 1.6s var(--ease) infinite; }
.mic .level { position: absolute; left: 14px; right: 14px; bottom: 4px; height: 3px; border-radius: 2px; overflow: hidden; }
.mic .level i { display: block; height: 100%; background: var(--live); transform-origin: left; transform: scaleX(0); transition: transform 80ms linear; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(45 212 191 / 0.6); } 100% { box-shadow: 0 0 0 10px rgb(45 212 191 / 0); } }

.banner { padding: 8px 14px; background: #3a2a0c; color: #fcd58a; border-bottom: 1px solid #5a4214; font-size: 0.92em; }

/* ---- layout (phone: one column, dock at the bottom) ------------------------------------ */
.layout { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-bottom: var(--dock-h); }
.layout > * { min-width: 0; }
.pane { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
body[data-view="prep"] .transcript-pane, body[data-view="prep"] .dock { display: none; }
body[data-view="prep"] .layout { padding-bottom: 0; }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: grid; grid-template-columns: 1fr 1fr 1.4fr 1fr; gap: 6px; align-items: center;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgb(11 14 18 / 0.96); border-top: 1px solid var(--line); backdrop-filter: blur(10px);
}
.dock-btn { min-height: 48px; border-radius: var(--radius-m); color: var(--text-dim); font-weight: 600; font-size: 0.9rem; }
.dock-btn.active { color: var(--live); background: var(--surface-2); }
.dock-btn.accent { background: var(--surface-3); color: var(--text); border: 1px solid var(--line); }
.dock-mic { min-height: 52px; padding: 10px 14px; }

/* ---- settings sheet (phone: bottom sheet) ---------------------------------------------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; max-height: 88vh; overflow-y: auto;
  padding: 14px 16px calc(24px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line); border-radius: var(--radius-l) var(--radius-l) 0 0;
  box-shadow: var(--shadow); animation: rise 220ms var(--ease);
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sheet-head h2 { margin: 0; font: 650 1.1rem var(--font-read); }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.toggle { display: flex; gap: 10px; align-items: center; min-height: var(--tap); }
.toggle input, input[type="range"] { accent-color: var(--live); }
.toggle input { width: 20px; height: 20px; }
.tip { padding: 12px 14px; border-radius: var(--radius-m); background: var(--surface-2); border: 1px solid var(--line); color: var(--text-dim); font-size: 0.9em; }
.tip b { color: var(--text); }

/* ---- login & toasts ------------------------------------------------------------------- */
.login { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgb(5 7 9 / 0.94); }
.login-card {
  display: flex; flex-direction: column; gap: 12px; width: min(340px, 90vw); padding: 26px;
  border-radius: var(--radius-l); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.login-card .error { margin: 0; min-height: 1.2em; font-size: 0.9em; }
.toasts {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + var(--dock-h)); z-index: 50;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  max-width: 560px; padding: 10px 16px; border-radius: var(--radius-m);
  background: var(--surface-3); border: 1px solid var(--line); box-shadow: var(--shadow); animation: enter 200ms var(--ease);
}
.toast.error { border-color: #7f2d2d; color: #fecaca; }
.toast.success { border-color: #1f5135; color: #bbf7d0; }
@keyframes enter { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---- wide screens (laptop next to the call) ---------------------------------------------- */
@media (min-width: 960px) {
  :root { --dock-h: 0px; }
  .wide-only { display: flex !important; }
  .brand-name, .wide-label { display: inline !important; }
  .brand-name { font-weight: 700; margin-right: 4px; }
  .topbar { gap: 10px; padding: 9px 16px; }
  .topbar .spacer { display: block; }
  .scenario-picker { flex: 0 1 240px; }
  .dock { display: none; }
  .layout { display: grid; grid-template-columns: minmax(280px, 30fr) 70fr; padding-bottom: 0; }
  body[data-view="prep"] .layout { grid-template-columns: 1fr; }
  .sheet {
    left: auto; top: 0; width: 420px; max-height: none; border-top: 0; border-left: 1px solid var(--line);
    border-radius: 0; animation: slide 220ms var(--ease);
  }
  @keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
  .toasts { bottom: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
