/* BTC-TC Preferred Yield Curve / Relative Spread Dashboard
   STRC-aesthetic mNAV theme. Loaded by index.html.
   Single self-contained stylesheet — does NOT import _lib/ui platform CSS,
   to keep this dashboard independent of the broader platform refactor. */

:root {
  color-scheme: dark;

  /* mNAV palette (matches _lib/ui/tokens.css) */
  --bg:      #121421;
  --panel:   #171c2a;
  --panel-2: #141827;
  --line:    #1e293b;
  --grid:    #232932;
  --text:    #FFFFFF;
  --muted:   #B8BEC6;
  --dim:     #8A8F99;
  --faint:   #5A606A;

  /* Status + accent */
  --green:   #2EC07A;
  --amber:   #F5C518;
  --red:     #FF4D4D;
  --btc:     #F7931A;
  --accent:  #818CF8;       /* indigo — yield-curve accent */
  --accent-dim: #3D4480;

  /* Chart-specific tokens (unchanged variable names from v1 to keep app.js working) */
  --line-band: rgba(129,140,248,0.18);  /* indigo OLS confidence band */
  --pstack:   #F59E0B;                  /* premium-stack X markers */
  --strategy: #38BDF8;                  /* Strategy issuer dots (sky) */
  --strive:   #C084FC;                  /* Strive issuer dots (violet) */
  --cheap:    #22C55E;
  --rich:     #EF4444;
  --fair:     #94A3B8;

  /* NOTE: app.js still uses var(--line) for the OLS regression line color.
     This collides with --line-as-divider above. We resolve by overriding
     the SVG-only stroke via class selectors in the chart section below. */
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout — STRC parity at 800px wrap */
.wrap { max-width: 800px; margin: 0 auto; padding: 28px 24px 80px; }

/* Title block — Fraunces serif with accent on first word (STRC parity) */
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 6px;
}
.title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--text);
}
.title .accent { color: var(--accent); }
.sub {
  color: var(--dim);
  font-size: 13px;
  margin-top: 4px;
  letter-spacing: 0.02em;
  line-height: 1.5;
}

/* Banner — orange-tinted n=5 caution box */
.banner {
  background: linear-gradient(90deg, rgba(247,147,26,0.10), rgba(247,147,26,0.02));
  border: 1px solid rgba(247,147,26,0.25);
  border-left: 4px solid var(--btc);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
  margin: 18px 0 18px;
}
.banner b { color: var(--btc); }

/* Hero + cards strip (5 KPIs above the chart) — STRC tile aesthetic.
   Markup: <div class="hero"><div id="cards" class="hero-row">...</div></div>
   The .hero is a panel-bg container that wraps the cards; .card rules
   inside use .tile-style values (panel-2 bg, centered, big numbers). */
.row { display: grid; gap: 12px; }
.hero {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 18px;
}
.hero-row {
  display: grid; gap: 8px;
  grid-template-columns: repeat(5, 1fr);   /* force 5-across at 800px wrap */
  align-items: stretch;
}
.card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  min-width: 0;       /* prevent grid blowout from long content */
  overflow: hidden;
}
.card .lbl {
  color: var(--dim);
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  margin-bottom: 8px;
  line-height: 1.25;  /* allow 2-line label wrap */
}
.card .val {
  font-size: 19px; font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em; line-height: 1.1;
  white-space: nowrap;
}
.card .val.tic { color: var(--btc); }
.card .sm {
  color: var(--dim);
  font-size: 10px; margin-top: 5px; line-height: 1.3;
}

/* Hero card info tooltips — hover to show, click to pin/unpin.
   Cards with a tooltip get .has-tip; the tooltip text lives in a
   .card-tip child. On hover or pinned, the card lifts above peers
   (z-index) and overflow:visible lets the tooltip render below. */
