/* ============================================================
   DESIGN TOKENS
   ============================================================ */

:root {
  /* Colors */
  --ink:          #0f172a;
  --paper:        #ffffff;
  --surface:      #f8fafc;
  --accent:       #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: #818cf8;
  --accent-glow:  rgba(99, 102, 241, .12);
  --muted:        #64748b;
  --border:       #e2e8f0;
  --border-hover: #cbd5e1;

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

  /* Layout */
  --max-w:     1200px;
  --content-w: 720px;

  /* Shape */
  --radius:    12px;
  --radius-lg: 20px;
}


/* ============================================================
   RESET & BASE
   ============================================================ */

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--surface);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  color: var(--accent-hover);
}


/* ============================================================
   COMPONENTS
   ============================================================ */

/* — Topbar -------------------------------------------------- */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60px;
  background: rgba(255, 255, 255, .8);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: box-shadow .3s;
}

.topbar.scrolled {
  box-shadow: 0 1px 12px rgba(0, 0, 0, .06);
}

.topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: var(--max-w);
  padding: 0 2rem;
}

.topbar-inner > a {
  display: flex;
  align-items: center;
}

.topbar-inner > a img {
  height: 32px;
  width: auto;
}

.topbar-inner nav {
  display: flex;
  align-items: center;
  gap: .25rem;
}

.topbar a {
  padding: .4rem .75rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 500;
  text-decoration: none;
  transition: color .2s;
}

.topbar a:hover {
  color: var(--ink);
  background: var(--accent-glow);
}


/* — Masthead ----------------------------------------------- */

.masthead {
  position: relative;
  overflow: hidden;
  margin-top: 60px;
  padding: 5rem 2rem 4rem;
  background: var(--paper);
  text-align: center;
}

.masthead::before {
  content: '';
  position: absolute;
  top: -50%;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
}

.masthead-label {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
  padding: .35rem 1rem;
  border-radius: 100px;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.masthead h1 {
  position: relative;
  margin-bottom: 1rem;
  line-height: 1;
  cursor: pointer;
}

.masthead h1 img {
  max-width: clamp(240px, 40vw, 420px);
  height: auto;
}

.masthead-tagline {
  max-width: 540px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 400;
  line-height: 1.6;
}

.masthead-rule {
  display: none;
}


/* — Hero ---------------------------------------------------- */

.hero {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
}

.hero-text h2 {
  margin-bottom: 1rem;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.02em;
}

.hero-text p {
  margin-bottom: 2rem;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.7;
}

.hero-tabs {
  margin-top: 2rem;
}

.tab-nav {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.5rem;
}

.tab-btn {
  padding: .4rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}

.tab-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tab-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.hero-chart {
  position: relative;
  height: 260px;
  margin-bottom: 1.75rem;
}

.hero-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
}

@media (max-width: 768px) {
  .hero-chart {
    height: 200px;
  }

  .hero-stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat-card {
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  transition: all .25s;
}

.stat-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.stat-card .num {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.03em;
  background: linear-gradient(135deg, var(--ink), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card .label {
  margin-top: .35rem;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
}


/* — Sections ------------------------------------------------ */

.section {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 0;
  border: none;
}

.section-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.section-header .tag {
  padding: 4px 10px;
  border-radius: 100px;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}


/* — Search bar ---------------------------------------------- */

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1.5rem;
  padding: .5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--paper);
  transition: border-color .2s, box-shadow .2s;
}

.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  fill: var(--muted);
}

.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: .9rem;
}

.search-bar input::placeholder {
  color: var(--muted);
  opacity: .7;
}

.search-clear {
  padding: 0 .25rem;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: color .2s;
}

.search-clear:hover {
  color: var(--ink);
}

.search-btn {
  padding: .45rem 1.1rem;
  border: none;
  border-radius: 100px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-body);
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background .2s;
}

.search-btn:hover {
  background: var(--accent-hover);
}


/* — Articles grid ------------------------------------------- */

.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.loading {
  padding: 3rem;
  color: var(--muted);
  text-align: center;
}

.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  grid-column: 1 / -1;
  min-height: 120px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: .85rem;
}


/* — Article card -------------------------------------------- */

.article-card {
  position: relative;
  display: block;
  overflow: hidden;
  padding: 1.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: all .3s cubic-bezier(.4, 0, .2, 1);
}

.article-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 12px 40px var(--accent-glow);
}

.article-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .4s cubic-bezier(.4, 0, .2, 1);
}

.article-card:hover::before {
  transform: scaleX(1);
}

.article-card .date {
  margin-bottom: .75rem;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.article-card h3 {
  margin-bottom: .5rem;
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.01em;
}

.article-card p {
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.6;
}

.article-card .card-tag {
  display: inline-block;
  margin-top: 1rem;
  padding: 3px 10px;
  border: none;
  border-radius: 100px;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: .6rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}


/* — Pagination ---------------------------------------------- */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 2rem;
}

.pagination button {
  padding: .5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}

.pagination button:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent);
}

.pagination button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.pagination button:disabled {
  border-color: var(--border);
  background: var(--paper);
  color: var(--muted);
  opacity: .4;
  cursor: default;
}


/* — About band ---------------------------------------------- */

.about-band {
  position: relative;
  overflow: hidden;
  margin-top: 2rem;
  padding: 5rem 2rem;
  background: var(--ink);
  color: var(--paper);
}

