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

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;

  /* Light theme */
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-card: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #555770;
  --text-muted: #8888a0;
  --border: #e2e4e9;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --tag-bg: #f0f4ff;
  --tag-text: #2563eb;
  --code-bg: #f4f4f8;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.1);
  --radius: 8px;
  --radius-lg: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #1e1e32;
    --text: #e8e8f0;
    --text-secondary: #a0a0b8;
    --text-muted: #6e6e88;
    --border: #2a2a40;
    --accent: #60a5fa;
    --accent-hover: #93c5fd;
    --accent-light: #1e293b;
    --tag-bg: #1e293b;
    --tag-text: #60a5fa;
    --code-bg: #1a1a2e;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
  }
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

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

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ===== HEADER ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.9);
}

@media (prefers-color-scheme: dark) {
  .site-header {
    background: rgba(15,15,26,0.9);
  }
}

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

.site-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.site-logo:hover {
  color: var(--accent);
}

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

.site-nav a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--accent);
}

.header-search {
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  padding: 0.4rem;
  border-radius: var(--radius);
  transition: color 0.2s;
}

.header-search:hover {
  color: var(--accent);
}

.lang-switcher {
  position: relative;
  display: flex;
  align-items: center;
}

.lang-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  transition: color 0.2s;
}

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

.lang-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-width: 120px;
  z-index: 200;
  padding: 0.25rem 0;
}

.lang-dropdown.open {
  display: block;
}

.lang-dropdown a {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.15s;
}

.lang-dropdown a:hover {
  background: var(--bg-secondary);
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0.5rem;
  min-width: 44px;
  min-height: 44px;
  touch-action: manipulation;
}

.mobile-menu-btn svg {
  width: 24px;
  height: 24px;
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: block;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 1rem 1.5rem;
    gap: 0.25rem;
    box-shadow: var(--shadow-md);
  }

  .site-nav.open {
    display: flex;
  }

  .site-nav a {
    padding: 0.75rem 0;
    font-size: 1rem;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* ===== MAIN CONTENT ===== */
main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
}

/* ===== BREADCRUMBS ===== */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.breadcrumbs a {
  color: var(--text-secondary);
}

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

.breadcrumbs .separator {
  color: var(--text-muted);
  user-select: none;
}

.breadcrumbs .current {
  color: var(--text);
}

/* ===== HERO / PAGE HEADER ===== */
.page-hero {
  text-align: center;
  padding: 3rem 0 2rem;
}

.page-hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

.page-hero p {
  color: var(--text-secondary);
  font-size: 1.125rem;
  max-width: 600px;
  margin: 0 auto;
}

@media (max-width: 480px) {
  .page-hero {
    padding: 2rem 0 1.5rem;
  }

  .page-hero h1 {
    font-size: 1.75rem;
  }

  .page-hero p {
    font-size: 1rem;
  }
}

/* ===== ARTICLE CARDS GRID ===== */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

@media (max-width: 480px) {
  .articles-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

.article-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: box-shadow 0.2s, transform 0.2s;
  display: flex;
  flex-direction: column;
}

.article-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.article-card .card-category {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tag-text);
  background: var(--tag-bg);
  padding: 0.25rem 0.75rem;
  border-radius: 100px;
  margin-bottom: 0.75rem;
  align-self: flex-start;
}

.article-card h2 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}

.article-card h2 a {
  color: var(--text);
}

.article-card h2 a:hover {
  color: var(--accent);
}

.article-card .card-excerpt {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 1rem;
  flex: 1;
}

.article-card .card-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  flex-wrap: wrap;
}

/* ===== AUTHOR AVATARS ===== */
.author-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.author-avatar-lg {
  width: 36px;
  height: 36px;
}

.author-link {
  color: var(--text-muted);
  text-decoration: none;
}

.author-link:hover {
  color: var(--accent);
}

/* ===== FEATURED SECTION ===== */
.featured-section {
  margin-bottom: 2.5rem;
}

.featured-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

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

.featured-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.featured-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.featured-card .card-category {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tag-text);
  background: var(--tag-bg);
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  margin-bottom: 0.75rem;
  align-self: flex-start;
}

.featured-card h2 {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}

.featured-card h2 a {
  color: var(--text);
}

.featured-card h2 a:hover {
  color: var(--accent);
}

.featured-card .card-excerpt {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
  margin-bottom: 1rem;
  flex-grow: 1;
}

.featured-card .card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

/* ===== CATEGORY NAV ===== */
.category-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.category-nav a {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 0.4rem 1rem;
  border-radius: 100px;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.category-nav a:hover,
.category-nav a.active {
  color: var(--tag-text);
  background: var(--tag-bg);
  border-color: var(--accent);
}

/* ===== ARTICLE PAGE ===== */
.article-header {
  max-width: 720px;
  margin: 0 auto 2rem;
  text-align: center;
}

.article-header .card-category {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tag-text);
  background: var(--tag-bg);
  padding: 0.25rem 0.75rem;
  border-radius: 100px;
  margin-bottom: 1rem;
}

.article-header h1 {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
}

.article-header .article-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  flex-wrap: wrap;
}

