/* =============================================================================================
   AI PAGES (<tool>/ai/, written by _ref/agent-doc.mjs through _ref/ai-skill.mjs)
   Builds on guide-shared.css (.gd-*): the install demo (a mock app window that ai-page.js
   plays step by step, beside .gd-steps) and the example conversation.
   Colours come only from the site tokens (dark.css, light.css). Class prefix: .ai-
   ============================================================================================= */

.ai-files { margin: 14px 0 0; font-size: .88rem; line-height: 1.6; color: var(--muted); }
.ai .ai-dl { gap: 2px; }

/* ---- Tabs: one per assistant ---------------------------------------------------------------- */
.ai-tabs { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 14px; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--input-bg); }
.ai-tab { padding: 6px 16px; border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--muted); font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer; transition: background var(--motion-fast), color var(--motion-fast); }
.ai-tab[aria-selected="true"] { background: var(--accent-strong); color: var(--text-inv); }
.ai-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- The mock app window -------------------------------------------------------------------- */
.ai-stage { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: var(--bg-subtle); font-size: clamp(9px, 1.25vw, 14px); }
.ai-win { position: absolute; inset: 4% 3%; display: grid; grid-template-rows: auto 1fr; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); overflow: hidden; box-shadow: 0 10px 30px rgba(0, 0, 0, .12); }
.ai-win-bar { display: flex; align-items: center; gap: .6em; padding: .55em .9em; border-bottom: 1px solid var(--border); font-weight: 700; color: var(--text); }
.ai-win-bar i { width: .7em; height: .7em; border-radius: 50%; background: var(--border); }
.ai-win-bar span { margin-left: .4em; }
.ai-win-body { display: grid; grid-template-columns: 26% 1fr; min-height: 0; }
.ai-side { padding: .8em .6em; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: .3em; }
.ai-side b { display: block; padding: .45em .7em; border-radius: 8px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-side b.on { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--text); }
.ai-side .ai-gap { flex: 1; }
.ai-main { position: relative; padding: 1em 1.3em; min-width: 0; display: flex; flex-direction: column; gap: .7em; }
.ai-main h4 { margin: 0; font-size: 1.15em; color: var(--text); }
.ai-main p { margin: 0; color: var(--muted); line-height: 1.45; }
.ai-row { display: flex; align-items: center; justify-content: space-between; gap: 1em; padding: .6em .8em; border: 1px solid var(--border); border-radius: 10px; color: var(--text); }
.ai-row small { display: block; color: var(--muted); font-size: .85em; }
.ai-btn { display: inline-flex; align-self: flex-start; align-items: center; gap: .4em; padding: .45em .9em; border-radius: 8px; background: var(--accent-strong); color: var(--text-inv); font-weight: 700; }
.ai-btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.ai-menu { position: absolute; left: .6em; bottom: 2.6em; width: 70%; padding: .4em; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); box-shadow: 0 8px 22px rgba(0, 0, 0, .14); display: flex; flex-direction: column; gap: .2em; animation: ai-pop .25s ease-out; }
.ai-menu b { padding: .4em .6em; border-radius: 6px; font-weight: 600; color: var(--text); }
.ai-tog { flex: none; width: 2.4em; height: 1.35em; border-radius: 1em; background: var(--border); position: relative; transition: background .35s; }
.ai-tog::after { content: ""; position: absolute; top: .18em; left: .2em; width: 1em; height: 1em; border-radius: 50%; background: var(--panel); transition: transform .35s; }
.ai-tog.on { background: var(--accent2); }
.ai-tog.on::after { transform: translateX(1.05em); }
.ai-drop { flex: 1; display: grid; place-items: center; align-content: center; gap: .5em; border: 2px dashed var(--border); border-radius: 12px; color: var(--muted); text-align: center; padding: 1em; }
.ai-drop.hot { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.ai-file { display: inline-flex; align-items: center; gap: .45em; padding: .45em .8em; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--text); font-family: 'DM Mono', monospace; font-size: .9em; box-shadow: 0 6px 16px rgba(0, 0, 0, .12); }
.ai-file.fly { animation: ai-fly 1.1s cubic-bezier(.2, .8, .3, 1) both; }
.ai-scan { height: .5em; border-radius: 1em; background: var(--input-bg); overflow: hidden; }
.ai-scan i { display: block; height: 100%; width: 100%; background: var(--accent2); transform-origin: left; animation: ai-scan 1.6s ease-out both; }
.ai-ok { color: var(--text); font-weight: 700; }
.ai-dialog { position: absolute; inset: 8% 10%; display: flex; flex-direction: column; gap: .7em; padding: 1em 1.2em; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); box-shadow: 0 14px 40px rgba(0, 0, 0, .2); animation: ai-pop .25s ease-out; }
.ai-target { position: relative; }

