/* ============================================================
   VRS – AI live demos (ai-demo.js companion)
   A: .ai-card[data-aidemo] – question types in, answer reveals,
      proposal buttons actually respond. Progressive enhancement:
      without JS the cards stay fully static.
   C: #aid-agent – proactive Agent recommendations demo (AI.html).
   Revert: remove ai-demo.css/js includes + data-aidemo attrs +
   the #agent-demo-section block; cards fall back to static.
   ============================================================ */

/* ---------- A/B · live ai-cards ---------- */
.ai-card[data-aidemo] { position: relative; }
.ai-card.aid-armed .ai-t,
.ai-card.aid-armed .ai-d,
.ai-card.aid-armed .ai-box { opacity: 0; transform: translateY(7px); transition: opacity .45s ease, transform .45s ease; }
.ai-card .aid-in { opacity: 1 !important; transform: none !important; }

/* typing dots – absolutely positioned inside the question line so
   they never shift layout */
.aid-q { position: relative; }
.aid-dots { display: inline-flex; gap: 3px; margin-left: 8px; vertical-align: middle; }
.aid-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--text-3); animation: aidDot 1s infinite; }
.aid-dots i:nth-child(2) { animation-delay: .18s; }
.aid-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes aidDot { 0%, 60%, 100% { opacity: .25; transform: none; } 30% { opacity: 1; transform: translateY(-2px); } }

/* typewriter caret on the question while typing */
.aid-typing::after { content: ''; display: inline-block; width: 7px; height: 12px; margin-left: 2px; vertical-align: -1px; background: var(--accent-text); opacity: .75; animation: aidCaret 1s steps(1) infinite; }
@keyframes aidCaret { 50% { opacity: 0; } }

/* replay control in the card header */
.aid-replay { margin-left: 8px; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--text-3); cursor: pointer; transition: color .2s, border-color .2s; flex: none; }
.aid-replay:hover { color: var(--accent-text); border-color: var(--green); }
.aid-replay svg { width: 11px; height: 11px; }

/* action buttons: confirmed / declined states */
.ai-acts .a { transition: opacity .25s, background .25s, color .25s; }
.ai-acts .a.aid-done { background: var(--green-wash); color: var(--accent-text); pointer-events: none; }
.ai-acts .a.aid-off { opacity: .38; pointer-events: none; }
.aid-audit { display: flex; align-items: center; gap: 7px; margin-top: 12px; font-family: var(--mono); font-size: 10.5px; color: var(--text-3); opacity: 0; transform: translateY(4px); transition: opacity .4s, transform .4s; }
.aid-audit.aid-in { opacity: 1; transform: none; }
.aid-audit .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex: none; }

/* ---------- API code block reveal (AI.html) ---------- */
#aid-api .aid-resp { transition: opacity .7s ease; }
#aid-api.aid-armed .aid-resp { opacity: 0; }
#aid-api.aid-armed .aid-resp.aid-in { opacity: 1; }

/* ---------- C · proactive Agent demo ---------- */
.aid-tag { font-family: var(--mono); font-size: 9.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--accent-text); background: var(--green-wash); border-radius: 999px; padding: 3px 9px; margin-left: auto; margin-right: 96px; white-space: nowrap; }
.aid-reset { position: absolute; top: 10px; right: 14px; z-index: 5; display: inline-flex; align-items: center; gap: 6px; font: 600 11px var(--mono); letter-spacing: .05em; color: var(--text-3); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; cursor: pointer; transition: color .2s, border-color .2s; }
.aid-reset:hover { color: var(--accent-text); border-color: var(--green); }
.aid-reset svg { width: 11px; height: 11px; }

.aid-agent { display: grid; grid-template-columns: 4fr 7fr; background: var(--surface); }
.aid-rail { border-right: 1px solid var(--hairline); padding: 18px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.aid-rh { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); }
.aid-rh b { color: var(--accent-text); }
.aid-rh .s { display: block; margin-top: 3px; font-family: inherit; text-transform: none; letter-spacing: 0; font-size: 11px; }

.aid-rec { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 13px; cursor: pointer; font: inherit; color: inherit; transition: border-color .2s, background .2s, opacity .3s; position: relative; }
.aid-rec:hover { border-color: var(--green); }
.aid-rec.on { border-color: var(--green); background: var(--green-wash); }
.aid-rec .bl { display: flex; align-items: center; gap: 6px; margin-bottom: 7px; }
.aid-rec .tt { font-size: 12.5px; font-weight: 600; line-height: 1.35; color: var(--text); }
.aid-rec .cf { position: absolute; top: 11px; right: 12px; font-family: var(--mono); font-size: 10px; color: var(--text-3); }
.aid-rec.done-ok, .aid-rec.done-adj { opacity: .72; }
.aid-rec.done-no { opacity: .45; }
.aid-rec .st { display: none; margin-top: 7px; font-family: var(--mono); font-size: 9.5px; letter-spacing: .06em; }
.aid-rec.done-ok .st.ok, .aid-rec.done-adj .st.adj, .aid-rec.done-no .st.no { display: block; }
.aid-rec .st.ok { color: var(--accent-text); }
.aid-rec .st.adj { color: var(--warn-tx); }
.aid-rec .st.no { color: var(--text-3); }

