/* Revenue assurance v3: citation viewer. Kit tokens only.
   Matches the live revenue product (research/live/03 citation drawer, 04 checklist side by side).
   Lineage: revenue accounting demo checklist-review.css (.cr-evidence chip, .document-pane toolbar),
   checklist-documents.css (.checklist-pdf-page, .citation-mark), lifecycle-pdf.css (page viewport). */

.cite-ico { width: 14px; height: 14px; flex-shrink: 0; }

/* ---------- Chip: "p.2" or "Order form · p. 1" ---------- */
.cite-chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--background); color: var(--primary); font-family: var(--font-sans); font-size: 12px; line-height: 16px; font-weight: 500; white-space: nowrap; cursor: pointer; vertical-align: middle; transition: background var(--motion-quick) var(--ease-move), border-color var(--motion-quick) var(--ease-move); }
.cite-chip .cite-ico { width: 12px; height: 12px; }
.cite-chip:hover { background: var(--muted-brand); border-color: var(--border-brand); }
.cite-chip[aria-pressed="true"] { background: var(--muted-brand); border-color: var(--border-brand); }

/* ---------- Viewer: tabs, toolbar, scrolling pages ---------- */
.cite-viewer { display: flex; flex-direction: column; min-height: 0; height: 100%; background: var(--background); }
.cite-tabs { display: flex; gap: 2px; padding: 8px 12px; border-bottom: 1px solid var(--border); overflow-x: auto; flex-shrink: 0; }
.cite-tab { display: flex; align-items: center; gap: 8px; max-width: 220px; min-height: 44px; padding: 4px 12px 4px 8px; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--foreground); cursor: pointer; text-align: left; }
.cite-tab:hover { background: var(--muted); }
.cite-tab[aria-selected="true"] { background: var(--secondary); box-shadow: var(--shadow-sm); }
.cite-pdf { display: grid; place-items: center; width: 20px; height: 20px; flex-shrink: 0; border-radius: var(--radius-ds-sm); background: var(--artifact-pdf); color: var(--universal-white); }
.cite-pdf .cite-ico { width: 12px; height: 12px; }
.cite-tab-text { min-width: 0; display: flex; flex-direction: column; }
.cite-tab-text strong { font-size: 14px; line-height: 20px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cite-tab-text small { font-size: 12px; line-height: 16px; color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cite-toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--background); flex-shrink: 0; }
.cite-search { display: flex; align-items: center; gap: 8px; flex: 0 1 240px; min-width: 120px; height: 32px; padding: 0 10px; border: 1px solid var(--input); border-radius: var(--radius-md); color: var(--muted-foreground); }
.cite-search:focus-within { border-color: var(--ring); box-shadow: var(--shadow-input-group-focus); }
.cite-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 14px; color: var(--foreground); }
.cite-count { font-size: 12px; color: var(--muted-foreground); white-space: nowrap; }
.cite-spacer { flex: 1; }
.cite-zoom { min-width: 40px; text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; }
.cite-tool { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--background); color: var(--foreground); cursor: pointer; flex-shrink: 0; }
.cite-tool:hover { background: var(--muted); }
.cite-tool .cite-ico { width: 16px; height: 16px; }

.cite-scroll { flex: 1; min-height: 0; overflow: auto; background: var(--secondary); padding: 24px 16px 64px; }
.cite-pages { --cite-z: .75; display: flex; flex-direction: column; align-items: center; gap: 16px; }

/* ---------- Contract page (US letter proportions at 96 dpi, scaled by zoom) ---------- */
.cite-page { position: relative; flex-shrink: 0; width: calc(816px * var(--cite-z)); max-width: 100%; min-height: calc(1056px * var(--cite-z)); padding: calc(72px * var(--cite-z)) calc(80px * var(--cite-z)); background: var(--card); color: var(--card-foreground); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); font-family: var(--font-serif); font-size: calc(15px * var(--cite-z)); line-height: 1.5; }
.cite-page-no { position: absolute; top: calc(24px * var(--cite-z)); right: calc(24px * var(--cite-z)); min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-ds-sm); background: var(--muted-foreground); color: var(--background); font-family: var(--font-sans); font-size: 12px; line-height: 20px; text-align: center; }
.cite-page-title { margin: 0 0 1.4em; font-family: var(--font-sans); font-size: 1.45em; line-height: 1.3; font-weight: 600; text-align: center; text-transform: uppercase; letter-spacing: .02em; }
.cite-para { margin: 0 0 .9em; padding: 2px 4px; margin-left: -4px; margin-right: -4px; border-radius: var(--radius-xs); text-align: justify; hyphens: auto; }
.cite-para-head { font-weight: 600; }
.cite-para.is-active { background: var(--background-brand); }