.card.has-tip { position: relative; cursor: pointer; }
.card.has-tip:hover, .card.has-tip.pinned {
  overflow: visible;
  z-index: 10;
  border-color: var(--accent);
}
.card .info-mark {
  position: absolute; top: 6px; right: 8px;
  font-size: 12px; color: var(--faint);
  user-select: none; pointer-events: none;
  transition: color 0.15s;
}
.card.has-tip:hover .info-mark,
.card.has-tip.pinned .info-mark { color: var(--accent); }
.card .card-tip {
  display: none;
  position: absolute;
  top: calc(100% + 6px); left: 0; right: 0;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  font-weight: normal;
  white-space: normal;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  z-index: 11;
}
.card.has-tip:hover .card-tip,
.card.has-tip.pinned .card-tip { display: block; }
.card.has-tip.pinned .card-tip::after {
  content: "Click outside to close.";
  display: block; margin-top: 6px;
  font-size: 10px; font-style: italic; color: var(--faint);
}

/* Hero responsive: collapse 5-col grid to 3 then 2 on narrower viewports */
@media (max-width: 760px) {
  .hero-row { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .card { padding: 12px 10px; }
  .card .val { font-size: 18px; }
  .card .lbl { font-size: 10px; letter-spacing: 0.08em; }
}
@media (max-width: 480px) {
  .hero-row { grid-template-columns: repeat(2, 1fr); }
}

/* Controls bar */
.controls {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
  display: flex; flex-wrap: wrap;
  gap: 14px 22px; align-items: center;
}
.controls label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 10px; color: var(--dim);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.controls select,
.controls input[type="number"] {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 9px; font-size: 12px; min-width: 140px;
  font-family: inherit;
}
.controls select:focus,
.controls input[type="number"]:focus {
  outline: none; border-color: var(--accent);
}
.controls input[type="checkbox"] { accent-color: var(--accent); }
.controls .chk {
  flex-direction: row; align-items: center; gap: 6px;
  text-transform: none; letter-spacing: 0;
  font-size: 12px; color: var(--text); font-weight: 500;
}

/* Toggle button row inside controls */
.toggle-row {
  display: flex; gap: 2px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px; padding: 2px;
}
.toggle-row button {
  background: transparent; border: 0;
  color: var(--dim);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; padding: 5px 10px;
  border-radius: 6px; cursor: pointer; font-family: inherit;
}
.toggle-row button:hover { color: var(--text); }
.toggle-row button.active {
  background: var(--accent); color: #FFFFFF;
}

/* Panel = section card (chart, table, residuals, methodology, etc.).
   STRC parity: 24px padding, 16px Fraunces h2, 22px margin-bottom. */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 22px;
}
.panel h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  color: var(--text);
}
.panel .sub {
  font-size: 11px;
  color: var(--dim);
  margin: 0 0 14px;
  letter-spacing: 0;
  line-height: 1.5;
}

