/* ══════════════════════════════════════════════════════════════════════
   Ori — Orion's in-app assistant. Night-sky treatment, INVERSE of the app theme
   (Ori UX pass 1): light app -> dark Ori panel (default tokens below); dark app ->
   light Ori panel (token override at the end of this file). App fonts
   (--f-head / --f-body) + brand canon colours; no new font loads.
   Layering: panel/FAB z-35 (drawers at 40 must overlay Ori); mobile
   sheet z-95 (over the burger navsheet).
   ══════════════════════════════════════════════════════════════════════ */
:root {
  --ori-w: 420px;
  --ori-void: #0A1128;
  --ori-void-deep: #060B1C;
  --ori-regal: #1B3B6F;
  --ori-regal-dim: #14294D;
  --ori-gold: #C9A24D;
  --ori-gold-soft: rgba(201, 162, 77, .35);
  --ori-ivory: #F7F5EF;
  --ori-ivory-dim: rgba(247, 245, 239, .62);
  --ori-ivory-faint: rgba(247, 245, 239, .38);
  --ori-ink-rgb: 247, 245, 239;       /* borders / tints are built from this (flips with the theme) */
  --ori-strong: #fff;                 /* bold text inside an answer */
  --ori-gold-btn: #C9A24D;            /* gold button fill - the same in both themes */
  --ori-on-gold: #0A1128;             /* text ON a gold button - always dark */
  --ori-shadow: rgba(6, 11, 28, .45);
}

/* ── Push, not overlay (desktop): the app narrows while Ori is open ── */
.nav, main#app { transition: margin-right .3s ease; }
body.ori-open .nav, body.ori-open main#app { margin-right: var(--ori-w); }

/* ── Collapsed FAB (kept clear of #syncPill at bottom 22px) ── */
#oriFab {
  position: fixed; right: 18px; bottom: 86px; z-index: 35;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--ori-void); border: 1.5px solid var(--ori-gold-soft);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 22px var(--ori-shadow);
  transition: transform .15s ease, border-color .2s ease;
}
#oriFab:hover { transform: scale(1.06); border-color: var(--ori-gold); }
#oriFab[hidden] { display: none; }
/* B2-1 - FAB gutter: reserve a right gutter (desktop) so content never sits under the FAB,
   and fade/shrink it while scrolling (all widths; phone gets a smaller FAB, no gutter). */
body:not(.ori-open):has(#oriFab:not([hidden])) .wrap { padding-right: 88px; }
body.ori-scrolling #oriFab { opacity: .3; transform: scale(.8); pointer-events: none; }
#oriFab { transition: transform .15s ease, border-color .2s ease, opacity .2s ease; }
@media (max-width: 760px) {
  body:not(.ori-open):has(#oriFab:not([hidden])) .wrap { padding-right: 16px; }
  #oriFab { width: 44px; height: 44px; right: 10px; bottom: 78px; }
}
#oriFab .ori-dot {
  position: absolute; top: 5px; right: 5px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--ori-gold); border: 2px solid var(--ori-void);
}

/* ── Armillary mark: the shared Orion mark (armillary.css) - drifts at rest, whirls ONLY while retrieval is in flight.
   Tinted from Ori's tokens so it follows the inverse (light) panel too. ── */
#oriPanel .ori-arm, #oriFab .ori-arm { color: var(--ori-gold); }
#oriPanel .ori-arm, #oriFab .ori-arm { --oarm-star: var(--ori-gold); }
:root:not([data-theme="dark"]) #oriPanel .ori-arm, :root:not([data-theme="dark"]) #oriFab .ori-arm { --oarm-star: #E4C878; }

/* ── Panel ── */
#oriPanel {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--ori-w); z-index: 35;
  display: flex; flex-direction: column;
  background: var(--ori-void); border-left: 1px solid rgba(201, 162, 77, .25);
  transform: translateX(102%); transition: transform .3s ease;
  font-family: var(--f-body);
}
body.ori-open #oriPanel { transform: none; }

.ori-head {
  display: flex; align-items: center; gap: 11px; padding: 13px 16px;
  border-bottom: 1px solid rgba(var(--ori-ink-rgb), .09); flex: 0 0 auto;
}
.ori-head__name {
  font-family: var(--f-head); font-weight: 800; font-size: 19px;
  letter-spacing: .08em; color: var(--ori-ivory);
}
.ori-head__name b { color: var(--ori-gold); }         /* the gold full stop */
.ori-head__sub {
  font-size: 9.5px; letter-spacing: .14em; color: var(--ori-ivory-faint);
  text-transform: uppercase;
}
.ori-head__actions { margin-left: auto; display: flex; gap: 6px; }
.ori-btn-ghost {
  background: none; border: 1px solid rgba(var(--ori-ink-rgb), .18); border-radius: 6px;
  color: var(--ori-ivory-dim); font-family: var(--f-body); font-size: 11px;
  padding: 5px 10px; cursor: pointer; transition: border-color .15s ease, color .15s ease;
}
.ori-btn-ghost:hover { border-color: var(--ori-gold-soft); color: var(--ori-ivory); }

