/* Retrieval-augmented generation chain (includes/visuals/rag.php) */
.rg { container-type: inline-size; min-width: 0; }
.rg-phase { margin: 0 0 16px; }
.rg-phase--live { margin-top: 10px; padding-top: 22px; border-top: 1px solid rgba(255, 255, 255, .14); }

.rg-chain { list-style: none; margin: 0; padding: 0; }
.rg-step { position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr); column-gap: 16px; padding-bottom: 24px; }
.rg-step:last-child { padding-bottom: 0; }
.rg-chain--prep .rg-step:last-child { padding-bottom: 18px; }
/* rail between two markers */
.rg-step:not(:last-child)::before { content: ""; position: absolute; left: 16px; top: 38px; bottom: 4px; width: 2px; background: var(--green); opacity: .55; }
.rg-chain--prep .rg-step:not(:last-child)::before { opacity: 1; background: linear-gradient(to bottom, rgba(255, 255, 255, .45) 50%, transparent 0) 0 0 / 2px 8px; }

.rg-n { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-size: 14px; font-weight: 700; background: var(--green); color: var(--forest); }
.rg-chain--prep .rg-n { background: transparent; color: var(--white); border: 1.5px dashed rgba(255, 255, 255, .55); }
.rg-step--q .rg-n { background: var(--white); color: var(--forest); }
.rg-n svg { width: 17px; height: 17px; }
.rg-body { min-width: 0; padding-top: 5px; }
.rg-t { margin: 0; font-family: var(--font-sans); font-size: 17px; font-weight: 700; line-height: 1.3; color: var(--white); }
.rg-d { margin: 5px 0 0; font-size: 14.5px; line-height: 1.5; color: rgba(255, 255, 255, .8); }
.rg-ico { flex: none; width: 15px; height: 15px; }

/* 1 · documents */
.rg-docs { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.rg-docs li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border-radius: 6px; background: rgba(255, 255, 255, .08); font-size: 13px; font-weight: 600; color: var(--white); }
.rg-docs .rg-ico { color: var(--green); }
/* 2 · passages in the index */
.rg-chunks { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; max-width: 360px; }
.rg-c { display: block; height: 7px; border-radius: 4px; background: rgba(255, 255, 255, .22); }
.rg-c--a { width: 44px; }
.rg-c--b { width: 28px; }
.rg-c--c { width: 60px; }
.rg-c--hit { background: var(--green); }

/* question */
.rg-step--q .rg-body { padding: 12px 16px 13px; border-radius: 10px; background: var(--white); color: var(--ink); }
.rg-q-l { margin: 0; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--green-text); }
.rg-q-t { margin: 3px 0 0; font-family: var(--font-serif); font-size: 17px; line-height: 1.4; color: var(--forest); }
.rg-q-p { margin: 6px 0 0; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }

/* 3 · passages found */
.rg-pass { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.rg-p { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 7px 10px; border-radius: 7px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); font-size: 13.5px; line-height: 1.35; }
.rg-p-t { min-width: 0; flex: 1; color: rgba(255, 255, 255, .72); }
.rg-p-s { flex: none; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: rgba(255, 255, 255, .72); }
.rg-p .rg-ico { color: rgba(255, 255, 255, .72); }
.rg-p--keep { background: rgba(150, 248, 120, .12); border-color: rgba(150, 248, 120, .45); }
.rg-p--keep .rg-p-t { color: var(--white); font-weight: 600; }
.rg-p--keep .rg-p-s, .rg-p--keep .rg-ico { color: var(--green); }
.rg-p--drop .rg-p-t { text-decoration: line-through; text-decoration-color: rgba(255, 255, 255, .4); }

/* 4 · model */
.rg-tags { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.rg-tags li { padding: 3px 10px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .28); font-size: 12.5px; font-weight: 600; color: var(--white); }

