/* Chat bot demo: only what is special to this page. Tokens, cards, chips, buttons, the guide and the folds come from /_s/shell.css. */
/* one chat window; "Behind the scenes" opens beside it */
.work { display: grid; grid-template-columns: minmax(0, 720px); justify-content: start; gap: 16px; align-items: stretch; }
.work.sr-open { grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); justify-content: stretch; }
@media (max-width: 900px) { .work, .work.sr-open { grid-template-columns: minmax(0, 1fr); } }
.card-head { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h2 { margin: 0 auto 0 0; }
.card-head .linkish { min-height: 32px; }
.chat, .sr-scenes { display: flex; flex-direction: column; min-width: 0; }
.chat .row { margin: 12px 0 0; flex-wrap: nowrap; }
.chat .row input[type=text] { flex: 1 1 120px; }
.chat .row button { min-height: 46px; }
#typed-note { margin: 8px 0 0; }
#botcheck:not(:empty) { margin-top: 10px; }

/* the conversation */
.log { height: clamp(240px, 36vh, 400px); overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 12px; background: var(--surface2); border: 1px solid var(--grid); border-radius: var(--r-sm); }
.msg { max-width: 86%; padding: 9px 13px; border-radius: 16px 16px 16px 4px; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--grid); background: var(--surface); align-self: flex-start; line-height: 1.45; }
.msg.visitor { align-self: flex-end; border-radius: 16px 16px 4px 16px; background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 38%, var(--grid)); }
.msg.proactive { border-style: dashed; border-color: var(--field); }
.msg .meta { display: block; font: 500 .68rem var(--mono); color: var(--muted); letter-spacing: .03em; margin-bottom: 2px; }
.msg .btns { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.msg .btns button { min-height: 44px; }
.msg .btns button[data-button="confirm_yes"] { background: var(--accent-ink); border-color: var(--accent-ink); color: var(--on-accent); }
.log > p { margin: 0; align-self: center; }

/* behind the scenes: a server log in a terminal. Always dark, in both themes, like a real one. */
.term { --t-bg: #12110e; --t-bar: #1d1b17; --t-line: #2a2722; --t-ink: #e9e5db; --t-dim: #8d8778; --t-in: #82b4e6; --t-sql: #93c98b; --t-write: #e2b55c;
  --t-ai: #ec9a76; --t-ok: #93c98b; --t-bad: #f0897a; --t-warn: #e2b55c;
  display: flex; flex-direction: column; min-width: 0; background: var(--t-bg); color: var(--t-ink); border: 1px solid #000; border-radius: var(--r); overflow: hidden;
  box-shadow: var(--shadow); font: 400 .78rem/1.5 var(--mono); }
.term-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--t-bar); border-bottom: 1px solid var(--t-line); }
.term-dots { display: flex; gap: 8px; }
.term-btn { position: relative; width: 13px; height: 13px; min-height: 0; padding: 0; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; }
.term-btn::after { content: ""; position: absolute; inset: -8px; }                          /* a bigger target than the dot */
.term-btn.t-close { background: #e0705f; } .term-btn.t-min { background: #d9a441; } .term-btn.t-wide { background: #5fae62; }
.term-btn svg { width: 9px; height: 9px; fill: none; stroke: #2a1a14; stroke-width: 1.4; stroke-linecap: round; opacity: 0; transition: opacity .12s; }
.term-dots:hover .term-btn svg, .term-btn:focus-visible svg { opacity: .85; }
.term-btn:hover { filter: brightness(1.08); } .term-btn:focus-visible { outline: 2px solid var(--t-in); outline-offset: 2px; }
.term-bar h2 { margin: 0 auto 0 0; font: 600 .8rem var(--mono); color: var(--t-ink); letter-spacing: .02em; }
.term-title { all: unset; cursor: default; } .term-title span { color: var(--t-dim); font-weight: 400; }
.term.min .term-title { cursor: pointer; } .term.min .term-title:hover { color: #fff; }
/* minimized: only the title bar, in the terminal's own place */
.term.min { align-self: start; } .term.min .term-bar { border-bottom: 0; } .term.min .term-intro, .term.min .term-body { display: none; }
/* widened: the terminal over both columns, the conversation underneath */
.work.sr-open.term-wide { grid-template-columns: minmax(0, 1fr); }
.work.term-wide .term { order: -1; } .work.term-wide .term-body { max-height: 460px; min-height: 260px; }
@media (max-width: 900px) { .term-btn.t-wide { display: none; } }                     /* one column already: nothing to widen */
.term-live { display: flex; align-items: center; gap: 6px; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--t-ok); }
.term-live i { width: 7px; height: 7px; border-radius: 50%; background: var(--t-ok); animation: term-pulse 1.6s ease-in-out infinite; }
@keyframes term-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .term-live i { animation: none; } }
.term-intro { margin: 0; padding: 10px 14px; color: var(--t-dim); font: 400 .8rem/1.5 var(--sans); border-bottom: 1px dashed var(--t-line); }
.term-body { list-style: none; margin: 0; padding: 6px 0 14px; flex: 1; min-height: 320px; max-height: 640px; overflow-y: auto; scrollbar-color: #3a362f transparent; }
.term-body:focus-visible { outline: 2px solid var(--t-in); outline-offset: -2px; }
.turn { padding: 8px 14px 10px; border-bottom: 1px solid var(--t-line); animation: term-in .25s ease-out; }
@keyframes term-in { from { opacity: 0; transform: translateY(4px); } }
.ln { display: grid; grid-template-columns: 76px 52px minmax(0, 1fr); gap: 0 8px; padding: 1px 0; }
.ln .ts { color: var(--t-dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ln .tg { font-weight: 600; white-space: nowrap; color: var(--t-dim); }
.ln .tx { overflow-wrap: anywhere; white-space: pre-wrap; }
.ln .sub { display: block; color: var(--t-dim); }
.ln.in .tg, .ln.in .tx { color: var(--t-in); } .ln.in .tx { font-weight: 600; } .ln.in .ts { color: var(--t-ink); }
.ln.dim .tx { color: var(--t-dim); }
.ln.tool .tg { color: var(--t-ink); } .ln.tool .tx { color: var(--t-ink); font-weight: 600; }
.ln.sql .tg, .ln.sql .tx { color: var(--t-sql); } .ln.sql.write .tg, .ln.sql.write .tx { color: var(--t-write); }
.ln.ai .tg, .ln.ai .tx { color: var(--t-ai); }
.ln.emb .tg, .ln.emb .tx { color: #c4a5ee; }
.ln.rag .tg { color: #c4a5ee; } .ln.rag .tx { color: var(--t-ink); } .ln.rag.off .tx { color: var(--t-dim); text-decoration: line-through; text-decoration-color: #5a554b; }
.ln.ok .tg { color: var(--t-ok); } .ln.ok .tx { color: #c9c4b8; }
.ln.bad .tg, .ln.bad .tx { color: var(--t-bad); }
.ln.warn .tg, .ln.warn .tx { color: var(--t-warn); }
.ln.out .tg { color: var(--t-in); } .ln.out .tx { color: var(--t-ink); }
.ln.sum { margin-top: 3px; } .ln.sum .tg { color: var(--t-ok); } .ln.sum .tx { color: var(--t-dim); }
.ln.sum.bad .tg { color: var(--t-bad); }
@media (max-width: 600px) {
  .term { font-size: .72rem; border-radius: var(--r-sm); }
  .ln { grid-template-columns: 58px 44px minmax(0, 1fr); gap: 0 6px; }
  .turn { padding: 8px 10px; }
  .term-body { min-height: 240px; max-height: 70vh; }
}

/* more to try: three plain cards, always open */
.extras { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin: 28px 0 8px; }      /* one full-width card, whatever else is switched on */
.x-card { background: var(--surface); border: 1px solid var(--grid); border-radius: var(--r); padding: 20px 20px 18px; box-shadow: var(--shadow-sm); min-width: 0; }
.x-card h2 { margin: 0; font: 600 1.05rem var(--sans); letter-spacing: 0; }
.x-sub { margin: 4px 0 14px; color: var(--muted); font-size: .9rem; line-height: 1.45; }
.x-card.flash { animation: x-flash 1.2s var(--ease); }
@keyframes x-flash { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }
.ev-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 1000px) { .ev-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .ev-grid { grid-template-columns: minmax(0, 1fr); } }
.ev-grid .ev { grid-template-columns: 36px minmax(0, 1fr); align-items: start; } .ev-grid .ev-done { position: absolute; bottom: 8px; right: 10px; }
.ev { position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; min-height: 0; padding: 10px 12px;
  text-align: left; border-radius: var(--r-sm); background: var(--surface2); border: 1px solid transparent; color: var(--ink); font: inherit; cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), transform .12s; }
.ev:hover { background: var(--hover); border-color: var(--axis); } .ev:active { transform: scale(.99); }
.ev svg { width: 36px; height: 36px; padding: 8px; border-radius: 10px; background: var(--surface); color: var(--accent-ink); border: 1px solid var(--grid); }
.ev-words { display: grid; gap: 1px; min-width: 0; } .ev-words b { font-size: .92rem; font-weight: 600; } .ev-words small { color: var(--muted); font-size: .8rem; line-height: 1.35; }
.ev-done { font: 600 .68rem var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--goodtext); opacity: 0; transition: opacity .2s; }
.ev.sent { border-color: color-mix(in srgb, var(--good) 45%, transparent); background: var(--good-soft); } .ev.sent .ev-done { opacity: 1; }
.codebox { font: 500 .9rem var(--mono); background: var(--surface2); border: 1px solid var(--axis); border-radius: var(--r-sm); padding: .25rem .6rem; display: inline-block; user-select: all; }
#channels p { margin: .4rem 0; }
@media (prefers-reduced-motion: no-preference) {
  .msg, .turn { animation: chat-in 220ms var(--ease) both; }
  @keyframes chat-in { from { opacity: 0; transform: translateY(6px); } }
}
@media (max-width: 600px) { .log { height: clamp(180px, 32vh, 280px); } }

/* who the visitor is talking to: the bot's identity leads the page */
.bot-kicker { font: 600 .72rem var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--accent-ink); margin: 0 0 12px !important; }
.bot-id { display: flex; align-items: center; gap: 16px; }
.bot-id h1 { margin: 0; line-height: 1.1; }
.bot-avatar { flex: none; display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-sm); }
.bot-avatar svg { width: 30px; height: 30px; }
.bot-avatar.sm { width: 28px; height: 28px; box-shadow: none; }
.bot-avatar.sm svg { width: 15px; height: 15px; }
.sr-intro .bot-role { display: flex; align-items: center; gap: 8px; margin: 4px 0 0; font-size: .98rem; color: var(--muted); }
.bot-live { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.sr-intro .bot-you { margin-top: 16px; }
.card-head .chat-title { display: flex; align-items: center; gap: 9px; font-size: 1.04rem; }
@media (max-width: 600px) {
  .bot-avatar { width: 48px; height: 48px; } .bot-avatar svg { width: 24px; height: 24px; }
  .bot-id { gap: 12px; }
  .sr-intro .bot-role { font-size: .9rem; }
  .sr-intro .bot-you { margin-top: 12px; }
}
.card-head .restart { min-height: 0; width: 38px; height: 38px; padding: 0; display: grid; place-items: center; border-radius: 50%; background: none; border: 1px solid var(--axis); color: var(--ink2); }
.card-head .restart:hover { background: var(--hover); }
.card-head .restart svg { width: 17px; height: 17px; }

/* first visit in a tab session: one blurred veil covers the page and the bot's introduction sits above it (intro.js).
   Nothing moves: the layout is the same before and after, the button floats, and the reveal fades the single veil out. */
.bot-intro { position: relative; }
.intro-go { display: none; }
html.intro-on .intro-go:not([hidden]), html.intro-reveal .intro-go { display: inline-flex; }
.intro-go { position: absolute; left: 0; top: calc(100% + 18px); align-items: center; gap: 10px; min-height: 50px; padding: 0 22px 0 24px; border-radius: 999px;
  font-size: 1rem; white-space: nowrap; background: var(--accent-ink); border-color: var(--accent-ink); color: var(--on-accent);
  box-shadow: 0 10px 28px -10px color-mix(in srgb, var(--accent) 70%, transparent); }
.intro-go svg { width: 18px; height: 18px; transition: transform var(--dur) var(--ease); }
.intro-go:hover svg { transform: translateX(3px); }
@media (hover: hover) and (pointer: fine) { html { scrollbar-gutter: stable; } }   /* desktop: the page does not shift sideways when scrolling comes back */
html.intro-on, html.intro-on body { overflow: hidden; }
html.intro-on body::before, html.intro-reveal body::before { content: ""; position: fixed; inset: 0; z-index: 1000; pointer-events: none;
  background: color-mix(in srgb, var(--page) 62%, transparent); -webkit-backdrop-filter: blur(12px) saturate(.7); backdrop-filter: blur(12px) saturate(.7); }
html.intro-on .bot-intro, html.intro-reveal .bot-intro { z-index: 1001; }
html.intro-on .bot-kicker { opacity: .35; }
html.intro-reveal body::before { opacity: 0; -webkit-backdrop-filter: blur(0) saturate(1); backdrop-filter: blur(0) saturate(1);
  transition: opacity 1s cubic-bezier(.37, 0, .63, 1), backdrop-filter 1s cubic-bezier(.37, 0, .63, 1), -webkit-backdrop-filter 1s cubic-bezier(.37, 0, .63, 1); }
html.intro-reveal .bot-kicker { opacity: 1; transition: opacity 1s cubic-bezier(.37, 0, .63, 1); }
html.intro-reveal .intro-go { opacity: 0; transform: translateY(6px) scale(.96); pointer-events: none; transition: opacity .35s ease, transform .35s ease; }
@media (max-width: 600px) { .intro-go { right: 0; justify-content: center; } }
.sr-scenes-btn .term-emoji { font-size: 1.05em; line-height: 1; margin-right: 2px; }
.sr-scenes-btn[aria-expanded="true"] { display: none; }        /* only an opener: the terminal closes itself with its red button */

/* RAG, said quietly: the source under a document answer, and a soft note on the label */
.msg .cite { display: block; margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--grid); font: 400 .7rem/1.4 var(--mono); color: var(--muted); letter-spacing: 0; }
.hint-quiet { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); opacity: .8; }

/* questions under the chat: a quiet two-way switch, one row of chips at a time */
.qtabs { display: flex; gap: 18px; margin: 14px 0 10px; border-bottom: 1px solid var(--grid); }
.qtabs button { position: relative; padding: 0 0 8px; min-height: 0; background: none; border: 0; border-radius: 0; font: 600 .74rem var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); cursor: pointer; }
.qtabs button .hint-quiet { font-family: var(--mono); font-size: .7rem; }
.qtabs button[aria-selected="true"] { color: var(--ink); }
.qtabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.qtabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#quick button, #docq button { min-height: 34px; padding: 0 13px; font-size: .86rem; }
#typed-note { margin: 10px 0 0; font-size: .8rem; }
@media (max-width: 480px) { .qtabs .hint-quiet { display: none; } }
/* side by side: the conversation grows to the terminal's height instead of leaving a gap under the questions */
@media (min-width: 901px) {
  .work.sr-open:not(.term-wide) .chat { display: flex; flex-direction: column; }
  .work.sr-open:not(.term-wide) .chat .log { flex: 1 1 auto; height: auto; min-height: clamp(240px, 36vh, 400px); max-height: 720px; }
}
/* touch screens: no hover colour left on a tapped chip, and taller tab targets */
@media (hover: none) { .chips button:hover:not(:disabled) { background: var(--surface); border-color: var(--axis); } }
@media (pointer: coarse) { .qtabs button { padding: 12px 0 12px; } }
