/* ============================================================
   MarketPulse — Verified Ledger design system
   Ink-terminal shell, warm ledger-paper text, amber verified data.
   Committed to one mode deliberately — the same discipline as the
   product itself: one register, no hedging.
   ============================================================ */

:root {
  --ink: #0B0E14;
  --panel: #12161F;
  --panel-raised: #171C27;
  --paper: #E8E6DE;
  --paper-dim: #9AA0AC;
  --amber: #C9A24B;
  --amber-dim: #8A7238;
  --verified: #4C9A6A;
  --caution: #C1544C;
  --hairline: #262C39;
  --hairline-strong: #3A4254;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;

  --container: 780px;
  --radius: 3px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

.news-item.is-cited, .gauge-card.is-cited {
  outline: 2px solid var(--amber);
  outline-offset: 4px;
}

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--ink);
  background-image:
    linear-gradient(180deg, rgba(201,162,75,0.04) 0%, transparent 320px);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 20px 96px;
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 36px;
}

.wordmark {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--paper);
}

.wordmark em {
  font-style: normal;
  color: var(--amber);
}

.edition-toggle {
  display: flex;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 2px;
}

.edition-toggle button {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--paper-dim);
  background: transparent;
  border: none;
  padding: 6px 12px;
  border-radius: 2px;
  cursor: pointer;
}

.edition-toggle button[aria-pressed="true"] {
  background: var(--panel-raised);
  color: var(--amber);
}

.edition-toggle button:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* ---------- Hero: the thesis, and the interaction tutorial ---------- */

.hero {
  margin-bottom: 44px;
}

.hero .eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--paper-dim);
  text-transform: uppercase;
  margin-bottom: 14px;
}

.hero .eyebrow .date { color: var(--paper); }

.publication-time, .analysis-notice, .source-link-unavailable {
  color: var(--paper-dim);
  font-size: 12px;
}

.hero h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.15;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.sentiment-word {
  font-style: italic;
  border-bottom: 1px dashed var(--amber-dim);
  cursor: pointer;
  transition: color 0.15s ease;
}

.sentiment-word:hover,
.sentiment-word.is-active {
  color: var(--amber);
  border-bottom-color: var(--amber);
}

.hero .sub {
  font-size: 15px;
  color: var(--paper-dim);
  max-width: 56ch;
}

.hero .hint {
  margin-top: 18px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--amber-dim);
  display: flex;
  align-items: center;
  gap: 8px;
}

.hero .hint::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--amber-dim);
  display: inline-block;
}

/* ---------- Section scaffolding ---------- */

section { margin-bottom: 40px; }

.section-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper-dim);
  padding-bottom: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--hairline);
}

/* ---------- Ledger (statement-style data grid) ---------- */

.ledger {
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
}

.ledger-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: baseline;
  padding: 11px 16px;
  border-bottom: 1px solid var(--hairline);
  transition: background 0.4s ease;
}

.ledger-row:last-child { border-bottom: none; }
.ledger-row:nth-child(even) { background: rgba(255,255,255,0.012); }

.ledger-row.is-cited {
  background: rgba(201, 162, 75, 0.1);
}

.ledger-row .label {
  font-size: 13.5px;
  color: var(--paper-dim);
}

.ledger-row .status {
  font-size: 12px;
  color: var(--paper-dim);
  white-space: nowrap;
}

.ledger-row .value {
  font-family: var(--mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 6ch;
}

.ledger-row .change.up { color: var(--verified); }
.ledger-row .change.down { color: var(--caution); }

/* dashboard rows get a two-line treatment: reading + status label under it */
.ledger-row.dashboard-row {
  grid-template-columns: 1fr auto;
}
.ledger-row.dashboard-row .stack .label { display: block; }
.ledger-row.dashboard-row .stack .status { display: block; font-size: 11px; margin-top: 2px; }

/* ---------- Fear & Greed gauge ---------- */

.gauge-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 18px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.gauge-track {
  position: relative;
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--caution), var(--hairline-strong) 50%, var(--verified));
}

.gauge-dot {
  position: absolute;
  top: 50%;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--ink);
  transform: translate(-50%, -50%);
}

.gauge-readout {
  font-family: var(--mono);
  text-align: right;
  white-space: nowrap;
}
.gauge-readout .score { font-size: 20px; color: var(--amber); }
.gauge-readout .label { display: block; font-size: 11px; color: var(--paper-dim); margin-top: 2px; }

/* ---------- Track record ---------- */

.trackrecord {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  flex-wrap: wrap;
}

.trackrecord .accuracy {
  font-family: var(--mono);
  font-size: 18px;
  color: var(--amber);
}

.trackrecord .last {
  font-size: 13px;
  color: var(--paper-dim);
  text-align: right;
  flex: 1;
  min-width: 220px;
}

/* ---------- Sentiment history (day-by-day timeline) ---------- */

.history-strip {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  padding: 16px 4px 10px;
  overflow-x: auto;
}

