/* chat-widget.css — Socratii Concierge floating chat widget */

.sc-chat-fab {
  position: fixed;
  right: var(--space-6);
  bottom: var(--space-6);
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  z-index: 9998;
  transition: transform var(--transition-interactive), background var(--transition-interactive);
}

.sc-chat-fab:hover {
  background: var(--color-primary-hover);
  transform: translateY(-2px);
}

.sc-chat-fab svg {
  width: 24px;
  height: 24px;
}

.sc-chat-fab .sc-chat-fab-icon-close {
  display: none;
}

.sc-chat-fab[aria-expanded='true'] .sc-chat-fab-icon-open {
  display: none;
}

.sc-chat-fab[aria-expanded='true'] .sc-chat-fab-icon-close {
  display: block;
}

.sc-chat-fab-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--color-gold);
  border: 2px solid var(--color-bg);
}

.sc-chat-panel {
  position: fixed;
  right: var(--space-6);
  bottom: calc(var(--space-6) + 68px);
  width: 380px;
  max-width: calc(100vw - 2 * var(--space-4));
  height: 540px;
  max-height: calc(100vh - 140px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 200ms var(--ease-out-expo), transform 200ms var(--ease-out-expo);
}

.sc-chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.sc-chat-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  flex-shrink: 0;
}

.sc-chat-header-mark {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sc-chat-header-mark img {
  width: 18px;
  height: 18px;
  display: block;
}

.sc-chat-header-text {
  flex: 1;
  min-width: 0;
}

.sc-chat-header-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
  line-height: 1.2;
}

.sc-chat-header-tagline {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-top: 2px;
}

.sc-chat-close {
  background: none;
  border: none;
  color: var(--color-text-inverse);
  opacity: 0.8;
  cursor: pointer;
  padding: var(--space-1);
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.sc-chat-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

.sc-chat-close svg {
  width: 18px;
  height: 18px;
}

.sc-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--color-bg);
}

.sc-chat-welcome {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
  padding-bottom: var(--space-1);
}

.sc-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding-bottom: var(--space-2);
}

.sc-chat-chip {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: border-color var(--transition-interactive), background var(--transition-interactive);
}

.sc-chat-chip:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-highlight);
}

.sc-chat-msg {
  max-width: 88%;
  font-size: var(--text-xs);
  line-height: 1.55;
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
}

.sc-chat-msg.is-user {
  align-self: flex-end;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-bottom-right-radius: var(--radius-sm);
}

.sc-chat-msg.is-assistant {
  align-self: flex-start;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  border-bottom-left-radius: var(--radius-sm);
}

.sc-chat-attribution {
  display: block;
  margin-top: var(--space-2);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--color-text-muted);
}

.sc-chat-attribution a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sc-chat-attribution a:hover { color: var(--color-primary); }

.sc-chat-msg.is-error {
  background: var(--color-error-highlight);
  border-color: var(--color-error);
  color: var(--color-error);
}

.sc-chat-sources {
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 88%;
  margin-top: calc(-1 * var(--space-2));
}

.sc-chat-source-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-primary);
  background: var(--color-primary-highlight);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  text-decoration: none;
  transition: background var(--transition-interactive);
}

.sc-chat-source-link:hover {
  background: var(--color-gold-highlight);
  color: var(--color-text);
}

.sc-chat-source-link svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.sc-chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-sm);
}

.sc-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-text-faint);
  animation: sc-chat-bounce 1.2s infinite ease-in-out;
}

.sc-chat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.sc-chat-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes sc-chat-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.sc-chat-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--color-border);
  padding: var(--space-3);
  background: var(--color-surface);
}

.sc-chat-disclaimer {
  font-size: 10px;
  color: var(--color-text-faint);
  line-height: 1.4;
  margin-bottom: var(--space-2);
}

.sc-chat-form {
  display: flex;
  gap: var(--space-2);
}

.sc-chat-input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-3) var(--space-4);
}

.sc-chat-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.sc-chat-send {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  border: none;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-interactive);
}

.sc-chat-send:hover {
  background: var(--color-primary-hover);
}

.sc-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sc-chat-send svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 480px) {
  .sc-chat-panel {
    right: var(--space-3);
    left: var(--space-3);
    width: auto;
    bottom: calc(var(--space-6) + 68px);
  }

  .sc-chat-fab {
    right: var(--space-4);
    bottom: var(--space-4);
  }
}