.aid-b { font-family: var(--mono); font-size: 9px; font-weight: 700; letter-spacing: .08em; padding: 2.5px 7px; border-radius: 999px; }
.aid-b.anom { background: rgba(220,38,38,.1); color: #dc2626; }
[data-theme="dark"] .aid-b.anom { color: #f87171; }
.aid-b.rule { background: var(--warn-bg); color: var(--warn-tx); }
.aid-b.rep { background: rgba(42,111,219,.1); color: #2A6FDB; }
[data-theme="dark"] .aid-b.rep { color: #7DB0F5; }
.aid-b.sev { background: transparent; padding-left: 0; color: var(--text-3); font-weight: 600; }
.aid-b.sev.hi { color: #dc2626; }
[data-theme="dark"] .aid-b.sev.hi { color: #f87171; }
.aid-b.sev.md { color: var(--warn-tx); }

.aid-summary { margin-top: auto; border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; font-size: 12px; line-height: 1.5; color: var(--text-2); opacity: 0; transform: translateY(5px); transition: opacity .5s, transform .5s; }
.aid-summary.aid-in { opacity: 1; transform: none; border-color: var(--green); background: var(--green-wash); }
.aid-summary b { color: var(--accent-text); }

.aid-detail { padding: 22px 24px; min-height: 380px; display: flex; flex-direction: column; }
.aid-detail .bl { display: flex; align-items: center; gap: 8px; }
.aid-detail .cfp { font-family: var(--mono); font-size: 10px; color: var(--accent-text); background: var(--green-wash); border-radius: 999px; padding: 3px 9px; }
.aid-detail h4 { font-size: 18px; font-weight: 700; margin: 12px 0 8px; letter-spacing: -0.01em; }
.aid-detail .ds { font-size: 13.5px; color: var(--text-2); line-height: 1.6; }
.aid-lbl { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); margin: 18px 0 8px; }
.aid-act { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--surface-2); }
.aid-act .ax { font-size: 13.5px; font-weight: 600; }
.aid-btns { display: flex; gap: 8px; margin-top: 13px; flex-wrap: wrap; }
.aid-btns button { font: 700 12px var(--font, inherit); padding: 9px 14px; border-radius: 9px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); transition: border-color .2s, background .2s, color .2s; }
.aid-btns button svg { width: 12px; height: 12px; }
.aid-btns button.ok { background: var(--green); border-color: var(--green); color: var(--on-green); }
.aid-btns button.ok:hover { filter: brightness(1.05); }
.aid-btns button:not(.ok):hover { border-color: var(--text-3); }
.aid-ctx { display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; border: 1px solid var(--line); border-radius: 10px; padding: 9px 13px; font-size: 12.5px; color: var(--text-2); }
.aid-ctx svg { width: 13px; height: 13px; color: var(--text-3); }

/* decision result panel */
.aid-result { border-radius: 12px; padding: 14px; margin-top: 16px; opacity: 0; transform: translateY(6px); transition: opacity .45s, transform .45s; }
.aid-result.aid-in { opacity: 1; transform: none; }
.aid-result.ok { border: 1px solid color-mix(in oklab, var(--green) 45%, transparent); background: var(--green-wash); }
.aid-result.adj { border: 1px solid var(--warn-brd); background: var(--warn-bg); }
.aid-result.no { border: 1px solid var(--line); background: var(--surface-2); }
.aid-result .rt { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.aid-result.ok .rt { color: var(--accent-text); }
.aid-result.adj .rt { color: var(--warn-tx); }
.aid-result .rt svg { width: 13px; height: 13px; flex: none; }
.aid-result .rd { font-size: 12.5px; color: var(--text-2); margin-top: 5px; line-height: 1.5; }
.aid-result .au { font-family: var(--mono); font-size: 10px; color: var(--text-3); margin-top: 9px; }

/* adjust mini-form */
.aid-adjust { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; opacity: 0; transform: translateY(5px); transition: opacity .35s, transform .35s; }
.aid-adjust.aid-in { opacity: 1; transform: none; }
.aid-adjust .opt { font: 600 12px var(--mono); padding: 8px 12px; border-radius: 9px; border: 1px dashed var(--line); background: var(--surface); color: var(--text-2); cursor: pointer; transition: border-color .2s, color .2s; }
.aid-adjust .opt:hover, .aid-adjust .opt.sel { border-style: solid; border-color: var(--warn-tx); color: var(--warn-tx); }

@media (max-width: 860px) {
  .aid-agent { grid-template-columns: 1fr; }
  .aid-rail { border-right: 0; border-bottom: 1px solid var(--hairline); }
  .aid-detail { min-height: 0; }
  .aid-tag { margin-right: 0; display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ai-card.aid-armed .ai-t, .ai-card.aid-armed .ai-d, .ai-card.aid-armed .ai-box { opacity: 1; transform: none; transition: none; }
  .aid-dots i { animation: none; opacity: .6; }
  .aid-typing::after { animation: none; }
  .aid-audit, .aid-result, .aid-adjust, .aid-summary { transition: none; }
}
