/*
 * The agent panel, in webmcp.academy's own clothes.
 *
 * Light, on the marketing site's --bone, with its ink hairlines, offset hard
 * shadows and type. The palette and geometry are lifted token for token from
 * styles.css — matching it exactly is the point, so do not "tidy" these values
 * into something approximate.
 *
 * The vocabulary is the site's, applied to this panel's parts:
 *
 *   .card    -> a tool call      bone-lift, ink hairline, offset shadow
 *   .chip    -> a tool name      ink hairline, mono, muted
 *   .form    -> the composer     bone-in inputs, ink borders, mono caps labels
 *   .btn--fire -> send           accent fill, ink offset shadow
 *   .form__msg--ok -> the result line   lime fill, lime-ink text
 *
 * Lime is a *fill* here, never text. On a dark ground --accent2 is a signal
 * colour; on bone it is nearly invisible, which is why the site pairs it with
 * --lime-ink and why this file does too.
 *
 * Read tools carry a lime shadow, the one tool that acts carries the accent —
 * the light-ground equivalent of .toolcard and .toolcard--fire in the homepage's
 * chat mockup, which is a drawing of this exact panel.
 *
 * FONTS: needs Bricolage Grotesque and Chivo alongside JetBrains Mono. Every
 * demo's index.html must request all three. The fallback stacks below make
 * forgetting survivable rather than broken.
 */

:root { --ap-w: 400px; }

.ap {
  /* Straight from the marketing site's :root. */
  --ap-bone:      oklch(0.966 0.021 92);
  --ap-bone-lift: oklch(0.985 0.012 92);
  --ap-bone-in:   oklch(0.99  0.008 92);
  --ap-ink:       oklch(0.19  0.016 55);
  --ap-body:      oklch(0.28  0.018 58);
  --ap-muted:     oklch(0.40  0.018 58);
  --ap-dim:       oklch(0.47  0.020 60);
  --ap-faint:     oklch(0.55  0.020 60);
  --ap-accent:    #E8412A;
  --ap-lime:      #C9F53F;
  --ap-lime-ink:  oklch(0.23 0.040 108);
  --ap-on-accent: oklch(0.98 0.012 92);

  /* Two darker variants of the same red, both for legibility rather than taste.
     --ap-accent-tx  red *text* on bone. #E8412A is 3.9:1 there — fine as a fill
                     or a border, too light for an 11px label.
     --ap-accent-fill a red *fill* with cream text on it. Cream on #E8412A is
                     3.79:1: the site's own pairing, and fine under the 30px
                     display type it uses it for, but not under a 9px badge.
     #E8412A itself stays for offset shadows, borders and the send button, where
     nothing small is written on top of it. */
  --ap-accent-tx:   oklch(0.46 0.19 27);
  --ap-accent-fill: oklch(0.52 0.20 27);
  --ap-warn-tx:     oklch(0.47 0.12 75);

  --ap-disp: "Bricolage Grotesque", "Arial Black", "Helvetica Neue", sans-serif;
  --ap-sans: "Chivo", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --ap-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --ap-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ap-hair: 1.5px;

  position: fixed;
  inset: 0 0 0 auto;
  width: var(--ap-w);
  max-width: 100vw;
  z-index: 900;
  transform: translateX(100%);
  transition: transform 0.42s var(--ap-ease);
  font-family: var(--ap-sans);
}
.ap--open { transform: translateX(0); }

/* The page makes room rather than being covered. Watching the results grid
   reflow under the agent's search is half the demo.
   --ap-w lives on :root, not on .ap: body needs it, and custom properties
   inherit down, not sideways. */
@media (min-width: 1100px) {
  body { transition: padding-right 0.42s cubic-bezier(0.16, 1, 0.3, 1); }
  body.has-agent-panel { padding-right: var(--ap-w); }
}

.ap__inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--ap-bone);
  color: var(--ap-ink);
  border-left: var(--ap-hair) solid var(--ap-ink);
  box-shadow: -20px 0 50px -34px rgb(26 20 12 / 0.4);
}

/* --- the reopen tab --- */
.ap__tab {
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: var(--ap-bone);
  color: var(--ap-ink);
  border: var(--ap-hair) solid var(--ap-ink);
  border-right: 0;
  box-shadow: -5px 5px 0 var(--ap-accent);
  padding: 20px 10px;
  cursor: pointer;
  transition: opacity 0.2s ease, box-shadow 0.35s var(--ap-ease);
}
.ap__tab:hover { box-shadow: -8px 8px 0 var(--ap-accent); }
.ap--open .ap__tab { opacity: 0; pointer-events: none; }
.ap__tab-text {
  display: block;
  writing-mode: vertical-rl;
  font-family: var(--ap-mono);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
}

