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

:root {
  --bg: #fafaf8;
  --bg-card: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #6b6b6b;
  --accent: #2d5016;
  --accent-light: #e8f0e2;
  --border: #e5e5e3;
  --max-width: 680px;
  --font-serif: 'Frank Ruhl Libre', 'Georgia', 'Times New Roman', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg: #111111;
  --bg-card: #1a1a1a;
  --text: #e5e5e3;
  --text-secondary: #8a8a8a;
  --accent: #7cb663;
  --accent-light: #1e2e16;
  --border: #2a2a2a;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 17px;
  transition: background var(--transition), color var(--transition);
  min-height: 100vh;
}

/* === Typography === */
h1, h2, h3 { font-family: var(--font-serif); font-weight: 700; line-height: 1.3; }
h1 { font-size: 2.4rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.6rem; margin-bottom: 0.4rem; }
h3 { font-size: 1.25rem; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity var(--transition);
}
a:hover { opacity: 0.75; }

/* === RTL Support === */
[dir="rtl"] { text-align: right; }
[dir="ltr"] { text-align: left; }

/* === Layout === */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* === Header === */
header {
  padding: 40px 0 0;
  margin-bottom: 48px;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  letter-spacing: -0.01em;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.lang-toggle, .theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.8rem;
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
}

.lang-toggle:hover, .theme-toggle:hover {
  border-color: var(--text-secondary);
  color: var(--text);
}

/* === Navigation === */
nav {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 32px;
}

nav a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  padding-bottom: 2px;
  position: relative;
}

nav a.active {
  color: var(--text);
}

nav a.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

/* === Sections === */
.section { display: none; }
.section.active { display: block; }

/* === Home === */
.hero {
  padding: 48px 0 64px;
}

.hero-tagline {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}

.hero-description {
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.8;
  max-width: 560px;
}

.topics {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.topics-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-weight: 600;
}

.topics-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.topic-tag {
  font-size: 0.85rem;
  padding: 6px 16px;
  border-radius: 20px;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 500;
}

/* === Thoughts Feed (Twitter-style) === */
.thoughts-feed {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.tweet {
  padding: 16px;
  border: 1px solid var(--border);
  border-bottom: none;
  background: var(--bg-card);
  transition: background var(--transition);
}

.tweet:first-child {
  border-radius: 12px 12px 0 0;
}

.tweet:last-child {
  border-bottom: 1px solid var(--border);
  border-radius: 0 0 12px 12px;
}

.tweet:only-child {
  border-bottom: 1px solid var(--border);
  border-radius: 12px;
}

.tweet:hover {
  background: color-mix(in srgb, var(--bg-card) 90%, var(--text) 10%);
}

.tweet-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.tweet-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 1rem;
  font-family: var(--font-serif);
  flex-shrink: 0;
}

.tweet-author-info {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.tweet-author {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.2;
}

.tweet-handle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.2;
}

.tweet-body {
  font-size: 1rem;
  line-height: 1.65;
  margin-bottom: 12px;
  padding-inline-start: 50px;
}

.tweet-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-inline-start: 50px;
}

.tweet-date {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.tweet-tag {
  font-size: 0.7rem;
  padding: 2px 10px;
  border-radius: 12px;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.tweet-dot {
  color: var(--text-secondary);
  font-size: 0.6rem;
}

/* === Home section titles === */
.home-section-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.home-more-link {
  display: inline-block;
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 500;
}

/* === Charts === */
.chart-container {
  margin: 32px 0;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.chart-title {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
}

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bar-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  min-width: 50px;
  text-align: end;
  flex-shrink: 0;
}

.bar-track {
  flex: 1;
  height: 28px;
  background: color-mix(in srgb, var(--border) 50%, transparent);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 8px;
  transition: width 0.8s ease;
  min-width: fit-content;
}

.bar-value {
  font-size: 0.72rem;
  font-weight: 600;
  color: white;
  white-space: nowrap;
}

.bar-fill.narrow .bar-value {
  color: var(--text);
  position: absolute;
  right: -8px;
  transform: translateX(100%);
}

.chart-source {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 12px;
  text-align: center;
  font-style: italic;
}

/* === Articles List === */
.articles-list {
  display: flex;
  flex-direction: column;
}

.article-item {
  padding: 28px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: opacity var(--transition);
}

.article-item:first-child {
  padding-top: 0;
}

.article-item:hover { opacity: 0.7; }

.article-date {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.article-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

.article-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* === Article View === */
.article-view {
  padding-bottom: 80px;
}

.article-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.article-back:hover { color: var(--text); }

.article-header {
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.article-header h1 {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.article-header .subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.article-header .meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.article-body {
  font-size: 1.05rem;
  line-height: 1.85;
}

.article-body h1 { font-size: 1.8rem; margin: 48px 0 16px; }
.article-body h2 { font-size: 1.4rem; margin: 40px 0 12px; }
.article-body h3 { font-size: 1.15rem; margin: 32px 0 10px; }
.article-body p { margin-bottom: 20px; }
.article-body ul, .article-body ol { margin-bottom: 20px; padding-inline-start: 24px; }
.article-body li { margin-bottom: 6px; }
.article-body strong { font-weight: 600; }
.article-body em { font-style: italic; }
.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}
.article-body blockquote {
  border-inline-start: 3px solid var(--accent);
  padding-inline-start: 20px;
  color: var(--text-secondary);
  margin: 24px 0;
  font-style: italic;
}
.article-body code {
  background: var(--accent-light);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* === Footer === */
footer {
  padding: 48px 0 40px;
  border-top: 1px solid var(--border);
  margin-top: 64px;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 64px 0;
  color: var(--text-secondary);
}

/* === Filter === */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.filter-btn {
  font-size: 0.8rem;
  padding: 5px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
}

.filter-btn:hover { border-color: var(--text-secondary); }
.filter-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* === Responsive === */
@media (max-width: 600px) {
  body { font-size: 16px; }
  h1 { font-size: 1.8rem; }
  .hero-tagline { font-size: 1.5rem; }
  header { padding-top: 24px; margin-bottom: 32px; }
  nav { gap: 24px; }
  .container { padding: 0 20px; }
  .tweet-body { padding-inline-start: 0; }
  .tweet-footer { padding-inline-start: 0; }
  .bar-label { min-width: 40px; font-size: 0.7rem; }
  .chart-container { padding: 14px; }
  .bar-value { font-size: 0.65rem; }
}

/* === Fonts === */
@import url('https://fonts.googleapis.com/css2?family=Frank+Ruhl+Libre:wght@400;700&family=Inter:wght@400;500;600&display=swap');
