/* Clayrune public demo — shell chrome only.
 *
 * The product's REAL UI rules live in _real-ui.css, extracted verbatim from the
 * app's static/css/app.css (see demo/README.md). Do NOT restyle product
 * components here — if the app changes, re-extract _real-ui.css instead.
 * This file holds only what the demo needs and the app does not: the bounded
 * frame, the coach-marks, and the settings modal.
 */

/* ── Bounded frame (the demo lives in a ~1100×640 iframe, not a viewport) ── */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px; overflow: hidden;
}
.demo-root { display: flex; flex-direction: column; height: 100%; min-height: 0; }

/* ── App bar (mirrors the product's header) ── */
.demo-appbar {
  height: 48px; flex: 0 0 48px; display: flex; align-items: center; gap: 10px;
  padding: 0 14px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.demo-logo { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: .2px; }
.demo-logo-mark {
  width: 22px; height: 22px; border-radius: 6px; flex: 0 0 22px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
}
.demo-crumb { color: var(--text-dim); font-size: 13px; }
.demo-crumb b { color: var(--text); font-weight: 600; }

/* Back-to-dashboard button (project view only). */
.demo-backbtn {
  display: none; align-items: center; gap: 6px; cursor: pointer;
  height: 30px; padding: 0 11px 0 8px; border-radius: 8px;
  background: var(--surface2); border: 1px solid var(--border); color: var(--text-dim);
  font-size: 12.5px; font-weight: 600;
}
.demo-backbtn:hover { color: var(--text); border-color: var(--border2); }
body.view-project .demo-backbtn { display: inline-flex; }
/* The crumb is only meaningful once you're inside a project. */
body.view-dashboard .demo-crumb { display: none; }
.demo-appbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.demo-livepill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px;
  border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--green-dim); color: var(--green-text);
}
.demo-livedot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--green);
  animation: demoPulse 1.6s ease-in-out infinite;
}
@keyframes demoPulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.demo-iconbtn {
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
  display: grid; place-items: center;
  background: var(--surface2); border: 1px solid var(--border); color: var(--text-dim);
}
.demo-iconbtn:hover { color: var(--text); border-color: var(--border2); }

/* The body hosts two swappable views: the fleet dashboard and the 3-pane
   project view. Only one is mounted at a time (toggled by a body class). */
.demo-body { flex: 1 1 auto; min-height: 0; display: flex; }
.demo-body .agent-panel { flex: 1 1 auto; min-height: 0; }

.demo-view { flex: 1 1 auto; min-height: 0; display: none; }
body.view-dashboard #dashView { display: flex; flex-direction: column; }
body.view-project    #projView { display: flex; }

/* ── Dashboard (the fleet grid — 'one dashboard instead of N terminals') ── */
.dash-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px 20px 22px; }
.dash-toolbar {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.dash-title { font-size: 15px; font-weight: 700; letter-spacing: .1px; }
.dash-title .dash-count { color: var(--text-faint); font-weight: 600; margin-left: 8px; font-size: 13px; }
.dash-sub { font-size: 12px; color: var(--text-dim); }
.dash-hint { font-size: 11.5px; color: var(--text-faint); }

/* Agent-count chip in the tile footer (mirrors the app's live pill, small). */
.tile-agents {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px;
  border-radius: 999px; font-size: 10px; font-weight: 600;
  background: var(--green-dim); color: var(--green-text);
}
.tile-agents.idle { background: var(--surface3); color: var(--text-faint); }
.tile-agents .tile-agents-dot {
  width: 5px; height: 5px; border-radius: 50%; background: currentColor;
  animation: demoPulse 1.6s ease-in-out infinite;
}
.tile-agents.idle .tile-agents-dot { animation: none; }
.tile-footer .tile-spacer { flex: 1 1 auto; }

/* Mobile conversation switcher — the desktop rail is hidden on phones, so the
   thread carries a compact <select> to hop between a project's conversations. */
.demo-conv-mobilebar { display: none; }

/* Plain agent prose keeps its paragraph breaks (plans, summaries). */
.agent-line.md { white-space: pre-wrap; }
/* A conversation whose agent is still mid-task shows a live, pulsing footer
   line instead of a completion status — reinforces the "fleet is live" pitch. */
.agent-line.demo-working {
  color: var(--green-text); font-style: italic;
  display: inline-flex; align-items: center; gap: 7px;
}
.agent-line.demo-working::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; animation: demoPulse 1.4s ease-in-out infinite;
}
/* A fade so statically-rendered transcript lines don't all snap in at once. */
@keyframes demoLineIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.agent-line.fade-in { animation: demoLineIn .26s ease both; }