/* Two-column grid (small charts) */
.grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* Ranking table */
table { width: 100%; border-collapse: collapse; font-size: 12px; }
table th, table td {
  text-align: right; padding: 8px 9px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table th {
  color: var(--dim); font-weight: 600;
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.06em; background: var(--panel-2);
  cursor: pointer; user-select: none;
}
table th:hover { color: var(--text); }
table th.sort-asc::after { content: " \25B2"; font-size: 9px; }
table th.sort-desc::after { content: " \25BC"; font-size: 9px; }
table td.left, table th.left { text-align: left; }
table tr.selectable { cursor: pointer; }
table tr.selectable:hover { background: rgba(255,255,255,0.025); }
table tr.selected { background: rgba(129,140,248,0.08); }
.tic-cell { color: var(--btc); font-weight: 600; }

/* Cheap/fair/rich pills */
.lbl-pill {
  display: inline-block;
  font-size: 10px; padding: 2px 7px;
  border-radius: 9px; font-weight: 600;
  letter-spacing: 0.02em;
}
.lbl-cheap-2 { background: rgba(34,197,94,0.18);  color: #4ADE80; }
.lbl-cheap-1 { background: rgba(34,197,94,0.10);  color: #6EE7B7; }
.lbl-fair    { background: rgba(148,163,184,0.15); color: var(--fair); }
.lbl-rich-1  { background: rgba(239,68,68,0.10);  color: #FCA5A5; }
.lbl-rich-2  { background: rgba(239,68,68,0.18);  color: #F87171; }

/* Structural flags (conv / non-cum / var) */
.struct-flag {
  display: inline-block;
  font-size: 10px; padding: 1px 5px;
  border: 1px solid var(--line); border-radius: 3px;
  color: var(--muted); margin-right: 3px;
}
.struct-flag.warn {
  color: var(--amber);
  border-color: rgba(245,197,24,0.4);
}

/* Legend rows (under charts) */
.legend {
  display: flex; flex-wrap: wrap; gap: 14px;
  font-size: 11px; color: var(--muted);
  margin: 8px 0 0;
}
.legend span { display: flex; align-items: center; gap: 5px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.swatch.line { width: 14px; height: 2px; border-radius: 0; }

/* SVG chart primitives */
svg .axis { stroke: var(--dim); stroke-width: 1; }
svg .axis-label { fill: var(--muted); font-size: 10.5px; }
svg .axis-title { fill: var(--text); font-size: 11px; font-weight: 500; }
svg .gridline { stroke: var(--grid); stroke-width: 0.5; stroke-dasharray: 2 3; }
svg text.point-label {
  fill: var(--text); font-size: 10px; font-weight: 600;
  text-anchor: middle; pointer-events: none;
}
svg circle.pt, svg path.pt, svg rect.pt {
  cursor: pointer; transition: stroke-width 0.1s;
}
svg circle.pt:hover, svg path.pt:hover, svg rect.pt:hover { stroke-width: 3; }
svg circle.pt.selected, svg path.pt.selected {
  stroke: var(--btc); stroke-width: 2.5;
}

/* Detail panel */
.detail {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.detail .item .lbl {
  font-size: 10px; color: var(--dim);
  text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 700;
}
.detail .item .val {
  font-size: 14px; color: var(--text);
  font-weight: 500; margin-top: 2px;
}
.detail .item .sm { font-size: 11px; color: var(--muted); }

/* Premium-stack horizontal bar */
.stack-bars {
  display: flex; height: 26px;
  border-radius: 6px; overflow: hidden;
  background: var(--panel-2);
  margin: 6px 0 8px;
}
.stack-bars .seg {
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: rgba(0,0,0,0.7);
  font-weight: 600; min-width: 0; overflow: hidden;
}
.stack-legend {
  display: flex; flex-wrap: wrap; gap: 12px;
  font-size: 11px; color: var(--muted);
  margin-top: 4px;
}
.stack-legend span { display: flex; align-items: center; gap: 4px; }

/* Auto-comment narrative blocks (matches STRC/SATA pattern).
   Gold left-border accent; sit under section headings to interpret the
   chart/table for a normal reader. Populated by app.js from
   DATA.narratives. Renamed from .ai-comment 2026-05-09 across the suite. */
.auto-comment {
  display: flex; gap: 10px; align-items: flex-start;
  color: var(--muted); font-size: 12px; line-height: 1.55;
  margin: 12px 0 0;
  padding: 10px 14px;
  background: var(--panel-2);
  border-left: 3px solid #E5A12C;  /* gold (matches STRC/SATA) */
  border-radius: 6px;
}
.auto-comment.cards-blurb { margin: 0 0 22px; }
.auto-comment.detail-blurb { margin-top: 14px; }
/* Hide empty narrative containers — the auto-comment blocks expect narratives
   from a regenerator step that hasn't been built yet (audit 2026-05-12 item 3).
   Until then, don't render empty grey boxes. */
.auto-comment:empty { display: none; }

/* Sub-note on a control label, e.g. the BTC-stress scope clarifier. */
.controls label .ctrl-note {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  font-style: italic;
  font-weight: normal;
  text-transform: none;
  letter-spacing: 0;
}

/* Methodology + caveats — collapsible <details>, mirrors STRC's details.expl */
details.methodology {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 24px;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}
details.methodology summary {
  cursor: pointer;
  list-style: none;
  font-family: 'Fraunces', Georgia, serif;
  outline: none;
}
details.methodology summary::-webkit-details-marker { display: none; }
details.methodology summary::after {
  content: "—";
  float: right;
  color: var(--dim);
  font-family: inherit;
}
details.methodology:not([open]) summary::after { content: "+"; }
details.methodology summary h2 {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--text);
  font-family: 'Fraunces', Georgia, serif;
}
.methodology p { margin: 0 0 9px; }
.methodology code {
  background: var(--panel-2); padding: 1px 5px;
  border-radius: 3px; font-size: 11px;
  color: var(--accent);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.caveat {
  background: rgba(239,68,68,0.05);
  border-left: 3px solid var(--red);
  padding: 8px 12px; margin: 8px 0;
  color: #FCA5A5; font-size: 12px;
  line-height: 1.55; border-radius: 3px;
}
.caveat b { color: #F87171; }

/* Footer */
.footer {
  margin-top: 24px; font-size: 11px;
  color: var(--faint);
  text-align: center; line-height: 1.6;
}
.footer code {
  background: var(--panel-2); padding: 1px 5px;
  border-radius: 3px; color: var(--muted);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

/* Mobile responsive */
@media (max-width: 600px) {
  .wrap { padding: 18px 14px 60px; }
  .title { font-size: 22px; }
  .panel { padding: 14px 16px; }
  .controls { gap: 10px 14px; padding: 12px; }
}

/* ── Accessibility layer (handoff 2026-05-23) ───────────────────────────── */

/* Item 5: Opener subtitle — punchy one-liner under the title */
.opener-subtitle {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  margin: 8px 0 4px;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

/* Item 1: Hero readout — cheapest / richest / spread / callout */
#hero-readout {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 15px;
  line-height: 1.85;
  margin: 0 0 18px;
  color: var(--text);
}
#hero-readout .hero-bps { font-weight: 700; }
#hero-readout .hero-bps-cheap { color: var(--cheap); }
#hero-readout .hero-bps-rich  { color: var(--rich); }
#hero-readout a {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}
#hero-readout a:hover { color: var(--accent); text-decoration: underline; }
#hero-readout .hero-unavail {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

/* Item 4: Stress callout — pull-quote with accent left rule */
.stress-callout {
  border-left: 3px solid var(--accent);
  padding: 12px 18px;
  margin: 0 0 18px;
  background: rgba(129, 140, 248, 0.05);
  border-radius: 0 8px 8px 0;
}
.stress-callout-headline {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 4px;
  line-height: 1.45;
  color: var(--text);
}
.stress-callout-headline .sc-strd { color: var(--rich); }
.stress-callout-headline .sc-strf { color: var(--cheap); }
.stress-callout-bridge {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

/* Item 2: Ticker key strip */
.ticker-key {
  font-size: 12.5px;
  color: var(--dim);
  margin: 0 0 18px;
  line-height: 1.7;
}
.ticker-key .tk-dot { color: var(--faint); margin: 0 5px; }
.tk-ticker {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  position: relative;
  display: inline-block; /* needed for absolute-positioned tooltip */
}
.tk-ticker:hover { text-decoration: underline; }
/* CSS-only tooltip: hidden child span revealed on hover */
.tk-tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 260px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 11.5px;
  font-weight: normal;
  color: var(--muted);
  line-height: 1.5;
  white-space: normal;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  z-index: 20;
  text-align: left;
  pointer-events: none;
}
.tk-ticker:hover .tk-tip { display: block; }

/* Mobile: ticker key wraps naturally; tooltip left-anchored to avoid off-screen */
@media (max-width: 600px) {
  .tk-tip { left: 0; transform: none; }
  .opener-subtitle { font-size: 14px; }
  #hero-readout { font-size: 14px; }
}
