/* === NewsPulse — Config-driven Editorial Design === */

:root {
  --bg: #ffffff;
  --bg-secondary: #fafafa;
  --text: #111111;
  --text-secondary: #555555;
  --text-tertiary: #999999;
  --border: #e5e5e5;
  /* --accent and level colors injected via <style> in base.html from config */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: Georgia, 'Times New Roman', serif;
  --font-mono: 'SF Mono', 'Fira Code', Consolas, monospace;
  --max-width: 1100px;
  --radius: 4px;
}

[data-theme="dark"] {
  --bg: #111111;
  --bg-secondary: #1a1a1a;
  --text: #eeeeee;
  --text-secondary: #aaaaaa;
  --text-tertiary: #666666;
  --border: #2a2a2a;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

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

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-mark {
  width: 24px;
  height: 16px;
  color: var(--accent);
}

.header-tagline {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.75rem;
}

.header-tagline-text { font-weight: 400; }
.header-tagline-meta { font-size: 0.625rem; color: var(--text-tertiary); }

.nav { display: flex; align-items: center; gap: 0.25rem; }

.nav a {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius);
  transition: color 0.15s;
}

.nav a:hover { color: var(--text); }
.nav a.active { color: var(--text); font-weight: 600; }

/* Search bar */
.search-bar {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.search-bar-form {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search-bar-icon { color: var(--text-tertiary); flex-shrink: 0; }

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

.search-bar-input::placeholder { color: var(--text-tertiary); }

.theme-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.875rem;
  margin-left: 0.5rem;
  transition: border-color 0.15s;
}

.theme-btn:hover { border-color: var(--text-secondary); }

/* Feed */
.feed {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem;
}

.scroll-sentinel { height: 1px; }

.feed-columns {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) { .feed-columns { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .feed-columns { grid-template-columns: 1fr; } }

.feed-column { display: flex; flex-direction: column; }

.column-header {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
  color: var(--text-tertiary);
}

.column-header--essentials { border-bottom-color: var(--essentials, #16a34a); color: var(--essentials, #16a34a); }
.column-header--technical { border-bottom-color: var(--technical, #2563eb); color: var(--technical, #2563eb); }
.column-header--deep-dives { border-bottom-color: var(--deep-dives, #7c3aed); color: var(--deep-dives, #7c3aed); }

/* Card */
.card {
  background: var(--bg);
  padding: 1rem 1.25rem;
  display: inline-flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  break-inside: avoid;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: background 0.15s, box-shadow 0.2s ease;
  text-decoration: none;
  color: inherit;
  position: relative;
}

/* Card spacing within columns */
.feed-column .card { margin-bottom: 1rem; }

.card:hover {
  background: var(--bg-secondary);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

[data-theme="dark"] .card:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

/* Dismiss button */
.card-dismiss {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 24px;
  height: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-tertiary);
  font-size: 0.75rem;
  cursor: pointer;
  z-index: 2;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  transition: color 0.15s, background 0.15s;
}

.card:hover .card-dismiss { display: flex; }
.card-dismiss:hover { color: var(--text); background: var(--bg-secondary); }

.card.dismissing {
  opacity: 0;
  transform: scale(0.8);
  max-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  overflow: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease, max-height 0.4s 0.15s ease, padding 0.4s 0.15s ease, margin 0.4s 0.15s ease, border 0.4s 0.15s ease;
}

/* First-visit tagline */
.header-tagline.hidden { display: none; }

.card-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.level-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Level dots — uses CSS variables from config */
.level-dot--essentials { background: var(--essentials, #16a34a); }
.level-dot--technical { background: var(--technical, #2563eb); }
.level-dot--deep-dives { background: var(--deep-dives, #7c3aed); }
.level-dot--beginner { background: var(--beginner, #16a34a); }
.level-dot--intermediate { background: var(--intermediate, #2563eb); }
.level-dot--advanced { background: var(--advanced, #7c3aed); }
.level-dot--news { background: var(--news, #0066cc); }
.level-dot--analysis { background: var(--analysis, #7c3aed); }
.level-dot--tutorial { background: var(--tutorial, #16a34a); }

.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--text);
}

.card-summary {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-thumb {
  width: 100%;
  object-fit: cover;
  border-radius: 4px;
  margin-top: 0.375rem;
}

/* Vary image sizes for visual rhythm */
.card:nth-child(5n+1) .card-thumb { aspect-ratio: 16/9; }
.card:nth-child(5n+2) .card-thumb { aspect-ratio: 4/3; }
.card:nth-child(5n+3) .card-thumb { aspect-ratio: 3/2; }
.card:nth-child(5n+4) .card-thumb { aspect-ratio: 1/1; max-height: 180px; }
.card:nth-child(5n+5) .card-thumb { aspect-ratio: 2/1; }

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.6875rem;
  color: var(--text-tertiary);
}

.card.hidden { display: none; }

.card.is-read {
  opacity: 0.55;
}

.card.is-read .card-title {
  color: var(--text-tertiary);
}

.card.is-read .card-thumb {
  filter: grayscale(40%);
}

.card.is-read:hover {
  opacity: 0.8;
}

.card.is-read:hover .card-title {
  color: var(--text);
}

.card.is-read:hover .card-thumb {
  filter: grayscale(0%);
}

/* Search */
.search-form { margin-bottom: 1rem; }
.search-input {
  width: 100%;
  padding: 0.625rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--accent); }
.search-header { margin-bottom: 1rem; }
.feed-count {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  display: block;
  margin-top: 0.5rem;
}

/* Newsletter */
.newsletter {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--border);
}

.newsletter-text {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.newsletter-text strong {
  color: var(--text);
  font-weight: 600;
}

.newsletter-form {
  display: flex;
  gap: 0.375rem;
}

.newsletter-input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.8125rem;
  font-family: var(--font);
  width: 220px;
  outline: none;
  transition: border-color 0.15s;
}

.newsletter-input:focus { border-color: var(--accent); }

.newsletter-submit {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s;
}

.newsletter-submit:hover { opacity: 0.8; }

.newsletter-msg {
  font-size: 0.75rem;
  margin-left: 0.5rem;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  text-align: center;
  font-size: 0.6875rem;
  color: var(--text-tertiary);
}

.footer a { color: var(--text-secondary); transition: color 0.15s; }
.footer a:hover { color: var(--text); }

/* Article page */
.article-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.article-page .breadcrumb {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-bottom: 1.5rem;
}

.article-page .breadcrumb a { color: var(--text-secondary); }
.article-page .breadcrumb a:hover { color: var(--accent); }

.article-page h1 {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.025em;
  margin-bottom: 0.75rem;
}

.article-page .article-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.article-page .article-meta a { color: var(--accent); }

.article-page .article-hero {
  width: 100%;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  max-height: 360px;
  object-fit: cover;
}

.ai-disclosure {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  padding: 0.75rem 0;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  font-style: italic;
}

.ai-disclosure a { color: var(--accent); }

.article-body {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--text);
}

.article-body p { margin-bottom: 1.25rem; }
.article-body a { color: var(--accent); text-decoration: underline; }

.article-body h2, .article-body h3, .article-body h4 {
  font-family: var(--font);
  font-weight: 700;
  line-height: 1.3;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  letter-spacing: -0.015em;
}

.article-body h2 { font-size: 1.375rem; }
.article-body h3 { font-size: 1.125rem; }
.article-body h4 { font-size: 1rem; }

.article-body code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-secondary);
  padding: 0.15em 0.3em;
  border-radius: 2px;
}

.article-body pre {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
}

.article-body pre code { background: none; padding: 0; font-size: 0.875rem; }

.article-body ul, .article-body ol {
  padding-left: 1.5rem;
  margin-bottom: 1.25rem;
}

.article-body li { margin-bottom: 0.375rem; }

.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1.25rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 1.25rem;
}

/* Article actions */
.article-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.share-label {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

.share-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: transparent;
  transition: all 0.15s;
  text-decoration: none;
  font-family: var(--font);
  line-height: 1;
}

.share-btn:hover { border-color: var(--text); color: var(--text); }

.btn-text {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
  text-decoration: none;
}

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

/* Related articles */
.related { padding-top: 2rem; border-top: 1px solid var(--border); }
.related h3 { font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-tertiary); margin-bottom: 1rem; font-weight: 600; }
.related-cards { display: flex; flex-direction: column; gap: 1rem; }
.related-card { display: flex; gap: 1rem; align-items: center; text-decoration: none; color: inherit; padding: 0.75rem; border-radius: var(--radius); transition: background 0.15s; }
.related-card:hover { background: var(--bg-secondary); }
.related-img { width: 80px; height: 56px; object-fit: cover; border-radius: var(--radius); flex-shrink: 0; }
.related-info { flex: 1; min-width: 0; }
.related-title { font-size: 0.875rem; font-weight: 600; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.35; }
.related-meta { font-size: 0.6875rem; color: var(--text-tertiary); display: block; margin-top: 0.25rem; }

/* New-since-last-visit banner */
.new-since { font-size: 0.75rem; font-weight: 600; color: var(--accent); padding: 0.625rem 1.25rem; margin-bottom: 0.5rem; border-bottom: 1px solid var(--border); }

/* Reading progress bar */
.reading-progress { position: fixed; top: 52px; left: 0; height: 2px; background: var(--accent); width: 0%; z-index: 99; transition: width 0.1s linear; }

/* Save button saved state */
.save-article-btn.saved { color: #f59e0b; border-color: #f59e0b; }

/* Visit streak badge */
.streak-badge { font-size: 0.6875rem; font-weight: 600; color: #f59e0b; margin-left: 0.5rem; }

/* 404 page */
.page-404 {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 6rem 1.5rem;
  text-align: center;
}

.page-404 h1 { font-size: 4rem; font-weight: 800; color: var(--text-tertiary); }
.page-404 p { color: var(--text-secondary); margin: 1rem 0 2rem; }

/* Responsive */
@media (max-width: 600px) {
  .header-inner { padding: 0 1rem; }
  .feed { padding: 1rem; }
  .article-page { padding: 1.5rem 1rem; }
  .article-page h1 { font-size: 1.375rem; }
  .newsletter { flex-direction: column; align-items: flex-start; }
  .newsletter-input { width: 100%; }
}


/* Header shadow on scroll */
.header.scrolled {
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}

[data-theme="dark"] .header.scrolled {
  box-shadow: 0 1px 8px rgba(0,0,0,0.3);
}
