/* Interaction polish: request indicator, transitions, focus, motion preferences. */

/* slim indeterminate bar under the top bar while any request is running */
body::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 200; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--accent) 35%, var(--accent-2) 65%, transparent);
  background-size: 40% 100%; background-repeat: no-repeat;
  opacity: 0; transition: opacity .25s ease .15s;
}
body.is-busy::before { opacity: 1; animation: busy-slide 1.1s ease-in-out infinite; transition-delay: .15s; }
@keyframes busy-slide { 0% { background-position: -40% 0; } 100% { background-position: 140% 0; } }

/* panels fade in when switching tabs */
.panel.on { animation: panel-in .18s ease-out; }
@keyframes panel-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.home:not([hidden]) .home-inner { animation: panel-in .25s ease-out; }

/* consistent, smooth control feedback */
.btn, .seg button, .tabs > button, .link, .doc, .concept-chip, .rank-row, .loop, .path, .bar-row, .home-item {
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease, transform .15s ease;
}
.btn:active:not(:disabled), .send:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { box-shadow: 0 1px 0 rgba(255, 255, 255, .15) inset, 0 4px 14px -6px color-mix(in srgb, var(--accent) 70%, transparent); }

/* visible keyboard focus everywhere, invisible for mouse clicks */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

/* nicer text rendering and selection */
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }
body { text-rendering: optimizeLegibility; font-feature-settings: "ss01", "tnum"; }
.stat b, .kpi b, td.n { font-variant-numeric: tabular-nums; }

/* the inspector slides in rather than popping */
.inspector:not([hidden]) { animation: drawer .2s cubic-bezier(.2, .8, .2, 1); }

/* toasts stack with a gentle entrance and exit */
.toast { animation: toast-in .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* scrollbars that don't shout */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

/* zoom readout between + and − (click = back to 100%) */
.overlay.zoom button.zoom-pct { font: 600 10.5px var(--mono); height: 24px; color: var(--ink-3); letter-spacing: -.02em; }
.overlay.zoom button.zoom-pct:hover { color: var(--accent); }

/* key-links toggle in the map toolbar */
.link-mode { font-size: 13px; padding: 4px 10px; }
.link-mode.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--ink); }

/* condense dialog */
dialog.condense-dialog { width: 500px; }
/* condense: 15–50 scale */
.cd-scale-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.cd-value { font: 700 26px var(--mono); color: var(--accent); letter-spacing: -.02em; line-height: 1; }
.cd-scale { position: relative; padding: 4px 8px 0; margin-bottom: 16px; }
.cd-scale input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border-radius: 99px; cursor: pointer;
  background: linear-gradient(90deg, var(--accent) 0 var(--fill, 42.86%), var(--surface-3) var(--fill, 42.86%) 100%); outline: none; }
.cd-scale input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent); box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
.cd-scale input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent); }
.cd-scale input[type=range]:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }
.cd-ticks { position: relative; height: 22px; margin: 6px 3px 0; }
.cd-ticks button { position: absolute; transform: translateX(-50%); border: 0; background: none; cursor: pointer; padding: 2px 4px;
  font: 600 12px var(--mono); color: var(--ink-3); border-radius: 5px; }
.cd-ticks button::before { content: ""; position: absolute; top: -6px; left: 50%; width: 1px; height: 5px; background: var(--line-2); }
.cd-ticks button:hover, .cd-ticks button.on { color: var(--accent); }
.cd-hint { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.cd-check { display: grid; grid-template-columns: 18px 1fr; gap: 10px; align-items: start; padding: 10px 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.cd-check input { margin-top: 3px; accent-color: var(--accent); }
.cd-check small { font-size: 12px; line-height: 1.45; }
.cd-how { margin-top: 10px; font-size: 12.5px; }
.cd-how summary { cursor: pointer; color: var(--ink-2); }
.cd-how p { margin: 6px 0 0; font-size: 12px; }

/* Ask: causal-map evidence next to document passages */
.srcs-title { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 6px 0 2px; }
details.src.map summary b { background: color-mix(in srgb, var(--driver) 16%, transparent); color: var(--driver); }
details.src.map summary strong { font-weight: 600; }
.cite.map[data-src] { cursor: pointer; }
.msg.bot .bubble h2 { font-size: 15px; margin: 18px 0 6px; letter-spacing: -.01em; }
.msg.bot .bubble h2:first-child { margin-top: 2px; }

/* respect "reduce motion" */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  body.is-busy::before { animation: none; background-size: 100% 100%; }
}

/* tab bar: always one line */
.tabs { flex-wrap: nowrap; }   /* no overflow clipping: the Export menu drops down from this bar */
.tabs > button { white-space: nowrap; flex: none; }
.tabs-right { flex: none; padding-left: 12px; }
.tabs-right .menu { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; white-space: nowrap; }
