/* public/css/oracle-chat.css
 *
 * Styling for the reusable Oracle chat panel. Markup is built by
 * public/js/oracle-chat.js and inserted into the document body when
 * the panel opens. CSS values are pulled verbatim from
 * docs/oracle-chat/tokens.md and the matching prototype.html — when
 * the design system changes, update tokens.md first then mirror here.
 *
 * Scoping rule: every selector is prefixed with .oracle-chat or
 * .oc- so this file can't accidentally style anything outside the
 * chat panel + its scrim/launcher.
 */

:root {
  /* Tokens — duplicated here (not in sacred-acid-tokens.css) because
     the chat panel ships standalone and shouldn't depend on whatever
     subset of tokens the rest of the app loads. If a token clashes
     with one declared globally, the global wins (these are scoped
     under .oracle-chat in usage). */
  --oc-void:           #000000;
  --oc-ink:            #0B0A0A;
  --oc-parchment:      #E1E1DF;
  --oc-moonstone:      #A3A39E;
  --oc-ash:            #545150;
  --oc-smoke:          #5D5349;
  --oc-oracle:         #E0F251;
  --oc-oracle-deep:    #C2D33D;
  --oc-gold:           #C9A96D;
  --oc-gold-deep:      #B7935A;
  --oc-rose:           #F7D1AC;
  --oc-signal:         #F25170;
  --oc-hairline:        rgba(247, 209, 172, 0.18);
  --oc-hairline-strong: rgba(247, 209, 172, 0.35);
  --oc-divider-gold:    rgba(201, 169, 109, 0.55);
  --oc-r-pill: 9999px;
  --oc-r-card: 8px;
  --oc-ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --oc-ease-ritual:   cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ════════════════════════════════════════════════════════════════════
   SCRIM — blur + dim the page behind the panel while it's open.
   Fallback for browsers without backdrop-filter: solid darker scrim
   so legibility is preserved. Older Android WebViews are the only
   real target here.
   ════════════════════════════════════════════════════════════════════ */
.oc-scrim {
  position: fixed; inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 320ms var(--oc-ease-standard);
  pointer-events: none;
}
.oc-scrim.is-open { opacity: 1; pointer-events: auto; }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .oc-scrim { background: rgba(0, 0, 0, 0.7); }
}

/* ════════════════════════════════════════════════════════════════════
   PANEL — slide-up surface
   ════════════════════════════════════════════════════════════════════ */
.oracle-chat {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: 86vh;
  z-index: 9100;
  background: linear-gradient(180deg, rgba(11,10,10,0.985) 0%, rgba(0,0,0,0.995) 100%);
  border-top: 1px solid var(--oc-divider-gold);
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  box-shadow: 0 -30px 80px -10px rgba(0,0,0,0.95),
              inset 0 -1px 0 rgba(247,209,172,0.08);
  color: var(--oc-parchment);
  font-family: "Futura PT", "Futura", "Avenir Next", "Nunito Sans", sans-serif;
  display: flex; flex-direction: column;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform 400ms var(--oc-ease-ritual);
}
.oracle-chat.is-open { transform: translateY(0); }

.oc-panel-grip {
  width: 44px; height: 3px; border-radius: 2px;
  background: rgba(247,209,172,0.25);
  margin: 10px auto 0;
}

.oc-panel-header {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 18px 20px 14px;
}
.oc-panel-close {
  position: absolute; right: 20px; top: 50%;
  transform: translateY(-50%);
  width: 32px; height: 32px; padding: 0; border-radius: var(--oc-r-pill);
  background: transparent;
  border: 1px solid var(--oc-hairline);
  color: var(--oc-moonstone); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.oc-panel-close svg { width: 11px; height: 11px; }

.oc-panel-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--oc-divider-gold) 50%, transparent);
}

.oc-panel-context {
  padding: 12px 22px 0;
  display: flex; justify-content: center;
}

.oc-panel-body {
  flex: 1; min-height: 0;
  overflow: auto;
  padding: 14px 22px 14px;
  display: flex; flex-direction: column;
  gap: 22px;
}

.oc-panel-footer { flex-shrink: 0; }

/* ════════════════════════════════════════════════════════════════════
   SIGIL — three-state image swap on a circular plate
   ════════════════════════════════════════════════════════════════════ */
