/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Tajawal', sans-serif;
  background: #FAFAF8;
  color: #2C2C2C;
  line-height: 1.9;
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
}

/* === Typography === */
h1, h2, h3, h4, h5 { font-weight: 700; line-height: 1.4; }
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.8rem); }
h3 { font-size: clamp(1.1rem, 2.5vw, 1.4rem); }
h4 { font-size: clamp(1rem, 2vw, 1.2rem); }
p { margin-bottom: 1rem; }
a { color: #2E5090; text-decoration: none; transition: color 0.2s; }
a:hover { color: #1B2A4A; }
strong { font-weight: 700; }

/* === Colors === */
:root {
  --navy: #1B2A4A;
  --gold: #B8860B;
  --gold-light: #F5E6C0;
  --blue: #2E5090;
  --blue-light: #E8EEF7;
  --bg: #FAFAF8;
  --paper: #FFFFFF;
  --text: #2C2C2C;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --border-dark: #D1D5DB;
  --verified: #059669;
  --verified-bg: #ECFDF5;
  --needs-check: #D97706;
  --needs-check-bg: #FFFBEB;
  --inference: #2563EB;
  --inference-bg: #EFF6FF;
}

/* === Shared Nav === */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--navy);
  color: #fff;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.site-nav .logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
}
.site-nav a { color: rgba(255,255,255,0.85); font-size: 0.9rem; }
.site-nav a:hover { color: #fff; }
.nav-links { display: flex; gap: 1.25rem; align-items: center; }

/* ============================
   LANDING PAGE
   ============================ */

/* Hero */
.hero {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  background: linear-gradient(160deg, var(--navy) 0%, #243B6A 50%, var(--navy) 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 40%, rgba(184,134,11,0.08) 0%, transparent 60%);
}
.hero > * { position: relative; z-index: 1; }
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  margin-bottom: 1rem;
  color: var(--gold);
}
.hero .subtitle {
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  color: rgba(255,255,255,0.85);
  max-width: 700px;
  line-height: 2;
}
.hero .cta-row {
  margin-top: 2rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.8rem;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-outline { background: transparent; color: #fff; border: 1.5px solid rgba(255,255,255,0.4); }
.btn-outline:hover { border-color: #fff; color: #fff; }

/* Methodology Section */
.methodology {
  padding: 4rem 1.5rem;
  max-width: 1000px;
  margin: 0 auto;
}
.methodology h2 {
  text-align: center;
  color: var(--navy);
  margin-bottom: 0.5rem;
}
.methodology .section-desc {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  max-width: 600px;
  margin-inline: auto;
}
.layers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}
.layer-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  transition: box-shadow 0.2s, transform 0.2s;
}
.layer-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); transform: translateY(-2px); }
.layer-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}
.layer-card:nth-child(1) .layer-num { background: var(--blue-light); color: var(--blue); }
.layer-card:nth-child(2) .layer-num { background: var(--gold-light); color: var(--gold); }
.layer-card:nth-child(3) .layer-num { background: var(--verified-bg); color: var(--verified); }
.layer-card h3 { font-size: 1.15rem; margin-bottom: 0.5rem; color: var(--navy); }
.layer-card p { font-size: 0.95rem; color: var(--text-muted); line-height: 1.8; }

/* Badges Section */
.badges-section {
  background: var(--blue-light);
  padding: 3rem 1.5rem;
}
.badges-section .inner {
  max-width: 800px;
  margin: 0 auto;
}
.badges-section h2 {
  text-align: center;
  color: var(--navy);
  margin-bottom: 2rem;
}
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.badge-item {
  background: var(--paper);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.badge-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-top: 0.4rem;
  flex-shrink: 0;
}
.badge-dot.verified { background: var(--verified); }
.badge-dot.needs-check { background: var(--needs-check); }
.badge-dot.inference { background: var(--inference); }
.badge-item strong { display: block; font-size: 0.95rem; }
.badge-item span { font-size: 0.85rem; color: var(--text-muted); }

/* Research Index */
.research-index {
  padding: 4rem 1.5rem;
  max-width: 900px;
  margin: 0 auto;
}
.research-index h2 {
  text-align: center;
  color: var(--navy);
  margin-bottom: 0.5rem;
}
.research-index .section-desc {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 2rem;
}
.research-list { list-style: none; display: grid; gap: 1rem; }
.research-item {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  transition: box-shadow 0.2s;
  text-decoration: none;
  color: inherit;
}
.research-item:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); color: inherit; }
.research-num {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold);
  font-feature-settings: 'tnum';
}
.research-info h3 { font-size: 1.05rem; color: var(--navy); margin-bottom: 0.2rem; }
.research-info p { font-size: 0.85rem; color: var(--text-muted); margin: 0; }
.research-status {
  font-size: 0.75rem;
  padding: 0.25rem 0.75rem;
  border-radius: 99px;
  font-weight: 600;
  white-space: nowrap;
}
.status-draft { background: var(--needs-check-bg); color: var(--needs-check); }
.status-complete { background: var(--verified-bg); color: var(--verified); }

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

