/* Torchsec AI chat widget — inherits the site's dark theme + design tokens (style.css) */

.tsc-launcher {
  position: fixed;
  right: clamp(16px, 4vw, 28px);
  bottom: clamp(16px, 4vw, 28px);
  z-index: 9000;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 1.1rem 0.7rem 0.85rem;
  border: 1px solid color-mix(in oklab, var(--color-primary) 45%, var(--color-border));
  border-radius: 999px;
  background: linear-gradient(180deg,
    color-mix(in oklab, var(--color-primary) 22%, var(--color-surface)),
    var(--color-surface));
  color: var(--color-text);
  font-family: var(--font-body, sans-serif);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(0, 0, 0, 0.2);
  transition: transform 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}
.tsc-launcher:hover { transform: translateY(-2px); border-color: var(--color-primary); }
.tsc-launcher:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.tsc-launcher svg { width: 20px; height: 20px; color: var(--color-primary); }
.tsc-launcher[hidden] { display: none; }

.tsc-panel {
  position: fixed;
  right: clamp(12px, 4vw, 28px);
  bottom: clamp(12px, 4vw, 28px);
  z-index: 9001;
  width: min(380px, calc(100vw - 24px));
  height: min(560px, calc(100vh - 24px));
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  font-family: var(--font-body, sans-serif);
  color: var(--color-text);
}
.tsc-panel.is-open { display: flex; animation: tsc-rise 0.22s ease; }
@keyframes tsc-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .tsc-panel.is-open { animation: none; } }

.tsc-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-2);
}
.tsc-head-mark {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  flex: none;
  border-radius: 50%;
  background: color-mix(in oklab, var(--color-primary) 18%, var(--color-surface));
  border: 1px solid color-mix(in oklab, var(--color-primary) 40%, var(--color-border));
}
.tsc-head-mark svg { width: 18px; height: 18px; color: var(--color-primary); }
.tsc-head-text { display: flex; flex-direction: column; line-height: 1.2; }
.tsc-head-text strong { font-family: var(--font-display, sans-serif); font-size: 0.98rem; }
.tsc-head-text span { font-size: 0.72rem; color: var(--color-text-dim, #9a9aa3); }
.tsc-head-text span::before {
  content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 5px;
  border-radius: 50%; background: #3ddc84; vertical-align: middle;
}
.tsc-close {
  margin-left: auto;
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
}
.tsc-close:hover { background: var(--color-surface-offset); border-color: var(--color-border); }
.tsc-close:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.tsc-close svg { width: 18px; height: 18px; }

.tsc-log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  scrollbar-width: thin;
}
.tsc-msg {
  max-width: 86%;
  padding: 0.6rem 0.8rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.tsc-msg a { color: var(--color-primary); }
.tsc-msg--bot {
  align-self: flex-start;
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 4px;
}
.tsc-msg--user {
  align-self: flex-end;
  background: color-mix(in oklab, var(--color-primary) 22%, var(--color-surface-2));
  border: 1px solid color-mix(in oklab, var(--color-primary) 35%, var(--color-border));
  border-bottom-right-radius: 4px;
}
.tsc-msg--error {
  align-self: center;
  background: color-mix(in oklab, var(--color-primary) 10%, var(--color-surface));
  border: 1px dashed color-mix(in oklab, var(--color-primary) 50%, var(--color-border));
  font-size: 0.82rem;
  color: var(--color-text-dim, #c9c9d0);
}

.tsc-typing { display: inline-flex; gap: 4px; align-items: center; }
.tsc-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-text-dim, #8a8a93);
  animation: tsc-blink 1.2s infinite ease-in-out;
}
.tsc-typing span:nth-child(2) { animation-delay: 0.2s; }
.tsc-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes tsc-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.tsc-suggest {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  padding: 0 1rem 0.6rem;
}
.tsc-suggest button {
  font-family: inherit;
  font-size: 0.78rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  cursor: pointer;
}
.tsc-suggest button:hover { border-color: color-mix(in oklab, var(--color-primary) 45%, var(--color-border)); }

.tsc-foot { border-top: 1px solid var(--color-border); padding: 0.7rem; }
.tsc-form { display: flex; gap: 0.5rem; align-items: flex-end; }
.tsc-input {
  flex: 1;
  resize: none;
  max-height: 120px;
  min-height: 42px;
  padding: 0.6rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--color-text);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: 10px;
}
.tsc-input:focus-visible { outline: none; border-color: color-mix(in oklab, var(--color-primary) 55%, var(--color-border)); }
.tsc-send {
  flex: none;
  display: grid; place-items: center;
  width: 42px; height: 42px;
  border: none;
  border-radius: 10px;
  background: var(--color-primary);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.tsc-send:disabled { opacity: 0.45; cursor: default; }
.tsc-send:focus-visible { outline: 2px solid #fff; outline-offset: -3px; }
.tsc-send svg { width: 18px; height: 18px; }

.tsc-turnstile { margin-top: 0.55rem; min-height: 0; display: flex; justify-content: center; }
.tsc-turnstile:empty { margin-top: 0; }
.tsc-disclaimer {
  margin: 0.5rem 2px 0;
  font-size: 0.68rem;
  line-height: 1.4;
  color: var(--color-text-dim, #84848d);
  text-align: center;
}
.tsc-disclaimer a { color: inherit; text-decoration: underline; }
