/* iKAG AI-authoring shell — shared three-pane room styling for every
   Claude-driven surface in the portal.

   Substage 1 extraction (Studio Charter One · 2026-05-24).
   Consumers (live + planned):
     · signal-authoring.html  (Signal Authoring; inline CSS still owns the
                                live ruleset, this file ships alongside as
                                the shared seam — de-dup pass in Charter Two)
     · studio.html            (Studio Charter One; born on this stylesheet)
     · (future)               (WTE / MRA / QB / APP — Charter Two onward)

   Doctrine:
     · Persona is "Claude" (open intelligence) on the product surface; Tron
       remains the Grid program. Display name is set per-surface via a
       data-display-name attribute on body so a future swap (Gina → Yori /
       Quorra) is a one-token change in studio-config.js, not a CSS rewrite.
     · Bit is the behavior layer presence indicator — one element, six states,
       navy=Flynn / copper=Penny. The label never reads "Bit" — only the
       middle word changes (state-text).
     · Three-pane layout (history rail | center | research) is the canonical
       AI-authoring shape. Pane widths live in CSS vars so body classes can
       collapse them in lockstep.
     · No emojis. iKAG showpiece standard.

   Cascade contract:
     · Linked stylesheet ships at /assets/styles/ai-authoring.css.
     · Surfaces should link this AFTER tokens.css (so it can reference the
       palette) and BEFORE any inline <style> (so surface-specific overrides
       win when they collide).
   ─────────────────────────────────────────────────────────────────────── */


/* ═══════════════════════════════════════════════════════════════════════
   THREE-PANE LAYOUT
   ═══════════════════════════════════════════════════════════════════════
   Center pane is fluid; history rail (left) and research pane (right) have
   fixed widths via CSS vars. Body classes flip the vars to 0 to collapse
   either side without recomputing grid-template-columns. The pane content
   itself is responsible for hiding overflow when the var hits 0. */

:root {
  --drafts-w:   280px;
  --research-w: 320px;
}

body.left-pane-collapsed  { --drafts-w:   0px; }
body.right-pane-collapsed { --research-w: 0px; }

