/* ask-jade — see docs/ARCHITECTURE.md. Loaded by index.html after styles.css. */
/* Ask Jade upgrade (Colin 2026-11-21): one-click questions, progress steps, table Copy / CSV, 👍 / 👎, Recent chats,
   the 🎤 button. The panel's size and place stay in styles.css (2/3 of the screen wide; phones ≤ 60% tall). */

/* Header: Recent / Suggest / New chat / × on one line, Recent's menu dropping down under it. */
.aj-panel .aj-head { position: relative; flex-wrap: nowrap; gap: 8px; }
.aj-panel .aj-head > b { white-space: nowrap; }
.aj-hbtns { gap: 6px; flex-wrap: nowrap; min-width: 0; }
.aj-recent-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 2; width: min(360px, 100%); max-height: 320px; overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--shadow-lg); padding: 4px; display: flex; flex-direction: column; gap: 2px; }
.aj-recent-menu[hidden] { display: none; }
.aj-recent-menu p { margin: 6px 8px; }
.aj-recent-menu button { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; width: 100%; text-align: left; border: 0; background: transparent; box-shadow: none; padding: 7px 8px; border-radius: var(--r-sm); min-height: 0; }
.aj-recent-menu button:hover, .aj-recent-menu button:focus-visible { background: var(--brand-soft); }
.aj-recent-menu button[aria-current="true"] { font-weight: 700; }
.aj-recent-menu .aj-rt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.aj-recent-menu .small { flex: none; }

/* One-click questions for the page on screen. */
.aj-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.aj-chips p { flex-basis: 100%; margin: 0 0 2px; }
.aj-chip { border: 1px solid var(--line); background: var(--brand-soft); color: var(--ink); border-radius: var(--r-pill); padding: 5px 12px; font-size: var(--fs-sm); line-height: 1.3; min-height: 0; text-align: left; }
.aj-chip:hover { border-color: var(--brand); }

/* While it works: the steps so far, the current one with a dot. */
.aj-busy .aj-done { list-style: none; margin: 0 0 4px; padding: 0; }
.aj-busy .aj-done li { margin: 0 0 2px; }
.aj-busy .aj-now { display: flex; align-items: center; gap: 8px; }
.aj-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: none; animation: aj-pulse 1.1s ease-in-out infinite; }
@keyframes aj-pulse { 0%, 100% { opacity: .35; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.1); } }

/* Answer tables: the table scrolls on its own; Copy / CSV sit under it. */
.aj-tblock { margin: 4px 0 6px; }
.aj-tblock .aj-table { margin: 0; }
.aj-tbar { display: flex; gap: 6px; margin-top: 4px; }
.aj-tbar button { padding: 2px 10px; line-height: 18px; font-size: var(--fs-xs); min-height: 0; }

/* The calculator's output: a chart (PNG) inside the answer, white behind it so it reads in dark mode; CSVs as links. */
.aj-files { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 6px; }
.aj-chart { margin: 0; max-width: 100%; }
.aj-chart img { display: block; max-width: 100%; height: auto; border-radius: 6px; background: #fff; border: 1px solid var(--line, rgba(0,0,0,.12)); }
.aj-file { text-decoration: none; }

/* Under an answer: how it found it, 👍 / 👎, the optional note. */
.aj-under { align-self: stretch; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: -4px; }
.aj-steps summary { cursor: pointer; }
.aj-steps ol { margin: 4px 0 0; padding-left: 20px; }
.aj-fb { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.aj-vote { border: 1px solid transparent; background: transparent; box-shadow: none; padding: 2px 6px; min-height: 0; line-height: 1.2; font-size: var(--fs-md); border-radius: var(--r-sm); filter: grayscale(1); opacity: .65; }
.aj-vote:hover, .aj-vote:focus-visible { opacity: 1; filter: none; }
.aj-vote.on { filter: none; opacity: 1; border-color: var(--line); background: var(--brand-soft); }
.aj-fbmsg { color: var(--bad); }
.aj-note { flex-basis: 100%; gap: 6px; flex-wrap: nowrap; }
.aj-note input { flex: 1; min-width: 0; }

/* Prepared actions under an answer (js/prepared.js draws the card, css/prepared.css styles it): full width of the chat. */
.aj-prep { align-self: stretch; min-width: 0; max-width: 100%; }
.aj-prep .pa-card { margin: 2px 0 4px; }
.aj-prep-used { margin: 0 0 4px; }
.aj-panel .aj-actions .aj-foot { min-width: 0; }

/* 🎤 beside Ask: the same height; listening = red dot that pulses. */
.aj-panel .aj-actions { gap: 8px; flex-wrap: nowrap; }
.aj-mic { position: relative; min-height: var(--ctl-h); min-width: var(--ctl-h); padding: 0 10px; font-size: var(--fs-md); line-height: 1; flex: none; }
.aj-mic[hidden] { display: none; }
.aj-mic.listening { border-color: var(--red); background: var(--bad-soft); }
.aj-mic.listening::after { content: ""; position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); animation: aj-pulse 1s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  .aj-dot, .aj-mic.listening::after { animation: none; }
}

@media (max-width: 700px) {
  .aj-hbtns button.small { padding: 4px 7px; }
  .aj-panel .aj-actions .small { font-size: var(--fs-xs); }
}

/* Panel tint (Colin 2026-11-22: "ask jade window should have a slightly different color so we can distinguish it from
   the content behind it"): a light wash of the theme's brand color, a brand-tinted border and a deeper shadow ("and give it a shadow"); answers and the text box stay
   on the plain card color so they read clearly on it. Works in every theme and in dark mode. */
.aj-panel { background: color-mix(in srgb, var(--brand) 7%, var(--card)); border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
  box-shadow: 0 18px 48px rgba(0, 0, 0, .22), 0 4px 12px rgba(0, 0, 0, .12); }
.aj-panel .aj-bot { background: var(--card); }
.aj-panel .aj-me { background: color-mix(in srgb, var(--brand) 16%, var(--card)); }
.aj-panel textarea { background: var(--card); }