/* ---------- The exact words: green, like the live product ---------- */
mark.cite-mark { color: inherit; background: color-mix(in srgb, var(--finrep-300) 45%, transparent); border-radius: 2px; padding: 1px 0; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
mark.cite-mark.is-pulse { animation: cite-pulse 1.4s var(--ease-enter) 1; }
mark.cite-mark-search { background: color-mix(in srgb, var(--warning) 30%, transparent); }
@keyframes cite-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--finrep-400) 70%, transparent); }
  100% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--finrep-400) 0%, transparent); }
}

/* ---------- Drawer ---------- */
.cite-scrim { position: fixed; inset: 0; z-index: 80; background: color-mix(in srgb, var(--universal-black) 45%, transparent); opacity: 0; visibility: hidden; transition: opacity var(--motion-deliberate) var(--ease-move), visibility var(--motion-deliberate); }
.cite-scrim.is-open { opacity: 1; visibility: visible; }
.cite-drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 81; width: min(60vw, 960px); min-width: min(100vw, 480px); display: flex; flex-direction: column; background: var(--background); box-shadow: var(--shadow-lg); transform: translateX(100%); visibility: hidden; transition: transform var(--motion-deliberate) var(--ease-enter), visibility var(--motion-deliberate); }
.cite-drawer.is-open { transform: none; visibility: visible; }
body.cite-drawer-lock { overflow: hidden; }
.cite-drawer-head { display: flex; align-items: flex-start; gap: 16px; padding: 20px 20px 16px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.cite-drawer-titles { flex: 1; min-width: 0; }
.cite-drawer-head h2 { margin: 0; font-size: 20px; line-height: 28px; font-weight: 600; }
.cite-drawer-value { margin: 4px 0 0; font-size: 16px; line-height: 24px; color: var(--muted-foreground); }
.cite-drawer-head .cite-tool { border: 0; }
.cite-quote { position: relative; margin: 12px 16px; padding: 12px 44px 12px 16px; border-radius: var(--radius-md); background: var(--background-brand); box-shadow: inset 0 0 0 1px var(--muted-brand); flex-shrink: 0; }
.cite-quote-src { display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; color: var(--muted-foreground); }
.cite-quote-src span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cite-quote p { margin: 6px 0 0; font-size: 16px; line-height: 24px; color: var(--foreground); }
.cite-quote-close { position: absolute; top: 8px; right: 8px; border: 0; background: transparent; width: 28px; height: 28px; }
.cite-drawer-viewer { flex: 1; min-height: 0; display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.cite-top { position: absolute; right: 24px; bottom: 24px; width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: var(--radius-full); background: var(--background); color: var(--foreground); box-shadow: var(--shadow-md); cursor: pointer; }
.cite-top .cite-ico { width: 16px; height: 16px; }

@media (max-width: 760px) {
  .cite-drawer { width: 100vw; min-width: 0; }
  .cite-search { flex-basis: 160px; }
}
@media (prefers-reduced-motion: reduce) {
  .cite-drawer, .cite-scrim, .cite-chip { transition: none; }
  mark.cite-mark.is-pulse { animation: none; }
}
/* Integration pass: heading paragraphs and SOW tables (rate cards, slabs, service levels). */
.cite-para-h { margin: 1.1em -4px .5em; font-size: 1em; font-weight: 600; text-align: left; }
.cite-page > .cite-para-h:first-of-type { margin-top: 0; }
.cite-table { width: 100%; border-collapse: collapse; margin: 0 0 1em; font-size: .92em; }
.cite-table td, .cite-table th { padding: 4px 8px; border: 1px solid var(--border); text-align: left; vertical-align: top; font-weight: 400; }
.cite-table th { font-weight: 600; background: var(--muted); }
.cite-table tr.cite-para { margin: 0; }
.cite-table tr.cite-para.is-active td, .cite-table tr.cite-para.is-active th { background: var(--background-brand); }
.cite-sep { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