.ai-authoring-shell {
  display: grid;
  grid-template-columns: var(--drafts-w) 1fr var(--research-w);
  min-height: calc(100vh - var(--shell-topbar-h, 60px));
  background: var(--bg, #FAFAF7);
  transition: grid-template-columns 0.25s var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.ai-authoring-shell > .pane-left,
.ai-authoring-shell > .pane-right {
  overflow: hidden;
  border-color: var(--hairline, #E6E5E0);
  border-style: solid;
  border-width: 0;
  background: var(--surface, #FFFFFF);
}

.ai-authoring-shell > .pane-left   { border-right-width: 1px; }
.ai-authoring-shell > .pane-right  { border-left-width: 1px; }
.ai-authoring-shell > .pane-center {
  display: flex;
  flex-direction: column;
  min-width: 0;            /* prevent flex children from forcing overflow */
  background: var(--bg, #FAFAF7);
}


/* ═══════════════════════════════════════════════════════════════════════
   SLIDER OVERLAY
   ═══════════════════════════════════════════════════════════════════════
   Used by Cell-style slider mounts. body.slider-open locks page scroll +
   activates the backdrop. The overlay sits beneath the slider; click-to-
   close handled by JS. */

body.slider-open {
  overflow: hidden;
}

.slider-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.50);
  z-index: 900;
  display: none;
}

body.slider-open .slider-overlay { display: block; }


/* ═══════════════════════════════════════════════════════════════════════
   BIT — behavior layer presence indicator
   ═══════════════════════════════════════════════════════════════════════
   One element, six states. Color flips between navy (Flynn — listening,
   present, normal cadence) and copper (Penny — speaking, working,
   focused cadence). Label structure: "<prefix> · <state> · <suffix>" —
   prefix + suffix are stable, only state-text rotates.

   States: idle, listening, thinking, working, delivering, error. */

.bit-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 12px/1.4 system-ui, -apple-system, sans-serif;
  color: var(--ink-soft, #4B5360);
  user-select: none;
}

.bit-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.bit-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--navy, #1B2A4A);
  transition: background 0.4s var(--ease);
}

.bit-state-text {
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink, #1B2A4A);
}

.bit-status-state {
  text-transform: lowercase;
}

/* State variants — drive by body data-bit-state="<name>" so JS toggles
   once and CSS owns the visual. */

body[data-bit-state="listening"] .bit-dot {
  background: var(--navy, #1B2A4A);
  animation: bit-breathe-navy 2.4s ease-in-out infinite;
}

body[data-bit-state="thinking"] .bit-dot {
  background: var(--copper, #C87533);
  animation: bit-breathe-copper 1.4s ease-in-out infinite;
}

body[data-bit-state="working"] .bit-dot {
  background: var(--copper, #C87533);
  animation: bit-pulse-copper 0.9s ease-in-out infinite;
}

body[data-bit-state="delivering"] .bit-dot {
  background: var(--copper, #C87533);
  box-shadow: 0 0 0 4px rgba(200, 117, 51, 0.18);
}

body[data-bit-state="error"] .bit-dot {
  background: var(--burgundy, #6B1D2A);
  animation: bit-flash-burgundy 0.5s ease-in-out 2;
}

body[data-bit-state="idle"] .bit-dot {
  background: var(--ink-mute, #8A8F99);
}

@keyframes bit-breathe-navy {
  0%, 100% { opacity: 1.0; }
  50%      { opacity: 0.55; }
}
@keyframes bit-breathe-copper {
  0%, 100% { opacity: 1.0; transform: scale(1.00); }
  50%      { opacity: 0.65; transform: scale(0.92); }
}
@keyframes bit-pulse-copper {
  0%, 100% { box-shadow: 0 0 0 0px rgba(200, 117, 51, 0.40); }
  50%      { box-shadow: 0 0 0 6px rgba(200, 117, 51, 0.00); }
}
@keyframes bit-flash-burgundy {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}


/* ═══════════════════════════════════════════════════════════════════════
   CHAT MESSAGE TYPOGRAPHY
   ═══════════════════════════════════════════════════════════════════════
   Two-column message layout (avatar | body). Author + role-tag on the
   first line of the body; markdown-rendered text below. */

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 32px;
  max-width: 880px;
  margin: 0 auto;
  width: 100%;
}

.chat-message {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  align-items: flex-start;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 600 12px/1 system-ui, -apple-system, sans-serif;
  color: var(--surface, #FFFFFF);
  flex-shrink: 0;
}

.message-avatar.flynn { background: var(--navy,   #1B2A4A); }
.message-avatar.tron,
.message-avatar.claude { background: var(--copper, #C87533); }

.message-body {
  min-width: 0;
}

.message-author {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
  font: 600 13px/1.2 system-ui, -apple-system, sans-serif;
  color: var(--ink, #1B2A4A);
}

.message-author .role-tag {
  font-weight: 400;
  font-size: 11px;
  color: var(--ink-mute, #8A8F99);
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

.message-text {
  font: 400 14px/1.5 Georgia, "Times New Roman", serif;
  color: var(--ink, #1B2A4A);
  word-wrap: break-word;
}

.message-text p          { margin: 0 0 8px 0; }
.message-text p:last-child { margin-bottom: 0; }
.message-text ul,
.message-text ol         { margin: 0 0 8px 24px; padding: 0; }
.message-text li         { margin: 0 0 4px 0; }
.message-text code       { font: 0.92em/1 "SF Mono", Menlo, Consolas, monospace;
                           background: var(--pale2, #eef3f9);
                           padding: 1px 4px;
                           border-radius: 3px; }
.message-text pre        { background: var(--pale2, #eef3f9);
                           padding: 12px 14px;
                           border-radius: 6px;
                           overflow-x: auto;
                           margin: 0 0 8px 0; }
.message-text pre code   { background: transparent; padding: 0; }
.message-text a          { color: var(--copper-deep, #A85F22); text-decoration: underline; }
.message-text a:hover    { color: var(--copper, #C87533); }


/* ═══════════════════════════════════════════════════════════════════════
   CHAT HEADER (topic block + action buttons)
   ═══════════════════════════════════════════════════════════════════════ */

.chat-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 16px;
  padding: 20px 32px 16px 32px;
  border-bottom: 1px solid var(--hairline, #E6E5E0);
  background: var(--surface, #FFFFFF);
}

.chat-header.is-hidden { display: none; }

.chat-topic-block { min-width: 0; }

.chat-topic-eyebrow {
  font: 500 10px/1 system-ui, -apple-system, sans-serif;
  color: var(--ink-mute, #8A8F99);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  margin: 0 0 6px 0;
}

.chat-topic-title {
  font: 600 22px/1.25 Georgia, "Times New Roman", serif;
  color: var(--ink, #1B2A4A);
  margin: 0;
  word-wrap: break-word;
}

.chat-topic-meta {
  font: 400 12px/1.4 system-ui, -apple-system, sans-serif;
  color: var(--ink-soft, #4B5360);
  margin: 4px 0 0 0;
}

.chat-header-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.chat-action-btn {
  appearance: none;
  border: 1px solid var(--hairline-strong, #D8D6CF);
  background: var(--surface, #FFFFFF);
  color: var(--ink, #1B2A4A);
  font: 500 12px/1 system-ui, -apple-system, sans-serif;
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.chat-action-btn:hover {
  background: var(--copper-tint, rgba(200,117,51,0.06));
  border-color: var(--copper-line, rgba(200,117,51,0.22));
}


/* ═══════════════════════════════════════════════════════════════════════
   CHAT COMPOSER (input + send)
   ═══════════════════════════════════════════════════════════════════════ */

.chat-composer {
  padding: 16px 32px 24px 32px;
  border-top: 1px solid var(--hairline, #E6E5E0);
  background: var(--surface, #FFFFFF);
}

.chat-composer-row {
  max-width: 880px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.chat-composer textarea {
  width: 100%;
  min-height: 44px;
  max-height: 200px;
  resize: vertical;
  padding: 12px 14px;
  font: 400 14px/1.4 Georgia, "Times New Roman", serif;
  color: var(--ink, #1B2A4A);
  background: var(--bg, #FAFAF7);
  border: 1px solid var(--hairline-strong, #D8D6CF);
  border-radius: 4px;
  outline: none;
  transition: border-color 0.15s;
}
.chat-composer textarea:focus {
  border-color: var(--copper, #C87533);
}

.chat-composer .send-btn {
  appearance: none;
  border: none;
  background: var(--copper, #C87533);
  color: var(--surface, #FFFFFF);
  font: 600 13px/1 system-ui, -apple-system, sans-serif;
  padding: 12px 20px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}
.chat-composer .send-btn:hover    { background: var(--copper-deep, #A85F22); }
.chat-composer .send-btn:disabled { opacity: 0.45; cursor: not-allowed; }


/* ═══════════════════════════════════════════════════════════════════════
   PANE HEADERS (rail + research)
   ═══════════════════════════════════════════════════════════════════════ */

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--hairline, #E6E5E0);
}

.pane-header-title {
  font: 600 11px/1 system-ui, -apple-system, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--ink-soft, #4B5360);
  margin: 0;
}

.pane-collapse-btn {
  appearance: none;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--ink-mute, #8A8F99);
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 3px;
  transition: background 0.15s, color 0.15s;
}
.pane-collapse-btn:hover {
  background: var(--copper-tint, rgba(200,117,51,0.06));
  color: var(--copper-deep, #A85F22);
}


/* ═══════════════════════════════════════════════════════════════════════
   HONEST EMPTY STATE
   ═══════════════════════════════════════════════════════════════════════
   Doctrine: new live surfaces ship honest empty states, never demo seeding.
   This class is the canonical empty-state container. Pair with simple
   prose, no illustrations, no fake rows. */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  color: var(--ink-soft, #4B5360);
  font: 400 13px/1.5 Georgia, "Times New Roman", serif;
  max-width: 420px;
  margin: 0 auto;
}

.empty-state h2 {
  font: 600 14px/1.3 system-ui, -apple-system, sans-serif;
  color: var(--ink, #1B2A4A);
  margin: 0 0 6px 0;
  text-transform: uppercase;
  letter-spacing: 0.10em;
}

.empty-state p {
  margin: 0;
}

/* ── Phone (Jul 2026): collapse both rails so the shell is a single-column
   chat/work surface instead of three fixed columns overflowing the viewport.
   The shell's grid reads these vars, so every consumer reflows from here —
   studio.html was missing an inline equivalent; signal-authoring.html already
   has one (this makes it the shared default so future rooms inherit it). ── */
@media (max-width: 768px) {
  body { --drafts-w: 0px; --research-w: 0px; }
}