.history-cell {
  flex: 0 0 auto;
  width: 16px;
  height: 34px;
  border-radius: 2px;
  background: var(--hairline-strong);
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.history-cell.bullish { background: var(--verified); }
.history-cell.bearish { background: var(--caution); }
.history-cell.neutral { background: var(--paper-dim); opacity: 0.55; }

.history-cell:hover,
.history-cell.is-active {
  transform: scaleY(1.08);
  opacity: 1;
}

.history-cell .history-dot {
  position: absolute;
  left: 50%;
  bottom: -11px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  transform: translateX(-50%);
  background: transparent;
  border: 1px solid var(--hairline-strong);
}
.history-cell .history-dot.hit { background: var(--verified); border-color: var(--verified); }
.history-cell .history-dot.miss { background: var(--caution); border-color: var(--caution); }
/* "flat": the market moved too little to judge a directional call either way. Deliberately
   neither green nor red — a filled dim centre distinguishes it from the hollow "not yet
   scored" dot, without implying a verdict that was never earned. */
.history-cell .history-dot.flat { background: var(--paper-dim); border-color: var(--paper-dim); opacity: 0.5; }

.history-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: baseline;
  margin-top: 18px;
  padding: 10px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  font-size: 13px;
  background: rgba(201, 162, 75, 0.05);
}
.history-detail .history-detail-date { font-family: var(--mono); color: var(--amber); font-size: 12px; }
.history-detail .history-detail-sentiment { color: var(--paper); }
.history-detail .history-detail-result { color: var(--paper-dim); font-size: 12px; }

.history-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--paper-dim);
}
.history-legend span { display: inline-flex; align-items: center; gap: 5px; }
.history-legend .swatch { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.history-legend .swatch.bullish { background: var(--verified); }
.history-legend .swatch.bearish { background: var(--caution); }
.history-legend .swatch.neutral { background: var(--paper-dim); opacity: 0.55; }
.history-legend .dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.history-legend .dot.hit { background: var(--verified); }
.history-legend .dot.miss { background: var(--caution); }
.history-legend .dot.flat { background: var(--paper-dim); opacity: 0.5; }

/* ---------- Data quality banner ---------- */

.flag-banner {
  font-size: 13px;
  padding: 12px 16px;
  border: 1px solid var(--caution);
  border-radius: var(--radius);
  color: var(--paper);
  background: rgba(193, 84, 76, 0.08);
  margin-bottom: 24px;
}
.flag-banner b { color: var(--caution); }

/* ---------- Claims (the signature: click a claim, its evidence lights up above) ---------- */

.claim {
  display: flex;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--hairline);
  cursor: pointer;
  border-radius: 2px;
}
.claim:last-child { border-bottom: none; }

.claim:hover, .claim.is-active { background: rgba(201, 162, 75, 0.06); }

.claim .dir {
  flex-shrink: 0;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 7px;
}
.claim .dir.supports_bullish { background: var(--verified); }
.claim .dir.supports_bearish { background: var(--caution); }
.claim .dir.neutral { background: var(--paper-dim); }

.claim .text { font-size: 14.5px; }

.claim .evidence-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--amber-dim);
  overflow-wrap: anywhere;
}
.evidence-unavailable .value { color: var(--caution); }
.extra-evidence-ledger .ledger-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.extra-evidence-ledger .value { overflow-wrap: anywhere; }
.claim .evidence-tag::before { content: "\2192"; }
.claim.is-active .evidence-tag { color: var(--amber); }

/* ---------- Interpretation + wisdom ---------- */

.interpretation {
  font-size: 14.5px;
  color: var(--paper-dim);
  line-height: 1.65;
  margin-bottom: 20px;
}

.wisdom {
  font-family: var(--serif);
  font-style: italic;
  font-size: 20px;
  line-height: 1.5;
  color: var(--paper);
  padding-left: 20px;
  border-left: 2px solid var(--amber);
}

/* ---------- Today's headlines ---------- */

.news-list {
  margin: 0;
  padding-left: 1.4em;
}

.news-item {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--paper);
  margin: 7px 0;
  line-height: 1.5;
}

.news-item a {
  color: var(--paper);
  text-decoration: underline;
  text-decoration-color: var(--amber-dim);
  text-underline-offset: 3px;
}

.news-item a:hover {
  color: var(--amber);
}

/* ---------- Watchlist ---------- */

.watchlist-block {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--paper);
  white-space: pre-wrap;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}

/* ---------- Verified footer ---------- */

.verified-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--verified);
  padding: 12px 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.verified-strip[data-status="approved"]::before { content: "\2713"; font-weight: 700; }
.verified-strip[data-status="withheld"] { color: var(--caution); }
.verified-strip[data-status="unavailable"], .verified-strip[data-status="historical"] { color: var(--paper-dim); }

.footer {
  font-size: 12px;
  color: var(--paper-dim);
  padding-top: 20px;
  border-top: 1px solid var(--hairline);
}
.footer a { color: var(--amber-dim); }
.footer .sources { margin-top: 6px; }

/* ---------- Loading / empty ---------- */

.state-msg {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--paper-dim);
  padding: 40px 0;
  text-align: center;
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Responsive ---------- */

@media (max-width: 560px) {
  .ledger-row { grid-template-columns: 1fr auto; }
  .ledger-row .status { display: none; }
  .trackrecord { flex-direction: column; align-items: flex-start; }
  .trackrecord .last { text-align: left; }
}
