/* ============================================================
   base.css — Shared design tokens & utilities
   Used by: index.html, intelligence.html, all future pages
   ============================================================ */

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design tokens ── */
:root {
  /* Brand */
  --accent:        #3a7d0a;   /* dark green — primary CTA, links */
  --accent-light:  #b5e853;   /* lime — logo color, ticker highlights */
  --accent-bg:     #f0f9e0;   /* light green background tint */
  --accent-border: #c8e89a;   /* green border */

  /* Status */
  --danger:        #d32f2f;
  --danger-bg:     #fff0f0;
  --warning:       #e65100;
  --warning-bg:    #fff8e1;

  /* Neutral palette — light pages */
  --text-primary:   #1a1a1a;
  --text-secondary: #444444;
  --text-muted:     #888888;
  --border:         #e2e2e2;
  --border-light:   #f0f0ee;
  --surface:        #ffffff;
  --bg:             #f5f5f0;
  --bg-deep:        #eeede8;
  --bg-hover:       #fafaf8;

  /* Dark palette — intelligence dashboard & ticker */
  --dark-bg:        #0d0d0d;
  --dark-surface:   #141414;
  --dark-card:      #1a1a1a;
  --dark-border:    #2a2a2a;
  --dark-text:      #f0f0f0;
  --dark-muted:     #888888;
  --dark-danger:    #ff4d4d;

  /* Typography */
  --font-sans: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Spacing */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;

  /* Shadows */
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.06);
  --shadow-md:  0 4px 20px rgba(0,0,0,0.09);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.12);
}

/* ── Base typography ── */
body {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.num { font-family: var(--font-mono); }

/* ── Scrollbar ── */
::-webkit-scrollbar              { width: 6px; height: 6px; }
::-webkit-scrollbar-track        { background: #f0f0f0; }
::-webkit-scrollbar-thumb        { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover  { background: #bbb; }

/* ── Layout container ── */
.container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Badges ── */
.badge-up   { background: #e8f5e0; color: #2e7d0e; border-radius: 5px; padding: 1px 7px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-down { background: #ffeaea; color: #c62828; border-radius: 5px; padding: 1px 7px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-neu  { background: #f0f0f0; color: #666666; border-radius: 5px; padding: 1px 7px; font-size: 11px; font-weight: 700; white-space: nowrap; }

/* Dark variants (used in intelligence.html) */
.badge-up-dark   { background: rgba(181,232,83,0.15); color: #b5e853; border-radius: 5px; padding: 1px 7px; font-size: 11px; font-weight: 600; }
.badge-down-dark { background: rgba(255,77,77,0.15);  color: #ff4d4d; border-radius: 5px; padding: 1px 7px; font-size: 11px; font-weight: 600; }

/* ── Ticker pill ── */
.ticker-pill {
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: 5px;
  padding: 1px 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* ── Category / topic tags ── */
.tag         { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; border-radius: 4px; padding: 2px 7px; }
.tag-green   { background: #e6f4d8; color: #2d6a06; }
.tag-red     { background: #fde8e8; color: #b71c1c; }
.tag-blue    { background: #e3f0fb; color: #1565c0; }
.tag-amber   { background: #fff8e1; color: #e65100; }
.tag-gray    { background: #f0f0f0; color: #555555; }
.tag-purple  { background: #f3e8ff; color: #6b21a8; }

/* ── Source badge ── */
.source-badge {
  font-size: 10px;
  font-weight: 600;
  color: #888;
  background: #f4f4f0;
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
}

/* ── Buttons ── */
.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-size: 13px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
  text-align: center;
}
.btn-primary:hover { background: #2d6208; }

.btn-outline {
  display: inline-block;
  background: transparent;
  border: 1px solid #d0d0d0;
  color: #555;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

/* ── Sparklines ── */
.sparkline { display: inline-block; vertical-align: middle; }

/* ── Sentiment dots ── */
.dot-pos { width: 6px; height: 6px; border-radius: 50%; background: #4caf50; display: inline-block; flex-shrink: 0; }
.dot-neg { width: 6px; height: 6px; border-radius: 50%; background: #f44336; display: inline-block; flex-shrink: 0; }
.dot-neu { width: 6px; height: 6px; border-radius: 50%; background: #9e9e9e; display: inline-block; flex-shrink: 0; }

/* ── Section headings ── */
.section-title { font-size: 16px; font-weight: 800; color: var(--text-primary); }
.section-more  { font-size: 12px; font-weight: 600; color: var(--accent); text-decoration: none; }
.section-more:hover { text-decoration: underline; }

/* ── Ticker tape ── */
.ticker-wrap { overflow: hidden; background: #1a1a1a; }
.ticker-inner {
  display: flex;
  gap: 40px;
  white-space: nowrap;
  animation: tickerRoll 38s linear infinite;
  padding: 8px 0;
}
.ticker-inner:hover { animation-play-state: paused; }
@keyframes tickerRoll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ── Footer (shared dark footer) ── */
footer { background: #1a1a1a; color: #aaa; }
footer a { color: #aaa; text-decoration: none; transition: color 0.15s; }
footer a:hover { color: #fff; }

/* ── Live dot pulse ── */
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #2e7d0e; display: inline-block; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Core Web Vitals — CLS prevention ─────────────────────────────────────
   Prevents layout shift when images, ads, or embeds load.
   ── */

/* Reserve space for images before they load — prevents CLS */
img {
  height: auto;
  max-width: 100%;
  /* Stabilises layout while loading */
  content-visibility: auto;
}

/* News card thumbnails: fixed aspect ratio box so layout doesn't jump */
.news-card-img-wrap {
  position: relative;
  overflow: hidden;
  background: #f0f0ee; /* placeholder background */
}
.news-card-img-wrap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Ad slot placeholders — explicit min-height prevents CLS when AdSense loads */
.ad-leaderboard {
  min-height: 90px;
  contain: layout style; /* isolate ad reflows from rest of page */
}
.ad-sidebar {
  min-height: 250px;
  contain: layout style;
}

/* ── Core Web Vitals — INP optimisation ────────────────────────────────────
   Improves Interaction to Next Paint on interactive elements.
   ── */

/* All interactive elements: composited layer, no paint on hover */
a, button, [role="button"], input, select, textarea {
  touch-action: manipulation; /* removes 300ms tap delay on mobile */
}

/* Filter buttons / pill links — instant visual feedback via CSS, no JS needed */
.nav-link,
.page-btn,
.cap-pill,
.btn-primary,
.btn-outline,
.scr-select,
.scr-input {
  will-change: auto; /* only promote layers when browser decides to */
  transition-property: background-color, border-color, color, opacity;
  transition-duration: 0.12s;
  transition-timing-function: ease;
}

/* Table rows: hardware-accelerated hover highlight to avoid paint */
.it-table tr,
.scr-table tr,
.earn-tbl-row {
  transition: background-color 0.08s ease;
}

/* ── Content-visibility for off-screen sections ────────────────────────────
   Skips rendering of content below the fold until user scrolls near it.
   Dramatically improves LCP and TTI on long pages.
   ── */
.below-fold {
  content-visibility: auto;
  contain-intrinsic-size: auto 400px; /* estimated height — adjust per section */
}
