/*
 * Research Report Design System — Public CSS variable contract
 * ----------------------------------------------------------------------------
 * Used by:
 *   - equity-research-report skill         (e.g. /YYYY/MM/DD/<ticker>-research/)
 *   - will-discord-analysis-report-to-page (Discord research → HTML)
 *   - daily-macro-strategy-briefing        (/YYYY/MM/DD/daily-macro-strategy-briefing/)
 *
 * Visual identity: "newspaper print" — cream paper, ink-on-paper typography,
 * sharp 2px corners, left-border accents, double rules. No rounded cards,
 * no hover-lift effects.
 *
 * Usage from a page:
 *   <link rel="stylesheet" href="/assets/css/research-report.css">
 *   Optionally override variables in a tiny inline <style>:
 *     :root { --accent: #1a4d2e; }   (e.g. green for bullish-only briefing)
 *
 * ----------------------------------------------------------------------------
 * EXPOSED CSS CUSTOM PROPERTIES (override these per article)
 * ----------------------------------------------------------------------------
 *
 *   --cream          #f5f0e8   Soft cream, used for stat-card / highlight-box /
 *                              callout backgrounds. Override for tonal variants.
 *   --paper          #faf7f0   Newspaper page surface (.newspaper container bg
 *                              and inverse text on .ticker-badge / tooltips).
 *   --page-bg        #e8e0d0   Outer body background framing the .newspaper.
 *   --ink            #1a1a1a   Primary text + dark ink elements (badges,
 *                              .newspaper top/bottom rules, back-to-top).
 *   --ink-light      #4a4a4a   Secondary text (subtitles, body copy).
 *   --ink-faint      #8a8a7a   Tertiary text (labels, captions, metadata).
 *   --rule           #2a2a2a   Strong horizontal rules (section dividers,
 *                              table headers, masthead bottom).
 *   --rule-light     #c8c0b0   Soft hairline rules (table cells, dividers).
 *   --accent         #8b0000   Brand accent — section h3 left-border, stat
 *                              numbers, topic-tags, link color, bear-card border.
 *                              MOST COMMON OVERRIDE per article.
 *   --accent-soft    rgba(139,0,0,0.04)   Tinted accent wash for .highlight-row.
 *                              When you override --accent, also override this.
 *   --positive       #2d6a2d   Green for positive numbers / catalyst dots /
 *                              bull-card border.
 *   --bull-bg        #f0f7f0   Bull thesis-card background (light green wash).
 *   --bear-bg        #fdf0f0   Bear thesis-card background (light red wash).
 *   --max-width      960px     Newspaper container max-width.
 *
 * ----------------------------------------------------------------------------
 * REQUIRED FONTS (pages must @import these themselves, or rely on system fall-
 * backs). The recommended import line for a page:
 *
 *   @import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;700;900&family=Noto+Sans+SC:wght@400;700&family=Playfair+Display:wght@400;700;900&display=swap');
 *
 * ----------------------------------------------------------------------------
 */

:root {
  --cream: #f5f0e8;
  --paper: #faf7f0;
  --page-bg: #e8e0d0;
  --ink: #1a1a1a;
  --ink-light: #4a4a4a;
  --ink-faint: #8a8a7a;
  --rule: #2a2a2a;
  --rule-light: #c8c0b0;
  --accent: #8b0000;
  --accent-soft: rgba(139, 0, 0, 0.04);
  --positive: #2d6a2d;
  --bull-bg: #f0f7f0;
  --bear-bg: #fdf0f0;
  --max-width: 960px;
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
ul, ol { padding-left: 1.5em; }

body {
  font-family: 'Noto Serif SC', 'Georgia', serif;
  line-height: 1.85;
  background: var(--page-bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

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

/* ── Reading progress bar ──────────────────────────────────────────────── */
#progress-bar {
  position: fixed; top: 0; left: 0;
  width: 0%; height: 3px;
  background: var(--accent);
  z-index: 9999;
  transition: width 0.1s linear;
}

/* ── Newspaper container ───────────────────────────────────────────────── */
.newspaper {
  max-width: var(--max-width);
  margin: 40px auto;
  background: var(--paper);
  padding: 48px 52px 60px;
  box-shadow: 0 4px 30px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
  position: relative;
}
.newspaper::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 6px; background: var(--ink);
}
.newspaper::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0;
  height: 3px; background: var(--ink);
}

