/* ════════════════════════════════════════════════════════════════════
   FinsightAI — Editorial Finance Design System
   Inspired by serious finance publications (FT, Bloomberg, WSJ)
   AdSense-optimized: clean layout, generous whitespace, mobile-first
   ════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700;9..144,800;9..144,900&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Editorial palette — newspaper feel */
  --paper:        #fbfaf7;
  --paper-dark:   #f5f3ed;
  --ink:          #1a1a1a;
  --ink-soft:     #2c2c2c;
  --ink-muted:    #6b6b6b;
  --ink-faint:    #9a9a9a;
  --rule:         #e8e4dc;
  --rule-strong:  #d4cfc3;

  /* Accents — financial green/red, brand orange */
  --green:        #1a7f3c;
  --green-soft:   #e8f5ec;
  --red:          #c83232;
  --red-soft:     #fbecec;
  --brand:        #c8552b;        /* Editorial orange */
  --brand-dark:   #a3411e;
  --brand-soft:   #fdf2ec;
  --gold:         #b8862a;

  /* Typography */
  --font-serif:   'Fraunces', Georgia, serif;
  --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'JetBrains Mono', Menlo, monospace;

  /* Layout */
  --max-w:        1240px;
  --max-w-article: 720px;
  --gutter:       24px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: var(--ink);
}
h1 { font-size: clamp(36px, 5vw, 56px); margin-bottom: 16px; }
h2 { font-size: clamp(26px, 3.6vw, 36px); margin-bottom: 14px; }
h3 { font-size: clamp(20px, 2.4vw, 24px); margin-bottom: 10px; }
h4 { font-size: 18px; margin-bottom: 8px; }

p { margin-bottom: 16px; color: var(--ink-soft); }
a { color: var(--brand); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--brand-dark); text-decoration: underline; }

.lead {
  font-family: var(--font-serif);
  font-size: clamp(18px, 2.2vw, 22px);
  line-height: 1.5;
  color: var(--ink-soft);
  margin-bottom: 24px;
}

.kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--brand);
  margin-bottom: 12px;
  display: block;
}

.mono { font-family: var(--font-mono); }
.num  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ── Layout containers ──────────────────────────────────────── */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.container-narrow {
  max-width: var(--max-w-article);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ── Header (newspaper masthead) ────────────────────────────── */
.masthead {
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: rgba(251, 250, 247, 0.95);
}
.masthead-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.brand:hover { text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 36px; height: 36px;
  background: var(--ink);
  color: var(--paper);
  display: grid; place-items: center;
  font-family: var(--font-serif);
  font-weight: 800;
  font-size: 20px;
  border-radius: 2px;
}
.brand-mark::after { content: 'F'; }
.brand .ai-tag { color: var(--brand); font-style: italic; }

.nav {
  display: flex;
  gap: 28px;
  align-items: center;
}
.nav a {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  text-decoration: none;
}
.nav a:hover { color: var(--brand); }
.nav a.active { color: var(--brand); font-weight: 600; }

.menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--rule);
  font-size: 22px;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
}

/* ── Datestamp bar (under masthead) ─────────────────────────── */
.datestamp {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
}
.datestamp-inner {
  padding: 8px 0;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  text-transform: uppercase;
}
.datestamp .live-dot {
  width: 7px; height: 7px;
  background: var(--green);
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  50% { opacity: 0.4; }
}

/* ── Hero ──────────────────────────────────────────────────── */
.hero {
  padding: 56px 0 48px;
  border-bottom: 1px solid var(--rule);
}
.hero-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 48px;
}
.hero-title {
  font-size: clamp(40px, 6vw, 72px);
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-bottom: 20px;
}
.hero-title em {
  font-style: italic;
  color: var(--brand);
  font-weight: 500;
}
.hero-sub {
  font-family: var(--font-serif);
  font-size: 20px;
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 580px;
  margin-bottom: 28px;
}
.hero-cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  border-radius: 4px;
  text-decoration: none;
  transition: all 0.15s;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--ink);
  color: var(--paper);
}
.btn-primary:hover {
  background: var(--brand);
  color: var(--paper);
  text-decoration: none;
}
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule-strong);
}
.btn-ghost:hover {
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
}