/* --- header --- */
.ap__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 18px 14px;
  border-bottom: var(--ap-hair) solid var(--ap-ink);
}
.ap__eyebrow {
  margin: 0 0 4px;
  font-family: var(--ap-mono); font-weight: 700;
  font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ap-accent-tx);
}
.ap__title {
  margin: 0;
  font-family: var(--ap-disp); font-weight: 800;
  font-size: 23px; line-height: 0.95; letter-spacing: -0.03em;
  color: var(--ap-ink);
}
.ap__icon {
  background: none; border: 0; color: var(--ap-muted);
  cursor: pointer; padding: 4px; line-height: 0;
}
.ap__icon:hover { color: var(--ap-ink); }

/* --- tool strip --- */
.ap__tools {
  padding: 14px 18px;
  border-bottom: var(--ap-hair) solid var(--ap-ink);
  background: var(--ap-bone-lift);
}
.ap__tools-head { margin: 0 0 10px; font-size: 12.5px; line-height: 1.5; color: var(--ap-muted); }
.ap__tools-head strong { color: var(--ap-ink); }
.ap__native {
  display: inline-block; margin-left: 6px; padding: 3px 8px;
  font-family: var(--ap-mono); font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  border: 1px solid var(--ap-faint); color: var(--ap-dim);
  cursor: help;
}
/* Lime as a fill with lime-ink on top — the site's .form__msg--ok pairing.
   Lime as text on bone would be unreadable. */
.ap__native.is-on {
  background: var(--ap-lime); border-color: var(--ap-lime-ink); color: var(--ap-lime-ink);
}

.ap__chips { display: flex; flex-wrap: wrap; gap: 5px; }
.ap__chip {
  font-family: var(--ap-mono); font-size: 10.5px;
  padding: 4px 8px;
  background: var(--ap-bone); color: var(--ap-muted);
  border: 1px solid var(--ap-ink);
  cursor: help;
}
.ap__chip.is-firing { animation: ap-fire 1.1s var(--ap-ease); }
@keyframes ap-fire {
  0%   { background: var(--ap-lime); color: var(--ap-lime-ink); }
  100% { background: var(--ap-bone); color: var(--ap-muted); }
}

/* --- what the model is sent --- */
.ap__wire { margin-top: 12px; }
.ap__wire > summary {
  cursor: pointer;
  font-family: var(--ap-mono); font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ap-dim);
}
.ap__wire > summary:hover { color: var(--ap-accent-tx); }
.ap__wire-note { margin: 10px 0; font-size: 12px; line-height: 1.55; color: var(--ap-muted); }

/* --- transcript --- */
.ap__log {
  flex: 1; overflow-y: auto; padding: 18px;
  display: flex; flex-direction: column; gap: 14px;
  scrollbar-width: thin; scrollbar-color: var(--ap-faint) transparent;
}
/* Flex children shrink by default, and the tool rows are by far the tallest
   thing in here — so they were the ones getting crushed, to a two-pixel sliver
   with all the trace detail inside it. The log scrolls; nothing is compressed. */
.ap__log > * { flex: 0 0 auto; }

.ap__msg {
  max-width: 88%;
  font-size: 14px; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere;
  padding: 12px 16px;
}
.ap__msg--user {
  align-self: flex-end;
  background: var(--ap-ink); color: var(--ap-bone);
  border-radius: 14px 14px 3px 14px;
}
.ap__msg--assistant {
  align-self: flex-start;
  background: var(--ap-bone-lift); color: var(--ap-body);
  border: 1px solid var(--ap-faint);
  border-radius: 14px 14px 14px 3px;
}

.ap__note {
  margin: 0; font-size: 11.5px; line-height: 1.6; color: var(--ap-dim);
  border-left: 2px solid var(--ap-faint); padding: 2px 0 2px 11px;
}
.ap__note strong { color: var(--ap-ink); }
.ap__note.is-bad  { color: var(--ap-accent-tx); border-left-color: var(--ap-accent); }
.ap__note.is-ok   { color: var(--ap-lime-ink);  border-left-color: var(--ap-lime-ink); }
.ap__note.is-warn { color: var(--ap-warn-tx);   border-left-color: var(--ap-warn-tx); }