/* ── Masthead ──────────────────────────────────────────────────────────── */
.masthead {
  padding-bottom: 20px;
  border-bottom: 4px double var(--rule);
  margin-bottom: 24px;
}
.masthead-top {
  display: flex; justify-content: space-between; align-items: center;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 12px;
}
.masthead h1 {
  font-family: 'Noto Serif SC', Georgia, serif;
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 900; line-height: 1.2;
  margin-bottom: 8px;
}
.masthead .subtitle {
  font-family: 'Noto Serif SC', serif;
  font-size: 16px; color: var(--ink-light);
  margin-bottom: 6px; line-height: 1.6;
}
.masthead .tagline {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 13px; color: var(--ink-faint);
  margin-bottom: 12px;
}

.topic-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.topic-tag {
  border: 1px solid var(--accent);
  border-radius: 2px;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 11px; padding: 2px 8px;
  color: var(--accent);
  letter-spacing: 0.5px;
}

/* ── Ticker badge ──────────────────────────────────────────────────────── */
.ticker-badge {
  display: inline-block;
  background: var(--ink); color: var(--paper);
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 2px;
  letter-spacing: 0.5px; vertical-align: middle;
}

/* ── Edition bar ───────────────────────────────────────────────────────── */
.edition-bar {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 13px; color: var(--ink-faint);
  border-bottom: 1px solid var(--rule);
  padding: 8px 0; margin-bottom: 24px;
}

/* ── Stats bar (top 4-up KPIs) ─────────────────────────────────────────── */
.stats-bar {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 2px solid var(--rule);
  border-bottom: 2px solid var(--rule);
  margin-bottom: 32px;
}
.stat {
  text-align: center; padding: 16px 8px;
  border-right: 1px solid var(--rule-light);
}
.stat:last-child { border-right: none; }
.stat-number {
  font-family: 'Playfair Display', serif;
  font-size: 28px; font-weight: 900;
  color: var(--accent); line-height: 1.2;
}
.stat-label {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 11px; color: var(--ink-faint);
  margin-top: 4px; letter-spacing: 0.5px;
}
.stat-context {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 10px; color: var(--ink-faint);
  margin-top: 2px;
}
.stat-context.positive { color: var(--positive); }
.stat-context.negative { color: var(--accent); }

/* ── Sections (collapsible) ────────────────────────────────────────────── */
.section { margin-bottom: 28px; }
.section-header {
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; padding: 8px 0;
  user-select: none;
}
.section-header h2 {
  font-family: 'Playfair Display', 'Noto Serif SC', serif;
  font-size: clamp(22px, 3.5vw, 30px);
  font-weight: 900; line-height: 1.25;
}
.collapse-icon {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 18px; color: var(--ink-faint);
  transition: transform 0.3s ease;
  flex-shrink: 0; margin-left: 12px;
}
.collapse-icon.collapsed { transform: rotate(-90deg); }
.section-body { overflow: visible; transition: max-height 0.3s ease; }
.section-body.collapsed { max-height: 0 !important; overflow: hidden; }

.section-body p { margin: 12px 0; font-size: 16px; }

h3 {
  font-family: 'Noto Serif SC', serif;
  font-size: 18px; font-weight: 700;
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  margin: 24px 0 12px;
}

p { margin: 12px 0; font-size: 16px; }

/* ── Stat card (inline highlight) ──────────────────────────────────────── */
.stat-card {
  background: var(--cream);
  border-left: 4px solid var(--accent);
  padding: 16px 20px; margin: 20px 0;
  text-align: center;
}
.stat-card .stat-number {
  font-family: 'Playfair Display', serif;
  font-size: 36px; font-weight: 900;
  color: var(--accent);
}
.stat-card .stat-label {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 13px; color: var(--ink); margin-top: 4px;
}
.stat-card .stat-context {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 12px; color: var(--ink-faint); margin-top: 2px;
}
.stat-card-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 16px; margin: 20px 0;
}
.stat-card-grid .stat-card { margin: 0; }