/* The pointer that moves to the next thing to press (ai-page.js places it) */
.ai-cursor { position: absolute; left: 0; top: 0; width: 1.6em; height: 1.6em; pointer-events: none; transition: transform .7s cubic-bezier(.3, .7, .3, 1); z-index: 3; }
.ai-cursor svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .35)); }
.ai-cursor.press::before { content: ""; position: absolute; left: -.6em; top: -.6em; width: 1.4em; height: 1.4em; border-radius: 50%; border: 2px solid var(--accent); animation: ai-press .5s ease-out both; }

@keyframes ai-pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes ai-fly { from { opacity: 0; transform: translate(-60%, 120%) rotate(-8deg); } 60% { opacity: 1; } to { opacity: 1; transform: none; } }
@keyframes ai-scan { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes ai-press { from { opacity: 1; transform: scale(.3); } to { opacity: 0; transform: scale(1.6); } }

/* ---- The example conversation --------------------------------------------------------------- */
.ai-chat { display: flex; flex-direction: column; gap: 12px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-subtle); }
.ai-msg { max-width: 52rem; padding: 14px 18px; border-radius: 16px; line-height: 1.55; font-size: .95rem; color: var(--text); }
.ai-msg p { margin: 0 0 8px; }
.ai-msg p:last-child { margin-bottom: 0; }
.ai .ai-user p { color: var(--text-inv); }
.ai-user { align-self: flex-end; max-width: 34rem; background: var(--accent-strong); color: var(--text-inv); border-bottom-right-radius: 4px; }
.ai-bot { align-self: flex-start; background: var(--panel); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.ai-bot h3 { margin: 12px 0 6px; font-size: .98rem; }
.ai-bot h3:first-child { margin-top: 0; }
.ai-bot ul, .ai-bot ol { margin: 0 0 8px; padding-left: 1.3em; }
.ai-bot li { margin: 3px 0; }
.ai-work { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--panel); font-size: .8rem; color: var(--muted); }
.ai-chip strong { color: var(--text); }
.gd .ai-link { font-weight: 700; }
.ai-code { margin: 6px 0 8px; padding: 8px 10px; border-radius: var(--radius-md); background: var(--input-bg); font-family: 'DM Mono', monospace; font-size: .76rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-all; color: var(--text); }
.ai-code code { background: none; padding: 0; font-size: inherit; }
.ai-chat-bar { display: flex; justify-content: flex-end; gap: 8px; }
.ai-chat-bar .btn-sm { padding: 6px 14px; font-size: .82rem; text-decoration: none; }

/* Played in order once the card is in view (ai-page.js); without the script all of it shows. */
.ai-chat.ai-anim .ai-step { opacity: 0; transform: translateY(8px); transition: opacity .45s ease, transform .45s ease; }
.ai-chat.ai-anim .ai-step.in { opacity: 1; transform: none; }
.ai-typing { display: inline-flex; gap: 4px; padding: 12px 16px; border-radius: 16px; background: var(--panel); border: 1px solid var(--border); align-self: flex-start; }
.ai-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: ai-dot 1s infinite; }
.ai-typing i:nth-child(2) { animation-delay: .15s; }
.ai-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

@media (max-width: 700px) {
  .ai-stage { aspect-ratio: 4 / 3.4; font-size: 11px; }
  .ai-win { inset: 3% 2%; }
  .ai-win-body { grid-template-columns: 30% 1fr; }
  .ai-chat { padding: 12px; }
  .ai-msg { padding: 12px 14px; }
  }
@media (prefers-reduced-motion: reduce) {
  .ai-cursor, .ai-file.fly, .ai-menu, .ai-dialog, .ai-scan i, .ai-tog, .ai-tog::after { animation: none !important; transition: none !important; }
  .ai-chat.ai-anim .ai-step { transition: none; }
}