/* --- round-trip marker ---
   Tool use is more than one call to the model. Numbering the rounds is the
   clearest way to show that, and it is the thing people most often miss. */
.ap__turn {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--ap-mono); font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.11em; text-transform: uppercase; color: var(--ap-dim);
}
.ap__turn::after { content: ""; flex: 1; height: 1px; background: var(--ap-faint); }
.ap__turn-n { color: var(--ap-lime-ink); background: var(--ap-lime); padding: 3px 8px; }
.ap__turn-d { color: var(--ap-dim); text-transform: none; letter-spacing: 0.02em; }

/* --- a tool call ---
   The site's .card: bone-lift, ink hairline, offset hard shadow. The shadow
   carries the read/act distinction that .toolcard / .toolcard--fire carry on
   the dark homepage mockup. */
.ap__tool {
  background: var(--ap-bone-lift);
  border: var(--ap-hair) solid var(--ap-ink);
  box-shadow: 4px 4px 0 var(--ap-lime);
  font-family: var(--ap-mono);
  margin-right: 4px;                 /* room for the shadow inside the scroller */
}
.ap__tool.is-write { box-shadow: 4px 4px 0 var(--ap-accent); }
/* A tool whose effect leaves the browser — a booked table, an order, an email.
   Doubled shadow rather than a new colour: still unmistakably the accent, but
   heavier than a tool that only rearranges the page. */
.ap__tool.is-commit {
  border-color: var(--ap-accent-fill);
  box-shadow: 4px 4px 0 var(--ap-accent), 8px 8px 0 var(--ap-bone), 9px 9px 0 var(--ap-accent-fill);
  margin-right: 9px;
}
.ap__tool.is-bad   { box-shadow: 4px 4px 0 var(--ap-faint); }

.ap__tool > summary {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 13px; cursor: pointer; font-size: 11.5px;
  list-style: none;
}
.ap__tool > summary::-webkit-details-marker { display: none; }
.ap__tool > summary:hover { background: var(--ap-bone); }
.ap__tool-n {
  flex: none; display: grid; place-items: center;
  width: 18px; height: 18px;
  background: var(--ap-lime); color: var(--ap-lime-ink);
  font-size: 10px; font-weight: 700;
}
.ap__tool.is-write .ap__tool-n { background: var(--ap-accent-fill); color: var(--ap-on-accent); }
.ap__tool > summary code { color: var(--ap-ink); font-weight: 700; }
.ap__tool-kind {
  font-size: 9px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  padding: 3px 6px; border: 1px solid var(--ap-faint); color: var(--ap-dim);
}
/* Solid fill rather than coloured text: guarantees contrast at 9px. */
.ap__tool-kind.is-write {
  background: var(--ap-accent-fill); border-color: var(--ap-accent-fill); color: var(--ap-on-accent);
}
.ap__tool-state { margin-left: auto; color: var(--ap-dim); font-size: 10px; }
.ap__tool-state.is-bad { color: var(--ap-accent-tx); }

.ap__tool-body { padding: 0 13px 13px; border-top: 1px solid var(--ap-faint); }

/* The one-line human reading of the result, above the raw JSON. Most people
   want this and nothing else; the JSON is for when they want to check it.
   Styled as the site's .form__msg--ok. */
.ap__tool-sum {
  margin: 12px 0 0; padding: 9px 11px;
  background: var(--ap-lime); color: var(--ap-lime-ink);
  font-family: var(--ap-sans); font-size: 12.5px; line-height: 1.5;
}
.ap__tool.is-write .ap__tool-sum { background: var(--ap-accent-fill); color: var(--ap-on-accent); }

.ap__tool-label {
  margin: 12px 0 5px;
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ap-dim);
}
.ap__tool-page { margin: 0; font-size: 11px; line-height: 1.55; color: var(--ap-lime-ink); }
.ap__tool.is-write .ap__tool-page { color: var(--ap-accent-tx); }

/* Bounded and internally scrollable. A search result can run to forty lines of
   JSON, and three of those in a row pushes the actual conversation off screen —
   which defeats the point of showing the trace next to it. */
.ap__tool-body pre,
.ap__wire pre {
  margin: 0; padding: 10px 11px;
  background: var(--ap-bone-in); color: var(--ap-body);
  border: 1px solid var(--ap-faint);
  font-family: var(--ap-mono); font-size: 10.5px; line-height: 1.55;
  max-height: 170px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  scrollbar-width: thin; scrollbar-color: var(--ap-faint) transparent;
}
.ap__wire pre { max-height: 300px; font-size: 10px; }