@media (max-width: 480px) {
  .article-header h1 {
    font-size: 1.6rem;
  }

  .article-header .article-meta {
    gap: 0.75rem;
    font-size: 0.8rem;
  }

  .article-content h2 {
    font-size: 1.35rem;
  }

  .article-content h3 {
    font-size: 1.15rem;
  }

  .article-content p,
  .article-content ul,
  .article-content ol {
    font-size: 1rem;
  }

  .article-content pre {
    font-size: 0.8rem;
    padding: 1rem;
  }
}

.article-header .article-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.article-header .article-tags a.article-tag {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}

.article-header .article-tags a.article-tag:hover {
  background: var(--tag-bg);
  color: var(--tag-text);
}

/* ===== ARTICLE CONTENT ===== */
.article-content {
  max-width: 720px;
  margin: 0 auto;
}

.article-content p {
  margin-bottom: 1.5rem;
  font-size: 1.0625rem;
  line-height: 1.8;
}

.article-content h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.article-content h3 {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  letter-spacing: -0.01em;
}

.article-content h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}

.article-content ul,
.article-content ol {
  margin: 0 0 1.5rem 1.5rem;
  font-size: 1.0625rem;
  line-height: 1.8;
}

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

.article-content blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-secondary);
  font-style: italic;
}

.article-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.875rem;
  line-height: 1.6;
}

.article-content code {
  font-family: var(--font-mono);
}

.article-content p code {
  background: var(--code-bg);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.9em;
}

.article-content a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ===== SECTION LABEL ===== */
.section-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ===== FOOTER ===== */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  margin-top: auto;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 1.5rem 2rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

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

.footer-heading {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.footer-grid p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
}

.footer-grid ul {
  list-style: none;
}

.footer-grid ul li {
  margin-bottom: 0.4rem;
}

.footer-grid ul a {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

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

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ===== 404 PAGE ===== */
.not-found {
  text-align: center;
  padding: 5rem 1.5rem;
}

.not-found h1 {
  font-size: 6rem;
  font-weight: 800;
  color: var(--border);
  line-height: 1;
}

.not-found h2 {
  font-size: 1.5rem;
  margin: 1rem 0;
}

.not-found p {
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.not-found a {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 600;
  transition: background 0.2s;
}

.not-found a:hover {
  background: var(--accent-hover);
  color: #fff;
}

/* ===== MOBILE FOOTER ===== */
@media (max-width: 480px) {
  .footer-inner {
    padding: 2rem 1rem 1.5rem;
  }
}

/* ===== SKIP LINK ===== */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  z-index: 200;
  font-weight: 600;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0.5rem;
  color: #fff;
}

/* ===== READING PROGRESS ===== */
.reading-progress {
  position: fixed;
  top: 64px;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--accent);
  z-index: 99;
  pointer-events: none;
}

/* ===== SHARE BUTTONS ===== */
.share-buttons {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 720px;
  margin: 2.5rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.share-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 0.25rem;
}

.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.share-btn:hover {
  color: #fff;
  border-color: transparent;
}

.share-twitter:hover { background: #000; }
.share-linkedin:hover { background: #0a66c2; }
.share-hn:hover { background: #ff6600; }

/* ===== RELATED ARTICLES ===== */
.related-articles {
  margin: 3rem 0 0;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.pagination a,
.pagination span {
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
}

.pagination a {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text);
  transition: border-color 0.2s, color 0.2s;
}

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

.pagination .current-page {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}

/* ===== SEARCH ===== */
.search-box {
  max-width: 500px;
  margin: 1.5rem auto 0;
}

.search-box input {
  width: 100%;
  padding: 0.875rem 1.25rem;
  font-size: 1rem;
  font-family: var(--font-sans);
  background: var(--bg-card);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  outline: none;
  transition: border-color 0.2s;
}

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

.search-box input::placeholder {
  color: var(--text-muted);
}

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

/* ===== UTILITIES ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ===== PRINT ===== */
@media print {
  .site-header,
  .site-footer,
  .breadcrumbs,
  .article-tags,
  .related-articles,
  .reading-progress,
  .skip-link,
  .pagination {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 12pt;
  }

  .article-content {
    max-width: 100%;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  .article-content a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }

  .article-content a[href^="/"]::after {
    content: " (datadaily.news" attr(href) ")";
  }

  pre {
    white-space: pre-wrap;
    border: 1px solid #ccc;
  }
}

/* ===== RTL SUPPORT (Arabic) ===== */
[dir="rtl"] {
  direction: rtl;
}

[dir="rtl"] .header-inner {
  flex-direction: row-reverse;
}

[dir="rtl"] .site-nav {
  direction: rtl;
}

[dir="rtl"] .breadcrumbs {
  direction: rtl;
}

[dir="rtl"] .breadcrumbs .separator {
  transform: scaleX(-1);
}

[dir="rtl"] .article-meta {
  direction: rtl;
}

[dir="rtl"] .card-meta {
  direction: rtl;
}

[dir="rtl"] .article-content {
  text-align: right;
}

[dir="rtl"] .article-content pre,
[dir="rtl"] .article-content code {
  direction: ltr;
  text-align: left;
}

[dir="rtl"] .share-buttons {
  direction: rtl;
}

[dir="rtl"] .pagination a,
[dir="rtl"] .pagination .current-page {
  direction: rtl;
}

[dir="rtl"] .footer-grid {
  direction: rtl;
}
