:root {
  --primary: #CC0000;
  --primary-dark: #990000;
  --secondary: #1a1a1a;
  --text: #333;
  --text-light: #666;
  --bg: #fff;
  --bg-alt: #f4f4f4;
  --border: #ddd;
  --font-main: 'Merriweather', 'Vazirmatn', sans-serif;
  --container-width: 1400px;
  --header-height: 156px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-main);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}
[dir="rtl"] body { text-align: right; }
[dir="ltr"] body { text-align: left; }

a { text-decoration: none; color: inherit; transition: 0.2s; font-family: inherit; }
ul { list-style: none; }
img { max-width: 100%; height: auto; display: block; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
.container { max-width: var(--container-width); margin: 0 auto; padding: 0 20px; }
.hidden { display: none !important; }

/* Global Layout with Persistent Sidebars */
.global-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 280px;
  grid-template-areas: "left-sidebar main right-sidebar";
  gap: 30px;
  margin-top: 30px;
  align-items: flex-start;
}

[dir="rtl"] .global-layout {
  grid-template-areas: "right-sidebar main left-sidebar";
}

.sidebar-left { grid-area: left-sidebar; }
.sidebar-right { grid-area: right-sidebar; }
.main-content { grid-area: main; min-width: 0; }

.sidebar {
  position: sticky;
  top: calc(var(--header-height) + 20px);
  height: calc(100vh - var(--header-height) - 40px);
  overflow-y: auto;
  padding: 0 10px 40px;
  -webkit-overflow-scrolling: touch;
}
/* Hide scrollbar but keep functionality */
.sidebar::-webkit-scrollbar { width: 0; }
.sidebar { -ms-overflow-style: none; scrollbar-width: none; }

.sidebar-title {
  font-size: 18px;
  font-weight: 900;
  margin-bottom: 25px;
  border-right: 4px solid var(--primary);
  padding-right: 12px;
  color: var(--secondary);
  font-family: 'Vazirmatn', sans-serif;
  text-transform: uppercase;
}
[dir="ltr"] .sidebar-title {
  border-right: none;
  border-left: 4px solid var(--primary);
  padding-right: 0;
  padding-left: 12px;
}

/* Header */
.header {
  background: #fff;
  padding: 0;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
}
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 16px;
  position: relative;
}
.brand {
  display: flex;
  align-items: center;
  height: var(--header-height);
  gap: 20px;
  flex: 1 1 auto;
  min-width: 0;
}
.brand.has-logo #site-title {
  /* Wordmark logo already carries the site name */
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
#logo-container {
  height: var(--header-height);
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}
#logo-container img {
  display: block;
  width: auto;
  height: calc(var(--header-height) - 24px);
  max-height: calc(var(--header-height) - 24px);
  max-width: min(640px, 72vw);
  object-fit: contain;
  object-position: right center;
}
[dir="ltr"] #logo-container img {
  object-position: left center;
}
#site-title {
  font-size: clamp(18px, 2.2vw, 26px);
  font-weight: 900;
  line-height: 1.2;
  margin: 0;
  font-family: 'Vazirmatn', sans-serif;
  color: var(--secondary);
}

.menu-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  padding: 0;
  flex-shrink: 0;
  z-index: 1002;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.menu-toggle:hover,
.menu-toggle:focus-visible {
  border-color: var(--primary);
  outline: none;
}
.menu-toggle-bar {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--secondary);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
body.nav-open .menu-toggle-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
body.nav-open .menu-toggle-bar:nth-child(2) {
  opacity: 0;
}
body.nav-open .menu-toggle-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.nav-container {
  flex-grow: 1;
  display: flex;
  justify-content: center;
}
.nav {
  display: flex;
  gap: 30px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}
.nav-link {
  font-weight: 900;
  font-size: 16px;
  white-space: nowrap;
  color: var(--secondary);
  font-family: 'Vazirmatn', sans-serif;
}
.nav-link:hover { color: var(--primary); }

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 999;
}

/* Button Styles */
.btn {
  display: inline-block;
  padding: 12px 28px;
  border-radius: 6px;
  font-weight: 900;
  font-size: 15px;
  transition: all 0.3s ease;
  cursor: pointer;
  text-align: center;
  border: 2px solid transparent;
  font-family: 'Vazirmatn', sans-serif;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-2px); box-shadow: 0 5px 15px rgba(204, 0, 0, 0.2); }