/* --- suggestions --- */
.ap__suggest { display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.ap__suggest button {
  text-align: left; font: inherit; font-size: 13px; line-height: 1.45;
  background: var(--ap-bone-lift); color: var(--ap-body);
  border: 1px solid var(--ap-ink);
  padding: 10px 13px; cursor: pointer;
  transition: color 0.18s var(--ap-ease), box-shadow 0.3s var(--ap-ease), transform 0.3s var(--ap-ease);
}
.ap__suggest button:hover {
  color: var(--ap-ink);
  box-shadow: 3px 3px 0 var(--ap-accent);
  transform: translate(-1px, -1px);
}

/* --- passcode gate --- */
.ap__gate {
  padding: 16px 18px;
  border-top: var(--ap-hair) solid var(--ap-ink);
  background: var(--ap-bone-lift);
}
.ap__gate-title {
  margin: 0 0 5px;
  font-family: var(--ap-disp); font-weight: 800;
  font-size: 17px; letter-spacing: -0.02em; color: var(--ap-ink);
}
.ap__gate-note { margin: 0 0 12px; font-size: 12px; color: var(--ap-muted); line-height: 1.55; }
.ap__gate form { display: flex; gap: 8px; }
.ap__gate input {
  flex: 1; font: inherit; font-size: 13.5px;
  background: var(--ap-bone-in); color: var(--ap-ink);
  border: var(--ap-hair) solid var(--ap-ink);
  padding: 10px 12px; border-radius: 0; -webkit-appearance: none;
}
.ap__gate-error { margin: 10px 0 0; font-size: 11.5px; color: var(--ap-accent-tx); }

/* --- composer --- */
.ap__composer {
  display: flex; gap: 9px; align-items: flex-end;
  padding: 13px 18px; border-top: var(--ap-hair) solid var(--ap-ink);
}
.ap__composer textarea {
  flex: 1; font: inherit; font-size: 14px; line-height: 1.5; resize: none;
  background: var(--ap-bone-in); color: var(--ap-ink);
  border: var(--ap-hair) solid var(--ap-ink);
  padding: 11px 13px; max-height: 140px; border-radius: 0;
}
.ap__composer textarea::placeholder { color: var(--ap-faint); }

/* The site's .btn--fire: accent fill, ink hairline, offset hard shadow. */
.ap__send {
  flex: none; display: grid; place-items: center;
  width: 40px; height: 40px;
  border: var(--ap-hair) solid var(--ap-ink);
  background: var(--ap-accent); color: var(--ap-on-accent);
  box-shadow: 3px 3px 0 var(--ap-ink); cursor: pointer;
  transition: transform 0.3s var(--ap-ease), box-shadow 0.3s var(--ap-ease);
}
.ap__send:hover  { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ap-ink); }
.ap__send:active { transform: translate(1px, 1px);   box-shadow: 1px 1px 0 var(--ap-ink); }
.ap__send:disabled { opacity: 0.5; cursor: progress; transform: none; box-shadow: 3px 3px 0 var(--ap-ink); }
.ap__gate .ap__send {
  width: auto; height: 40px; padding: 0 16px;
  font-family: var(--ap-mono); font-size: 11.5px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
}

/* --- footer --- */
.ap__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 0 18px 13px;
  font-family: var(--ap-mono); font-size: 10px; color: var(--ap-dim);
}
.ap__foot-actions { display: flex; gap: 14px; }
.ap__link {
  background: none; border: 0; color: var(--ap-dim);
  font: inherit; letter-spacing: 0.06em; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; padding: 0;
}
.ap__link:hover { color: var(--ap-accent-tx); }

.ap :where(button, input, textarea, summary):focus-visible {
  outline: 3px solid var(--ap-accent); outline-offset: 1px;
}

/* An author `display` beats the UA's [hidden] rule, so `el.hidden = true` does
   nothing to anything styled display:flex — which is most of this panel.
   Caught with the composer sitting visible underneath the passcode gate. */
.ap [hidden] { display: none !important; }

@media (max-width: 520px) {
  :root { --ap-w: 100vw; }
}

@media (prefers-reduced-motion: reduce) {
  .ap, body, .ap__chip.is-firing, .ap__send, .ap__suggest button { transition: none; animation: none; }
}