/* ── Comparison & timeline tables ─────────────────────────────────────── */
.comparison-table,
.timeline-table {
  width: 100%; border-collapse: collapse;
  margin: 16px 0; font-size: 14px;
}
.comparison-table th,
.timeline-table th {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 12px; text-transform: uppercase;
  text-align: left; padding: 10px 12px;
  border-bottom: 2px solid var(--rule);
  color: var(--ink-light);
  letter-spacing: 0.5px;
}
.comparison-table td,
.timeline-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule-light);
  vertical-align: top;
}
.comparison-table tr:hover td,
.timeline-table tr:hover td { background: var(--cream); }
.comparison-table tr:last-child td,
.timeline-table tr:last-child td { border-bottom: 2px solid var(--rule); }

.highlight-row td {
  background: var(--accent-soft);
  font-weight: 600;
}
.positive { color: var(--positive); }
.negative { color: var(--accent); }

/* ── Investment / kv table (macro briefing) ────────────────────────────── */
.inv-table {
  width: 100%; border-collapse: collapse;
  margin: 16px 0; font-size: 14px;
}
.inv-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--rule-light);
  vertical-align: top;
}
.inv-table td:first-child {
  font-family: 'Noto Sans SC', sans-serif;
  font-weight: 700; font-size: 12px;
  color: var(--ink-light);
  white-space: nowrap; width: 130px;
}
.inv-table tr:first-child td { border-top: 2px solid var(--rule); }
.inv-table tr:last-child td { border-bottom: 2px solid var(--rule); }

/* ── Thesis cards (bull / bear) ────────────────────────────────────────── */
.thesis-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 20px; margin: 20px 0;
}
.thesis-card { padding: 20px; border-radius: 2px; }
.thesis-card h4 {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 14px; font-weight: 700;
  margin-bottom: 10px;
}
.thesis-card ul { padding-left: 20px; font-size: 14px; }
.thesis-card li { margin-bottom: 8px; line-height: 1.7; }
.thesis-card.bull,
.bull { background: var(--bull-bg); border-left: 4px solid var(--positive); }
.thesis-card.bear,
.bear { background: var(--bear-bg); border-left: 4px solid var(--accent); }

/* ── Risk / catalyst lists ─────────────────────────────────────────────── */
.risk-list, .catalyst-list { list-style: none; padding: 0; margin: 16px 0; }
.risk-list li, .catalyst-list li {
  padding: 10px 0 10px 16px;
  border-bottom: 1px solid var(--rule-light);
  position: relative;
  font-size: 14px; line-height: 1.7;
}
.risk-list li::before,
.catalyst-list li::before {
  content: ''; position: absolute; left: 0; top: 16px;
  width: 6px; height: 6px; border-radius: 50%;
}
.risk-list li::before { background: var(--accent); }
.catalyst-list li::before { background: var(--positive); }

/* ── Highlight box (callouts) ──────────────────────────────────────────── */
.highlight-box {
  background: var(--cream);
  border: 1px solid var(--rule-light);
  padding: 16px 20px; margin: 20px 0;
  font-size: 15px; line-height: 1.75;
}
.highlight-box strong { color: var(--accent); }

/* ── Company card (related stocks) ─────────────────────────────────────── */
.company-card {
  background: var(--cream);
  padding: 16px 20px; border-radius: 2px;
  border: 1px solid var(--rule-light);
  margin-bottom: 12px;
}
.company-card-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.company-card .name { font-weight: 700; font-size: 14px; }
.company-card p { font-size: 13px; color: var(--ink-light); margin: 4px 0 0; }

/* ── Proportion bars ───────────────────────────────────────────────────── */
.proportion-bar-container { margin: 20px 0; }
.proportion-bar-label {
  display: flex; justify-content: space-between;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 13px; font-weight: 700;
  margin-bottom: 6px;
}
.proportion-bar {
  display: flex; height: 28px;
  border-radius: 2px; overflow: hidden;
  background: var(--cream);
}
.proportion-segment {
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 10px; font-weight: 700;
  white-space: nowrap; overflow: hidden;
  transition: flex-basis 0.5s ease;
}
.proportion-legend {
  display: flex; flex-wrap: wrap; gap: 12px;
  margin-top: 8px;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 11px; color: var(--ink-light);
}
.legend-item { display: flex; align-items: center; gap: 4px; }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