.btn-outline { background: transparent; color: var(--secondary); border-color: var(--secondary); }
.btn-outline:hover { background: var(--secondary); color: #fff; }

/* Secondary CTA on dark hero art needs a solid fill (outline alone disappears) */
.hero-btns .btn-outline {
  background: #fff;
  color: var(--secondary);
  border-color: #fff;
}
.hero-btns .btn-outline:hover {
  background: rgba(255, 255, 255, 0.92);
  color: var(--primary);
  border-color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.18);
}

.pillar-btn {
  display: inline-block;
  padding: 8px 20px;
  background: #f0f0f0;
  color: var(--secondary);
  border-radius: 4px;
  font-weight: 900;
  font-size: 13px;
  transition: 0.3s;
  margin-top: 15px;
  font-family: 'Vazirmatn', sans-serif;
}
.pillar-btn:hover { background: var(--primary); color: #fff; }

/* Hero - No longer full width */
.hero {
  position: relative;
  min-height: 320px;
  height: 450px;
  background: #222;
  color: #fff;
  display: flex;
  align-items: center;
  text-align: center;
  background-size: cover;
  background-position: center;
  border-radius: 15px;
  overflow: hidden;
  margin-bottom: 40px;
  font-family: 'Vazirmatn', sans-serif;
}
.hero-overlay { position: absolute; inset: 0; z-index: 1; }
.hero-content { position: relative; z-index: 2; padding: 40px; width: 100%; }
.hero-title { font-size: clamp(28px, 4vw, 42px); font-weight: 900; line-height: 1.2; margin-bottom: 20px; }
.hero-subtitle { font-size: clamp(15px, 2vw, 18px); margin-bottom: 30px; opacity: 0.9; }
.hero-btns {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Page Hero - For detail pages, now constrained */
.page-hero {
  position: relative;
  min-height: 220px;
  height: 350px;
  border-radius: 15px;
  overflow: hidden;
  margin-bottom: 40px;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: 'Vazirmatn', sans-serif;
}
.page-hero-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); z-index: 1; }
.page-hero-content { position: relative; z-index: 2; padding: 40px 24px; color: #fff; }
.page-hero-title { font-size: clamp(28px, 4vw, 48px); font-weight: 900; line-height: 1.2; }

/* Pillars Section */
.pillars-section { padding: 60px 0; border-top: 1px solid #eee; margin-top: 60px; }
.pillars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 30px;
  justify-content: center;
}
.pillar {
  min-width: 0;
  text-align: center;
  padding: 30px 20px;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 12px;
  transition: 0.3s;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.pillar:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
  box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}
.pillar-icon { margin-bottom: 15px; color: var(--primary); }
.pillar-title {
  font-size: 20px;
  font-weight: 900;
  margin-bottom: 10px;
  color: var(--secondary);
  font-family: 'Vazirmatn', sans-serif;
}
.pillar-desc { font-size: 14px; opacity: 0.7; line-height: 1.6; flex-grow: 1; }

/* Campaign Cards */
.campaigns-grid,
.large-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 25px;
}
.campaign-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #eee;
  display: flex;
  flex-direction: column;
  transition: 0.3s;
  min-width: 0;
}
.campaign-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0,0,0,0.05);
}
.campaign-img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.campaign-body {
  padding: 20px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.campaign-title {
  font-size: 18px;
  font-weight: 900;
  margin-bottom: 10px;
  font-family: 'Vazirmatn', sans-serif;
}
.campaign-preview {
  font-size: 14px;
  opacity: 0.7;
  margin-bottom: 20px;
  flex-grow: 1;
}

/* Progress Bar */
.progress-wrap { margin-bottom: 20px; }
.progress-bar {
  height: 8px;
  background: #eee;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill { height: 100%; background: var(--primary); transition: 1s; }
.progress-bar.completed .progress-fill { background: #4caf50; }
.progress-text {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: 'Vazirmatn', sans-serif;
}

/* Publication Cards */
.footer-pub-card {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #eee;
  background: #fafafa;
}
.footer-pub-cover {
  width: 60px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.pub-issue-tag {
  font-size: 12px;
  font-weight: 900;
  color: var(--primary);
  display: block;
  font-family: 'Vazirmatn', sans-serif;
}
.pub-title-sm {
  font-size: 13px;
  font-weight: 900;
  margin: 3px 0;
  display: block;
  font-family: 'Vazirmatn', sans-serif;
}

/* News Items */
.news-item-sidebar {
  border-bottom: 1px solid #eee;
  padding-bottom: 15px;
  margin-bottom: 15px;
}
.news-title-sm {
  font-size: 15px;
  font-weight: 900;
  line-height: 1.4;
  font-family: 'Vazirmatn', sans-serif;
}

/* Detail View Layout */
.detail-view-content { padding: 0 0 60px; }
.article-body {
  font-size: 19px;
  line-height: 1.8;
  color: #333;
  font-family: 'Merriweather', 'Vazirmatn', serif;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.article-body p { margin-bottom: 25px; }
.article-body img,
.article-body iframe,
.article-body table,
.block-table {
  max-width: 100%;
}
.block-table {
  width: 100%;
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
}
.block-table td {
  border: 1px solid #eee;
  padding: 8px 10px;
  vertical-align: top;
}

/* Ticker */
.ticker {
  background: var(--primary);
  color: #fff;
  padding: 8px 0;
  font-family: 'Vazirmatn', sans-serif;
}
.ticker-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.ticker-label {
  flex-shrink: 0;
  font-weight: 900;
  font-size: 12px;
  background: rgba(255,255,255,0.15);
  padding: 4px 10px;
  border-radius: 999px;
}
.ticker-content {
  min-width: 0;
  overflow: hidden;
}
.ticker-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  font-weight: 700;
}

/* Lang Switcher */
.lang-switcher-bar {
  background: #f8f8f8;
  border-bottom: 1px solid #eee;
  padding: 10px 0;
  font-family: 'Vazirmatn', sans-serif;
}
.lang-bar-inner {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
.lang-switcher {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.lang-btn {
  cursor: pointer;
  opacity: 0.5;
  font-weight: 900;
  font-size: 13px;
  transition: 0.3s;
  padding: 4px 2px;
}
.lang-btn.active { opacity: 1; color: var(--primary); }

/* Footer */
.footer {
  background: var(--secondary);
  color: #fff;
  padding: 60px 0 calc(40px + var(--safe-bottom));
  margin-top: 80px;
}
.copyright {
  text-align: center;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 13px;
  opacity: 0.5;
  font-family: 'Vazirmatn', sans-serif;
}
.social-list {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 30px;
}
.social-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.social-btn:hover { background: var(--primary); }

/* Comments Section */
.comments-section { margin-top: 60px; padding-top: 40px; border-top: 1px solid #eee; }
.comment-item {
  background: #fafafa;
  padding: 20px;
  border-radius: 10px;
  margin-bottom: 15px;
  border: 1px solid #eee;
}
.comment-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid #eee;
  padding-bottom: 8px;
  flex-wrap: wrap;
}
.comment-author {
  font-weight: 900;
  color: var(--primary);
  font-size: 15px;
  font-family: 'Vazirmatn', sans-serif;
}
.comment-date {
  font-size: 11px;
  opacity: 0.5;
  font-family: 'Vazirmatn', sans-serif;
}
.comment-form {
  background: #fff;
  border: 1px solid #eee;
  padding: 30px;
  border-radius: 12px;
  margin-top: 40px;
}
.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-bottom: 15px;
  font-family: inherit;
  font-size: 16px;
}
.form-input:focus {
  outline: 2px solid rgba(204, 0, 0, 0.2);
  border-color: var(--primary);
}

.sidebar-right .sidebar-title { font-size: 20px; }
.sidebar-right .pub-issue-tag { font-size: 23px; }
.sidebar-right .pub-title-sm { font-size: 16px; }

/* Tablet */
@media (max-width: 1100px) {
  .global-layout {
    grid-template-columns: 220px minmax(0, 1fr) 220px;
    gap: 20px;
  }
  .nav { gap: 18px; }
  .nav-link { font-size: 15px; }
  :root { --header-height: 140px; }
  .brand { gap: 14px; }
  #logo-container img {
    height: calc(var(--header-height) - 20px);
    max-height: calc(var(--header-height) - 20px);
    max-width: min(560px, 68vw);
  }
}

/* Mobile / small tablet */
@media (max-width: 900px) {
  :root { --header-height: 96px; }

  .container { padding: 0 16px; }

  .header {
    min-height: var(--header-height);
  }

  .header-inner {
    min-height: var(--header-height);
    gap: 12px;
  }

  .brand {
    height: var(--header-height);
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
  }

  #logo-container {
    height: auto;
    width: 100%;
  }

  #logo-container img {
    height: 78px;
    max-height: 78px;
    max-width: min(420px, calc(100vw - 96px));
  }

  #site-title {
    font-size: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .brand.has-logo #site-title {
    display: none;
  }

  .menu-toggle {
    display: inline-flex;
    width: 48px;
    height: 48px;
  }

  .nav-container {
    position: fixed;
    top: 0;
    bottom: 0;
    width: min(360px, 90vw);
    background: #fff;
    box-shadow: 0 10px 40px rgba(0,0,0,0.18);
    padding: calc(var(--header-height) + 18px) 22px 28px;
    overflow-y: auto;
    z-index: 1001;
    transform: translateX(110%);
    transition: transform 0.25s ease;
    justify-content: flex-start;
    align-items: stretch;
  }

  [dir="rtl"] .nav-container {
    right: 0;
    left: auto;
    transform: translateX(110%);
  }

  [dir="ltr"] .nav-container {
    left: 0;
    right: auto;
    transform: translateX(-110%);
  }

  body.nav-open .nav-container {
    transform: translateX(0);
  }

  body.nav-open {
    overflow: hidden;
  }

  body.nav-open .nav-backdrop {
    display: block;
  }

  .nav {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 100%;
  }

  .nav li { width: 100%; }

  .nav-link {
    display: block;
    width: 100%;
    padding: 18px 16px;
    border-radius: 12px;
    font-size: 19px;
    line-height: 1.35;
    white-space: normal;
  }

  .nav-link:hover,
  .nav-link:focus-visible {
    background: #f7f7f7;
    color: var(--primary);
  }

  .global-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "main"
      "left-sidebar"
      "right-sidebar";
    gap: 28px;
    margin-top: 20px;
    margin-bottom: 20px;
  }

  [dir="rtl"] .global-layout {
    grid-template-areas:
      "main"
      "left-sidebar"
      "right-sidebar";
  }

  .sidebar {
    position: static;
    height: auto;
    overflow: visible;
    padding: 0;
    border-top: 1px solid #eee;
    padding-top: 24px;
  }

  .campaigns-grid,
  .large-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    height: auto;
    min-height: 280px;
    border-radius: 12px;
    margin-bottom: 28px;
  }

  .hero-content,
  .page-hero-content {
    padding: 28px 18px;
  }

  .hero-btns {
    gap: 10px;
  }

  .hero-btns .btn {
    flex: 1 1 160px;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .page-hero {
    height: auto;
    min-height: 200px;
    border-radius: 12px;
  }

  .pillars-section {
    padding: 36px 0;
    margin-top: 36px;
  }

  .article-body {
    font-size: 17px;
    line-height: 1.75;
  }

  .comment-form {
    padding: 20px;
  }

  .footer {
    padding: 40px 0 calc(28px + var(--safe-bottom));
    margin-top: 48px;
  }

  .sidebar-right .pub-issue-tag { font-size: 16px; }
  .sidebar-right .pub-title-sm { font-size: 14px; }
  .sidebar-right .sidebar-title { font-size: 18px; }

  .btn {
    padding: 12px 18px;
  }
}

@media (max-width: 480px) {
  .container { padding: 0 14px; }

  :root { --header-height: 90px; }

  .lang-switcher {
    gap: 12px;
  }

  .lang-btn {
    font-size: 12px;
  }

  #logo-container img {
    height: 70px;
    max-height: 70px;
    max-width: calc(100vw - 88px);
  }

  #site-title {
    font-size: 15px;
  }

  .nav-link {
    font-size: 18px;
    padding: 16px 14px;
  }

  .hero {
    min-height: 240px;
  }

  .hero-title {
    font-size: 24px;
  }

  .hero-subtitle {
    font-size: 14px;
    margin-bottom: 20px;
  }

  .campaign-body {
    padding: 16px;
  }

  .footer-pub-card {
    align-items: flex-start;
  }

  .ticker-inner {
    gap: 8px;
  }

  .ticker-text {
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