/* app.css ships `.agent-output:empty { display: none }` — sensible in the product
 * (a new conversation shows a composer empty-state instead), but the demo opens
 * on an EMPTY thread while the coach-marks run. With the output collapsed the
 * composer rides up under the app bar and the page reads as broken — which is
 * the FIRST thing a visitor sees. Keep the thread box laid out even when empty
 * so the composer stays bottom-anchored. Demo-only; product CSS is untouched. */
.agent-3pane .agent-main .agent-output:empty { display: flex; }

/* ── Coach-marks ──
 * The dim comes ENTIRELY from .coach-spot's 9999px box-shadow, which paints
 * everything outside the spotlight. The backdrop must therefore never capture
 * pointer events: the tour asks the user to click the highlighted control
 * ("Approve & run"), and a click-eating backdrop makes that impossible. Keep
 * pointer-events:none here — this is load-bearing, not cosmetic.
 */
.coach-backdrop {
  position: fixed; inset: 0; z-index: 60; pointer-events: none;
  background: transparent;
}
.coach-spot {
  position: fixed; z-index: 61; border-radius: 10px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(4, 6, 12, .58), 0 0 0 2px var(--accent);
  transition: all .3s cubic-bezier(.4, 0, .2, 1);
}
.coach-tip {
  position: fixed; z-index: 62; width: 268px; padding: 14px;
  background: var(--surface2); border: 1px solid var(--border2); border-radius: 12px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .5);
  transition: all .3s cubic-bezier(.4, 0, .2, 1);
}
.coach-step { font-size: 10px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--accent); }
.coach-title { margin: 5px 0 6px; font-size: 14px; font-weight: 650; }
.coach-body { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--text-dim); }
.coach-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.coach-next {
  margin-left: auto; padding: 6px 14px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #06101f; font-weight: 650; font-size: 12.5px;
}
.coach-next:hover { filter: brightness(1.08); }
.coach-skip { background: none; border: 0; color: var(--text-faint); cursor: pointer; font-size: 12.5px; }
.coach-skip:hover { color: var(--text-dim); }

/* ── Settings modal (demo-local; persists to localStorage, never a server) ── */
.demo-modal-overlay {
  position: fixed; inset: 0; z-index: 70; display: none;
  place-items: center; background: rgba(4, 6, 12, .6);
}
.demo-modal-overlay.on { display: grid; }
.demo-modal {
  width: min(440px, 92%); max-height: 84%; overflow: auto;
  background: var(--surface); border: 1px solid var(--border2); border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
}
.demo-modal-head {
  display: flex; align-items: center; padding: 14px 16px;
  border-bottom: 1px solid var(--border); font-weight: 650;
}
.demo-modal-head button {
  margin-left: auto; background: none; border: 0; cursor: pointer;
  color: var(--text-faint); font-size: 20px; line-height: 1;
}
.demo-modal-head button:hover { color: var(--text); }
.demo-set-group { padding: 6px 16px 14px; }
.demo-set-legend {
  font-size: 10px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  color: var(--text-faint); margin: 14px 0 4px;
}
.demo-set-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.demo-set-row:last-child { border-bottom: 0; }
.demo-set-label { font-size: 13px; }
.demo-set-hint { display: block; font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.demo-set-ctl { margin-left: auto; flex: 0 0 auto; }
.demo-set-ctl select {
  background: var(--surface2); color: var(--text); font-size: 12.5px;
  border: 1px solid var(--border2); border-radius: 7px; padding: 5px 8px;
}
.demo-switch {
  position: relative; width: 40px; height: 22px; border-radius: 999px; cursor: pointer;
  background: var(--surface3); border: 1px solid var(--border2); transition: background .18s ease;
}
.demo-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-faint); transition: transform .18s ease, background .18s ease;
}
.demo-switch.on { background: var(--accent-dim); border-color: var(--accent-soft); }
.demo-switch.on::after { transform: translateX(18px); background: var(--accent); }

