/* ============================================
   NINE COMMENTARIES — Persian Edition
   Design: Deep ink palette, calligraphic feel
   RTL / Persian-first layout
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;700&family=Playfair+Display:wght@400;700&display=swap');

/* ── Tokens ─────────────────────────────── */
:root {
  --ink:        #1a1410;
  --deep:       #2c1e12;
  --parchment:  #f5f0e8;
  --warm-white: #faf7f2;
  --gold:       #b8860b;
  --gold-light: #d4a017;
  --rust:       #8b3a1a;
  --mist:       #e8e0d0;
  --text:       #2d2318;
  --text-muted: #6b5c47;

  --font-persian: 'Vazirmatn', 'Tahoma', 'Arial', sans-serif;
  --font-display: 'Playfair Display', serif;

  --radius: 4px;
  --transition: 0.25s ease;
  --max-w: 860px;
  --max-w-wide: 1100px;
}

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

html {
  direction: rtl;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-persian);
  background: var(--warm-white);
  color: var(--text);
  line-height: 1.8;
  font-size: 17px;
}

img { max-width: 100%; height: auto; display: block; }
a   { color: var(--rust); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--gold); }

/* ── Ornament divider ────────────────────── */
.ornament {
  text-align: center;
  color: var(--gold);
  font-size: 1.4rem;
  letter-spacing: 0.5rem;
  margin: 2rem 0;
  opacity: 0.7;
  user-select: none;
}

/* ══════════════════════════════════════════
   LANDING PAGE
   ══════════════════════════════════════════ */

/* ── Site Header ─────────────────────────── */
.site-header {
  background: var(--ink);
  color: var(--parchment);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 2px solid var(--gold);
}

.site-header .logo {
  font-family: var(--font-persian);
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 0.02em;
}

.site-header nav a {
  color: var(--parchment);
  font-size: 0.85rem;
  margin-right: 1.5rem; /* RTL: left in LTR */
  opacity: 0.8;
  transition: opacity var(--transition);
}
.site-header nav a:first-child { margin-right: 0; }
.site-header nav a:hover { opacity: 1; color: var(--gold-light); }

/* ── Hero ────────────────────────────────── */
.hero {
  background: var(--ink);
  background-image:
    radial-gradient(ellipse 80% 60% at 50% 0%, #3d2910 0%, var(--ink) 70%);
  color: var(--parchment);
  padding: 5rem 2rem 4rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 60px,
    rgba(184,134,11,0.04) 60px,
    rgba(184,134,11,0.04) 61px
  );
  pointer-events: none;
}

.hero-eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 1.2rem;
  font-weight: 500;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.5rem;
  color: #fff;
}

.hero-subtitle {
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  color: var(--gold-light);
  font-weight: 300;
  margin-bottom: 2rem;
  letter-spacing: 0.05em;
}

.hero-divider {
  width: 60px;
  height: 2px;
  background: var(--gold);
  margin: 0 auto 2rem;
  opacity: 0.6;
}

.hero-intro {
  max-width: 640px;
  margin: 0 auto 3rem;
  font-size: 1rem;
  line-height: 1.9;
  color: rgba(245,240,232,0.82);
}

.hero-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Buttons ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.8rem;
  border-radius: var(--radius);
  font-family: var(--font-persian);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  border: none;
}

.btn-primary {
  background: var(--rust);
  color: #fff;
  border: 2px solid var(--rust);
}
.btn-primary:hover {
  background: #a34520;
  border-color: #a34520;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139,58,26,0.35);
}

.btn-outline {
  background: transparent;
  color: var(--parchment);
  border: 2px solid rgba(184,134,11,0.5);
}
.btn-outline:hover {
  background: rgba(184,134,11,0.1);
  border-color: var(--gold);
  color: var(--gold-light);
  transform: translateY(-2px);
}

/* ── Chapters Grid ───────────────────────── */
.chapters-section {
  max-width: var(--max-w-wide);
  margin: 0 auto;
  padding: 4rem 2rem;
}

.section-header {
  text-align: center;
  margin-bottom: 3rem;
}

.section-label {
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  color: var(--gold);
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 0.6rem;
  display: block;
}

.section-title {
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 700;
  color: var(--ink);
}