/* ── Quick search (hero-side) ──────────────────────────────── */
.quick-search {
  background: var(--paper-dark);
  border: 1px solid var(--rule);
  padding: 24px;
  border-radius: 4px;
}
.quick-search h4 {
  font-size: 12px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--brand);
  margin-bottom: 14px;
}
.quick-search-input {
  position: relative;
}
.quick-search-input input {
  width: 100%;
  padding: 14px 16px;
  font-size: 15px;
  font-family: var(--font-sans);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  outline: none;
}
.quick-search-input input:focus { border-color: var(--brand); }
.quick-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  z-index: 50;
  max-height: 320px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}
.quick-search-results.active { display: block; }
.qs-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.qs-item:hover { background: var(--paper-dark); }
.qs-item:last-child { border-bottom: none; }
.qs-item .sym {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--ink);
}
.qs-item .qs-name {
  font-size: 12px;
  color: var(--ink-muted);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Sections ──────────────────────────────────────────────── */
.section {
  padding: 56px 0;
  border-bottom: 1px solid var(--rule);
}
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 12px;
}
.section-head h2 {
  margin: 0;
}
.section-head a {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Market grid (homepage) ─────────────────────────────────── */
.market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}
.market-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 24px;
  border-radius: 4px;
  transition: border-color 0.15s;
}
.market-card:hover { border-color: var(--ink); }
.market-card h3 {
  font-size: 20px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.market-card .market-flag {
  font-size: 22px;
}
.market-card .market-meta {
  font-size: 13px;
  color: var(--ink-muted);
  margin-bottom: 16px;
}
.market-card .market-stat {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 14px;
}
.market-card .market-stat:last-of-type { border-bottom: none; }
.market-card .market-cta {
  display: block;
  margin-top: 14px;
  text-align: center;
  padding: 10px;
  background: var(--paper-dark);
  border-radius: 4px;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
}
.market-card .market-cta:hover {
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
}

/* ── Movers table (homepage) ────────────────────────────────── */
.movers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}
.movers-col h3 {
  font-size: 14px;
  font-family: var(--font-sans);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 12px;
}
.mover {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
  align-items: center;
  text-decoration: none;
  color: var(--ink);
}
.mover:hover { background: var(--paper-dark); text-decoration: none; }
.mover-sym {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  min-width: 70px;
}
.mover-name {
  font-size: 13px;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mover-change {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14px;
  text-align: right;
}
.mover-change.up { color: var(--green); }
.mover-change.down { color: var(--red); }

/* ── AdSense slots (CRITICAL — properly labeled) ─────────────── */
.ad-slot {
  margin: 32px auto;
  text-align: center;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--paper-dark);
  border: 1px dashed var(--rule-strong);
  padding: 12px;
  border-radius: 4px;
}
.ad-slot::before {
  content: 'ADVERTISEMENT';
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 0.15em;
  margin-bottom: 8px;
}
.ad-slot.placeholder::after {
  content: 'Ad space — AdSense will appear here';
  color: var(--ink-faint);
  font-size: 13px;
  font-style: italic;
}