/* ── Replay ── */
/* Sits above the composer, not on top of the send button. */
.demo-replay {
  position: absolute; right: 18px; bottom: 104px; z-index: 50;
  display: none; align-items: center; gap: 7px; padding: 8px 14px;
  border: 1px solid var(--border2); border-radius: 999px; cursor: pointer;
  background: var(--surface2); color: var(--text); font-size: 12.5px; font-weight: 600;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .4);
}
.demo-replay.on { display: inline-flex; }
.demo-replay:hover { border-color: var(--accent); color: var(--accent); }

/* Light theme, toggled from the demo settings panel. Mirrors the product's
   [data-theme="light"] switch; the palette itself comes from _real-ui.css. */
body[data-theme="light"] { background: var(--bg); color: var(--text); }

/* ── Demo → install bridge ──
 * Three quiet touchpoints steer interested visitors to the real install:
 *   .demo-getbtn   persistent, unobtrusive "Get it" in the app bar
 *   .demo-nudge    one soft toast the moment the agent starts real work
 *   .demo-endcard  the end-of-run conversion card in the thread
 * All calm, none pushy. Links use target=_top so they navigate the host page. */
.demo-getbtn {
  display: inline-flex; align-items: center; height: 30px; padding: 0 12px;
  border-radius: 8px; text-decoration: none; white-space: nowrap;
  background: var(--accent-dim); border: 1px solid var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 650; letter-spacing: .1px;
}
.demo-getbtn:hover { filter: brightness(1.08); border-color: var(--accent); }
@media (max-width: 560px) { .demo-getbtn { display: none; } }

/* One-time soft nudge (bottom-center toast). */
.demo-nudge {
  position: absolute; left: 50%; bottom: 18px; transform: translate(-50%, 14px);
  z-index: 55; display: flex; align-items: center; gap: 10px;
  max-width: min(560px, calc(100% - 32px)); padding: 9px 10px 9px 14px;
  background: var(--surface2); border: 1px solid var(--border2); border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .42);
  font-size: 12.5px; color: var(--text-dim);
  opacity: 0; pointer-events: none; transition: opacity .3s ease, transform .3s ease;
}
.demo-nudge.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.demo-nudge-dot {
  flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  animation: demoPulse 1.6s ease-in-out infinite;
}
.demo-nudge-txt { min-width: 0; }
.demo-nudge-txt b { color: var(--text); font-weight: 650; }
.demo-nudge-link {
  flex: 0 0 auto; text-decoration: none; font-weight: 700; color: var(--accent);
}
.demo-nudge-link:hover { text-decoration: underline; }
.demo-nudge-x {
  flex: 0 0 auto; background: none; border: 0; cursor: pointer;
  color: var(--text-faint); font-size: 17px; line-height: 1; padding: 0 2px;
}
.demo-nudge-x:hover { color: var(--text); }
@media (max-width: 560px) { .demo-nudge-txt { display: none; } }

