/* ============================================
   Al-Ri'aya Translation — Shared Styles
   ============================================ */

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

:root {
  --bg: #0b0f1a;
  --bg-card: #111827;
  --bg-card-hover: #1a2235;
  --bg-code: #0d1117;
  --bg-inline-code: #1e293b;
  --border: #1e293b;
  --border-accent: #d97706;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #d97706;
  --accent-light: #f59e0b;
  --accent-glow: rgba(217, 119, 6, 0.12);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.12);
  --orange: #f59e0b;
  --orange-dim: rgba(245, 158, 11, 0.12);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);
  --purple: #a78bfa;
  --purple-dim: rgba(167, 139, 250, 0.12);
  --cyan: #22d3ee;
  --cyan-dim: rgba(34, 211, 238, 0.12);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.12);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-arabic: 'Amiri', 'Scheherazade New', Georgia, serif;
  --max-width: 860px;
  --nav-height: 64px;
  --radius: 8px;
  --radius-lg: 12px;
}

html { font-size: 16px; scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-height) + 24px); }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: #fff; }

a { color: var(--accent-light); text-decoration: none; transition: color .2s; }
a:hover { color: #fbbf24; text-decoration: underline; }

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

/* --- Typography --- */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.3; color: #f1f5f9; }
h1 { font-size: 2.25rem; letter-spacing: -0.025em; }
h2 { font-size: 1.65rem; letter-spacing: -0.02em; margin-top: 3rem; margin-bottom: 1rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border); }
h3 { font-size: 1.25rem; margin-top: 2rem; margin-bottom: .75rem; }
h4 { font-size: 1.05rem; margin-top: 1.5rem; margin-bottom: .5rem; color: var(--text-muted); }

p { margin-bottom: 1rem; }
ul, ol { margin-bottom: 1rem; padding-left: 1.5rem; }
li { margin-bottom: .4rem; }
li::marker { color: var(--text-dim); }

strong { color: #f1f5f9; font-weight: 600; }
em { color: var(--accent-light); font-style: italic; }

hr { border: none; border-top: 1px solid var(--border); margin: 2.5rem 0; }

blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.25rem 0;
  padding: .75rem 1.25rem;
  background: var(--accent-glow);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-muted);
  font-style: italic;
}
blockquote p { margin-bottom: 0; }

/* --- Navigation --- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-height);
  background: rgba(11, 15, 26, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.nav-inner {
  width: 100%; max-width: 1200px;
  padding: 0 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-brand {
  font-weight: 700; font-size: 1.05rem; color: #f1f5f9;
  display: flex; align-items: center; gap: .6rem;
}
.nav-brand .brand-arabic {
  font-family: var(--font-arabic);
  font-size: 1.15rem;
  color: var(--accent-light);
  direction: rtl;
}
.nav-links { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.nav-links a {
  padding: .45rem .9rem; border-radius: 6px; font-size: .82rem;
  color: var(--text-muted); font-weight: 500; transition: all .2s;
  white-space: nowrap;
}
.nav-links a:hover { color: var(--text); background: var(--bg-card); text-decoration: none; }
.nav-links a.active { color: var(--accent-light); background: var(--accent-glow); }

.nav-toggle { display: none; background: none; border: none; color: var(--text); cursor: pointer; padding: .5rem; }
.nav-toggle svg { width: 24px; height: 24px; }

@media (max-width: 840px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none; position: absolute; top: var(--nav-height); left: 0; right: 0;
    background: var(--bg-card); border-bottom: 1px solid var(--border);
    flex-direction: column; padding: .75rem;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: .6rem 1rem; width: 100%; }
}

/* --- Layout --- */
.page { padding-top: calc(var(--nav-height) + 2rem); padding-bottom: 4rem; }
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 1.5rem; }

/* --- Hero --- */
.hero {
  text-align: center; padding: 5rem 1.5rem 3rem;
  background: radial-gradient(ellipse at 50% 0%, var(--accent-glow) 0%, transparent 60%);
}
.hero .basmala {
  font-family: var(--font-arabic);
  font-size: 1.35rem;
  color: var(--text-muted);
  line-height: 2;
  margin-bottom: 1.5rem;
  direction: rtl;
}

.hero .opening-dua {
  margin-bottom: 2rem;
}
.hero .opening-dua-ar {
  font-family: var(--font-arabic);
  font-size: 1.15rem;
  color: var(--text-muted);
  direction: rtl;
  line-height: 2;
}
.hero .opening-dua-en {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 0.25rem;
}
.hero .title-arabic {
  font-family: var(--font-arabic);
  font-size: 2.8rem;
  color: var(--accent-light);
  direction: rtl;
  margin-bottom: .5rem;
  letter-spacing: 0;
  line-height: 1.4;
}
.hero h1 { font-size: 1.9rem; margin-bottom: .5rem; color: #f1f5f9; }
.hero .author { font-size: 1rem; color: var(--text-muted); margin-bottom: 1.75rem; }
.hero .subtitle { font-size: 1.1rem; color: var(--text-dim); max-width: 600px; margin: 0 auto 2rem; line-height: 1.6; }
.hero-badges { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; margin-bottom: 2.5rem; }
.badge {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .35rem .85rem; border-radius: 999px; font-size: .8rem; font-weight: 500;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-muted);
}
.badge.gold { border-color: rgba(217,119,6,.35); color: var(--accent-light); background: var(--accent-glow); }
.badge.green { border-color: rgba(34,197,94,.3); color: var(--green); background: var(--green-dim); }
.badge.blue  { border-color: rgba(59,130,246,.3); color: var(--blue); background: var(--blue-dim); }