.oc-sigil {
  position: relative;
  width: 76px; height: 76px;
  display: flex; align-items: center; justify-content: center;
}
.oc-sigil-plate {
  position: absolute; inset: 0; border-radius: 50%;
  pointer-events: none;
}
.oc-sigil--rest .oc-sigil-plate {
  background: radial-gradient(circle at 50% 40%, #080707 0%, #000 80%);
  border: 1px solid rgba(224, 242, 81, 0.65);
  box-shadow: 0 0 18px rgba(224, 242, 81, 0.18),
              0 10px 22px -8px rgba(0,0,0,0.95),
              inset 0 1px 0 rgba(224,242,81,0.05);
}
.oc-sigil--waking .oc-sigil-plate {
  background: radial-gradient(circle at 50% 40%, #080707 0%, #000 80%);
  border: 1px solid rgba(224, 242, 81, 0.7);
  box-shadow: 0 0 22px rgba(224, 242, 81, 0.25),
              0 10px 22px -8px rgba(0,0,0,0.95);
}
.oc-sigil--awake .oc-sigil-plate {
  background: radial-gradient(circle at 50% 45%, #E0F251 0%, #B8C634 75%);
  border: 1px solid rgba(224, 242, 81, 0.95);
  box-shadow: 0 0 32px rgba(224, 242, 81, 0.45),
              0 10px 26px -8px rgba(0,0,0,0.9),
              inset 0 1px 0 rgba(255,255,255,0.15);
}
.oc-sigil-img {
  position: relative; z-index: 1;
  width: 86%; height: auto; max-height: 82%;
  object-fit: contain;
  user-select: none;
}

/* Breathing halo for rest state */
.oc-sigil-breathe {
  position: absolute; inset: -4px; border-radius: 50%;
  background: radial-gradient(circle, rgba(224,242,81,0.22) 0%, transparent 60%);
  pointer-events: none;
  animation: oc-breathe 4200ms ease-in-out infinite;
}
@keyframes oc-breathe {
  0%, 100% { opacity: 0.4; transform: scale(1);    }
  50%      { opacity: 1;   transform: scale(1.08); }
}

/* Awake idle ring ripples (two staggered) */
.oc-sigil-ring {
  position: absolute; inset: -2px; border-radius: 50%;
  border: 1px solid rgba(224, 242, 81, 0.7);
  pointer-events: none;
  animation: oc-ring-out 3200ms ease-out infinite;
}
.oc-sigil-ring--2 {
  border-color: rgba(224, 242, 81, 0.5);
  animation-delay: 1100ms;
}
@keyframes oc-ring-out {
  0%   { opacity: 0.8; transform: scale(1);    }
  80%  { opacity: 0;   transform: scale(1.32); }
  100% { opacity: 0;   transform: scale(1.32); }
}

/* Thinking pulse rings — replace the idle ripples while thinking=true */
.oc-sigil-pulse {
  position: absolute; width: 94%; height: 94%; border-radius: 50%;
  border: 1px solid rgba(224, 242, 81, 0.6);
  pointer-events: none;
  animation: oc-pulse 1800ms var(--oc-ease-ritual) infinite;
}
.oc-sigil-pulse--2 {
  border-color: rgba(224, 242, 81, 0.4);
  animation-delay: 600ms;
}
@keyframes oc-pulse {
  0%   { transform: scale(0.6);  opacity: 0.55; }
  70%  { transform: scale(1.35); opacity: 0;    }
  100% { transform: scale(1.35); opacity: 0;    }
}

/* ════════════════════════════════════════════════════════════════════
   CONTEXT PILL
   ════════════════════════════════════════════════════════════════════ */
.oc-context-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 10px;
  border: 1px solid rgba(201, 169, 109, 0.35);
  border-radius: var(--oc-r-pill);
  background: rgba(201, 169, 109, 0.06);
  max-width: 100%;
}
.oc-context-pill .oc-cp-star { color: var(--oc-gold); font-size: 11px; }
.oc-context-pill .oc-cp-label {
  color: var(--oc-moonstone);
  font-size: 10.5px; letter-spacing: 0.18em;
  text-transform: uppercase;
}
.oc-context-pill .oc-cp-what {
  color: var(--oc-rose);
  font-family: "The Silver Editorial", "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: 11.5px;
}
.oc-context-pill .oc-cp-dot { color: rgba(247,209,172,0.4); font-size: 10px; }
.oc-context-pill .oc-cp-sub {
  color: var(--oc-oracle);
  font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ════════════════════════════════════════════════════════════════════
   MESSAGES
   ════════════════════════════════════════════════════════════════════ */
.oc-msg-user {
  align-self: flex-end;
  max-width: 84%;
  padding: 11px 14px;
  border-radius: 14px 14px 4px 14px;
  background: rgba(247, 209, 172, 0.06);
  border: 1px solid rgba(247, 209, 172, 0.18);
  color: var(--oc-rose);
  font-size: 13.5px; line-height: 1.55;
}
.oc-msg-oracle {
  align-self: stretch;
  display: flex; flex-direction: row;
  gap: 10px; padding-right: 8px;
}
.oc-msg-oracle__star {
  flex-shrink: 0;
  width: 26px; height: 26px; margin-top: 3px;
  color: var(--oc-gold);
  font-family: "The Silver Editorial", "Cormorant Garamond", Georgia, serif;
  font-style: italic; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 0 8px rgba(201, 169, 109, 0.4));
}
.oc-msg-oracle__body {
  flex: 1;
  color: var(--oc-parchment);
  font-family: "Futura PT", "Futura", "Avenir Next", sans-serif;
  font-size: 14px; line-height: 1.55;
  white-space: pre-wrap;
}
.oc-msg-oracle__body em,
.oc-msg-oracle__body i { color: var(--oc-rose); font-style: italic; }

/* ── Thinking dots ── */
.oc-thinking-dots {
  align-self: flex-start;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 2px;
}
.oc-thinking-dots span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--oc-gold);
  animation: oc-dot 1400ms ease-in-out infinite;
  opacity: 0.6;
}
.oc-thinking-dots span:nth-child(2) { animation-delay: 180ms; }
.oc-thinking-dots span:nth-child(3) { animation-delay: 360ms; }
@keyframes oc-dot {
  0%, 60%, 100% { transform: scale(1);   opacity: 0.35; }
  30%           { transform: scale(1.4); opacity: 1;    }
}