.about-band::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(99, 102, 241, .15) 0%, transparent 70%);
  pointer-events: none;
}

.about-inner {
  position: relative;
  max-width: var(--content-w);
  margin: 0 auto;
}

.about-inner h2 {
  margin-bottom: 1.5rem;
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -.03em;
}

.about-inner p {
  margin-bottom: 1rem;
  color: #94a3b8;
  font-size: .95rem;
  line-height: 1.7;
}

.about-inner a {
  color: var(--accent-light);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(129, 140, 248, .4);
}

.about-inner a:hover {
  text-decoration-color: var(--accent-light);
}

.sources-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  column-gap: 2.5rem;
  margin-top: 1.75rem;
}

@media (max-width: 768px) {
  .sources-grid {
    grid-template-columns: 1fr;
  }
}

.source-row {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding: .65rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  color: inherit;
  text-decoration: none;
  transition: border-color .2s;
}

.source-row:hover .source-name {
  color: var(--accent-light);
}

.source-name {
  color: var(--paper);
  font-size: .85rem;
  font-weight: 600;
}

.source-desc {
  color: #94a3b8;
  font-size: .75rem;
  line-height: 1.45;
}


/* — Footer -------------------------------------------------- */

footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2.5rem 2rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .8rem;
}

footer a {
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
}

footer a:hover {
  color: var(--accent);
}

footer .disclaimer {
  width: 100%;
  margin-top: .5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.6;
  opacity: .75;
}


/* — Article view -------------------------------------------- */

.article-view {
  display: none;
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 3rem 2rem 5rem;
}

.article-view .back {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin-bottom: 2rem;
  padding: .4rem .75rem;
  border-radius: 8px;
  color: var(--accent);
  font-size: .8rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .2s;
}

.article-view .back:hover {
  background: var(--accent-glow);
}

.article-view .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.article-view .rendered h1 {
  margin-bottom: .75rem;
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.03em;
}

.article-view .rendered h2 {
  margin: 2.5rem 0 1rem;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.02em;
}

.article-view .rendered h3 {
  margin: 2rem 0 .75rem;
  font-size: 1.15rem;
  font-weight: 700;
}

.article-view .rendered p {
  margin-bottom: 1rem;
  font-size: 1rem;
  line-height: 1.75;
}

.article-view .rendered ul,
.article-view .rendered ol {
  margin: 0 0 1rem 1.5rem;
}

.article-view .rendered li {
  margin-bottom: .5rem;
  font-size: .95rem;
}

.article-view .rendered blockquote {
  margin: 1.5rem 0;
  padding: .75rem 1.25rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--accent-glow);
  color: var(--muted);
}

.article-view .rendered table {
  width: 100%;
  margin: 1.5rem 0;
  border-collapse: collapse;
  font-size: .85rem;
}

.article-view .rendered th {
  padding: .5rem .75rem;
  border-bottom: 2px solid var(--ink);
  color: var(--muted);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-align: left;
  text-transform: uppercase;
}

.article-view .rendered td {
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--border);
}

.article-view .rendered code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--accent-glow);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: .85em;
}

.article-view .rendered pre {
  overflow-x: auto;
  margin: 1.5rem 0;
  padding: 1.5rem;
  border-radius: var(--radius);
  background: var(--ink);
  color: #94a3b8;
  font-size: .8rem;
  line-height: 1.7;
}

.article-view .rendered pre code {
  padding: 0;
  background: none;
  color: inherit;
}

.article-view .rendered hr {
  margin: 2rem 0;
  border: none;
  border-top: 1px solid var(--border);
}

.article-view .rendered img {
  max-width: 100%;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.article-view .rendered strong {
  font-weight: 700;
}


/* — Podcast player ------------------------------------------ */

.podcast-player {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 2rem;
  padding: .75rem 1.25rem;
  border: 1px solid rgba(99, 102, 241, .2);
  border-radius: 100px;
  background: var(--accent-glow);
}

.podcast-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background .2s, transform .15s;
}

.podcast-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.podcast-btn:active {
  transform: scale(.95);
}

.podcast-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.podcast-btn.playing {
  background: var(--accent-hover);
}

.podcast-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.podcast-label {
  color: var(--ink);
  font-size: .8rem;
  font-weight: 600;
}

.podcast-status {
  color: var(--muted);
  font-size: .7rem;
}

.podcast-progress {
  flex: 1;
  overflow: hidden;
  min-width: 80px;
  height: 4px;
  border-radius: 100px;
  background: rgba(99, 102, 241, .15);
}

.podcast-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: 100px;
  background: var(--accent);
  transition: width .3s;
}

.podcast-voice-row {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.podcast-voice-label {
  font-size: .7rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.podcast-voice-select {
  font-family: var(--font-body);
  font-size: .7rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: .2rem .65rem;
  cursor: pointer;
  max-width: 200px;
  outline: none;
  transition: border-color .2s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2364748b' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .55rem center;
  padding-right: 1.6rem;
}

.podcast-voice-select:hover,
.podcast-voice-select:focus {
  border-color: var(--accent);
}


/* ============================================================
   ANIMATIONS & UTILITIES
   ============================================================ */

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeUp .6s cubic-bezier(.4, 0, .2, 1) both;
}
