/* GaiS agent chat mock-up — shared stylesheet (v1.3)
 *
 * Design standard: plans/agent-interface-design-standard.md.
 * Each agent supplies its own already-defined identity colour through the
 * body.agent-<slug> tokens below; the palette itself is unchanged from
 * css/styles.css. The palette is used for accent text, borders and fills,
 * with an accessible darkened/lightened "ink" variant for text.
 *
 * This is a demonstrative static page: no analytics, no external requests,
 * no cookies, no model provider, no sending.
 */

:root {
  --bg: #fffaf5;
  --panel: #ffffff;
  --surface: #fdf8f2;
  --ink: #29221c;
  --ink-soft: #4a3f34;
  --ink-mute: #6b6157;
  --line: #e8ded2;
  --line-strong: #d3c5b4;
  --bg-wash: rgba(255, 250, 245, .90);
  --focus: #29221c;
  --radius: 18px;
  --tap: 44px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #181a1e;
  --panel: #20232a;
  --surface: #262a32;
  --ink: #f3efe9;
  --ink-soft: #d8d2c8;
  --ink-mute: #b3aca1;
  --line: #343a45;
  --line-strong: #48505e;
  --bg-wash: rgba(24, 26, 30, .90);
  --focus: #c7ff02; /* accepted Jack reference for visible dark-mode focus */
}

html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Optional background: the agent's own portrait behind everything, default off.
 * Painted on the body so it can never be clicked, focused or announced and it
 * causes no layout shift. A 90% theme-colour wash keeps body-ink contrast
 * effectively unchanged. Suppressed where a decorative wash is not honest. */
:root[data-backdrop="on"] body {
  background-image: linear-gradient(var(--bg-wash), var(--bg-wash)), var(--portrait);
  background-repeat: no-repeat, no-repeat;
  background-position: 0 0, right -12px bottom -6px;
  background-size: auto, min(320px, 44vw) auto;
  background-attachment: fixed, fixed;
}
@media (forced-colors: active) {
  :root[data-backdrop="on"] body { background-image: none; }
}
@media (prefers-contrast: more) {
  :root[data-backdrop="on"] body { background-image: none; }
}
@media print {
  :root[data-backdrop="on"] body { background-image: none; }
}

