/* Equallto Assistant: chat UI shown inside the iframe.
   Brand reference: equallto.com (font Outfit; colours sampled from the site and logo). */

@font-face {
  font-family: "Outfit";
  src: url("assets/Outfit-Variable.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* brand */
  --eq-blue: #1d5aa9;
  --eq-blue-hover: #174a8c;
  --eq-blue-soft: #eef3fa;     /* tints of the blue for hovers and chips */
  --eq-blue-line: #c9d9ef;
  --eq-orange: #f05829;        /* accent only: fails contrast for text */
  --eq-cyan: #00aeee;          /* accent only: fails contrast for text */
  --eq-white: #ffffff;
  --eq-grey: #f2f2f2;
  --eq-text: #263445;
  --eq-text-2: #64748b;        /* secondary text: use on white only (4.8:1) */
  --eq-on-blue-2: #d6e4f5;     /* secondary text on blue (5.3:1) */
  --eq-border: #e3e8ef;
  --eq-danger: #b42318;
  --eq-success: #22c55e;

  /* roles */
  --bg: var(--eq-white);
  --surface: var(--eq-grey);
  --text: var(--eq-text);
  --muted: var(--eq-text-2);
  --brand: var(--eq-blue);
  --brand-contrast: var(--eq-white);
  --focus: var(--eq-cyan);

  /* shape and motion */
  --font: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgb(38 52 69 / .06), 0 1px 3px rgb(38 52 69 / .08);
  --shadow-md: 0 4px 14px rgb(29 90 169 / .14);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --fast: 150ms;
  --med: 240ms;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
button, textarea { font: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.app {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  background: var(--bg);
}

/* ------------------------------------------------------------------ header */
.header {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 10px 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: var(--brand); color: var(--brand-contrast);
}
.header::after { /* thin brand accent: orange into cyan, as in the logo */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, var(--eq-orange), var(--eq-cyan));
}
.brand-mark {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  background: var(--eq-white); border-radius: 50%; box-shadow: 0 2px 6px rgb(0 0 0 / .15);
}
.brand-mark img { display: block; width: 22px; height: auto; }
.header-text { flex: 1; min-width: 0; }
.header h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: .1px; line-height: 1.25; }
.subtitle { margin: 1px 0 0; font-size: 12.5px; color: var(--eq-on-blue-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark { position: relative; }
.status { position: absolute; right: -1px; bottom: -1px; display: block; }
.status-dot { display: block; width: 12px; height: 12px; border-radius: 50%; background: var(--eq-success); box-shadow: 0 0 0 2px var(--brand); }
.status.offline .status-dot { background: #fbbf24; }
.header-actions { display: flex; gap: 2px; }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer;
  background: transparent; border: 0; border-radius: 10px; color: inherit;
  transition: background-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { background: rgb(255 255 255 / .16); }
.icon-btn:active { transform: scale(.94); }
.header :focus-visible { outline: 2px solid var(--eq-white); outline-offset: 1px; }

/* ------------------------------------------------------------------ scroll area */
.scroll {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 16px 8px;
  scroll-behavior: smooth;
  scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent;
}

/* welcome */
.welcome { animation: rise var(--med) var(--ease) both; }
.welcome-mark {
  width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 12px;
  background: var(--eq-white); border: 1px solid var(--eq-border); border-radius: 14px; box-shadow: var(--shadow-sm);
}
.welcome-mark img { width: 28px; height: auto; display: block; }
.welcome-title { margin: 0 0 4px; font-size: 22px; font-weight: 600; color: var(--brand); line-height: 1.25; }
.welcome-text { margin: 0 0 16px; color: var(--text); font-weight: 300; font-size: 15.5px; }
/* once the conversation starts the greeting stays, smaller, as its opening line */
.welcome.compact { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--eq-border); }
.welcome.compact .welcome-mark { display: none; }
.welcome.compact .welcome-title { font-size: 16px; }
.welcome.compact .welcome-text { margin: 0; font-size: 14px; color: var(--muted); }
.suggestions { display: grid; gap: 8px; margin-bottom: 8px; }
.suggestions:empty { display: none; }
.suggestion {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  padding: 11px 12px 11px 14px; color: var(--text); font-size: 14.5px; font-weight: 400;
  background: var(--eq-white); border: 1px solid var(--eq-border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease),
              transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
  animation: rise var(--med) var(--ease) both;
}
.suggestion:nth-child(2) { animation-delay: 40ms; }
.suggestion:nth-child(3) { animation-delay: 80ms; }
.suggestion:nth-child(4) { animation-delay: 120ms; }
.suggestion span { flex: 1; }
.suggestion svg { width: 17px; height: 17px; color: var(--brand); transition: transform var(--fast) var(--ease); }
.suggestion:hover { border-color: var(--eq-blue-line); background: var(--eq-blue-soft); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.suggestion:hover svg { transform: translateX(3px); }
.suggestion:active { transform: translateY(0); }

/* ------------------------------------------------------------------ messages */
.messages { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.row { display: flex; gap: 8px; align-items: flex-end; animation: rise var(--med) var(--ease) both; }
.row.user { justify-content: flex-end; }
.row.bot { align-items: flex-start; }
.row.bot .avatar { margin-top: 4px; }
.avatar {
  width: 28px; height: 28px; flex: none; display: grid; place-items: center;
  background: var(--eq-white); border: 1px solid var(--eq-border); border-radius: 50%;
}
.avatar img { width: 15px; height: auto; display: block; }
.stack { display: flex; flex-direction: column; gap: 8px; min-width: 0; max-width: 86%; }
.row.user .stack { align-items: flex-end; }

.bubble { padding: 10px 14px; border-radius: var(--radius-lg); overflow-wrap: anywhere; }
.row.user .bubble {
  background: var(--brand); color: var(--brand-contrast); border-bottom-right-radius: 6px;
  white-space: pre-wrap; box-shadow: 0 2px 6px rgb(29 90 169 / .18);
}
.row.bot .bubble { background: var(--surface); color: var(--text); border-bottom-left-radius: 6px; }
.bubble p { margin: 0; }
.bubble p + p, .bubble p + ul, .bubble p + ol, .bubble ul + p, .bubble ol + p { margin-top: 8px; }
.bubble ul, .bubble ol { margin: 6px 0 0; padding-left: 20px; }
.bubble li + li { margin-top: 3px; }
.bubble li::marker { color: var(--brand); }
.bubble strong { font-weight: 600; }
.bubble a { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: rgb(29 90 169 / .4); }
.bubble a:hover { text-decoration-color: currentColor; }
.cite {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; margin: 0 1px;
  font-size: 11px; font-weight: 600; line-height: 1; vertical-align: 2px;
  color: var(--brand) !important; background: var(--eq-white); border: 1px solid var(--eq-blue-line);
  border-radius: 6px; text-decoration: none !important;
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.cite:hover { background: var(--brand); color: var(--brand-contrast) !important; }

/* error */
.row.bot .bubble.error { background: #fef3f2; color: var(--eq-danger); border: 1px solid #fecdca; display: flex; gap: 8px; }
.bubble.error svg { width: 18px; height: 18px; margin-top: 2px; }
.retry {
  margin-top: 8px; display: inline-block; cursor: pointer; font-size: 13.5px; font-weight: 500;
  color: var(--eq-danger); background: var(--eq-white); border: 1px solid currentColor; border-radius: 999px; padding: 3px 12px;
}
.retry:hover { background: #fee4e2; }

/* sources */
.sources { animation: fade 320ms var(--ease) 120ms both; }
.sources-label { display: flex; align-items: center; gap: 5px; margin: 0 0 5px 2px; font-size: 12px; font-weight: 500; color: var(--muted); }
.sources-label svg { width: 14px; height: 14px; }
.sources ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.source {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; text-decoration: none;
  color: var(--text); background: var(--eq-white); border: 1px solid var(--eq-border); border-radius: var(--radius-sm);
  font-size: 13px; line-height: 1.35;
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.source-num {
  flex: none; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 6px;
  font-size: 11px; font-weight: 600; color: var(--brand); background: var(--eq-blue-soft);
}
.source-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source svg { width: 15px; height: 15px; color: var(--muted); transition: transform var(--fast) var(--ease), color var(--fast) var(--ease); }
.source:hover { border-color: var(--eq-blue-line); background: var(--eq-blue-soft); }
.source:hover svg { color: var(--brand); transform: translate(2px, -2px); }

/* thinking indicator */
.thinking .bubble { display: inline-flex; align-items: center; gap: 10px; padding: 12px 14px; }
.dots { display: inline-flex; gap: 4px; }
.dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); animation: bounce 1.2s infinite var(--ease); }
.dots span:nth-child(2) { animation-delay: .15s; background: #4a7cc0; }
.dots span:nth-child(3) { animation-delay: .3s; background: #7aa0d4; }
.thinking-label { font-size: 13px; color: var(--text); }

/* ------------------------------------------------------------------ composer */
.composer { padding: 10px 14px; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--eq-border); }
.field {
  display: flex; align-items: flex-end; gap: 8px; padding: 5px 5px 5px 14px;
  background: var(--eq-white); border: 1.5px solid var(--eq-border); border-radius: 24px;
  transition: border-color var(--fast) var(--ease), box-shadow var(--med) var(--ease);
}
.field:hover { border-color: var(--eq-blue-line); }
.field:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px rgb(29 90 169 / .12); }
.field textarea {
  flex: 1; resize: none; border: 0; outline: 0; background: transparent; color: var(--text);
  padding: 8px 0; max-height: 120px; line-height: 1.4;
  font-size: 16px; /* 16px stops iOS Safari zooming on focus */
}
.field textarea::placeholder { color: var(--muted); }
.send {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center; cursor: pointer;
  border: 0; border-radius: 50%; background: var(--brand); color: var(--brand-contrast);
  transition: background-color var(--fast) var(--ease), transform var(--fast) var(--ease), opacity var(--fast) var(--ease);
}
.send svg { width: 18px; height: 18px; margin: 1px 1px 0 0; }
.send:hover:not(:disabled) { background: var(--eq-blue-hover); transform: scale(1.05); }
.send:active:not(:disabled) { transform: scale(.95); }
.send:disabled { background: #cbd5e1; cursor: not-allowed; }
.footnote { margin: 7px 0 0; text-align: center; font-size: 11.5px; color: var(--muted); }
.counter { margin-right: 6px; font-variant-numeric: tabular-nums; }
.counter.over { color: var(--eq-danger); font-weight: 600; }

/* ------------------------------------------------------------------ motion */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bounce { 0%, 70%, 100% { transform: translateY(0); opacity: .55; } 35% { transform: translateY(-5px); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  .dots span { animation: none !important; opacity: .7; }
}

@media (max-width: 420px) {
  .scroll { padding: 14px 12px 6px; }
  .stack { max-width: 90%; }
  .composer { padding-left: 10px; padding-right: 10px; }
}
