:root {
  --bg: #f9f7f4;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --accent: #0f4c81;
  --tag-bg: #eef2f7;
  --border: #e5e7eb;
  --font-brand: 'Orbitron', sans-serif; /* Changed to Orbitron */
  --font-serif: 'Roboto', sans-serif;   /* Changed to Roboto */
  --font-ui: 'Inter', sans-serif;      /* Changed to Inter */
  --max-width: 720px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 18px; scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: var(--font-serif); line-height: 1.75; }

/* Header */
.sticky-header { position: sticky; top: 0; z-index: 100; }
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }

/* Brand */
.site-brand { max-width: 1100px; margin: 0 auto; padding: 0.9rem 2rem 0.7rem; display: flex; flex-direction: column; gap: 0.1rem; }
.brand-name { font-family: var(--font-brand); font-size: 2rem; font-weight: 900; color: #000000; text-decoration: none; letter-spacing: -0.03em; line-height: 1; }
.brand-name:hover { color: #000000; }
.brand-tagline { font-family: var(--font-brand); font-size: 0.78rem; color: var(--muted); font-weight: 400; letter-spacing: 0.01em; }

/* Ticker */
.ticker-outer { overflow: hidden; border-top: 1px solid var(--border); background: var(--surface); height: 40px; user-select: none; }
.ticker-belt { display: flex; width: max-content; height: 40px; will-change: transform; }
.ticker-set { display: flex; align-items: center; height: 40px; }
.ti { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0 1.1rem; font-size: 0.72rem; font-family: var(--font-brand); white-space: nowrap; }
.ts { font-weight: 700; color: var(--text); }
.tp { color: #444; }
.tc { font-size: 0.7rem; }
.tc.up { color: #16a34a; }
.tc.dn { color: #dc2626; }
.tsep { color: #d1d5db; font-size: 0.6rem; padding: 0 0.1rem; }
/* Auto-scroll right-to-left: 2 copies, 45s duration */
.ticker-belt { animation: ticker-scroll 45s linear infinite; }
@keyframes ticker-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* Home */
.site-main { min-height: 80vh; }
.home { max-width: 1100px; margin: 0 auto; padding: 2.5rem 2rem; }

.posts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 2rem; }
.post-card { background: var(--surface); border-radius: 8px; overflow: hidden; border: 1px solid var(--border); transition: box-shadow 0.2s, transform 0.2s; }
.post-card:hover { box-shadow: 0 8px 30px rgba(0,0,0,0.08); transform: translateY(-2px); }
.card-image-link img { width: 100%; height: 200px; object-fit: cover; display: block; }
.card-body { padding: 1.5rem; }
.card-body h2 { font-size: 1.15rem; margin: 0.5rem 0; line-height: 1.4; }
.card-body h2 a { color: var(--text); text-decoration: none; }
.card-body h2 a:hover { color: var(--accent); }
.card-description { font-size: 0.9rem; color: var(--muted); margin-bottom: 0.75rem; }
.card-body time { font-family: var(--font-ui); font-size: 0.8rem; color: var(--muted); }

/* Tags */
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.75rem; }
.tag { background: var(--tag-bg); color: var(--accent); font-family: var(--font-ui); font-size: 0.72rem; font-weight: 600; padding: 0.2rem 0.6rem; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.05em; text-decoration: none; display: inline-block; }
.tag:hover { background: #d4e0f0; color: var(--accent); }

/* Article */
.article { padding-bottom: 4rem; }
.article-hero img { width: 100%; max-height: 480px; object-fit: cover; display: block; }
.article-hero .image-credit {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
  max-width: var(--max-width);
  margin: 0.5rem auto 0;
  padding: 0 1.5rem;
}
.article-hero .image-credit a {
  color: var(--muted);
  text-decoration: underline;
}
.article-container { max-width: var(--max-width); margin: 0 auto; padding: 2.5rem 1.5rem; }
.article-title { font-size: 2.2rem; line-height: 1.25; letter-spacing: -0.02em; margin: 1rem 0 0.75rem; }
.article-date { font-family: var(--font-ui); font-size: 0.85rem; color: var(--muted); display: block; margin-bottom: 2rem; }
.article-body { font-size: 1.05rem; line-height: 1.8; }
.article-body h2 { font-size: 1.5rem; margin: 2rem 0 0.75rem; }
.article-body h3 { font-size: 1.2rem; margin: 1.5rem 0 0.5rem; }
.article-body p { margin-bottom: 1.5rem; }
.article-body a { color: var(--accent); }
.article-body blockquote { border-left: 4px solid var(--accent); padding-left: 1.25rem; margin: 1.5rem 0; color: var(--muted); font-style: italic; }

/* Pagination */
.pagination { display: flex; justify-content: center; align-items: center; gap: 1.5rem; margin-top: 3rem; font-family: var(--font-ui); font-size: 0.9rem; }
.page-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.page-link:hover { text-decoration: underline; }
.page-info { color: var(--muted); }

/* Footer */
.site-footer { text-align: center; padding: 2rem; border-top: 1px solid var(--border); font-family: var(--font-ui); font-size: 0.85rem; color: var(--muted); }

/* Mobile */
@media (max-width: 640px) {
  html { font-size: 16px; }
  .home { padding: 1.5rem 1rem; }
  .brand-name { font-size: 1.6rem; }
  .article-title { font-size: 1.6rem; }
  .posts-grid { grid-template-columns: 1fr; }
  .site-brand { padding: 0.75rem 1rem 0.6rem; }
}

/* Share buttons */
.share-section { display: flex; align-items: center; gap: 1rem; margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border); }
.share-label { font-family: var(--font-brand); font-size: 0.75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; white-space: nowrap; }
.share-buttons { display: flex; gap: 0.45rem; flex-wrap: wrap; }
.share-btn { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; background: #111; color: #fff; text-decoration: none; border: none; cursor: pointer; transition: background 0.15s, transform 0.15s; flex-shrink: 0; }
.share-btn:hover { background: #444; transform: translateY(-2px); }
.share-btn:active { transform: translateY(0); }
.share-copy.copied { background: #1a7a4a; }

/* Category nav — fits all tabs on any screen width via fluid spacing/sizing */
.category-nav { background: var(--surface); border-bottom: 1px solid var(--border); }
.category-buttons {
  display: flex;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 clamp(0.5rem, 3vw, 2rem);
}
.category-btn {
  flex: 1 1 0;
  text-align: center;
  padding: clamp(0.55rem, 1.8vw, 0.7rem) clamp(0.15rem, 1.2vw, 1.1rem);
  text-decoration: none;
  color: var(--muted);
  font-family: var(--font-brand);
  font-weight: 600;
  font-size: clamp(0.62rem, 2.4vw, 0.82rem);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s, border-color 0.15s;
}
.category-btn:hover { color: var(--text); }
.category-btn.active { color: #000; font-weight: 700; border-bottom-color: #000; }

/* ── Dark mode ────────────────────────────────────────────────────────────── */
html.dark {
  --bg: #111111;
  --surface: #1c1c1e;
  --text: #f0f0f0;
  --muted: #8e8e93;
  --accent: #5ba3ff;
  --tag-bg: #1e2d3d;
  --border: #2c2c2e;
}

/* Smooth transition for theme switch */
body, .sticky-header, .post-card, .article-container, .site-footer,
.category-nav, .ticker-outer, .site-brand {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* Hard-coded colour overrides for dark mode */
html.dark .brand-name               { color: #fff; }
html.dark .brand-name:hover         { color: #fff; }
html.dark .tp                       { color: #aaa; }
html.dark .category-btn.active      { color: #fff; border-bottom-color: #fff; }
html.dark .card-body h2 a           { color: var(--text); }
html.dark .share-btn                { background: #2c2c2e; }
html.dark .share-btn:hover          { background: #3a3a3c; }
html.dark .post-card:hover          { box-shadow: 0 8px 30px rgba(0,0,0,0.5); }
html.dark .article-body a           { color: var(--accent); }
html.dark .article-body blockquote  { border-left-color: var(--accent); }

/* Toggle button */
.site-brand { flex-direction: row; align-items: center; justify-content: space-between; }
.brand-text { display: flex; flex-direction: column; gap: 0.1rem; }
.theme-toggle {
  background: none; border: 1px solid var(--border); cursor: pointer;
  color: var(--muted); border-radius: 50%; width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s; flex-shrink: 0;
}
.theme-toggle:hover { background: var(--tag-bg); color: var(--text); }
.icon-sun  { display: none; }
.icon-moon { display: block; }
html.dark .icon-sun  { display: block; }
html.dark .icon-moon { display: none; }

/* Likes / heart button */
.likes-wrap { display: flex; justify-content: center; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.like-btn { display: inline-flex; align-items: center; gap: 0.55rem; background: none; border: 1.5px solid var(--border); border-radius: 999px; padding: 0.55rem 1.4rem; cursor: pointer; color: var(--muted); font-family: var(--font-brand); font-size: 0.9rem; font-weight: 600; transition: border-color 0.15s, color 0.15s, background 0.15s; }
.like-btn:hover:not(.liked) { border-color: #e11d48; color: #e11d48; }
.like-btn.liked { border-color: #e11d48; color: #e11d48; background: #fff0f3; }
html.dark .like-btn.liked { background: #2d0a12; }
.heart-icon { transition: transform 0.15s; flex-shrink: 0; }
.like-btn.liked .heart-icon { fill: #e11d48; stroke: #e11d48; }
.like-btn.pulse .heart-icon { animation: heart-pulse 0.5s ease; }
@keyframes heart-pulse { 0%,100% { transform: scale(1); } 40% { transform: scale(1.45); } }

/* ── Author bylines & profiles ──────────────────────────────────────────────── */

/* Article page byline */
.author-byline { display: flex; align-items: center; gap: 0.75rem; margin: 1.25rem 0 1.75rem; text-decoration: none; width: fit-content; }
.author-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); }
.author-info { display: flex; flex-direction: column; line-height: 1.35; }
.author-name { font-family: var(--font-brand); font-weight: 700; font-size: 0.92rem; color: var(--text); }
.author-byline:hover .author-name { color: var(--accent); }
.author-title { font-family: var(--font-ui); font-size: 0.78rem; color: var(--muted); }

/* Card meta line (author + date) */
.card-meta { display: flex; align-items: center; gap: 0.4rem; font-family: var(--font-ui); font-size: 0.8rem; color: var(--muted); }
.card-author { color: var(--muted); text-decoration: none; font-weight: 600; }
.card-author:hover { color: var(--accent); }
.card-meta-sep { color: var(--border); }

/* Author profile header */
.author-header { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.6rem; padding: 2.5rem 1.5rem 2rem; max-width: 600px; margin: 0 auto; }
.author-avatar-large { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 3px solid var(--surface); box-shadow: 0 2px 12px rgba(0,0,0,0.08); margin-bottom: 0.5rem; }
.author-header h1 { font-size: 1.6rem; }
.author-title-large { font-family: var(--font-brand); font-weight: 700; color: var(--accent); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; }
.author-bio { font-family: var(--font-ui); color: var(--muted); font-size: 0.95rem; line-height: 1.65; }

/* Authors directory */
.authors-intro { text-align: center; margin-bottom: 1rem; }
.authors-intro h1 { margin-bottom: 0.5rem; }
.author-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.5rem; margin-top: 2rem; }
.author-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1.75rem 1.25rem; text-align: center; text-decoration: none; transition: box-shadow 0.2s, transform 0.2s; }
.author-card:hover { box-shadow: 0 8px 30px rgba(0,0,0,0.08); transform: translateY(-2px); }
html.dark .author-card:hover { box-shadow: 0 8px 30px rgba(0,0,0,0.5); }
.author-card img { width: 76px; height: 76px; border-radius: 50%; object-fit: cover; margin-bottom: 0.85rem; border: 1px solid var(--border); }
.author-card h3 { font-family: var(--font-brand); font-size: 1rem; color: var(--text); margin-bottom: 0.25rem; }
.author-card p { font-family: var(--font-ui); font-size: 0.8rem; color: var(--muted); }

/* ── Footer ──────────────────────────────────────────────────────────────────── */
.site-footer { border-top: 1px solid var(--border); padding: 2.5rem 2rem 1.5rem; }
.footer-inner { max-width: 1100px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); }

.footer-brand { display: flex; flex-direction: column; gap: 0.15rem; }
.footer-logo { font-family: var(--font-brand); font-weight: 900; font-size: 1.15rem; color: var(--text); letter-spacing: -0.02em; }
.footer-tagline { font-family: var(--font-ui); font-size: 0.78rem; color: var(--muted); }

.footer-links { display: flex; flex-wrap: wrap; gap: 1.5rem; }
.footer-links a { font-family: var(--font-ui); font-size: 0.85rem; color: var(--muted); text-decoration: none; transition: color 0.15s; }
.footer-links a:hover { color: var(--text); }

.footer-rss { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; background: #111; color: #fff; flex-shrink: 0; transition: background 0.15s, transform 0.15s; }
.footer-rss:hover { background: #444; transform: translateY(-2px); }
html.dark .footer-rss { background: #2c2c2e; }
html.dark .footer-rss:hover { background: #3a3a3c; }

.footer-copy { max-width: 1100px; margin: 1.25rem auto 0; font-family: var(--font-ui); font-size: 0.8rem; color: var(--muted); text-align: center; }

@media (max-width: 640px) {
  .site-footer { padding: 2rem 1.25rem 1.25rem; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 1.25rem; }
  .footer-links { gap: 1rem 1.25rem; }
}

/* ── Generic pages (About / Contact) ────────────────────────────────────────── */
.page-article {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.breadcrumb {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.page-container h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--text);
}

.page-description {
  font-size: 1.1rem;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 2rem;
  padding: 1rem;
  border-left: 4px solid var(--accent);
}

.page-content {
  line-height: 1.8;
  font-size: 1rem;
  color: var(--text);
}

.page-content h2 {
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.page-content h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 1.2rem;
}

.page-content p {
  margin-bottom: 1rem;
}

.page-content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
}

.page-content a:hover {
  opacity: 0.8;
}

.page-content ul,
.page-content ol {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.page-content li {
  margin-bottom: 0.5rem;
}

/* Contact form */
.contact-form { display: flex; flex-direction: column; gap: 1.1rem; margin-top: 1.5rem; max-width: 480px; }
.contact-form label { font-family: var(--font-brand); font-weight: 700; font-size: 0.82rem; color: var(--text); margin-bottom: 0.35rem; display: block; }
.contact-form input,
.contact-form textarea {
  width: 100%; font-family: var(--font-ui); font-size: 0.95rem; padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text);
  transition: border-color 0.15s; resize: vertical;
}
.contact-form input:focus, .contact-form textarea:focus { outline: none; border-color: var(--accent); }
.contact-form textarea { min-height: 140px; }
.contact-form button {
  font-family: var(--font-brand); font-weight: 700; font-size: 0.92rem; color: #fff; background: #111;
  border: none; border-radius: 6px; padding: 0.8rem 1.6rem; cursor: pointer; width: fit-content;
  transition: background 0.15s;
}
.contact-form button:hover { background: #333; }
.contact-form button:disabled { opacity: 0.6; cursor: not-allowed; }
html.dark .contact-form button { background: #f0f0f0; color: #111; }
html.dark .contact-form button:hover { background: #fff; }
.contact-status { font-family: var(--font-ui); font-size: 0.88rem; margin-top: 0.25rem; }
.contact-status.success { color: #16a34a; }
.contact-status.error { color: #dc2626; }

/* Related articles */
.related-section { margin-top: 2.5rem; padding-top: 2rem; border-top: 1px solid var(--border); }
.related-title { font-family: var(--font-brand); font-size: 1.1rem; font-weight: 800; margin-bottom: 1.25rem; letter-spacing: -0.01em; }
.related-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.25rem; }
.related-grid .card-body { padding: 1.1rem; }
.related-grid .card-image-link img { height: 140px; }
.related-grid h2 { font-size: 1rem; }

/* Read More link */
.read-more { display: inline-block; font-family: var(--font-brand); font-size: 0.8rem; font-weight: 700; color: var(--accent); text-decoration: none; margin-top: 0.5rem; letter-spacing: 0.01em; transition: color 0.15s; }
.read-more:hover { color: var(--text); }

/* ── Pagefind search UI ─────────────────────────────────────────────────────── */
/* Map Pagefind's CSS vars to our design tokens */
#search {
  --pagefind-ui-scale: 1;
  --pagefind-ui-primary: var(--accent);
  --pagefind-ui-text: var(--text);
  --pagefind-ui-background: var(--surface);
  --pagefind-ui-border: var(--border);
  --pagefind-ui-tag: var(--tag-bg);
  --pagefind-ui-border-width: 1.5px;
  --pagefind-ui-border-radius: 6px;
  --pagefind-ui-image-border-radius: 4px;
  --pagefind-ui-font: var(--font-brand);
}
.search-page { padding-top: 2rem; }
.search-page h1 { margin-bottom: 1.5rem; }
.pagefind-ui__search-input { font-size: 1rem !important; }
.pagefind-ui__result-title { font-family: var(--font-brand) !important; font-weight: 700; }
.pagefind-ui__result-excerpt { font-family: var(--font-serif) !important; color: var(--muted); }

/* Dark mode overrides for Pagefind */
html.dark #search {
  --pagefind-ui-primary: var(--accent);
  --pagefind-ui-text: var(--text);
  --pagefind-ui-background: var(--surface);
  --pagefind-ui-border: var(--border);
}
html.dark .pagefind-ui__search-input { color: #fff !important; }
html.dark .pagefind-ui__search-input::placeholder { color: var(--muted) !important; }

/* Search icon in header */
.header-actions { display: flex; align-items: center; gap: 0.5rem; }
.search-btn { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); color: var(--muted); text-decoration: none; transition: background 0.15s, color 0.15s; }
.search-btn:hover { background: var(--tag-bg); color: var(--text); }

/* ── Investopedia YouTube embed ────────────────────────────────────────────── */
.video-embed { margin: 2rem 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.video-label { margin: 0; padding: 0.75rem 1rem 0.5rem; font-family: var(--font-brand); font-size: 0.85rem; color: var(--muted); }
.video-embed iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: none; }

.author-credentials { font-family: var(--font-ui); font-size: 0.72rem; color: var(--muted); letter-spacing: 0.02em; }


.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
  gap: 1rem;
}

.read-time {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.5rem;
  background: var(--bg-secondary);
  border-radius: 4px;
}

.read-more {
  margin-left: auto;
}


.hero-card {
  grid-column: span 2;
}

.hero-card .card-image-link {
  position: relative;
  display: block;
}

.hero-badge {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  z-index: 10;
  backdrop-filter: blur(4px);
}

.hero-card .card-body {
  padding: 2rem;
}

.hero-card h2 {
  font-size: 1.75rem;
}

@media (max-width: 768px) {
  .hero-card {
    grid-column: span 1;
  }
}