/* agent.css: see header in app.css "Reading layer (2026-11-23)". Loaded after app.css. */

/* ============================================================================
   The floating assistant (views/agent.ts, static/agent.js). It serves both sides, so it wears
   neither amber nor teal: navy ink is its surface accent, first light its small details.
   Without JS only the launcher shows, as a link to the inline ask box.
   ========================================================================== */
body.lt .agent {
  --agent-ink: var(--ink-1, #15192E);
  --agent-first: #d9fbe0;          /* first light, on navy */
  --agent-first-wash: #E2F3E6;     /* first light, on paper */
  --agent-gap: 16px;
  --agent-bottom: max(16px, calc(env(safe-area-inset-bottom, 0px) + 10px));
  font-family: var(--font);
}

/* The page keeps its last buttons clear of the launcher. */
body.lt.has-agent main { padding-bottom: 88px; }
body.lt.has-agent .foot { padding-bottom: 88px; }

/* Launcher: a navy pill, bottom right; on phones it sits nearer the centre, above the safe area. */
body.lt .agent-launch {
  position: fixed; z-index: 60;
  right: max(var(--agent-gap), env(safe-area-inset-right, 0px));
  bottom: var(--agent-bottom);
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 52px; min-width: 52px; padding: 0 20px 0 16px;
  border: 0; border-radius: 999px;
  background: var(--agent-ink); color: #fff;
  font: 700 1rem/1 var(--heading); letter-spacing: 0.01em;
  text-decoration: none; cursor: pointer;
  box-shadow: 0 1px 2px rgba(21, 25, 46, 0.18), 0 8px 22px rgba(21, 25, 46, 0.22);
}
body.lt .agent-launch:hover { background: #232846; color: #fff; }
body.lt .agent-launch .agent-icon { color: var(--agent-first); flex: none; }
body.lt .agent-launch[aria-expanded="true"] { background: #232846; }
body.lt .agent-launch:focus-visible { outline: 3px solid #E0A400; outline-offset: 3px; border-radius: 999px; }
/* Phones: a round button at the right edge that slides away while you scroll down (agent.js adds
   .agent-tucked) and comes back when you scroll up or stop, so it never sits on a button for long. */
@media (max-width: 1099px) { body.lt .agent-launch.agent-tucked { transform: translateY(calc(100% + var(--agent-bottom) + 8px)); } }
@media (max-width: 639px) {
  body.lt .agent-launch { padding: 0; width: 52px; justify-content: center; }
  body.lt .agent-launch .agent-launch-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  body.lt.agent-open .agent-launch { visibility: hidden; }
  body.lt .agent-launch.agent-tucked { transform: translateY(calc(100% + var(--agent-bottom) + 8px)); }
}
@media (max-width: 1099px) and (prefers-reduced-motion: no-preference) {
  body.lt .agent-launch { transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1); }
}

/* The panel: a sheet beside the page on desktop, a bottom sheet on phones. Not modal. */
body.lt .agent-panel {
  position: fixed; z-index: 61;
  right: max(var(--agent-gap), env(safe-area-inset-right, 0px));
  bottom: calc(var(--agent-bottom) + 64px);
  width: min(380px, calc(100vw - 2 * var(--agent-gap)));
  height: min(560px, calc(100dvh - 120px));
  display: flex; flex-direction: column;
  background: var(--surface, #fff); color: var(--agent-ink);
  border: 1px solid var(--line-strong, rgba(21, 25, 46, 0.22));
  border-top: 3px solid var(--agent-ink);
  border-radius: var(--r-lg, 14px);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
  opacity: 0; transform: translateY(12px) scale(0.98); transform-origin: bottom right;
}
body.lt .agent-panel[hidden] { display: none; }
body.lt .agent-panel.is-open { opacity: 1; transform: none; }
@media (prefers-reduced-motion: no-preference) {
  body.lt .agent-panel { transition: opacity 180ms ease-out, transform 200ms cubic-bezier(0.22, 1, 0.36, 1); }
}
@media (max-width: 639px) {
  body.lt .agent-panel {
    left: 0; right: 0; bottom: 0; width: auto;
    height: 85vh; height: 85dvh;
    border-radius: 18px 18px 0 0; border-left: 0; border-right: 0; border-bottom: 0;
    transform: translateY(24px); transform-origin: bottom center;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* Header: what it answers about, clear and close. */
body.lt .agent-head { display: flex; align-items: flex-start; gap: 6px; padding: 14px 10px 12px 18px; border-bottom: 1px solid var(--line); }
body.lt .agent-head-text { flex: 1; min-width: 0; }
body.lt .agent-title { font: 800 1.12rem/1.2 var(--heading); margin: 0; color: var(--agent-ink); letter-spacing: 0; }
body.lt .agent-about { margin: 3px 0 0; font-size: 0.84rem; line-height: 1.35; color: var(--ink-3); max-width: none; }
body.lt .agent-close, body.lt .agent-clear {
  flex: none; min-height: var(--tap, 44px); min-width: var(--tap, 44px);
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--ink-2); border-radius: var(--r-sm, 6px); cursor: pointer;
}
body.lt .agent-clear { font: 600 0.85rem/1 var(--font); padding: 0 10px; text-decoration: underline; text-underline-offset: 0.2em; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); }
body.lt .agent-clear[hidden] { display: none; }
body.lt .agent-close:hover, body.lt .agent-clear:hover { background: var(--surface-3); color: var(--agent-ink); }

/* The thread. */
body.lt .agent-thread { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 14px 8px; background: var(--surface-2, #F8F6F1); }
body.lt .agent-thread:focus { outline: none; }
body.lt .agent-empty[hidden] { display: none; }
body.lt .agent-empty-lede { margin: 4px 4px 12px; font-size: 0.95rem; color: var(--ink-2); }
body.lt .agent-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
body.lt .agent-chip {
  min-height: var(--tap, 44px); padding: 8px 16px; text-align: left;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface, #fff); color: var(--agent-ink);
  font: 600 0.95rem/1.25 var(--font); cursor: pointer;
}
body.lt .agent-chip:hover { background: var(--agent-first-wash); border-color: color-mix(in srgb, #2E8B4A 45%, transparent); }

body.lt .agent-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
body.lt .agent-msg { display: flex; flex-direction: column; max-width: 88%; }
body.lt .agent-msg-me { align-self: flex-end; align-items: flex-end; }
body.lt .agent-msg-bot, body.lt .agent-msg-error { align-self: flex-start; align-items: flex-start; }
body.lt .agent-bubble { margin: 0; padding: 10px 14px; font: 400 1rem/1.5 var(--font); white-space: pre-wrap; overflow-wrap: anywhere; max-width: none; }
body.lt .agent-msg-me .agent-bubble { background: var(--agent-ink); color: #fff; border-radius: 16px 16px 4px 16px; }
body.lt .agent-msg-bot .agent-bubble { background: var(--surface, #fff); color: var(--agent-ink); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; }
body.lt .agent-msg-error .agent-bubble { background: #FFF4F2; color: #7A2A20; border: 1px solid rgba(122, 42, 32, 0.25); border-radius: 16px 16px 16px 4px; }
body.lt .agent-retry { margin-top: 6px; min-height: 40px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--agent-ink); font: 600 0.9rem/1 var(--font); cursor: pointer; }

/* Sources: small quiet tags under the answer. */
body.lt .agent-sources { list-style: none; margin: 6px 0 0; padding: 0 2px; display: flex; flex-wrap: wrap; gap: 4px; }
body.lt .agent-sources li { margin: 0; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--ink-3); font-size: 0.74rem; font-weight: 600; line-height: 1.35; max-width: 100%; }

/* Typing. */
body.lt .agent-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
body.lt .agent-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); opacity: 0.5; }
@media (prefers-reduced-motion: no-preference) {
  body.lt .agent-dots i { animation: agent-dot 1.1s ease-in-out infinite; }
  body.lt .agent-dots i:nth-child(2) { animation-delay: 0.15s; }
  body.lt .agent-dots i:nth-child(3) { animation-delay: 0.3s; }
}
@keyframes agent-dot { 0%, 60%, 100% { opacity: 0.35; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

/* Composer. */
body.lt .agent-compose { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 6px; border-top: 1px solid var(--line); background: var(--surface, #fff); }
body.lt .agent-compose textarea {
  flex: 1; min-width: 0; resize: none; margin: 0;
  min-height: var(--tap, 44px); padding: 10px 14px;
  font: 400 1rem/1.4 var(--font); color: var(--agent-ink);
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 22px;
  overflow-y: hidden;
}
body.lt .agent-compose textarea:focus-visible { outline: 3px solid #E0A400; outline-offset: 1px; border-radius: 22px; }
body.lt .agent-send {
  flex: none; width: var(--tap, 44px); height: var(--tap, 44px);
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: var(--agent-ink); color: var(--agent-first); cursor: pointer;
}
body.lt .agent-send:disabled { opacity: 0.5; cursor: default; }
body.lt .agent-send:focus-visible { border-radius: 50%; }
body.lt .agent-fine { margin: 0; padding: 4px 14px 10px; font-size: 0.72rem; line-height: 1.4; color: var(--ink-3); background: var(--surface, #fff); max-width: none; }

/* With the assistant running, it is the one place to ask: the inline boxes step aside. */
body.lt.agent-ready .ask-anywhere, body.lt.agent-ready .talk-ask { display: none; }
body.lt.agent-ready .talk-prompt-wrap { grid-template-columns: 1fr; }

@media print { body.lt .agent { display: none; } body.lt.has-agent main, body.lt.has-agent .foot { padding-bottom: 0; } }

/* ---------- How the question was read, where to read more, what to ask next (2026-11-23) ---------- */
body.lt .agent-intent { margin: 0 4px 4px; font-size: 0.8rem; line-height: 1.35; color: var(--ink-2); }
body.lt :is(.agent-intent, .ask-intent) b { font-weight: 700; color: var(--ink-1); }
body.lt .agent-more { margin: 6px 2px 0; font-size: 0.88rem; }
body.lt .agent-more a { color: var(--link); text-decoration: underline; text-underline-offset: 0.18em; }
body.lt .agent-next { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
body.lt .agent-next .agent-chip { font-size: 0.9rem; }

/* The same on the inline ask boxes (program page, shortlist, conversation guide). */
body.lt .talk-answer .ask-intent { background: none; padding: 0 2px 6px; font-size: 0.85rem; color: var(--ink-2); }
body.lt .talk-answer .ask-more { background: none; padding: 8px 14px 0; font-size: 0.92rem; }
body.lt .talk-answer .ask-sources { color: var(--ink-2); }
body.lt .ask-next { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; padding: 0; background: none; }
body.lt .ask-chip {
  min-height: var(--tap, 44px); padding: 8px 16px; text-align: left;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface, #fff); color: var(--ink-1);
  font: 600 0.92rem/1.25 var(--font); cursor: pointer;
}
body.lt .ask-chip:hover { background: var(--surface-2); border-color: var(--ink-3); }
body.lt .ask-chip:focus-visible { outline: 3px solid var(--gold-deep, #F2A900); outline-offset: 2px; }