.chapters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.chapter-card {
  background: #fff;
  border: 1px solid var(--mist);
  border-radius: var(--radius);
  padding: 1.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}

.chapter-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0; /* RTL leading edge */
  width: 3px;
  height: 0;
  background: var(--rust);
  transition: height 0.3s ease;
}

.chapter-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(26,20,16,0.1);
  border-color: var(--mist);
  color: inherit;
}

.chapter-card:hover::before {
  height: 100%;
}

.card-num {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.5;
}

.card-excerpt {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.7;
  flex: 1;
}

.card-arrow {
  font-size: 0.85rem;
  color: var(--rust);
  font-weight: 600;
  margin-top: 0.5rem;
}

/* ── PDF Section ─────────────────────────── */
.pdf-section {
  background: var(--deep);
  color: var(--parchment);
  padding: 3.5rem 2rem;
  text-align: center;
}

.pdf-section .section-label { color: var(--gold); }
.pdf-section .section-title { color: #fff; margin-bottom: 1rem; }

.pdf-desc {
  max-width: 520px;
  margin: 0 auto 2rem;
  font-size: 0.95rem;
  color: rgba(245,240,232,0.75);
  line-height: 1.8;
}

/* ── Footer ──────────────────────────────── */
.site-footer {
  background: var(--ink);
  color: rgba(245,240,232,0.5);
  text-align: center;
  padding: 2rem;
  font-size: 0.8rem;
  border-top: 1px solid rgba(184,134,11,0.2);
}

.site-footer a { color: rgba(245,240,232,0.6); }
.site-footer a:hover { color: var(--gold); }

/* ══════════════════════════════════════════
   CHAPTER PAGE
   ══════════════════════════════════════════ */

.chapter-header {
  background: var(--ink);
  background-image:
    radial-gradient(ellipse 70% 80% at 30% 50%, #2c1e12 0%, var(--ink) 100%);
  color: var(--parchment);
  padding: 3.5rem 2rem 3rem;
  text-align: center;
  border-bottom: 2px solid var(--gold);
}

.ch-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 0.8rem;
  font-weight: 600;
}

.ch-title {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  font-weight: 700;
  line-height: 1.35;
  color: #fff;
  margin-bottom: 0.6rem;
}

.ch-subtitle {
  font-size: 1rem;
  color: rgba(245,240,232,0.65);
  font-weight: 300;
}

/* ── Article Body ────────────────────────── */
.article-wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
}

/* Lead paragraph */
.article-wrap .lead {
  font-size: 1.13rem;
  line-height: 1.9;
  color: var(--text);
  font-weight: 400;
  border-right: 3px solid var(--gold); /* RTL leading edge */
  padding-right: 1.2rem;
  margin-bottom: 2.5rem;
}

/* Body text */
.article-wrap p {
  margin-bottom: 1.6rem;
  font-size: 1rem;
  line-height: 1.9;
  color: var(--text);
}

/* Headings */
.article-wrap h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--deep);
  margin: 3rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--mist);
}

.article-wrap h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--rust);
  margin: 2rem 0 0.8rem;
}

/* Blockquote */
.article-wrap blockquote {
  background: var(--parchment);
  border-right: 4px solid var(--gold); /* RTL */
  border-left: none;
  padding: 1.2rem 1.5rem;
  margin: 2rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
  color: var(--deep);
}

/* ── In-article image ────────────────────── */
.article-image {
  margin: 2.5rem 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--mist);
}

.article-image img {
  width: 100%;
  object-fit: cover;
  max-height: 560px;
}

.article-image figcaption {
  background: var(--parchment);
  padding: 0.6rem .8rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

/* ── Chapter Nav ─────────────────────────── */
.chapter-nav {
  border-top: 1px solid var(--mist);
  padding-top: 2.5rem;
  margin-top: 3rem;
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 1rem;
  flex-wrap: wrap;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.4rem;
  border: 1px solid var(--mist);
  border-radius: var(--radius);
  background: #fff;
  text-decoration: none;
  transition: all var(--transition);
  max-width: 48%;
  min-width: 160px;
}

.nav-btn:hover {
  border-color: var(--rust);
  background: var(--parchment);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(26,20,16,0.08);
  color: inherit;
}

.nav-btn.nav-prev { text-align: right; }
.nav-btn.nav-next { /*text-align: left*/;  margin-right: auto; }

.nav-label {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--gold);
  font-weight: 600;
  text-transform: uppercase;
}