/* --- Part cards (index) --- */
.part-grid { display: grid; grid-template-columns: 1fr; gap: .85rem; margin-top: 1.5rem; }

.part-card {
  display: flex; gap: 1.25rem; align-items: flex-start;
  padding: 1.15rem 1.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  transition: all .25s; cursor: pointer; color: var(--text);
}
.part-card:hover { border-color: var(--border-accent); background: var(--bg-card-hover); transform: translateY(-2px); text-decoration: none; }
.part-num {
  flex-shrink: 0; width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; font-weight: 700; font-size: .9rem;
  background: var(--accent-glow); color: var(--accent-light); border: 1px solid rgba(217,119,6,.3);
}
.part-card-body { flex: 1; min-width: 0; }
.part-card-body h3 { margin: 0 0 .3rem; font-size: 1rem; }
.part-card-body p { margin: 0; font-size: .85rem; color: var(--text-muted); line-height: 1.5; }
.part-card-meta { display: flex; gap: 1rem; margin-top: .5rem; }
.part-card-meta span { font-size: .78rem; color: var(--text-dim); }
.progress-bar-wrap { margin-top: .5rem; background: var(--border); border-radius: 999px; height: 4px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s; }

/* --- Chapter table (index) --- */
.chapter-section { margin-top: 3rem; }
.chapter-section h2 { font-size: 1.3rem; }
.chapter-section h2 .book-arabic {
  font-family: var(--font-arabic); font-size: 1rem;
  font-weight: 400; color: var(--text-muted);
  display: block; margin-top: .2rem;
}
.chapter-section .part-arabic {
  font-family: var(--font-arabic);
  direction: rtl;
  font-size: 1rem;
  color: var(--text-dim);
  margin-top: .25rem;
  margin-bottom: 1rem;
}

.chapter-list { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }

