/* ============================================================================
   HitchAI Assistant — right-docked slide-over (Universal UX Guide §6.1 / §7.305)
   Reuses tool.css tokens (--bg, --ink, --accent, --line, fonts).
   ========================================================================== */

/* accent-as-TEXT needs more contrast on the light theme than accent-as-fill;
   --accent-ink tracks --accent in dark and darkens under body.light (same
   convention as appearance.js darkening --accent-soft to #8a5a10) */
.asst, .asst-toggle { --accent-ink: var(--accent); }
body.light .asst, body.light .asst-toggle { --accent-ink: #8a5a10; --good: #2e7a35; --warn: #b3541e; }
body.light .asst { box-shadow: -24px 0 60px rgba(26, 18, 6, 0.15); }
body.light .asst-toggle:hover, body.light .asst__send:hover { background: #c9882a; }

/* topbar toggle (primary action, per §6.1 "one primary-styled action") */
.asst-toggle {
  font-family: var(--sans); font-size: 0.82rem; cursor: pointer; white-space: nowrap;
  background: var(--accent); color: #1a1206; border: 1px solid var(--accent);
  border-radius: 100px; padding: 0.45rem 0.95rem; font-weight: 500; margin-left: 0.6rem;
  display: inline-flex; align-items: center; gap: 0.4rem; transition: background 0.2s var(--ease);
}
.asst-toggle:hover { background: var(--accent-soft); }
.asst-toggle .dot { width: 6px; height: 6px; border-radius: 50%; background: #1a1206; }

/* dock: shift the app left when open */
.app { transition: margin-right 0.3s cubic-bezier(.4,0,.2,1); }
body.asst-open .app { margin-right: 400px; }

/* the slide-over */
.asst {
  position: fixed; top: 0; right: 0; width: 400px; max-width: 96vw; height: 100%;
  z-index: 70; background: var(--bg-panel, #0d0f12); border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  transform: translateX(103%); transition: transform 0.3s cubic-bezier(.4,0,.2,1);
  box-shadow: -24px 0 60px rgba(0,0,0,0.35);
}
body.asst-open .asst { transform: none; }

/* header — radial amber glow + Hitch(serif)+AI(italic amber) + live pulse */
.asst__head {
  position: relative; padding: 1rem 1.1rem 0.9rem; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 0.7rem;
  background: radial-gradient(120% 140% at 20% -10%, rgba(232,161,60,0.14), transparent 60%);
}
.asst__mark { font-family: var(--serif); font-size: 1.35rem; letter-spacing: 0.01em; }
.asst__mark b { color: var(--accent-ink); font-style: italic; font-weight: 400; }
.asst__live {
  font-family: var(--mono); font-size:.6875rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-faint); display: inline-flex; align-items: center; gap: 0.35rem;
  border: 1px solid var(--line); border-radius: 100px; padding: 0.2rem 0.5rem;
}
.asst__live i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: asstpulse 2s infinite; }
@keyframes asstpulse { 0%,100% { opacity: 1; box-shadow: 0 0 8px var(--accent); } 50% { opacity: 0.35; box-shadow: none; } }
.asst__spacer { flex: 1; }
.asst__x { background: none; border: none; color: var(--ink-dim); font-size: 1.1rem; cursor: pointer; padding: 0.2rem 0.4rem; }
.asst__x:hover { color: var(--ink); }
.asst__ctx {
  font-family: var(--mono); font-size:.6875rem; color: var(--ink-faint); letter-spacing: 0.03em;
  padding: 0.4rem 1.1rem 0; border-bottom: 1px solid var(--line-soft);
}
.asst__ctx b { color: var(--accent-ink); font-weight: 400; }

/* message log */
.asst__log { flex: 1; overflow-y: auto; padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.9rem; }
.asst__empty { color: var(--ink-faint); font-size: 0.85rem; line-height: 1.55; }
.asst__empty h4 { font-family: var(--serif); font-weight: 400; font-size: 1.15rem; color: var(--ink-dim); margin-bottom: 0.4rem; }
.asst__prompts { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1rem; }
.asst__prompt {
  text-align: left; background: var(--bg-soft); border: 1px solid var(--line); color: var(--ink);
  border-radius: 10px; padding: 0.6rem 0.8rem; font-size: 0.83rem; cursor: pointer;
  transition: transform 0.16s var(--ease), border-color 0.16s;
}
.asst__prompt:hover { transform: translateY(-2px); border-color: var(--ink-faint); }
.asst__prompt small { display: block; color: var(--ink-faint); font-size:.6875rem; margin-top: 0.15rem; }

.msg { display: flex; flex-direction: column; gap: 0.3rem; }
.msg--user { align-items: flex-end; }
.msg__body {
  max-width: 92%; font-size: 0.86rem; line-height: 1.55; border-radius: 12px; padding: 0.6rem 0.8rem;
}
.msg--user .msg__body { background: var(--accent); color: #1a1206; }
.msg--asst .msg__body { background: var(--bg-soft); border: 1px solid var(--line-soft); color: var(--ink); max-width: 100%; }
.msg--asst .msg__body p { margin: 0 0 0.5rem; }
.msg--asst .msg__body p:last-child { margin-bottom: 0; }
.msg--asst .msg__body b { color: var(--ink); font-weight: 500; }
.msg--asst .msg__body .num { font-family: var(--mono); color: var(--accent-ink); }
.msg__row { display: flex; justify-content: space-between; gap: 0.6rem; padding: 0.2rem 0; border-top: 1px solid var(--line-soft); font-size: 0.82rem; }
.msg__row:first-of-type { border-top: none; }
.msg__row span:last-child { font-family: var(--mono); color: var(--accent-ink); white-space: nowrap; }
.msg__cite {
  font-family: var(--mono); font-size:.6875rem; color: var(--ink-faint); letter-spacing: 0.02em; margin-top: 0.4rem;
}
.msg__cite a, .msg__go { color: var(--accent-ink); text-decoration: none; cursor: pointer; background: none; border: none; font: inherit; padding: 0; }
.msg__go:hover { text-decoration: underline; }
/* "From AI" honesty badge (§7 .kwai) */
.kwai {
  font-family: var(--mono); font-size:.6875rem; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--accent-ink); border: 1px solid var(--accent-ink); border-radius: 4px; padding: 0 0.3rem; margin-left: 0.4rem; vertical-align: middle;
}
.msg__caveat { color: var(--ink-faint); font-size: 0.72rem; line-height: 1.5; margin-top: 0.5rem; border-left: 2px solid var(--line); padding-left: 0.6rem; }

/* composer */
.asst__composer { border-top: 1px solid var(--line-soft); padding: 0.8rem 1.1rem 1rem; }
.asst__inputwrap { position: relative; }
.asst__ta {
  width: 100%; resize: none; background: var(--bg-soft); color: var(--ink); border: 1px solid var(--line);
  border-radius: 22px; padding: 0.7rem 3rem 0.7rem 1rem; font-family: var(--sans); font-size: 0.88rem;
  line-height: 1.4; max-height: 140px; transition: border-color 0.2s, box-shadow 0.2s;
}
.asst__ta:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,161,60,0.18); }
.asst__ta::placeholder { color: var(--ink-faint); }
.asst__send {
  position: absolute; right: 6px; bottom: 6px; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #1a1206; border: none; cursor: pointer; font-size: 1rem;
  display: grid; place-items: center; transition: background 0.2s;
}
.asst__send:hover { background: var(--accent-soft); }
.asst__send:disabled { opacity: 0.4; cursor: default; }
.asst__foot { display: flex; align-items: center; justify-content: space-between; margin-top: 0.5rem; }
.asst__key { background: none; border: none; color: var(--ink-faint); font-family: var(--mono); font-size:.6875rem; cursor: pointer; }
.asst__key:hover { color: var(--accent-ink); }
.asst__prov { background: var(--bg-soft); color: var(--ink); border: 1px solid var(--line); border-radius: 100px; font-family: var(--mono); font-size:.6875rem; padding: 0.2rem 0.5rem; cursor: pointer; }
.asst__prov:focus { outline: none; border-color: var(--accent); }
.asst__disclaim { font-family: var(--mono); font-size:.6875rem; color: var(--ink-faint); }

/* non-blocking "thinking" (not a spinner) */
.asst__think { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--ink-dim); font-size: 0.82rem; }
.asst__think i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: asstpulse 1.2s infinite; }

@media (max-width: 820px) {
  body.asst-open .app { margin-right: 0; }
  .asst { width: 96vw; }
}
@media (prefers-reduced-motion: reduce) {
  .asst, .app { transition: none; }
  .asst__live i, .asst__think i { animation: none; }
}