/* End-of-run conversion card (in-thread, appended after the summary). */
.demo-endcard {
  margin: 18px 0 8px; padding: 18px 18px 16px;
  background: linear-gradient(150deg, var(--accent-dim), var(--surface2));
  border: 1px solid var(--accent-soft); border-radius: 14px;
}
.demo-endcard-title { font-size: 15px; font-weight: 750; color: var(--text); }
.demo-endcard-sub {
  margin: 5px 0 14px; font-size: 12.5px; line-height: 1.6; color: var(--text-dim); max-width: 52ch;
}
.demo-endcard-sub b { color: var(--text); font-weight: 650; }
.demo-endcard-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.demo-endcard-btn {
  display: inline-flex; align-items: center; padding: 9px 15px; border-radius: 9px;
  text-decoration: none; font-size: 12.5px; font-weight: 650; white-space: nowrap;
}
.demo-endcard-btn.accent { background: var(--accent); color: #06101f; }
.demo-endcard-btn.accent:hover { filter: brightness(1.08); }
.demo-endcard-btn.ghost {
  background: transparent; border: 1px solid var(--border2); color: var(--text-dim);
}
.demo-endcard-btn.ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ── Ask Claydo modal shell ──
 * The real app opens Claydo as a draggable modal-window; the demo uses the
 * same centered-overlay treatment as Settings, with the product's real
 * claydo-* content classes (history/msg/chip/ready-card) inside from _real-ui.css.
 * position:relative anchors the absolute .claydo-save-panel overlay. */
.demo-claydo {
  position: relative; display: flex; flex-direction: column;
  width: min(520px, 94%); height: min(600px, 88%);
  background: var(--surface); border: 1px solid var(--border2); border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55); overflow: hidden;
}
.demo-claydo-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 13px 14px 12px 18px; border-bottom: 1px solid var(--border);
}
.demo-claydo-av {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 32px;
  border: 1px solid var(--border); object-fit: contain; background: var(--surface2);
}
.demo-claydo-titles { min-width: 0; margin-right: auto; }
.demo-claydo-title { font-size: 14px; font-weight: 700; color: var(--text); }
.demo-claydo-sub { font-size: 11px; color: var(--text-faint); }
.demo-claydo-x {
  background: none; border: 0; cursor: pointer; color: var(--text-faint);
  font-size: 20px; line-height: 1; padding: 0 4px;
}
.demo-claydo-x:hover { color: var(--text); }

/* On a phone the Claydo sheet fills most of the screen. */
@media (max-width: 960px) {
  .demo-claydo { width: 96%; height: 90%; }
}

/* ── Mobile (≤960px) ──
 * The product doesn't render the 3-pane on a phone at all: `agentPanelHTML()`
 * takes a different branch and emits a drill-down (conversation list → thread).
 * `.agent-panel.agent-3pane { flex-direction: row }` is GLOBAL in app.css, so a
 * demo that always emits the 3-pane DOM stays a row on mobile and squeezes the
 * thread off-screen. Collapse to the thread here — that's what the real app
 * shows once a conversation is open, and it's the state this demo is in.
 */
@media (max-width: 960px) {
  .agent-3pane .agent-rail,
  .agent-3pane .agent-rail-resizer,
  .agent-surfaces { display: none !important; }
  .agent-panel.agent-3pane .agent-main {
    flex: 1 1 auto; width: 100%; min-width: 0;
    display: flex; flex-direction: column; min-height: 0;
  }
  /* app.css only gives the thread its fill-height flex chain inside the desktop
     block, so on mobile .agent-chat collapses to content height and the
     composer floats to the top of a mostly-empty screen. Re-establish it. */
  .agent-panel.agent-3pane .agent-main .agent-chat {
    display: flex; flex-direction: column;
    flex: 1 1 auto; height: auto !important; min-height: 0;
  }
  .agent-panel.agent-3pane .agent-main .agent-output {
    flex: 1 1 auto; min-height: 0; overflow-y: auto;
  }
  .agent-panel.agent-3pane .agent-main .agent-chat-input { flex: 0 0 auto; }
  .demo-crumb { display: none; }
  /* Clear the taller mobile composer (model row + input pill), not just the input. */
  .demo-replay { right: 12px; bottom: 158px; }

  /* The rail is hidden on phones — surface conversation switching as a select. */
  .demo-conv-mobilebar {
    display: flex; align-items: center; gap: 8px; flex: 0 0 auto;
    padding: 8px 12px; border-bottom: 1px solid var(--border);
  }
  .demo-conv-mobilebar select {
    flex: 1 1 auto; min-width: 0; background: var(--surface2); color: var(--text);
    font-size: 12.5px; border: 1px solid var(--border2); border-radius: 8px; padding: 6px 8px;
  }
  .dash-scroll { padding: 12px; }

  /* Coach tip docks to the bottom — a floating tip beside a full-bleed thread
     has nowhere to go on a 390px screen. */
  .coach-tip {
    width: auto; left: 12px !important; right: 12px;
    top: auto !important; bottom: 12px;
  }
}