/* 5 · two outcomes */
.rg-out { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding-top: 1px; }
@container (min-width: 600px) { .rg-out { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
.rg-out-l { margin: 0 0 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.rg-ans { padding: 14px 16px 15px; border-radius: 10px; background: var(--mint); color: var(--ink); }
.rg-ans .rg-out-l { color: var(--green-text); }
.rg-ans-t { margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--ink); }
.rg-ref { display: inline-grid; place-items: center; min-width: 16px; height: 16px; margin-left: 2px; border-radius: 4px; background: var(--forest); color: var(--white); font-size: 10.5px; font-weight: 700; line-height: 1; vertical-align: 4px; }
.rg-cites { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.rg-cite { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border-radius: 999px; background: var(--white); border: 1px solid rgba(12, 43, 21, .18); font-size: 12.5px; font-weight: 600; color: var(--forest); }
.rg-cite-n { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--forest); color: var(--white); font-size: 10.5px; }
.rg-unk { padding: 14px 16px 15px; border-radius: 10px; border: 1.5px dashed rgba(255, 255, 255, .45); }
.rg-unk .rg-out-l { color: var(--green); }
.rg-unk-t { margin: 0; font-family: var(--font-serif); font-size: 15.5px; line-height: 1.45; color: var(--white); }
.rg-unk-n { margin: 8px 0 0; font-size: 13px; line-height: 1.45; color: rgba(255, 255, 255, .78); }

@media (max-width: 600px) {
  .rg-step { grid-template-columns: 28px minmax(0, 1fr); column-gap: 12px; }
  .rg-n { width: 28px; height: 28px; font-size: 13px; }
  .rg-step:not(:last-child)::before { left: 13px; top: 32px; }
  .rg-p { flex-wrap: wrap; gap: 4px 9px; }
  .rg-p-s { font-size: 10.5px; }
}

/* animation: the upstream steps, then the question, the passages sorted (retained ones light up),
   the model, then the two outcomes; afterwards a dot keeps running down the question's path */
.js .vz-figure .rg-step, .js .vz-figure .rg-phase { opacity: 0; transform: translateY(12px); transition: opacity .5s ease, transform .5s ease; }
.js .vz-figure .rg-p { transition: background-color .4s ease, border-color .4s ease; }
.js .vz-figure .rg-p-s, .js .vz-figure .rg-p .rg-ico { opacity: 0; transition: opacity .35s ease; }
.js .vz-figure .rg-cite { opacity: 0; transform: scale(.85); transition: opacity .35s ease, transform .35s ease; }
.js .vz-figure:not(.is-visible) .rg-p--keep { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .1); }
.js .vz-figure.is-visible .rg-step, .js .vz-figure.is-visible .rg-phase { opacity: 1; transform: none; }
.js .vz-figure.is-visible .rg-p-s, .js .vz-figure.is-visible .rg-p .rg-ico { opacity: 1; }
.js .vz-figure.is-visible .rg-cite { opacity: 1; transform: none; }
.js .vz-figure.is-visible .rg-step--2 { transition-delay: .2s; }
.js .vz-figure.is-visible .rg-phase--live { transition-delay: .45s; }
.js .vz-figure.is-visible .rg-step--q { transition-delay: .6s; }
.js .vz-figure.is-visible .rg-step--3 { transition-delay: .9s; }
.js .vz-figure.is-visible .rg-p--1, .js .vz-figure.is-visible .rg-p--1 .rg-p-s, .js .vz-figure.is-visible .rg-p--1 .rg-ico { transition-delay: 1.3s; }
.js .vz-figure.is-visible .rg-p--2, .js .vz-figure.is-visible .rg-p--2 .rg-p-s, .js .vz-figure.is-visible .rg-p--2 .rg-ico { transition-delay: 1.45s; }
.js .vz-figure.is-visible .rg-p--3 .rg-p-s, .js .vz-figure.is-visible .rg-p--3 .rg-ico { transition-delay: 1.6s; }
.js .vz-figure.is-visible .rg-p--4 .rg-p-s, .js .vz-figure.is-visible .rg-p--4 .rg-ico { transition-delay: 1.75s; }
.js .vz-figure.is-visible .rg-step--4 { transition-delay: 1.75s; }
.js .vz-figure.is-visible .rg-step--5 { transition-delay: 2.1s; }
.js .vz-figure.is-visible .rg-cite--1 { transition-delay: 2.5s; }
.js .vz-figure.is-visible .rg-cite--2 { transition-delay: 2.65s; }

/* travelling dot: one segment of the rail after the other (question → 3 → 4 → 5), then a pause */
.rg-chain--live .rg-step:not(:last-child)::after { content: ""; position: absolute; left: 11px; top: 38px; bottom: 4px; width: 12px; margin-top: -6px; opacity: 0;
  background: radial-gradient(circle at 6px 6px, var(--green) 4px, rgba(150, 248, 120, .35) 5px, transparent 6.5px) 0 0 / 12px 12px no-repeat; }
.js .vz-figure.is-visible .rg-chain--live .rg-step:not(:last-child)::after { animation: rg-run 4s linear 2.8s infinite; }
.js .vz-figure.is-visible .rg-chain--live .rg-step--3::after { animation-delay: 3.6s; }
.js .vz-figure.is-visible .rg-chain--live .rg-step--4::after { animation-delay: 4.4s; }
@keyframes rg-run {
  0% { opacity: 1; transform: translateY(0); }
  20% { opacity: 1; transform: translateY(100%); }
  20.1%, 100% { opacity: 0; transform: translateY(100%); }
}
@media (max-width: 600px) { .rg-chain--live .rg-step:not(:last-child)::after { left: 8px; top: 32px; } }