/* ── Tooltip ───────────────────────────────────────────────────────────── */
.tooltip-term {
  border-bottom: 1px dotted var(--ink-faint);
  cursor: help; position: relative;
}
.tooltip-text {
  display: none; position: absolute;
  bottom: 100%; left: 0;
  background: var(--ink); color: var(--paper);
  font-family: 'Noto Sans SC', sans-serif;
  padding: 8px 12px; border-radius: 6px;
  font-size: 12px; line-height: 1.5;
  z-index: 9990;
  max-width: min(480px, 90vw); width: max-content;
  margin-bottom: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
.tooltip-term:hover .tooltip-text { display: block; }

/* ── Macro briefing extras ─────────────────────────────────────────────── */
.confidence-badge {
  display: inline-block;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 2px;
  letter-spacing: 0.5px; vertical-align: middle;
}
.confidence-high { background: var(--accent); color: var(--paper); }
.confidence-medium-high { background: var(--ink-light); color: var(--paper); }

.trade-action {
  background: var(--cream);
  border-left: 4px solid var(--accent);
  padding: 12px 16px; margin: 12px 0;
  font-size: 14px;
}
.trade-action strong { color: var(--accent); }

.exec-summary {
  background: var(--cream);
  border-left: 4px solid var(--accent);
  padding: 20px 24px; margin-bottom: 28px;
}
.exec-summary h3 {
  border-left: none; padding-left: 0; margin-top: 0;
  font-size: 16px; color: var(--accent); margin-bottom: 12px;
}
.exec-summary ul { padding-left: 16px; }
.exec-summary li { font-size: 14px; margin-bottom: 8px; line-height: 1.7; }

/* ── Part divider ──────────────────────────────────────────────────────── */
.part-divider {
  text-align: center; position: relative;
  margin: 40px 0 32px;
}
.part-divider::before {
  content: ''; position: absolute; top: 50%; left: 0; right: 0;
  height: 1px; background: var(--rule-light);
}
.part-divider span {
  position: relative; background: var(--paper);
  padding: 0 20px;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 13px; color: var(--ink-faint);
  letter-spacing: 2px; text-transform: uppercase;
}

/* ── Disclaimer ────────────────────────────────────────────────────────── */
.disclaimer {
  margin-top: 40px; padding: 20px;
  border-top: 2px solid var(--rule);
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 12px; color: var(--ink-faint);
  line-height: 1.7;
  text-align: center;
}

/* ── Sources ───────────────────────────────────────────────────────────── */
.sources-list { font-size: 12px; color: var(--ink-faint); margin-top: 20px; }
.sources-list a { color: var(--ink-faint); text-decoration: underline; }
.source-link { font-size: 12px; color: var(--ink-faint); }

/* ── Back-to-top ───────────────────────────────────────────────────────── */
.back-to-top {
  position: fixed; bottom: 30px; right: 30px;
  width: 42px; height: 42px;
  background: var(--ink); color: var(--paper);
  border: none; border-radius: 50%;
  font-size: 18px; cursor: pointer;
  display: none; align-items: center; justify-content: center;
  z-index: 900; text-decoration: none;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.back-to-top.visible { display: flex; }

/* ── Table of Contents widget ──────────────────────────────────────────── */
/* Inline TOC block: rendered near the top of the article (after byline /
   stats-bar, before the first .section). Newspaper-style: cream wash with
   solid top/bottom rules, labelled header, two-column numbered list. */
.toc-block {
  background: var(--cream);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 22px 28px 26px;
  margin: 32px 0 36px;
}
.toc-block-label {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 12px;
  letter-spacing: 3px;
  color: var(--ink-faint);
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 14px;
}
.toc-block ol {
  list-style: none;
  padding: 0; margin: 0;
  columns: 2;
  column-gap: 28px;
  counter-reset: toc-counter;
}
.toc-block ol > li {
  counter-increment: toc-counter;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px dotted var(--rule-light);
  break-inside: avoid;
}
.toc-block ol > li::before {
  content: counter(toc-counter, decimal-leading-zero);
  font-family: 'Playfair Display', serif;
  font-size: 16px;
  font-weight: 900;
  color: var(--accent);
  flex-shrink: 0;
  min-width: 28px;
}
.toc-block a {
  font-family: 'Noto Serif SC', serif;
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.55;
  flex: 1;
  transition: color 0.15s;
}
.toc-block a:hover { color: var(--accent); }

/* Floating TOC button (mirror of .back-to-top, positioned bottom-left) */
.toc-fab {
  position: fixed; bottom: 30px; left: 30px;
  width: 42px; height: 42px;
  background: var(--ink); color: var(--paper);
  border: none; border-radius: 50%;
  font-size: 18px; line-height: 1; cursor: pointer;
  display: none; align-items: center; justify-content: center;
  z-index: 900;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  font-family: inherit;
}
.toc-fab.visible { display: flex; }

/* TOC overlay: full-screen scrim + centered card */
.toc-overlay {
  position: fixed; inset: 0;
  background: rgba(26, 26, 26, 0.78);
  display: none;
  align-items: flex-start; justify-content: center;
  z-index: 950;
  padding: 80px 16px 40px;
  overflow-y: auto;
}
.toc-overlay.visible { display: flex; }
.toc-overlay-card {
  background: var(--paper);
  max-width: 480px; width: 100%;
  padding: 28px 32px 32px;
  border-top: 4px solid var(--accent);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
  position: relative;
}
.toc-overlay-card .toc-block-label { margin-bottom: 18px; }
.toc-overlay-close {
  position: absolute;
  top: 12px; right: 16px;
  background: none; border: none;
  font-size: 24px; line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
  font-family: inherit;
}
.toc-overlay-close:hover { color: var(--ink); }
.toc-overlay-card ol {
  list-style: none;
  padding: 0; margin: 0;
  counter-reset: toc-counter;
}
.toc-overlay-card ol > li {
  counter-increment: toc-counter;
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule-light);
}
.toc-overlay-card ol > li:last-child { border-bottom: none; }
.toc-overlay-card ol > li::before {
  content: counter(toc-counter, decimal-leading-zero);
  font-family: 'Playfair Display', serif;
  font-size: 16px;
  font-weight: 900;
  color: var(--accent);
  flex-shrink: 0;
  min-width: 28px;
}
.toc-overlay-card a {
  font-family: 'Noto Serif SC', serif;
  font-size: 15px;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.55;
  flex: 1;
}
.toc-overlay-card a:hover { color: var(--accent); }

/* ── Responsive (single breakpoint) ────────────────────────────────────── */
@media (max-width: 700px) {
  p,
  .section-body p { font-size: 17px; }
  .newspaper { margin: 0; padding: 24px 18px 40px; box-shadow: none; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(1),
  .stat:nth-child(2) { border-bottom: 1px solid var(--rule-light); }
  .stat:nth-child(2) { border-right: none; }
  .thesis-grid,
  .stat-card-grid { grid-template-columns: 1fr; }
  .comparison-table,
  .timeline-table { font-size: 12px; }
  .comparison-table th, .comparison-table td,
  .timeline-table th, .timeline-table td { padding: 6px 8px; }
  .masthead h1 { font-size: clamp(24px, 6vw, 36px); }
  .edition-bar { flex-direction: column; gap: 4px; }
  .inv-table td:first-child { width: auto; white-space: normal; }
  .toc-block { padding: 18px 20px 22px; margin: 24px 0 28px; }
  .toc-block ol { columns: 1; gap: 4px 0; }
  .toc-fab { bottom: 24px; left: 24px; width: 40px; height: 40px; }
  .back-to-top { bottom: 24px; right: 24px; }
  .toc-overlay { padding: 40px 16px; }
  .toc-overlay-card { padding: 24px 22px 28px; }
}
