/* The AI chat answer loader that clears from the haze: the reply panel of an AI analytics assistant on a near black page. The
   answer's words are real text (for reading, copying and screen readers); over them the WebGL canvas draws the same
   words seen through hot air while the model thinks. Without WebGL the text blurs with CSS and a thin line sweeps it. */
:root {
  --page: #0a0a0c;           /* the page */
  --panel: #131317;          /* the panel */
  --panel-top: #18181d;      /* the top of the panel, a touch lighter */
  --edge: rgba(255, 255, 255, 0.075); /* its 1px edge */
  --ink: #ececf1;            /* the words */
  --muted: #8b8b97;          /* the small words */
  --faint: #5c5c66;          /* the quietest words */
  --heat: #ff9a5a;           /* the warm light of the haze and of the line */
  --cool: #8f80ff;           /* the cool light under it */
  --good: #6fd3a5;           /* the number that went the right way */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background:
    radial-gradient(120% 70% at 50% 0%, #121218 0%, transparent 60%),
    var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

/* ---------------------------------------------------------------- the panel */
.chat {
  position: relative;
  width: min(90vw, 360px);
  padding: clamp(12px, 3.4vh, 20px) clamp(14px, 4.6vw, 20px) clamp(12px, 3vh, 18px);
  border-radius: 22px;
  background: linear-gradient(180deg, var(--panel-top), var(--panel) 40%);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 24px 48px -20px rgba(0, 0, 0, 0.85),
    0 60px 90px -50px rgba(0, 0, 0, 0.9);
  opacity: 0;
}

/* a fine grain over the panel, so the dark is a material and not a flat fill */
.chat::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.chat__head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat__mark {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.3;
  stroke-linecap: round;
}

.chat__brand {
  font-size: 14px;
  font-weight: 620;
  font-variation-settings: 'wdth' 108;
  letter-spacing: 0.01em;
}

.chat__model {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* the question, a bubble on the right */
.chat__ask {
  margin: clamp(10px, 3vh, 18px) 0 0 auto;
  width: fit-content;
  max-width: 82%;
  padding: 8px 13px;
  border-radius: 16px 16px 5px 16px;
  font-size: 13.5px;
  line-height: 1.35;
  color: var(--ink);
  background: linear-gradient(180deg, #24242b, #1e1e24);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 6px 14px -8px rgba(0, 0, 0, 0.8);
}

.chat__reply {
  margin-top: clamp(8px, 2.4vh, 14px);
}

/* ---------------------------------------------------------------- the status line */
.chat__status {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  font-size: 12.5px;
  color: var(--muted);
}

.chat__spark {
  width: 13px;
  height: 13px;
  fill: var(--heat);
  flex: none;
}

/* "Thinking" with a light that runs through the letters (--sx moves it) */
.chat__status-words {
  --sx: -40%;
  font-weight: 540;
  background: linear-gradient(100deg, var(--muted) calc(var(--sx) - 18%), #ffffff var(--sx), var(--muted) calc(var(--sx) + 18%));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.chat__secs {
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.chat__chev {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: var(--faint);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

/* ---------------------------------------------------------------- the answer */
.chat__answer {
  position: relative;
  margin-top: clamp(4px, 1.2vh, 8px);
}

.chat__text {
  position: relative;
  margin: 0;
  font-size: 14px;
  font-weight: 420;
  line-height: 21px;
  color: var(--ink);
}

/* with WebGL the canvas draws the words; the real text stays for selection and reading, invisible */
.gl .chat__text {
  color: transparent;
}

.gl.settled .chat__text {
  color: var(--ink);
}

.chat__haze {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  pointer-events: none;
}

.gl.settled .chat__haze {
  visibility: hidden;
}

/* without WebGL: a blur on the words and a thin warm line that sweeps them */
.chat__front {
  position: absolute;
  left: -4px;
  right: -4px;
  top: 0;
  height: 1px;
  z-index: 2;
  pointer-events: none;
  display: none;
  background: linear-gradient(90deg, transparent, var(--heat) 25%, #ffffff 50%, var(--heat) 75%, transparent);
  box-shadow: 0 0 10px 1px color-mix(in srgb, var(--heat) 60%, transparent);
  opacity: 0;
}

.no-gl .chat__front {
  display: block;
}

/* ---------------------------------------------------------------- the numbers */
.chat__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: clamp(10px, 2.6vh, 14px);
  padding: 9px 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  position: relative;
}

/* while it thinks, three quiet placeholders wait in the box, with a sheen that passes (--sk moves it) */
.chat__skels {
  --sk: -30%;
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-content: center;
  pointer-events: none;
}

.chat__skels i {
  display: grid;
  gap: 7px;
  padding: 0 12px;
}

.chat__skels i + i {
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.06);
}

.chat__skels i::before,
.chat__skels i::after {
  content: '';
  height: 9px;
  width: 62%;
  border-radius: 5px;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0.05) calc(var(--sk) - 25%), rgba(255, 255, 255, 0.11) var(--sk), rgba(255, 255, 255, 0.05) calc(var(--sk) + 25%));
}

.chat__skels i::after {
  height: 7px;
  width: 44%;
}

.chat__stat {
  display: grid;
  gap: 2px;
  padding: 0 12px;
  opacity: 0;
}

.chat__stat + .chat__stat {
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.06);
}

.chat__num {
  display: flex;
  align-items: center;
  font-size: 15px;
  font-weight: 620;
  font-variation-settings: 'wdth' 96;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chat__num--down {
  color: var(--good);
}

.chat__num svg {
  width: 11px;
  height: 11px;
  margin-right: 3px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat__label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- the actions */
.chat__actions {
  display: flex;
  gap: 6px;
  margin-top: clamp(8px, 2.2vh, 12px);
}

.chat__act {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px 0 9px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 520;
  cursor: pointer;
  opacity: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  -webkit-tap-highlight-color: transparent;
  transition: color 0.25s ease, background-color 0.25s ease, box-shadow 0.25s ease;
}

.chat__act svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (hover: hover) {
  .chat__act:hover {
    color: var(--ink);
    background-color: rgba(255, 255, 255, 0.04);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  }
}

.chat__act:focus-visible {
  outline: 2px solid var(--heat);
  outline-offset: 2px;
}
