/* sibyl-chat-widget — light-mode lab aesthetic, matches sibyllabs.org tokens */

:root {
  --sc-paper:      #f5f1e6;
  --sc-paper-deep: #ede6d3;
  --sc-card:       #fdfbf5;
  --sc-ink:        #15110a;
  --sc-ink-soft:   #2c271d;
  --sc-ink-mute:   #6a6356;
  --sc-ink-faint:  #98917f;
  --sc-rule:       #d8d0bb;
  --sc-rule-strong:#b8ae93;
  --sc-accent:     #8a6a2a;
  --sc-accent-warm:#a08438;
  --sc-jade:       #2d6e6a;
  --sc-pulse:      #1d8a82;
  --sc-shadow-md:  0 8px 28px rgba(45, 35, 18, 0.18);
  --sc-shadow-lg:  0 18px 48px rgba(45, 35, 18, 0.28);
  --sc-ease:       cubic-bezier(0.19, 1, 0.22, 1);
}

#sc-root, #sc-root * { box-sizing: border-box; }

#sc-root {
  position: fixed;
  z-index: 9999;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  color: var(--sc-ink-soft);
  /* position is set inline by JS */
}

/* ─── avatar ─── */

.sc-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background-color: var(--sc-card);
  background-image: url('/sibyl-labs-logo.png');
  background-size: cover;
  background-position: center;
  border: 1.5px solid var(--sc-rule-strong);
  box-shadow: var(--sc-shadow-md);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: transform 0.22s var(--sc-ease), box-shadow 0.22s var(--sc-ease), border-color 0.22s var(--sc-ease);
  position: relative;
}
.sc-avatar:hover {
  transform: scale(1.06);
  box-shadow: var(--sc-shadow-lg);
  border-color: var(--sc-accent);
}
.sc-avatar.sc-dragging {
  cursor: grabbing;
  transform: scale(1.04);
  transition: none;
}
.sc-avatar.sc-pulsing::after {
  content: '';
  position: absolute;
  inset: -3px;
  border: 1.5px solid var(--sc-pulse);
  border-radius: 50%;
  animation: sc-pulse-ring 1.6s ease-out infinite;
  pointer-events: none;
}
@keyframes sc-pulse-ring {
  0%   { transform: scale(0.95); opacity: 0.85; }
  100% { transform: scale(1.40); opacity: 0; }
}

/* tooltip prompt on first paint */
.sc-hint {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: var(--sc-ink);
  color: var(--sc-paper);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  padding: 6px 10px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s var(--sc-ease);
}
.sc-avatar.sc-show-hint .sc-hint { opacity: 1; }

/* ─── panel ─── */

.sc-panel {
  position: absolute;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 96px));
  background: var(--sc-card);
  border: 1px solid var(--sc-rule-strong);
  border-radius: 14px;
  box-shadow: var(--sc-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.92) translateY(8px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.24s var(--sc-ease), opacity 0.18s var(--sc-ease);
}
.sc-panel.sc-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.sc-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--sc-rule);
  background: var(--sc-paper-deep);
}
.sc-header-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-image: url('/sibyl-labs-logo.png');
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  border: 1px solid var(--sc-rule);
}
.sc-header-text { flex: 1; min-width: 0; }
.sc-header-title {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 1rem;
  color: var(--sc-ink);
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.sc-header-status {
  font-size: 0.68rem;
  color: var(--sc-ink-mute);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sc-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sc-pulse);
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(29, 138, 130, 0.18);
}
.sc-close {
  background: transparent;
  border: 1px solid var(--sc-rule);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  color: var(--sc-ink-mute);
  font-size: 14px;
  font-family: inherit;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s var(--sc-ease);
  padding: 0;
}
.sc-close:hover {
  border-color: var(--sc-accent);
  color: var(--sc-ink);
  background: var(--sc-card);
}

/* messages */
.sc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--sc-rule-strong) transparent;
  background: var(--sc-card);
}
.sc-messages::-webkit-scrollbar { width: 6px; }
.sc-messages::-webkit-scrollbar-thumb { background: var(--sc-rule-strong); border-radius: 3px; }

.sc-msg {
  max-width: 88%;
  font-size: 0.86rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.sc-msg-user {
  align-self: flex-end;
  background: var(--sc-paper-deep);
  border: 1px solid var(--sc-rule);
  color: var(--sc-ink);
  padding: 10px 13px;
  border-radius: 14px 14px 4px 14px;
}
.sc-msg-assistant {
  align-self: flex-start;
  color: var(--sc-ink-soft);
  font-family: 'Fraunces', serif;
  font-size: 0.95rem;
  line-height: 1.55;
  padding: 4px 0;
  max-width: 100%;
}
.sc-msg-system {
  align-self: center;
  font-size: 0.72rem;
  color: var(--sc-ink-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  padding: 4px 8px;
}
.sc-msg-error {
  align-self: stretch;
  background: rgba(170, 50, 50, 0.05);
  border: 1px solid rgba(170, 50, 50, 0.25);
  color: #8a3a3a;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
}

/* typing dots */
.sc-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 8px 0;
}
.sc-typing span {
  width: 6px;
  height: 6px;
  background: var(--sc-ink-faint);
  border-radius: 50%;
  animation: sc-typing-bounce 1.2s ease-in-out infinite;
}
.sc-typing span:nth-child(2) { animation-delay: 0.15s; }
.sc-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes sc-typing-bounce {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* input */
.sc-input-row {
  border-top: 1px solid var(--sc-rule);
  padding: 12px 12px 14px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--sc-paper);
}
.sc-input {
  flex: 1;
  min-height: 38px;
  max-height: 120px;
  resize: none;
  border: 1px solid var(--sc-rule);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.86rem;
  color: var(--sc-ink);
  background: var(--sc-card);
  outline: none;
  transition: border-color 0.18s var(--sc-ease);
  line-height: 1.4;
}
.sc-input:focus {
  border-color: var(--sc-accent);
  box-shadow: 0 0 0 3px rgba(138, 106, 42, 0.10);
}
.sc-input::placeholder { color: var(--sc-ink-faint); }

.sc-send {
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--sc-accent-line, rgba(138,106,42,0.3));
  background: linear-gradient(135deg, rgba(138, 106, 42, 0.10) 0%, rgba(45, 110, 106, 0.12) 100%);
  color: var(--sc-accent);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: all 0.18s var(--sc-ease);
}
.sc-send:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(138, 106, 42, 0.20) 0%, rgba(45, 110, 106, 0.22) 100%);
  color: var(--sc-ink);
  border-color: var(--sc-accent);
}
.sc-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sc-footer {
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  color: var(--sc-ink-faint);
  text-align: center;
  padding: 0 12px 8px;
  background: var(--sc-paper);
}

/* mobile: full-screen panel from any avatar position */
@media (max-width: 540px) {
  .sc-panel {
    position: fixed;
    inset: auto 8px 8px 8px;
    width: auto;
    height: min(620px, calc(100dvh - 16px));
    transform-origin: bottom center;
  }
}

/* respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .sc-avatar, .sc-panel, .sc-typing span { transition: none !important; animation: none !important; }
  .sc-avatar.sc-pulsing::after { display: none; }
}