/* ── Article (blog + ticker pages) ──────────────────────────── */
.article {
  padding: 48px 0;
}
.article-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--rule);
}
.article-header h1 {
  font-size: clamp(32px, 4.5vw, 52px);
  margin-bottom: 16px;
}
.article-meta {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.article-meta .author { color: var(--ink); font-weight: 600; }
.article-body {
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.7;
  color: var(--ink-soft);
}
.article-body p { margin-bottom: 24px; }
.article-body h2 {
  font-size: 28px;
  margin-top: 40px;
  margin-bottom: 16px;
}
.article-body h3 {
  font-size: 22px;
  margin-top: 32px;
  margin-bottom: 12px;
}
.article-body ul, .article-body ol {
  margin-bottom: 24px;
  padding-left: 24px;
}
.article-body li { margin-bottom: 8px; }
.article-body blockquote {
  border-left: 4px solid var(--brand);
  padding-left: 20px;
  margin: 28px 0;
  font-style: italic;
  color: var(--ink-muted);
}
.article-body strong { color: var(--ink); font-weight: 700; }

/* ── Ticker page (asset overview) ────────────────────────────── */
.ticker-page { padding: 32px 0; }
.ticker-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 32px;
}
.ticker-title h1 {
  font-size: clamp(28px, 4vw, 42px);
  margin-bottom: 6px;
}
.ticker-title .ticker-meta {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ticker-quote {
  text-align: right;
}
.ticker-price {
  font-family: var(--font-mono);
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.ticker-change {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  margin-top: 4px;
}
.ticker-change.up { color: var(--green); }
.ticker-change.down { color: var(--red); }

.ticker-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 32px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th, .data-table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--rule);
  font-size: 14px;
}
.data-table th {
  font-family: var(--font-sans);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}
.data-table td.num {
  text-align: right;
  font-family: var(--font-mono);
}

.score-card {
  background: var(--paper-dark);
  padding: 28px 24px;
  border-radius: 4px;
  text-align: center;
  border: 1px solid var(--rule);
}
.score-big {
  font-family: var(--font-serif);
  font-size: 72px;
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
  margin: 12px 0;
}
.score-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-muted);
}
.score-verdict {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 18px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 4px;
}
.verdict-buy, .verdict-strong_buy { background: var(--green-soft); color: var(--green); }
.verdict-hold { background: #faf4e1; color: var(--gold); }
.verdict-sell, .verdict-strong_sell { background: var(--red-soft); color: var(--red); }

.factor-list {
  list-style: none;
  padding: 0;
}
.factor-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
}
.factor-list li::before {
  content: '→';
  color: var(--brand);
  flex-shrink: 0;
}
.factor-list.bear li::before { color: var(--red); }
.factor-list.bull li::before { color: var(--green); }

/* ── Disclaimer box (must appear on every analysis page) ─────── */
.disclaimer {
  background: var(--paper-dark);
  border-left: 4px solid var(--gold);
  padding: 16px 20px;
  font-size: 13px;
  color: var(--ink-soft);
  margin: 32px 0;
  border-radius: 0 4px 4px 0;
}
.disclaimer strong { color: var(--ink); }

/* ── Footer ─────────────────────────────────────────────────── */
.footer {
  background: var(--ink);
  color: var(--paper);
  padding: 56px 0 24px;
  margin-top: 64px;
}
.footer a {
  color: var(--paper);
  opacity: 0.8;
}
.footer a:hover { opacity: 1; color: var(--brand); }
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}
.footer-col h4 {
  font-family: var(--font-sans);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 14px;
  color: var(--paper);
}
.footer-col p { color: rgba(251, 250, 247, 0.7); font-size: 14px; }
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: 8px; font-size: 14px; }
.footer-bottom {
  border-top: 1px solid rgba(251, 250, 247, 0.15);
  padding-top: 20px;
  font-size: 12px;
  color: rgba(251, 250, 247, 0.6);
  text-align: center;
  font-family: var(--font-mono);
}
.footer .brand { color: var(--paper); }
.footer .brand-mark { background: var(--paper); color: var(--ink); }

/* ── Loading / spinner ──────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--rule);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .hero-grid, .ticker-grid, .movers-grid { grid-template-columns: 1fr; }
  .hero-grid { gap: 32px; }
  .ticker-grid { gap: 24px; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .nav { display: none; }
  .nav.open { display: flex; flex-direction: column; position: absolute; top: 100%; left: 0; right: 0; background: var(--paper); padding: 16px; border-bottom: 1px solid var(--rule); gap: 14px; }
  .menu-btn { display: block; }
  .hero { padding: 32px 0 28px; }
  .section { padding: 36px 0; }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .ticker-header { flex-direction: column; }
  .ticker-quote { text-align: left; }
}