/* ── Thread ── */
.ori-thread {
  flex: 1; overflow-y: auto; padding: 18px 16px;
  display: flex; flex-direction: column; gap: 16px;
}
.ori-thread::-webkit-scrollbar { width: 5px; }
.ori-thread::-webkit-scrollbar-thumb { background: var(--ori-regal); border-radius: 3px; }
.ori-greet { font-size: 15px; color: var(--ori-ivory); line-height: 1.55; }

.ori-user {
  align-self: flex-end; max-width: 85%; background: var(--ori-regal);
  color: var(--ori-ivory); font-size: 14px; line-height: 1.5;
  padding: 9px 13px; border-radius: 12px 12px 3px 12px; white-space: pre-wrap;
}
.ori-follow {
  font-size: 14px; line-height: 1.55; color: var(--ori-ivory);
  border-left: 2px solid var(--ori-gold); padding-left: 12px;
}

.ori-turn { display: flex; flex-direction: column; gap: 10px; }
.ori-cards { display: flex; flex-direction: column; gap: 6px; }
.ori-card {
  border: 1px solid rgba(var(--ori-ink-rgb), .14); border-radius: 8px;
  padding: 9px 11px; background: var(--ori-regal-dim);
  animation: oriCardIn .32s ease both; transition: border-color .3s ease;
}
.ori-card__tag { font-size: 9.5px; letter-spacing: .14em; color: var(--ori-ivory-faint); }
.ori-card--data .ori-card__tag { color: var(--ori-gold); }
.ori-card--data { border-color: var(--ori-gold-soft); }
.ori-card__title { font-size: 13.5px; color: var(--ori-ivory); margin-top: 3px; font-weight: 600; }
.ori-card__meta { font-size: 10.5px; color: var(--ori-ivory-faint); margin-top: 3px; }
@keyframes oriCardIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.ori-searching { display: flex; align-items: center; gap: 10px; }
.ori-searching .ori-arm { filter: drop-shadow(0 0 5px var(--ori-gold-soft)); }
/* "Looking that up..." - a gold glint sweeps the words while the mark whirls */
.ori-searching__txt { font-size: 11.5px; letter-spacing: .06em; color: var(--ori-ivory-faint);
  background: linear-gradient(100deg, var(--ori-ivory-faint) 40%, var(--ori-gold) 50%, var(--ori-ivory-faint) 60%) 0 0 / 250% 100%;
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; animation: oriGlint 1.8s linear infinite; }
@keyframes oriGlint { from { background-position: 100% 0; } to { background-position: -150% 0; } }

/* answer body — rendered from the matched article chunks */
.ori-answer { font-size: 14.5px; line-height: 1.62; color: var(--ori-ivory); }
.ori-answer p { margin: 0 0 10px; }
.ori-answer p:last-child { margin-bottom: 0; }
.ori-answer ol, .ori-answer ul { margin: 0 0 10px 20px; padding: 0; }
.ori-answer li { margin: 0 0 6px; }
.ori-answer b { color: var(--ori-strong); }
.ori-answer code {
  font-size: 12.5px; background: rgba(var(--ori-ink-rgb), .1); border-radius: 4px; padding: 1px 5px;
}
.ori-answer h5 {
  font-family: var(--f-head); font-size: 11px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ori-gold); margin: 14px 0 6px; font-weight: 700;
}
.ori-cite {
  background: none; border: none; color: var(--ori-gold); cursor: pointer;
  font-size: 11.5px; font-weight: 700; padding: 0 3px; vertical-align: super; line-height: 1; font-family: var(--f-body);
}

/* gate ("not in this cartridge") — bordered card */
.ori-gate {
  border: 1px solid var(--ori-gold-soft); border-left: 3px solid var(--ori-gold);
  border-radius: 8px; padding: 11px 13px; background: rgba(201, 162, 77, .06);
  font-size: 14px; line-height: 1.55; color: var(--ori-ivory);
}
.ori-gate__tag { font-size: 9.5px; letter-spacing: .16em; color: var(--ori-gold); margin-bottom: 7px; }

.ori-glow { animation: oriGlow .9s ease-out 3; border-color: var(--ori-gold) !important; }
.ori-target-pulse { animation: oriGlow 1s ease-out 4; }
@keyframes oriGlow {
  0% { box-shadow: 0 0 0 0 rgba(201, 162, 77, .65); }
  100% { box-shadow: 0 0 0 12px rgba(201, 162, 77, 0); }
}

.ori-deep {
  align-self: flex-start; font-size: 12.5px; font-weight: 600; color: var(--ori-on-gold);
  background: var(--ori-gold-btn); border: none; border-radius: 6px; padding: 8px 14px;
  cursor: pointer; font-family: var(--f-body); transition: filter .15s ease;
}
.ori-deep:hover { filter: brightness(1.08); }