.nav-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
}

.nav-btn-home {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  transition: color var(--transition);
  align-self: center;
}
.nav-btn-home:hover { color: var(--rust); }

/* ── Progress bar ────────────────────────── */
.progress-bar {
  position: fixed;
  top: 0;
  right: 0; /* RTL */
  left: 0;
  height: 3px;
  background: var(--mist);
  z-index: 999;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(to left, var(--rust), var(--gold));
  width: 0%;
  transition: width 0.1s linear;
}

/* ── TOC sidebar hint ────────────────────── */
.toc-box {
  background: var(--parchment);
  border: 1px solid var(--mist);
  border-radius: var(--radius);
  padding: 1.4rem 1.6rem;
  margin-bottom: 2.5rem;
}

.toc-box h4 {
  font-size: 0.78rem;
  letter-spacing: 0.15em;
  color: var(--gold);
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 0.8rem;
}

.toc-box ol {
  padding-right: 1.2rem; /* RTL */
  padding-left: 0;
}

.toc-box li {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.toc-box li a {
  color: var(--text-muted);
}
.toc-box li a:hover { color: var(--rust); }

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */

@media (max-width: 680px) {
  .ETlogo { display: none !important; }
  .hero { padding: 3.5rem 1.2rem 3rem; }
  .chapters-section { padding: 2.5rem 1.2rem; }
  .chapter-nav { flex-direction: column; }
  .nav-btn { max-width: 100%; }
  .nav-btn.nav-next { margin-right: 0; }
  .site-header nav { display: none; }
  .article-wrap { padding: 2rem 1.2rem 3rem; }
}

/* ── Reduced motion ──────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ══════════════════════════════════════════
   HERO BANNER — with background image + 3D book
   ══════════════════════════════════════════ */

.hero-banner {
  position: relative;
  padding: 0;
  overflow: hidden;
  min-height: 520px;
  display: flex;
  align-items: stretch;
  background: var(--ink);
}

/* Background image — fades from right (center) into solid dark on left */
.hero-bg-image {
  position: absolute;
  inset: 0;
  background-image: url('../assets/images/Header_NC.jpg');
  background-size: cover;
  background-position: center top;
  /* RTL: image visible on right half, fades to dark on left (where book sits) */
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0%,
    rgba(0,0,0,0.15) 28%,
    rgba(0,0,0,0.55) 45%,
    rgba(0,0,0,1) 70%,
    rgba(0,0,0,1) 100%
  );
  mask-image: linear-gradient(
    to right,
    transparent 0%,
    rgba(0,0,0,0.15) 28%,
    rgba(0,0,0,0.55) 45%,
    rgba(0,0,0,1) 70%,
    rgba(0,0,0,1) 100%
  );
  opacity: 0.85;
}

/* Subtle dark overlay so text stays readable */
.hero-banner::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to left,
    rgba(26,20,16,0.15) 0%,
    rgba(26,20,16,0.55) 50%,
    rgba(26,20,16,0.92) 100%
  );
  pointer-events: none;
}

/* Inner flex container */
.hero-inner {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between; /* RTL: pushes content to right (text side) */
  width: 100%;
  max-width: var(--max-w-wide);
  margin: 0 auto;
  padding: 4rem 2rem;
  gap: 3.5rem;
  /* RTL: book on visual LEFT = flex row start in RTL context */
  flex-direction: row; /* in RTL this flows right→left, so first child appears on right */
}

/* ── Text block (RTL: right side = reading start) ── */
.hero-text {
  flex: 1;
  text-align: right;
  max-width: 520px;
}

.hero-text .hero-title {
  font-size: clamp(1.7rem, 4vw, 3rem);
  line-height: 1.25;
  margin-bottom: 0.4rem;
}

.hero-text .hero-intro {
  max-width: 100%;
  margin-bottom: 2rem;
}

/* ── Book wrapper (visual LEFT side) ── */
.hero-book-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* In RTL flow, this element renders on the visual left */
}

