/* AI Agents before the first agent: the head with an example conversation beside it, the two packages and how it
   works. The conversation shows in full unless ai-start.js adds .plays; reveals fill backwards only. */

/* ---------- The head: the copy beside the example conversation ---------- */
.ag-start-in { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: center; gap: 26px 44px; }
.ag-start h1 { margin-top: 8px; font-size: 36px; line-height: 1.1; }
.ag-start .phead-lead { max-width: 54ch; }

/* The systems with a finished agent, joined by one bracket into the beam towards the assistant. */
.ag-start-flow { display: flex; align-items: center; max-width: 440px; margin-top: 22px; }
.ag-start-flow .deck-beam { min-width: 28px; margin-inline: 0; }
.ag-start-flow .deck-plate { flex: 0 1 180px; width: 180px; min-width: 0; height: 52px; padding: 0 14px; border-radius: var(--r-l); line-height: 1.2; }
.ag-start-flow .deck-plate svg { flex: none; }

.ag-start-do { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 22px; }
.ag-start-do small { flex-basis: 100%; min-width: 0; font-size: var(--fs-s); color: var(--stage-muted); text-wrap: pretty; }

/* ---------- The example conversation ---------- */
.ag-chat {
  display: flex; flex-direction: column; justify-self: end; width: 100%; max-width: 720px; min-width: 0; margin: 0; overflow: hidden;
  border-radius: var(--r-xl); background: var(--panel); color: var(--ink);
  box-shadow: 0 0 0 1px var(--stage-rim), 0 24px 48px -20px var(--stage-shade);
}
.ag-chat-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); font-size: var(--fs-s); font-weight: 500; color: var(--ink-3); }
.ag-chat-head b { font-weight: 600; color: var(--ink); }
.ag-chat-body { display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.ag-ask { align-self: flex-end; max-width: 80%; margin: 0; padding: 9px 14px; border-radius: 16px 16px var(--r-xs) 16px; background: var(--brand); color: var(--on-brand); font-size: var(--fs-m); line-height: 1.4; }
.ag-reply { position: relative; display: flex; flex-direction: column; align-self: flex-start; gap: 10px; width: 92%; min-width: 0; font-size: var(--fs-m); line-height: 1.45; color: var(--ink); }
.ag-reply p { margin: 0; }
.ag-deals { margin: 0; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-l); list-style: none; }
.ag-deal-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 62px; align-items: center; gap: 12px; padding: 8px 12px; border-top: 1px solid var(--line); font-size: var(--fs-s); }
.ag-deal-row:first-child { border-top: 0; }
.ag-deal-row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.ag-deal-row small { font-size: var(--fs-xs); text-align: right; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ag-deal { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ag-deal i { flex: none; width: 8px; height: 8px; border-radius: 3px; background: var(--rt-deal); }
.ag-ready { padding: 10px 12px; border-radius: var(--r-l); background: var(--brand-soft); color: var(--ink); }
.ag-ready b { font-weight: 600; }
.ag-dots { display: none; }

/* The dark panel is lifted a step, or it sinks into the dark head behind it; white text needs the deeper blue. */
:root[data-theme="dark"] .ag-chat { background: var(--panel-2); }
:root[data-theme="dark"] .ag-ask { background: var(--stage-action); }

/* ---------- The packages: two cells side by side, split by a line ---------- */
.ag-packs {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding-left: max(0px, calc(var(--zl, var(--pad-x)) - 20px)); padding-right: max(0px, calc(var(--zr, var(--pad-x)) - 20px));
}
.ag-pack { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; min-height: 168px; padding: 20px; color: inherit; }
.ag-pack + .ag-pack { border-left: 1px solid var(--line); }
.ag-pack b { display: flex; align-items: center; gap: 8px; font-size: var(--fs-m); font-weight: 600; color: var(--ink); }
.ag-pack-tap { transition: background .15s ease; }
.ag-pack-tap:hover { background: var(--panel-2); color: inherit; }
.ag-pack-ic { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: var(--r-m); background: var(--brand-soft); color: var(--brand-text); }
.ag-pack-ic svg { width: 16px; height: 16px; }
.ag-pack-go { position: absolute; top: 20px; right: 20px; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--panel-3); color: var(--ink-3); }
.ag-pack-go svg { width: 14px; height: 14px; }
.ag-price { margin-top: 6px; font-size: 28px; line-height: 1.1; font-weight: 600; letter-spacing: var(--tr-tight); font-variant-numeric: tabular-nums; color: var(--ink); }
.ag-price small { margin-left: 4px; font-size: var(--fs-s); font-weight: 500; letter-spacing: 0; color: var(--ink-4); }
.ag-pack-desc { font-size: var(--fs-xs); line-height: 1.5; color: var(--ink-4); }
.ag-pack-note { font-size: var(--fs-2xs); font-weight: 600; color: var(--ink-3); }
.ag-do { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 14px; }
.ag-do > form { display: flex; }

/* ---------- How it works: numbered steps in columns, split by lines ---------- */
ol.ag-how { margin-bottom: 0; list-style: none; }
.ag-how .colsplit-col { display: grid; align-content: start; justify-items: start; gap: 6px; }
.ag-step-n { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-text); font-size: var(--fs-xs); font-weight: 700; }
.ag-how b { font-size: var(--fs-m); font-weight: 600; color: var(--ink); }
.ag-how p { margin: 0; font-size: var(--fs-s); line-height: 1.5; color: var(--ink-3); }
.ag-how .ag-do { padding-top: 6px; }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  /* Waiting to be seen. The delayed reveal is the way out when ai-start.js never runs; once it runs it marks .waits. */
  html.js .ag-chat:not(.plays) :is(.ag-ask, .ag-say, .ag-ready) { opacity: 0; }
  html.js .ag-chat:not(.plays, .waits) :is(.ag-ask, .ag-say, .ag-ready) { animation: ag-chat-show 0s 6s forwards; }

  .ag-chat.plays :is(.ag-ask, .ag-say) { animation: ag-chat-in .45s var(--ease) var(--at, 0s) backwards; }
  .ag-chat.plays .ag-ready { animation: ag-chat-land .55s var(--ease) var(--at, 0s) backwards, ag-chat-ring 1.3s ease-out calc(var(--at, 0s) + .35s) 1; }

  .ag-dots {
    position: absolute; top: 0; left: 0; display: inline-flex; gap: 4px; padding: 10px 12px; border-radius: 14px 14px 14px var(--r-xs);
    background: var(--panel-3); opacity: 0;
  }
  .ag-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-4); }
  .ag-chat.plays .ag-dots { animation: ag-chat-typing var(--for, 1s) linear var(--at, 0s) backwards; }
  .ag-chat.plays .ag-dots i { animation: ag-chat-dot .6s ease-in-out var(--at, 0s) 2; }
  .ag-chat.plays .ag-dots i:nth-child(2) { animation-delay: calc(var(--at, 0s) + .12s); }
  .ag-chat.plays .ag-dots i:nth-child(3) { animation-delay: calc(var(--at, 0s) + .24s); }

  .ag-q1 { --at: .2s; }
  .ag-a1 .ag-dots { --at: .8s; --for: .95s; }
  .ag-a1 > p { --at: 1.75s; }
  .ag-deals { --at: 1.95s; }
  .ag-deal-row:nth-child(1) { --at: 2.05s; }
  .ag-deal-row:nth-child(2) { --at: 2.2s; }
  .ag-deal-row:nth-child(3) { --at: 2.35s; }
  .ag-q2 { --at: 3.4s; }
  .ag-a2 .ag-dots { --at: 4s; --for: .85s; }
  .ag-ready { --at: 4.85s; }
}