/* ============================
   RESEARCH PAGE
   ============================ */

.research-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  max-width: 1200px;
  margin: 0 auto;
  gap: 0;
  min-height: calc(100vh - 52px);
}

/* TOC Sidebar */
.toc {
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
  overflow-y: auto;
  padding: 1.5rem 1rem;
  border-left: 1px solid var(--border);
  background: var(--paper);
  font-size: 0.82rem;
}
.toc h4 {
  font-size: 0.85rem;
  color: var(--gold);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.toc ul { list-style: none; }
.toc li { margin-bottom: 0.4rem; }
.toc a {
  color: var(--text-muted);
  display: block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  line-height: 1.5;
  transition: all 0.15s;
}
.toc a:hover { color: var(--navy); background: var(--blue-light); }
.toc a.active { color: var(--blue); background: var(--blue-light); font-weight: 600; }
.toc .toc-h3 { padding-right: 1rem; font-size: 0.78rem; }
.toc .toc-h4 { padding-right: 1.8rem; font-size: 0.75rem; }

/* Article Content */
.article {
  padding: 2.5rem 3rem 4rem;
  max-width: 800px;
  min-width: 0;
}
.article h1 {
  color: var(--navy);
  margin-bottom: 0.5rem;
  padding-bottom: 1rem;
  border-bottom: 3px solid var(--gold);
}
.article h2 {
  color: var(--navy);
  margin-top: 3rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.article h3 {
  color: var(--blue);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}
.article h4 {
  color: var(--navy);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}
.article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}
.article blockquote {
  border-right: 4px solid var(--gold);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--gold-light);
  border-radius: 0 8px 8px 0;
  font-style: normal;
}
.article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}
.article th {
  background: var(--navy);
  color: #fff;
  padding: 0.6rem 0.75rem;
  font-weight: 600;
  text-align: right;
}
.article td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.article tr:hover td { background: rgba(46,80,144,0.03); }
.article ol, .article ul {
  padding-right: 1.5rem;
  margin-bottom: 1rem;
}
.article li { margin-bottom: 0.4rem; }

/* Citation Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  padding: 0.1rem 0.5rem;
  border-radius: 99px;
  font-weight: 600;
  vertical-align: middle;
  white-space: nowrap;
}
.badge-verified { background: var(--verified-bg); color: var(--verified); }
.badge-needs-check { background: var(--needs-check-bg); color: var(--needs-check); }
.badge-inference { background: var(--inference-bg); color: var(--inference); }

/* Footnotes */
sup.fn-ref {
  font-size: 0.7em;
  color: var(--blue);
  cursor: pointer;
  font-weight: 700;
  transition: color 0.15s;
}
sup.fn-ref:hover { color: var(--gold); }
.footnotes-section {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--navy);
}
.footnotes-section h2 { font-size: 1.2rem; margin-bottom: 1rem; }
.footnote-item {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
  line-height: 1.8;
}
.fn-num {
  font-weight: 700;
  color: var(--blue);
  text-align: center;
}

/* Stats Bar */
.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 2rem;
  font-size: 0.85rem;
}
.stat {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.stat-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}

/* Loading */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  color: var(--text-muted);
  gap: 1rem;
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 768px) {
  .research-layout {
    grid-template-columns: 1fr;
  }
  .toc {
    position: static;
    height: auto;
    border-left: none;
    border-bottom: 1px solid var(--border);
    padding: 1rem;
    max-height: 40vh;
  }
  .article {
    padding: 1.5rem 1.25rem 3rem;
  }
  .hero { min-height: 70vh; padding: 2rem 1.25rem; }
  .layers { grid-template-columns: 1fr; }
  .badge-grid { grid-template-columns: 1fr; }
  .research-item {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
  }
  .research-status {
    grid-column: 2;
    justify-self: start;
  }
  .site-nav {
    padding: 0.6rem 1rem;
    flex-wrap: wrap;
  }
  .nav-links { gap: 0.75rem; font-size: 0.85rem; }
  .stats-bar { flex-direction: column; gap: 0.5rem; }
  .article table { font-size: 0.8rem; }
  .article th, .article td { padding: 0.4rem 0.5rem; }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 1.6rem; }
  .article { padding: 1rem; }
  .toc { font-size: 0.78rem; }
  .research-item { padding: 1rem; }
}