/* ── 3D Book ── */
.book-3d {
  position: relative;
  width: 200px;
  height: 280px;
  transform-style: preserve-3d;
  transform: perspective(900px) rotateY(28deg) rotateX(4deg);
  filter: drop-shadow(-18px 24px 40px rgba(0,0,0,0.7));
  transition: transform 0.5s ease;
}

.book-3d:hover {
  transform: perspective(900px) rotateY(18deg) rotateX(2deg) translateY(-6px);
}

.book-face {
  position: absolute;
  backface-visibility: hidden;
}

/* Front cover */
.book-front {
  width: 200px;
  height: 280px;
  top: 0;
  left: 0;
  overflow: hidden;
  border-radius: 1px 3px 3px 1px;
  border: 1px solid rgba(255,255,255,0.08);
}

.book-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Spine */
.book-spine {
  width: 28px;
  height: 280px;
  background: linear-gradient(
    to right,
    #1a0e06,
    #3a200f 40%,
    #2a1509 70%,
    #1a0e06
  );
  top: 0;
  left: -28px;
  transform-origin: right center;
  transform: rotateY(-90deg);
  border-radius: 2px 0 0 2px;
  box-shadow: inset -3px 0 8px rgba(0,0,0,0.5);
}

/* Top edge */
.book-top {
  width: 200px;
  height: 28px;
  background: linear-gradient(
    to bottom,
    #e8dcc8,
    #d4c8b0
  );
  top: -28px;
  left: 0;
  transform-origin: bottom center;
  transform: rotateX(90deg);
}

/* ── Responsive ── */
@media (max-width: 760px) {
  .hero-inner {
    flex-direction: column;
    align-items: center;
    padding: 3rem 1.5rem;
    gap: 2.5rem;
  }

  .hero-text {
    text-align: center;
  }

  .hero-bg-image {
    -webkit-mask-image: linear-gradient(
      to top,
      transparent 0%,
      rgba(0,0,0,0.4) 30%,
      rgba(0,0,0,0.8) 60%,
      rgba(0,0,0,1) 100%
    );
    mask-image: linear-gradient(
      to top,
      transparent 0%,
      rgba(0,0,0,0.4) 30%,
      rgba(0,0,0,0.8) 60%,
      rgba(0,0,0,1) 100%
    );
  }

  .book-3d {
    width: 160px;
    height: 224px;
    transform: perspective(700px) rotateY(22deg) rotateX(3deg);
  }

  .book-front {
    width: 160px;
    height: 224px;
  }

  .book-spine {
    width: 22px;
    height: 224px;
    left: -22px;
  }

  .book-top {
    width: 160px;
    height: 22px;
    top: -22px;
  }
}

/* ══════════════════════════════════════════
   ARTICLE ENHANCEMENTS — bold headings, quotes
   ══════════════════════════════════════════ */

/* Section labels like الف - ب - ج */
.article-wrap .section-marker {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}

/* Pull-quote highlight box (like the > blockquotes on source site) */
.pull-quote {
  background: var(--parchment);
  border-right: 4px solid var(--rust);
  border-left: none;
  padding: 1.2rem 1.6rem;
  margin: 2.2rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--deep);
  line-height: 1.7;
}

/* Italic intro / book intro box */
.book-intro {
  background: var(--parchment);
  border: 1px solid var(--mist);
  border-radius: var(--radius);
  padding: 1.3rem 1.6rem;
  margin-bottom: 2.5rem;
  font-style: italic;
  font-size: 0.93rem;
  color: var(--text-muted);
  line-height: 1.9;
}

/* Image float options */
.article-image.float-right {
  float: right;
  width: 260px;
  margin: 0.5rem 0 1.5rem 2rem;
}

/* .article-image.float-right img { max-height: 320px; } */

.float-left {
  float: left;
  width: 260px;
  margin: 0.5rem 2rem 1.5rem 0;
}

/* Footnotes */
.footnotes {
  border-top: 1px solid var(--mist);
  margin-top: 3rem;
  padding-top: 1.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.7;
}
.footnotes p { margin-bottom: 0.4rem; font-size: 0.82rem; }

/* Clear floats after sections */
.clear { clear: both; }

/* Stronger h2 for main section titles (الف، ب، ج style) */
.article-wrap h2.section-title-bold {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ink);
  border-bottom: 2px solid var(--gold);
  padding-bottom: 0.4rem;
  margin-top: 3rem;
}