/* ---- per-agent identity tokens (unchanged colours from styles.css) ---- */
body.agent-john    { --accent: #708090; --accent-fill: #58687a; --on-accent: #ffffff; --accent-ink: #657382; --accent-ink-dark: #778696; --portrait: url("/images/agents/john.webp"); }
body.agent-mary    { --accent: #c98e97; --accent-fill: #c98e97; --on-accent: #29221c; --accent-ink: #8d636a; --accent-ink-dark: #c98e97; --portrait: url("/images/agents/mary.webp"); }
body.agent-james   { --accent: #9caf88; --accent-fill: #9caf88; --on-accent: #29221c; --accent-ink: #657258; --accent-ink-dark: #9caf88; --portrait: url("/images/agents/james.webp"); }
body.agent-jane    { --accent: #f4e9d2; --accent-fill: #f4e9d2; --on-accent: #29221c; --accent-ink: #6e695e; --accent-ink-dark: #f4e9d2; --portrait: url("/images/agents/jane.webp"); }
body.agent-william { --accent: #1f3a5f; --accent-fill: #1f3a5f; --on-accent: #ffffff; --accent-ink: #1f3a5f; --accent-ink-dark: #79899f; --portrait: url("/images/agents/william.webp"); }
body.agent-anne    { --accent: #d8c7e8; --accent-fill: #d8c7e8; --on-accent: #29221c; --accent-ink: #776d80; --accent-ink-dark: #d8c7e8; --portrait: url("/images/agents/anne.webp"); }
body.agent-thomas  { --accent: #a89988; --accent-fill: #a89988; --on-accent: #29221c; --accent-ink: #766b5f; --accent-ink-dark: #a89988; --portrait: url("/images/agents/thomas.webp"); }
body.agent-sarah   { --accent: #b8e2d0; --accent-fill: #b8e2d0; --on-accent: #29221c; --accent-ink: #5c7168; --accent-ink-dark: #b8e2d0; --portrait: url("/images/agents/sarah.webp"); }

/* Preview index: site accent only, no agent identity of its own. */
body.agent-index-page { --accent: #b94b08; --accent-fill: #b94b08; --on-accent: #ffffff; --accent-ink: #8f3a06; --accent-ink-dark: #ffb27a; --portrait: none; }

a { color: var(--accent-ink); }
:root[data-theme="dark"] a { color: var(--accent-ink-dark); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip {
  position: absolute; left: -9999px; top: 0;
  padding: 10px 14px; background: var(--panel); color: var(--ink);
  border: 1px solid var(--line-strong); z-index: 60;
}
.skip:focus { left: 12px; top: 12px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- demonstration ribbon ---- */
.demo-ribbon {
  display: block;
  margin: 0;
  padding: 8px 16px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--accent) 22%, var(--panel));
  color: var(--ink);
  font-size: 12.5px;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  text-align: center;
}
.demo-ribbon b { letter-spacing: .04em; text-transform: uppercase; font-size: 11.5px; }

/* ---- top bar ---- */
.chat-top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 4px 0 var(--accent);
}
.chat-brand {
  display: flex; align-items: center; gap: 10px;
  margin-right: auto; min-width: 0;
  color: var(--ink); text-decoration: none;
}
.mark {
  position: relative; overflow: hidden;
  display: grid; place-items: center;
  width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: 11px;
  background: var(--accent-fill); color: var(--on-accent);
  font-weight: 700; font-size: 16px;
}
/* Portrait sits over the letter, so a failed image keeps the initial fallback. */
.markFace {
  position: absolute; inset: 0;
  width: 100%; height: 100%; display: block;
  object-fit: cover; object-position: 50% 0;
}
.mark.big { width: 60px; height: 60px; border-radius: 18px; font-size: 26px; }
.chat-brand-text { display: grid; gap: 0; min-width: 0; }
.chat-brand-text strong { font-size: 16px; letter-spacing: -.01em; }
.chat-brand-text small { color: var(--ink-mute); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-top-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.chat-back, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); min-width: var(--tap);
  padding: 8px 12px;
  border: 1px solid transparent; border-radius: 999px;
  background: transparent; color: var(--ink);
  font-size: 13.5px; font-weight: 650; text-decoration: none;
}
.chat-back:hover, .icon-btn:hover { background: color-mix(in srgb, var(--accent) 16%, var(--panel)); }
.icon-btn { font-size: 18px; }

/* ---- shell ---- */
.chat-main { flex: 1; padding: 18px 14px 40px; }
.chat-shell { width: min(100%, 820px); margin: 0 auto; }

.welcome { text-align: center; padding: 14px 4px 6px; }
.welcome .mark.big { margin: 0 auto 12px; }
.welcome h1 {
  margin: 0 0 8px; font-family: var(--serif); font-weight: 600;
  font-size: clamp(1.5rem, 4.4vw, 2.1rem); line-height: 1.15; letter-spacing: -.015em;
}
.chat-lede { margin: 0 auto 10px; max-width: 58ch; color: var(--ink-soft); }
.chat-note {
  margin: 0 auto 4px; max-width: 58ch;
  font-size: 13px; color: var(--ink-mute);
}
.chat-details {
  max-width: 62ch; margin: 14px auto 0; text-align: left;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
}
.chat-details summary {
  padding: 11px 14px; cursor: pointer; font-weight: 650; font-size: 13.5px;
}
.chat-details > div { padding: 0 14px 12px; font-size: 13px; color: var(--ink-soft); }
.chat-details ul { margin: 0; padding-left: 20px; }

/* ---- thread ---- */
.thread { list-style: none; margin: 22px 0 0; padding: 0; display: grid; gap: 14px; }
.msg { display: grid; gap: 5px; max-width: min(100%, 680px); }
.msg.user { justify-self: end; justify-items: end; }
.msg.agent { justify-self: start; }
.who { font-size: 11.5px; color: var(--ink-mute); letter-spacing: .02em; }
.bubble {
  padding: 12px 15px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--panel);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.user .bubble {
  background: var(--accent-fill); color: var(--on-accent);
  border-color: var(--accent-fill);
  border-bottom-right-radius: 5px;
}
.msg.agent .bubble {
  background: var(--surface);
  border-left: 4px solid var(--accent);
  border-bottom-left-radius: 5px;
}
.bubble b { font-weight: 700; }
.labels { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--ink-mute);
}
.tag.agent-colour {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
  background: color-mix(in srgb, var(--accent) 20%, var(--panel));
  color: var(--ink);
}

.stop-note {
  margin: 18px 0 0; padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
  border-left: 6px solid var(--accent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  font-size: 13.5px; color: var(--ink);
}

/* ---- composer ---- */
.composer {
  display: flex; gap: 8px; align-items: flex-end;
  margin: 18px 0 0; padding: 8px;
  border: 1px solid var(--line-strong); border-radius: 16px;
  background: var(--panel);
}
.composer textarea {
  flex: 1; min-height: 44px; max-height: 8em; resize: none;
  padding: 11px 12px; border: 0; border-radius: 10px;
  background: transparent; color: var(--ink); font-size: 16px;
}
.composer textarea::placeholder { color: var(--ink-mute); }
.send {
  min-height: var(--tap); padding: 10px 18px;
  border-radius: 12px; border: 1px solid var(--accent-fill);
  background: var(--accent-fill); color: var(--on-accent);
  font-weight: 700;
}
.composer-note {
  margin: 8px 2px 0; font-size: 12.5px; color: var(--ink-mute);
}
.composer-note.is-active { color: var(--ink); font-weight: 650; }

/* ---- footer / links ---- */
.chat-foot {
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 14px;
  font-size: 12.5px; color: var(--ink-mute);
  text-align: center;
}
.chat-foot p { margin: 0 0 4px; }
.chat-foot p:last-child { margin-bottom: 0; }
.chat-foot a { color: var(--accent-ink); }
:root[data-theme="dark"] .chat-foot a { color: var(--accent-ink-dark); }

/* ---- settings dialog ---- */
dialog {
  width: min(100% - 28px, 420px);
  border: 1px solid var(--line-strong); border-radius: 18px;
  background: var(--panel); color: var(--ink);
  padding: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
}
dialog::backdrop { background: rgba(24, 26, 30, .45); }
dialog h2 { margin: 0 0 6px; font-size: 19px; }
dialog p { margin: 0 0 12px; font-size: 12.5px; color: var(--ink-mute); }
.switch-row {
  display: flex; align-items: center; gap: 10px;
  min-height: var(--tap); margin: 0 0 2px;
  font-size: 14.5px; font-weight: 600; cursor: pointer;
}
.switch-row input { width: 20px; height: 20px; accent-color: var(--accent-fill); }
.dialog-close {
  width: 100%; margin-top: 14px; min-height: var(--tap);
  border-radius: 12px; border: 1px solid var(--accent-fill);
  background: var(--accent-fill); color: var(--on-accent); font-weight: 700;
}

/* ---- chat index ---- */
.index-main { flex: 1; padding: 22px 14px 44px; }
.index-shell { width: min(100%, 1000px); margin: 0 auto; }
.index-head h1 {
  margin: 0 0 8px; font-family: var(--serif); font-weight: 600;
  font-size: clamp(1.6rem, 4.4vw, 2.3rem); line-height: 1.15;
}
.index-head p { max-width: 70ch; color: var(--ink-soft); }
.agent-index {
  list-style: none; margin: 22px 0 0; padding: 0;
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.agent-index a {
  display: grid; grid-template-columns: 64px minmax(0, 1fr);
  gap: 14px; align-items: center;
  padding: 14px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--ink); text-decoration: none;
  box-shadow: 0 8px 20px rgba(36, 26, 12, .06);
}
.agent-index a:hover { border-color: var(--line-strong); }
.agent-index .face {
  width: 64px; height: 85px; object-fit: cover; object-position: 50% 0;
  border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--surface);
}
.agent-index strong { display: block; font-family: var(--serif); font-size: 1.18rem; }
.agent-index small { display: block; color: var(--ink-soft); font-size: 13px; }
.agent-index .swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  margin-right: 6px; vertical-align: baseline;
  border: 1px solid rgba(36, 26, 12, .22);
}
.index-note {
  margin: 18px 0 0; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); font-size: 13px; color: var(--ink-soft);
}

@media (max-width: 520px) {
  .chat-main { padding: 14px 10px 32px; }
  .chat-back { display: none; }
  .msg { max-width: 100%; }
  .agent-index { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

@media print {
  .chat-top, .composer, .demo-ribbon, dialog { display: none !important; }
  body { background: #fff; color: #000; }
}
