/* Cite UX layer: first-run checklist + cited page side panel. Uses cite-ui.css tokens. */

/* Checklist sits inside the source bar: a section, not a nested card. */
.cite-checklist { margin: 0 0 14px; padding: 0 0 14px; border-bottom: 1px solid var(--c-line); }
.cite-checklist[hidden] { display: none; }
.cite-checklist-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.cite-checklist-head .eyebrow { margin: 0 0 3px; }
.cite-checklist-head strong { display: block; font: 600 14px/1.3 var(--font); color: var(--c-text); }
.cite-checklist-head strong span { color: var(--c-text-3); font-weight: 400; font-variant-numeric: tabular-nums; }

.cite-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; counter-reset: step; }
.cite-steps li {
  position: relative; display: grid; grid-template-rows: auto 1fr auto; gap: 4px; padding: 12px;
  border: 1px solid var(--c-line); border-radius: var(--r-2); background: var(--c-bg-2);
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.cite-steps li.next { border-color: var(--c-red-line); }
.cite-step-num { display: flex; align-items: center; gap: 8px; font: 500 12px/1 var(--font); color: var(--c-text-3); font-variant-numeric: tabular-nums; }
.cite-steps li.next .cite-step-num { color: var(--c-red-text); }
.cite-steps li strong { font: 600 13.5px/1.3 var(--font); color: var(--c-text); }
.cite-steps li small { font: 400 12.5px/1.45 var(--font); color: var(--c-text-3); }
.cite-steps li button { justify-self: start; margin-top: 6px; }
.cite-steps li:not(.next) button { background: transparent !important; }
.cite-steps li.next button { background: var(--c-red) !important; border-color: transparent; color: oklch(0.985 0.004 25); }
.cite-steps li.next button:hover { background: var(--c-red-hover) !important; }
.cite-steps li.done { background: transparent; }
.cite-steps li.done strong, .cite-steps li.done small { color: var(--c-text-3); }
.cite-tick { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--c-line-2); display: inline-grid; place-items: center; flex: none; }
.cite-steps li.next .cite-tick { border-color: var(--c-red); }
.cite-steps li.done .cite-tick { background: var(--c-ok); border-color: var(--c-ok); }
.cite-steps li.done .cite-tick::after { content: ""; width: 7px; height: 4px; border: 1.75px solid var(--c-bg); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }

/* Clickable citations and the per-answer "Open page" control. */
.engine-answer .inline-citation[role="button"] { cursor: pointer; transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease); }
.engine-answer .inline-citation[role="button"]:hover,
.engine-answer .inline-citation[role="button"]:focus-visible { border-color: var(--c-red-line) !important; color: var(--c-text) !important; background: var(--c-red-soft) !important; }
.engine-answer .inline-citation.is-open { border-color: var(--c-red) !important; color: var(--c-text) !important; background: var(--c-red-soft) !important; }
.cite-view-page {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; margin: 2px 0 0; padding: 0 10px;
  border: 1px solid var(--c-line); border-radius: var(--r-2); background: transparent;
  color: var(--c-text-2); font: 500 12.5px/1 var(--font); cursor: pointer;
}
.cite-view-page svg { width: 14px; height: 14px; color: var(--c-red-text); }
.cite-view-page:hover { background: var(--c-surface); border-color: var(--c-line-2); color: var(--c-text); }