@keyframes ag-chat-show { to { opacity: 1; } }
@keyframes ag-chat-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes ag-chat-land { from { opacity: 0; transform: translateY(12px) scale(.97); } }
@keyframes ag-chat-ring {
  from { box-shadow: 0 0 0 0 var(--brand-line); }
  to { box-shadow: 0 0 0 10px transparent; }
}
@keyframes ag-chat-typing {
  from, to { opacity: 0; }
  12%, 88% { opacity: 1; }
}
@keyframes ag-chat-dot { 50% { transform: translateY(-3px); } }

/* ---------- Narrower pages ---------- */
@container page (max-width: 1180px) {
  .ag-start-in { grid-template-columns: minmax(0, 1fr); }
  .ag-chat { justify-self: stretch; max-width: none; }
}

@container page (max-width: 640px) {
  .ag-start h1 { font-size: 27px; }
  .ag-start-do .btn { flex: 1 1 auto; }
  .ag-start-flow .deck-plate { padding: 0 10px; font-size: var(--fs-xs); }
  .ag-chat-body { padding: 14px 12px; }
  .ag-ask { max-width: 88%; }
  .ag-reply { width: 100%; }
  .ag-deal-row { grid-template-columns: minmax(0, 1fr) auto; gap: 0 10px; padding: 7px 10px; }
  .ag-deal-row small { grid-column: 1; grid-row: 2; padding-left: 16px; text-align: left; }
  .ag-packs { grid-template-columns: minmax(0, 1fr); }
  .ag-pack { min-height: 0; }
  .ag-pack + .ag-pack { border-left: 0; border-top: 1px solid var(--line); }
  .ag-do .btn { flex: 1 1 auto; }
}