/* ------------------------------------------------------------------
   Front-page hero chat (index.html). Large composer + inline thread.
   Shares messages with the floating panel.
------------------------------------------------------------------- */
.hero--chat .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0;
  max-width: 880px;
}
.hero--chat {
  padding-block: clamp(var(--space-12), 8vw, var(--space-24)) clamp(var(--space-10), 6vw, var(--space-16));
}
.hc-intro .eyebrow { margin-bottom: var(--space-4); }
.hc-intro h1 {
  font-size: clamp(2.4rem, 1.4rem + 3.6vw, 4.25rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.hc-intro h1 em { font-style: normal; color: var(--color-primary); }
.hc-intro p {
  margin: var(--space-5) auto 0;
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  max-width: 56ch;
  text-wrap: pretty;
}

.hero-chat {
  width: 100%;
  margin-top: var(--space-10);
  text-align: left;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  transition: border-color 180ms ease, box-shadow 180ms ease;
  overflow: hidden;
}
.hero-chat:focus-within {
  border-color: oklch(from var(--color-primary) l c h / 0.55);
  box-shadow: var(--shadow-lg), 0 0 0 4px oklch(from var(--color-primary) l c h / 0.12);
}

.hc-thread {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-height: min(56vh, 560px);
  overflow-y: auto;
  padding: var(--space-6) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--color-divider, var(--color-border));
  background: var(--color-bg);
  overscroll-behavior: contain;
}
.hc-thread[hidden] { display: none; }
.hc-thread .sc-chat-msg {
  font-size: var(--text-base);
  max-width: 82%;
  padding: var(--space-3) var(--space-5);
}
.hc-thread .sc-chat-sources {
  flex-direction: row;
  flex-wrap: wrap;
  max-width: 100%;
  margin-top: calc(-1 * var(--space-1));
}
.hc-thread .sc-chat-source-link { font-size: var(--text-sm); }

.hc-form { display: block; padding: var(--space-4) var(--space-4) var(--space-3) var(--space-6); }
.hc-input {
  display: block;
  width: 100%;
  min-height: 56px;
  max-height: 200px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-lg);
  line-height: 1.5;
  padding: var(--space-2) 0 0;
}
.hc-input::placeholder { color: var(--color-text-faint); }
.hc-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-2);
}
.hc-hint {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}
.hc-send {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  cursor: pointer;
  transition: transform 150ms ease, opacity 150ms ease;
}
.hc-send:hover { transform: translateY(-1px); }
.hc-send:disabled { opacity: 0.5; cursor: progress; }
.hc-send svg { width: 20px; height: 20px; }
.hc-send:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; }

.hc-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-5);
}
.hc-chips button {
  font: inherit;
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease;
}
.hc-chips button:hover { border-color: var(--color-primary); color: var(--color-primary); }
.hero-chat.has-thread ~ .hc-chips { display: none; }

.hc-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2) var(--space-3);
  margin-top: var(--space-8);
  font-size: var(--text-sm);
  color: var(--color-text-faint);
}
.hc-foot a { color: var(--color-primary); font-weight: 600; text-decoration: none; }
.hc-foot a:hover { text-decoration: underline; }
.hero--chat .hero-note { margin-top: var(--space-3); }

/* Floating button hides while the big box is on screen. */
body.has-hero-chat.hero-chat-visible .sc-chat-fab {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}
.sc-chat-fab { transition: opacity 200ms ease, transform 200ms ease, background var(--transition-interactive); }

@media (max-width: 640px) {
  .hero-chat { border-radius: 20px; margin-top: var(--space-8); }
  .hc-form { padding-left: var(--space-4); }
  .hc-input { font-size: var(--text-base); }
  .hc-hint { font-size: 11px; line-height: 1.35; }
  .hc-thread { padding: var(--space-4); max-height: 60vh; }
  .hc-thread .sc-chat-msg { max-width: 92%; font-size: var(--text-sm); }
  .hc-chips button { font-size: var(--text-xs); }
}

/* Once a conversation starts, compact the intro so the thread and composer fit. */
.hero--chat:has(.hero-chat.has-thread) .hc-intro p { display: none; }
.hero--chat:has(.hero-chat.has-thread) .hc-intro h1 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.5rem); }
.hero--chat:has(.hero-chat.has-thread) .hero-chat { margin-top: var(--space-6); }
.hero--chat:has(.hero-chat.has-thread) { padding-top: clamp(var(--space-8), 5vw, var(--space-12)); }

/* Label on answers written with AI help. */
.sc-chat-ai-tag {
  align-self: flex-start;
  margin-top: calc(-1 * var(--space-2));
  font-size: 11px;
  line-height: 1.4;
  color: var(--color-text-muted);
}
.sc-chat-msg.is-assistant { white-space: pre-line; }
/* Scroll containers are the offset parent, so offsetTop is measured from them. */
.hc-thread, .sc-chat-body { position: relative; }