.chapter-row {
  display: flex; align-items: center; gap: 1rem;
  padding: .75rem 1rem;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  transition: all .2s;
}
.chapter-row:hover { border-color: var(--border-accent); background: var(--bg-card-hover); text-decoration: none; color: var(--text); }
.chapter-row.pending { opacity: .55; pointer-events: none; cursor: default; }
.chapter-num { font-size: .75rem; color: var(--text-dim); font-weight: 600; min-width: 2.5rem; font-family: var(--font-mono); }
.chapter-titles { flex: 1; min-width: 0; }
.chapter-titles .en { font-size: .92rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chapter-titles .ar {
  font-family: var(--font-arabic);
  font-size: .88rem;
  color: var(--text-dim);
  direction: rtl;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chapter-page { font-size: .78rem; color: var(--text-dim); font-family: var(--font-mono); min-width: 3.5rem; text-align: right; }
.chapter-status { min-width: 1.5rem; text-align: center; }

/* Status dots */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.status-pending  { background: var(--text-dim); }
.status-draft    { background: var(--orange); }
.status-verified { background: var(--blue); }
.status-done     { background: var(--green); }

/* --- Section cards --- */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem; margin-bottom: 1.25rem;
}
.card.accent       { border-left: 3px solid var(--accent); }
.card.green-accent { border-left: 3px solid var(--green); }
.card.blue-accent  { border-left: 3px solid var(--blue); }

/* --- Callouts --- */
.callout {
  border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1.25rem;
  font-size: .92rem; line-height: 1.6;
}
.callout-title { font-weight: 600; margin-bottom: .35rem; display: flex; align-items: center; gap: .5rem; }
.callout.info    { background: var(--blue-dim);   border: 1px solid rgba(59,130,246,.25); }
.callout.info .callout-title { color: var(--blue); }
.callout.tip     { background: var(--green-dim);  border: 1px solid rgba(34,197,94,.25); }
.callout.tip .callout-title { color: var(--green); }
.callout.warning { background: var(--orange-dim); border: 1px solid rgba(245,158,11,.25); }
.callout.warning .callout-title { color: var(--orange); }

/* --- Tables --- */
table { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; font-size: .9rem; }
th { text-align: left; padding: .7rem 1rem; background: var(--bg-card); border-bottom: 2px solid var(--border); color: var(--text-muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
td { padding: .65rem 1rem; border-bottom: 1px solid var(--border); }
tr:hover td { background: rgba(30, 41, 59, 0.3); }

/* --- TOC sidebar --- */
.page-with-toc { display: flex; gap: 2.5rem; }
.page-with-toc .content { flex: 1; min-width: 0; }
.toc {
  position: sticky; top: calc(var(--nav-height) + 2rem);
  width: 240px; flex-shrink: 0; align-self: flex-start;
  max-height: calc(100vh - var(--nav-height) - 3rem); overflow-y: auto;
  padding-right: .5rem;
}
.toc-title { font-size: .75rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .75rem; }
.toc a {
  display: block; padding: .32rem 0 .32rem .85rem; font-size: .78rem;
  color: var(--text-dim); border-left: 2px solid var(--border); transition: all .2s;
  line-height: 1.4;
}
.toc a:hover { color: var(--text-muted); border-color: var(--text-dim); text-decoration: none; }
.toc a.active { color: var(--accent-light); border-color: var(--accent); }
.toc a.toc-sub { padding-left: 1.5rem; font-size: .76rem; }
.toc a.toc-current { color: var(--accent-light); border-color: var(--accent); font-weight: 600; }
.toc-subheadings { border-left: 2px solid var(--accent); margin-left: 0; padding-left: 0; }
.toc-subheadings a { border-left: none; padding-left: 1.25rem; font-size: .76rem; color: var(--text-muted); }
.toc-subheadings a:hover { color: var(--text); }

@media (max-width: 1080px) { .toc { display: none; } .page-with-toc { display: block; } }

/* --- Reader page --- */
.reader-header { margin-bottom: 2.5rem; }
.reader-header .part-label {
  font-size: .8rem; font-weight: 600; color: var(--accent-light);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: .4rem;
}
.reader-header .part-label .book-arabic {
  font-family: var(--font-arabic); font-size: 1rem;
  text-transform: none; letter-spacing: 0; font-weight: 400;
  color: var(--text-muted); margin-top: .15rem;
}
.reader-header h1 { margin-bottom: .4rem; font-size: 1.8rem; }
.reader-header .chapter-arabic {
  font-family: var(--font-arabic);
  font-size: 1.3rem;
  color: var(--text-muted);
  direction: rtl;
  margin-bottom: .75rem;
  line-height: 1.6;
}
.heading-arabic {
  font-family: var(--font-arabic);
  font-size: 1rem;
  color: var(--text-muted);
  direction: rtl;
  margin-top: -.4rem;
  margin-bottom: .75rem;
  line-height: 1.6;
}
.reader-header .reader-meta { display: flex; gap: 1.5rem; flex-wrap: wrap; color: var(--text-dim); font-size: .85rem; }

/* The rendered markdown content */
.markdown-body { line-height: 1.8; }
.markdown-body h2 { font-size: 1.4rem; }
.markdown-body h3 { font-size: 1.15rem; color: var(--accent-light); }
.markdown-body .page-break {
  text-align: center; font-size: .75rem; color: var(--text-dim);
  font-family: var(--font-mono); letter-spacing: .08em;
  margin: 2rem 0 1rem; opacity: .5;
}
.markdown-body .tn {
  font-size: .85rem; color: var(--text-dim); font-style: italic;
  background: var(--bg-card); border-left: 2px solid var(--text-dim);
  padding: .3rem .75rem; margin: .5rem 0; border-radius: 0 var(--radius) var(--radius) 0;
}

/* Page loading states */
.page-loading { text-align: center; padding: 3rem 0; color: var(--text-dim); font-size: .9rem; }
.page-not-translated {
  text-align: center; padding: 2rem;
  background: var(--bg-card); border: 1px dashed var(--border);
  border-radius: var(--radius); color: var(--text-dim); font-size: .9rem;
  margin: 1rem 0;
}

/* --- Prev/Next nav --- */
.page-nav {
  display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem;
  padding-top: 1.5rem; border-top: 1px solid var(--border);
}
.page-nav a {
  display: flex; flex-direction: column; gap: .25rem;
  padding: .85rem 1.15rem; border-radius: var(--radius);
  background: var(--bg-card); border: 1px solid var(--border);
  transition: all .2s; max-width: 48%;
}
.page-nav a:hover { border-color: var(--border-accent); text-decoration: none; }
.page-nav .nav-label { font-size: .72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.page-nav .nav-title { font-size: .9rem; font-weight: 600; color: var(--text); }
.page-nav .next { text-align: right; margin-left: auto; }

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

/* --- Utilities --- */
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-sm { font-size: .88rem; }
.text-xs { font-size: .78rem; }
.fw-600 { font-weight: 600; }
.tag {
  display: inline-block; padding: .2rem .65rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; letter-spacing: .02em;
}
.tag.done     { background: var(--green-dim);  color: var(--green);  border: 1px solid rgba(34,197,94,.25); }
.tag.draft    { background: var(--orange-dim); color: var(--orange); border: 1px solid rgba(245,158,11,.25); }
.tag.pending  { background: var(--bg-card);    color: var(--text-dim); border: 1px solid var(--border); }