/* ── Composer + footer ── */
.ori-compose { display: flex; gap: 8px; padding: 10px 16px; flex: 0 0 auto; }
/* #oriPanel prefix: the app's dark-mode input rule chains :not() selectors and would otherwise win */
#oriPanel .ori-compose input {
  flex: 1; font-family: var(--f-body); font-size: 13.5px; color: var(--ori-ivory);
  background: var(--ori-void-deep); border: 1px solid rgba(var(--ori-ink-rgb), .14);
  border-radius: 8px; padding: 10px 13px; outline: none;
}
#oriPanel .ori-compose input:focus-visible { border-color: var(--ori-gold-soft); }
#oriPanel .ori-compose input::placeholder { color: var(--ori-ivory-faint); }
.ori-ask-btn {
  font-family: var(--f-body); font-size: 13px; font-weight: 600; color: var(--ori-on-gold);
  background: var(--ori-gold-btn); border: none; border-radius: 8px; padding: 0 16px; cursor: pointer;
}
.ori-ask-btn:disabled { background: var(--ori-gold-soft); cursor: default; }
.ori-foot {
  font-size: 9.5px; letter-spacing: .08em; color: var(--ori-ivory-faint);
  text-align: center; padding: 7px 16px 10px; text-transform: uppercase;
  border-top: 1px solid rgba(var(--ori-ink-rgb), .07); flex: 0 0 auto;
}

/* ── Mobile: full-height sheet, no push ── */
@media (max-width: 900px) {
  body.ori-open .nav, body.ori-open main#app { margin-right: 0; }
  #oriPanel { width: 100%; z-index: 95; }
  #oriFab { bottom: 78px; }
}

@media (prefers-reduced-motion: reduce) {
  .ori-searching__txt, .ori-card, .ori-glow, .ori-target-pulse { animation: none !important; }
  #oriPanel, .nav, main#app { transition: none; }
}
#oriFab:focus-visible, .ori-btn-ghost:focus-visible, .ori-deep:focus-visible,
.ori-ask-btn:focus-visible, .ori-cite:focus-visible { outline: 2px solid var(--ori-gold); outline-offset: 2px; }

/* ── Suggested next questions (0-3) ── */
.ori-chips { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.ori-chip {
  font-family: var(--f-body); font-size: 12.5px; line-height: 1.4; text-align: left;
  color: var(--ori-ivory); background: transparent; cursor: pointer;
  border: 1px solid rgba(var(--ori-ink-rgb), .24); border-radius: 16px; padding: 6px 12px;
  transition: border-color .15s ease, color .15s ease;
}
.ori-chip:hover { border-color: var(--ori-gold); color: var(--ori-gold); }
.ori-chip:focus-visible, .ori-sources summary:focus-visible { outline: 2px solid var(--ori-gold); outline-offset: 2px; }

/* ── One "Sources" line on declined / not-in-help answers ── */
.ori-sources { font-size: 12px; color: var(--ori-ivory-dim); }
.ori-sources summary {
  cursor: pointer; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  padding: 4px 0; color: var(--ori-ivory-dim);
}
.ori-sources .ori-cards { margin-top: 8px; }

/* ── The passage behind a citation number, inline under the answer ── */
.ori-insrc {
  border-left: 2px solid var(--ori-gold); padding: 8px 0 8px 12px;
  font-size: 13px; line-height: 1.55; color: var(--ori-ivory-dim);
  animation: oriCardIn .25s ease both;
}
.ori-insrc__head {
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ori-gold); margin-bottom: 4px;
}
.ori-insrc__body p { margin: 0 0 6px; }
.ori-insrc__body p:last-child { margin-bottom: 0; }

/* ══ Inverse theme: DARK app -> LIGHT Ori panel + FAB. Tokens only - every rule above
   reads these, so the whole surface flips together and live with the theme toggle. ══ */
[data-theme="dark"] #oriPanel, [data-theme="dark"] #oriFab {
  --ori-void: #F7F5EF;
  --ori-void-deep: #ECE7D9;
  --ori-regal: #DCE5F4;
  --ori-regal-dim: #EEF2F9;
  --ori-gold: #7A5C14;                       /* gold TEXT / rules, darkened to read on ivory */
  --ori-gold-soft: rgba(122, 92, 20, .38);
  --ori-ivory: #0A1128;                      /* body ink */
  --ori-ivory-dim: rgba(10, 17, 40, .78);
  --ori-ivory-faint: rgba(10, 17, 40, .62);
  --ori-ink-rgb: 10, 17, 40;
  --ori-strong: #060B1C;
  --ori-shadow: rgba(10, 17, 40, .22);
}
[data-theme="dark"] #oriPanel { border-left-color: rgba(122, 92, 20, .3); }