/* Side panel: a docked reader, not a modal. */
.cite-page-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 60; width: min(560px, 100vw);
  display: flex; flex-direction: column; background: var(--c-bg-2); border-left: 1px solid var(--c-line-2);
  box-shadow: -12px 0 32px oklch(0.05 0.004 25 / 0.45);
  animation: cite-panel-in var(--t-med) var(--ease);
}
.cite-page-panel[hidden] { display: none; }
@keyframes cite-panel-in { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 1320px) { body.cite-panel-open .app-shell main { padding-right: 560px; } }
.cite-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px 12px 20px; }
.cite-panel-head .eyebrow { margin: 0 0 4px; font-variant-numeric: tabular-nums; }
.cite-panel-head h2 { margin: 0; font: 600 15px/1.35 var(--font); letter-spacing: -0.01em; color: var(--c-text); overflow-wrap: anywhere; }
.cite-panel-tabs { display: flex; gap: 2px; padding: 0 16px; border-bottom: 1px solid var(--c-line); }
.cite-panel-tabs button {
  position: relative; height: 36px; padding: 0 10px; border: 0; background: none; border-radius: 0;
  color: var(--c-text-3); font: 500 13px/1 var(--font); cursor: pointer;
}
.cite-panel-tabs button:hover { color: var(--c-text-2); }
.cite-panel-tabs button[aria-selected="true"] { color: var(--c-text); }
.cite-panel-tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--c-red); }
.cite-panel-body { flex: 1; overflow: auto; padding: 16px 20px 24px; scrollbar-width: thin; scrollbar-color: var(--c-line-2) transparent; }
.cite-panel-pane[hidden] { display: none; }
.cite-panel-hint { margin: 0 0 12px; font: 400 12.5px/1.4 var(--font); color: var(--c-text-3); }
.cite-panel-hint b { color: var(--c-text-2); font-weight: 500; }
.cite-panel-empty { margin: 16px 0; font: 400 13.5px/1.5 var(--font); color: var(--c-text-3); }
.cite-page-text { max-width: 64ch; font: 400 14px/1.7 var(--font); color: var(--c-text-2); }
.cite-page-text mark { background: var(--c-red-soft); color: var(--c-text); padding: 1px 0; border-radius: 2px; box-shadow: 0 1px 0 var(--c-red-line); }
.cite-skeleton { display: grid; gap: 9px; }
.cite-skeleton i { display: block; height: 11px; border-radius: 3px; background: var(--c-surface); animation: cite-shimmer 1.2s ease-in-out infinite; }
.cite-skeleton i:nth-child(3n) { width: 72%; } .cite-skeleton i:nth-child(4n) { width: 88%; }
@keyframes cite-shimmer { 50% { background: var(--c-surface-2); } }
.cite-page-frame { width: 100%; height: calc(100vh - 190px); border: 1px solid var(--c-line); border-radius: var(--r-2); background: oklch(0.97 0.004 70); }
.cite-page-image { max-width: 100%; border: 1px solid var(--c-line); border-radius: var(--r-2); }
.cite-panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px 12px 20px; border-top: 1px solid var(--c-line); }
.cite-panel-foot small { font: 400 11.5px/1.4 var(--mono); color: var(--c-text-3); }

@media (max-width: 900px) { .cite-steps { grid-template-columns: 1fr; } }
.cite-steps li > div { display: grid; gap: 3px; }
.cite-steps li strong, .cite-steps li small { display: block; }
.cite-steps li > div { align-content: start; } .cite-steps li { align-content: start; }

/* Reader: a calm, well-set page */
.cite-panel-head h2 { font: 600 16px/1.3 var(--font); }
.cite-panel-file { display: block; margin-top: 4px; font: 400 11.5px/1.3 var(--mono); color: var(--c-text-3); overflow-wrap: anywhere; }
.cite-page-text { max-width: 60ch; font: 400 16.5px/1.65 var(--read, Georgia, serif); color: var(--c-text-2); font-variation-settings: "opsz" 16; font-feature-settings: "kern", "liga", "onum"; hyphens: auto; }
.cite-page-text p { margin: 0 0 0.85em; }
.cite-page-text mark {
  padding: 0.04em 0.12em; margin: 0 -0.12em; border-radius: 3px; box-shadow: none;
  background: oklch(0.585 0.205 27 / 0.20); color: oklch(0.985 0.004 70);
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.cite-panel-hint { font: 400 12.5px/1.4 var(--font); }
.cite-page-text { hyphens: manual; }
.cite-panel-head .eyebrow { text-transform: none; letter-spacing: 0; font: 500 12px/1.2 var(--font); color: var(--c-text-3); }