/* ════════════════════════════════════════════════════════════════════
   EMPTY STATE — intro + Common Fixes chips
   ════════════════════════════════════════════════════════════════════ */
.oc-intro-italic {
  font-family: "The Silver Editorial", "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: 22px; line-height: 1.35;
  color: var(--oc-parchment);
  max-width: 300px;
}
.oc-intro-sub {
  color: var(--oc-moonstone);
  font-size: 13.5px; line-height: 1.6;
  max-width: 320px;
}
.oc-intro-eyebrow {
  color: var(--oc-smoke);
  font-size: 10px; letter-spacing: 0.28em;
  text-transform: uppercase;
  margin-top: 10px;
}
.oc-fix-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.oc-fix-chip {
  background: transparent;
  border: 1px solid var(--oc-hairline-strong);
  border-radius: var(--oc-r-pill);
  padding: 8px 14px;
  color: var(--oc-parchment);
  font-family: inherit;
  font-size: 12px; letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 200ms var(--oc-ease-standard);
}
.oc-fix-chip:hover {
  background: rgba(247, 209, 172, 0.08);
  color: var(--oc-rose);
}

/* ════════════════════════════════════════════════════════════════════
   COMPOSER
   ════════════════════════════════════════════════════════════════════ */
.oc-composer-wrap {
  padding: 10px 18px 22px;
  background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.85) 30%, var(--oc-void) 100%);
}
.oc-composer {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(201, 169, 109, 0.35);
  border-radius: var(--oc-r-pill);
  padding: 8px 8px 8px 18px;
}
.oc-composer input {
  flex: 1; min-width: 0;
  background: transparent; border: none; outline: none;
  color: var(--oc-parchment);
  font-family: inherit;
  font-size: 14px; letter-spacing: 0.02em;
}
.oc-composer input::placeholder { color: rgba(163,163,158,0.43); }
.oc-composer button {
  width: 36px; height: 36px; padding: 0; border-radius: 50%;
  background: var(--oc-oracle); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 18px rgba(224,242,81,0.35);
}
.oc-composer button svg { width: 15px; height: 15px; color: #0B0A0A; }
.oc-composer.is-disabled { opacity: 0.6; pointer-events: none; }

/* ════════════════════════════════════════════════════════════════════
   APPLY (confirm) CARD
   ════════════════════════════════════════════════════════════════════ */
.oc-confirm-card {
  border: 1px solid rgba(224, 242, 81, 0.35);
  background:
    radial-gradient(ellipse 110% 80% at 50% 0%, rgba(224,242,81,0.06), transparent 60%),
    rgba(11, 10, 10, 0.85);
  border-radius: 14px;
  padding: 18px 18px 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.oc-confirm-card__eyebrow {
  color: var(--oc-gold);
  font-size: 10px; letter-spacing: 0.32em;
  text-transform: uppercase; font-weight: 600;
}
.oc-diff-card {
  border: 1px solid rgba(201, 169, 109, 0.3);
  border-radius: var(--oc-r-card);
  padding: 14px 16px 16px;
  background: rgba(11, 10, 10, 0.6);
  display: flex; flex-direction: column; gap: 10px;
}
.oc-diff-card__field {
  color: var(--oc-gold);
  font-size: 10px; letter-spacing: 0.28em;
  text-transform: uppercase; font-weight: 500;
}
.oc-diff-row {
  display: grid;
  grid-template-columns: 1fr 16px 1fr;
  align-items: center; gap: 8px;
}
.oc-diff-row__before {
  color: var(--oc-smoke);
  font-size: 14px;
  text-decoration: line-through;
  text-decoration-color: rgba(242, 81, 112, 0.6);
}
.oc-diff-row__arrow { color: var(--oc-gold); font-size: 14px; text-align: center; }
.oc-diff-row__after { color: var(--oc-oracle); font-size: 14px; font-weight: 500; }

.oc-dep-preview {
  color: var(--oc-moonstone);
  font-size: 12.5px; line-height: 1.5;
  font-style: italic;
  font-family: "The Silver Editorial", "Cormorant Garamond", Georgia, serif;
}

.oc-confirm-actions {
  display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 6px;
}
.oc-btn-cancel {
  background: transparent;
  border: 1px solid rgba(247, 209, 172, 0.25);
  border-radius: var(--oc-r-pill);
  color: var(--oc-moonstone);
  font-size: 11px; letter-spacing: 0.22em;
  text-transform: uppercase; font-weight: 500;
  padding: 12px 14px;
  cursor: pointer;
  font-family: inherit;
}
.oc-btn-apply {
  background: var(--oc-oracle);
  border: 1px solid var(--oc-oracle);
  color: #0B0A0A;
  border-radius: var(--oc-r-pill);
  font-size: 11px; letter-spacing: 0.22em;
  text-transform: uppercase; font-weight: 600;
  padding: 12px 14px;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(224, 242, 81, 0.3);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit;
}
.oc-btn-apply svg { width: 11px; height: 11px; color: #0B0A0A; }
.oc-btn-apply:disabled { opacity: 0.6; cursor: not-allowed; }

/* ════════════════════════════════════════════════════════════════════
   RECALCULATING / SUCCESS / ERROR
   ════════════════════════════════════════════════════════════════════ */
.oc-status-center {
  height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 0 24px 40px;
  text-align: center; gap: 18px;
}
.oc-status-eyebrow {
  color: var(--oc-gold);
  font-size: 10px; letter-spacing: 0.36em;
  text-transform: uppercase; font-weight: 500;
}
.oc-status-title {
  font-family: "The Silver Editorial", "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  color: var(--oc-parchment);
  font-size: 22px; line-height: 1.35;
  max-width: 280px;
}
.oc-status-sub {
  color: var(--oc-moonstone);
  font-size: 12.5px; line-height: 1.5;
  max-width: 260px;
}
.oc-spinner {
  width: 96px; height: 96px;
  border-radius: 50%;
  border: 1px solid var(--oc-gold);
  border-top-color: var(--oc-oracle);
  animation: oc-spin 1600ms linear infinite;
  box-shadow: 0 0 30px rgba(224,242,81,0.2), inset 0 0 16px rgba(224,242,81,0.06);
}
@keyframes oc-spin { to { transform: rotate(360deg); } }

.oc-success-card {
  border: 1px solid rgba(224, 242, 81, 0.5);
  background:
    radial-gradient(ellipse 120% 90% at 50% 0%, rgba(224,242,81,0.10), transparent 65%),
    rgba(11, 10, 10, 0.85);
  border-radius: 14px;
  padding: 22px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center;
}
.oc-success-mark {
  width: 44px; height: 44px; border-radius: 50%;
  background: radial-gradient(circle, rgba(224,242,81,0.95), rgba(184,198,52,1));
  border: 1px solid rgba(224,242,81,0.95);
  display: flex; align-items: center; justify-content: center;
  color: #0B0A0A; font-size: 22px; font-weight: 700;
  box-shadow: 0 0 22px rgba(224,242,81,0.55);
}
.oc-success-back {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(224, 242, 81, 0.55);
  border-radius: var(--oc-r-pill);
  padding: 14px 22px;
  color: var(--oc-oracle);
  font-family: inherit;
  font-size: 11px; letter-spacing: 0.28em;
  text-transform: uppercase; font-weight: 600;
  cursor: pointer;
  box-shadow: 0 0 18px -6px rgba(224,242,81,0.35);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
.oc-success-back svg { width: 12px; height: 12px; color: var(--oc-oracle); }
.oc-success-hint {
  text-align: center; margin-top: 12px;
  color: var(--oc-smoke);
  font-size: 10.5px; letter-spacing: 0.22em;
  text-transform: uppercase;
}

.oc-error-card {
  border: 1px solid rgba(242, 81, 112, 0.45);
  background:
    radial-gradient(ellipse 120% 90% at 50% 0%, rgba(242,81,112,0.08), transparent 65%),
    rgba(11, 10, 10, 0.85);
  border-radius: 14px;
  padding: 20px 18px;
  display: flex; flex-direction: column; gap: 14px;
}
.oc-error-head {
  display: flex; align-items: center; gap: 10px;
  color: var(--oc-signal);
  font-size: 10.5px; letter-spacing: 0.3em;
  text-transform: uppercase; font-weight: 600;
}
.oc-error-bang {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--oc-signal);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; letter-spacing: 0;
}
.oc-error-body {
  color: var(--oc-parchment);
  font-size: 13.5px; line-height: 1.55;
}
.oc-error-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px;
}
.oc-btn-edit, .oc-btn-retry {
  border-radius: var(--oc-r-pill);
  padding: 11px 14px;
  font-size: 11px; letter-spacing: 0.22em;
  text-transform: uppercase;
  font-family: inherit;
  cursor: pointer;
}
.oc-btn-edit {
  background: transparent;
  border: 1px solid rgba(247,209,172,0.25);
  color: var(--oc-moonstone);
  font-weight: 500;
}
.oc-btn-retry {
  background: rgba(247,209,172,0.08);
  border: 1px solid var(--oc-rose);
  color: var(--oc-rose);
  font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}

/* ════════════════════════════════════════════════════════════════════
   COSMIC BLUEPRINT CTA BAR — Continue (chartreuse) + See an error? (gold)
   ════════════════════════════════════════════════════════════════════ */
.confirm-area .btn-see-error {
  display: inline-block;
  margin-top: 14px;
  background: linear-gradient(180deg, var(--oc-gold) 0%, var(--oc-gold-deep) 100%);
  border: 1px solid var(--oc-gold);
  border-radius: var(--oc-r-pill);
  padding: 12px 24px;
  color: #0B0A0A;
  font-family: inherit;
  font-size: 11px; letter-spacing: 0.28em;
  text-transform: uppercase; font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 18px -6px rgba(205, 169, 107, 0.55);
  transition: all 220ms var(--oc-ease-standard);
}
.confirm-area .btn-see-error:hover {
  box-shadow: 0 8px 24px -6px rgba(205, 169, 107, 0.8);
  transform: translateY(-1px);
}

/* ════════════════════════════════════════════════════════════════════
   CHART-SUMMARY ROW-PULSE (post-correction highlight)
   Plays once on mount; ~2.4s ease-out. Targets .chart-row[data-pulse]
   rows that the renderer marks based on changed_fields.
   ════════════════════════════════════════════════════════════════════ */
.chart-row[data-pulse="true"] {
  animation: oc-row-pulse 2400ms ease-out 1;
  border-radius: 6px;
}
@keyframes oc-row-pulse {
  0%   { background: rgba(224, 242, 81, 0); }
  20%  { background: rgba(224, 242, 81, 0.22); box-shadow: 0 0 18px -4px rgba(224, 242, 81, 0.45); }
  100% { background: rgba(224, 242, 81, 0);   box-shadow: 0 0 0 0    rgba(224, 242, 81, 0); }
}

/* ════════════════════════════════════════════════════════════════════
   REDUCED MOTION
   Disable infinite-loop ambient animations + the success-card auto
   dismiss timer is still honored (just visually quiet).
   ════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .oc-sigil-breathe,
  .oc-sigil-ring,
  .oc-sigil-pulse,
  .oc-thinking-dots span,
  .oc-spinner {
    animation: none !important;
  }
  .chart-row[data-pulse="true"] {
    animation: none !important;
    /* Replace ambient pulse with a static highlight so the user still
       sees WHICH rows changed, just without the animation. */
    background: rgba(224, 242, 81, 0.12);
    box-shadow: inset 0 0 0 1px rgba(224, 242, 81, 0.35);
  }
}
