/* ═══════════════════════════════════════════════════════
   SHAHNAMEH — Stylesheet
   Aesthetic: Illuminated manuscript · warm parchment
   Fonts: Cinzel (display) · EB Garamond (body/Persian)
═══════════════════════════════════════════════════════ */

:root {
  --parchment:    #f5efe0;
  --parchment-dk: #ede3cc;
  --parchment-md: #e8dbb8;
  --ink:          #1c1408;
  --ink-soft:     #3d3020;
  --ink-faint:    #6b5a3e;
  --gold:         #b8872a;
  --gold-lt:      #d4a84b;
  --gold-pale:    #f0dfa8;
  --crimson:      #8b1a1a;
  --border:       #c9aa72;
  --border-lt:    #ddc98a;
  --shadow:       rgba(28, 20, 8, 0.14);

  --font-title:   'Cinzel', 'Palatino Linotype', serif;
  --font-body:    'EB Garamond', 'Palatino', 'Georgia', serif;
  --font-persian: 'EB Garamond', 'Scheherazade New', 'Traditional Arabic', serif;
}

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

html { font-size: 18px; scroll-behavior: smooth; }

body {
  background-color: var(--parchment);
  background-image:
    radial-gradient(ellipse at 18% 8%,  rgba(184,135,42,0.09) 0%, transparent 52%),
    radial-gradient(ellipse at 82% 92%, rgba(139,26,26,0.06)  0%, transparent 52%);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }


/* ══════════════════════════════════════
   SITE HEADER
══════════════════════════════════════ */
.site-header {
  background: var(--ink);
  color: var(--parchment);
  text-align: center;
  padding: 3rem 2rem 2.5rem;
  position: relative;
  overflow: hidden;
}

/* subtle vertical stripe texture */
.site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg, transparent, transparent 48px,
    rgba(184,135,42,0.035) 48px, rgba(184,135,42,0.035) 50px
  );
  pointer-events: none;
}

.header-ornament {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), var(--gold-lt), var(--gold), transparent);
  max-width: 480px;
  margin: 0 auto;
  border-radius: 2px;
}
.header-ornament.top    { margin-bottom: 1.8rem; }
.header-ornament.bottom { margin-top:    1.8rem; }

.header-inner { position: relative; z-index: 1; }

.subtitle-persian {
  font-family: var(--font-persian);
  font-size: 1.5rem;
  color: var(--gold-lt);
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
  direction: rtl;
}

.site-title {
  font-family: var(--font-title);
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--parchment);
  text-shadow: 0 2px 24px rgba(184,135,42,0.4);
  line-height: 1;
}

.subtitle-en {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--gold-pale);
  margin-top: 0.45rem;
  letter-spacing: 0.03em;
}

/* Compact header on reading page */
.site-header.compact {
  padding: 0.85rem 1.6rem;
  text-align: left;
}
.site-header.compact .header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.back-link {
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--gold-pale);
  letter-spacing: 0.02em;
  transition: color 0.18s;
}
.back-link:hover { color: var(--gold-lt); }
.site-title-small {
  font-family: var(--font-title);
  font-size: 1.15rem;
  letter-spacing: 0.1em;
  color: var(--gold-pale);
}


/* ══════════════════════════════════════
   TABLE OF CONTENTS
══════════════════════════════════════ */
.toc-main {
  flex: 1;
  max-width: 860px;
  width: 100%;
  margin: 3rem auto 4rem;
  padding: 0 1.5rem;
}

.loading-msg {
  text-align: center;
  color: var(--ink-faint);
  font-style: italic;
  padding: 3rem;
}

/* Chapter block */
.chapter-block {
  margin-bottom: 1.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 14px var(--shadow);
}

.chapter-header {
  background: var(--ink);
  color: var(--parchment);
  padding: 0.95rem 1.4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transition: background 0.18s;
  gap: 1rem;
}
.chapter-header:hover { background: #271c0c; }

.chapter-title-group {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.chapter-num {
  font-family: var(--font-title);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  white-space: nowrap;
  flex-shrink: 0;
}
.chapter-title-en {
  font-family: var(--font-title);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--parchment);
}
.chapter-meta {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-shrink: 0;
}

/* Farsi title lives inside .chapter-meta so it sits on the right side */
.chapter-title-fa {
  font-family: var(--font-persian);
  font-size: 1rem;
  color: var(--gold-pale);
  direction: rtl;
  text-align: right;
}
.chapter-stats {
  font-family: var(--font-title);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.8;
}
.chevron {
  font-size: 1.1rem;
  color: var(--gold);
  transition: transform 0.3s ease;
}
.chevron.rotated { transform: rotate(-90deg); }

/* Subheadings */
.subheading-list {
  background: var(--parchment-dk);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.subheading-list.open { max-height: 1200px; }

.subheading-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1.6rem;
  border-bottom: 1px solid var(--border-lt);
  transition: background 0.14s;
  cursor: pointer;
}
.subheading-item:last-child { border-bottom: none; }
.subheading-item:hover { background: var(--gold-pale); }

.sub-title-en {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  flex: 1;
  transition: color 0.14s;
}
.subheading-item:hover .sub-title-en { color: var(--crimson); }

.sub-title-fa {
  font-family: var(--font-persian);
  font-size: 0.95rem;
  color: var(--ink-faint);
  direction: rtl;
}
.sub-count {
  font-family: var(--font-title);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  white-space: nowrap;
  flex-shrink: 0;
}


/* ══════════════════════════════════════
   READING PAGE
══════════════════════════════════════ */
.chapter-main {
  flex: 1;
  max-width: 1000px;
  width: 100%;
  margin: 2rem auto 4rem;
  padding: 0 1.5rem;
}

/* Reading header */
.reading-header {
  text-align: center;
  margin-bottom: 2.2rem;
  padding-bottom: 1.4rem;
}
.reading-chapter-label {
  font-family: var(--font-title);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.6rem;
}
.reading-chapter-fa {
  font-family: var(--font-persian);
  font-style: normal;
  text-transform: none;
  letter-spacing: 0.05em;
  font-size: 0.88rem;
  margin-left: 0.5rem;
}
.reading-subheading-en {
  font-family: var(--font-title);
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
  margin-bottom: 0.25rem;
}
.reading-section-en {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink-soft);
  margin-bottom: 0.2rem;
}
.reading-section-fa {
  font-family: var(--font-persian);
  font-size: 1.2rem;
  color: var(--ink-faint);
  direction: rtl;
  margin-bottom: 1rem;
}
.header-rule {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), var(--gold-lt), var(--gold), transparent);
  max-width: 400px;
  margin: 0.6rem auto 0;
  border-radius: 1px;
}

/* Section nav bar */
.verse-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
  padding: 0.6rem 1rem;
  background: var(--parchment-dk);
  border: 1px solid var(--border);
  border-radius: 3px;
}
.verse-nav:empty { display: none; }
.nav-label {
  font-family: var(--font-title);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin-right: 0.3rem;
  white-space: nowrap;
}
.sub-nav-link {
  font-family: var(--font-body);
  font-size: 0.88rem;
  padding: 0.22rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--ink-soft);
  transition: all 0.14s;
  white-space: nowrap;
}
.sub-nav-link:hover { background: var(--gold-pale); color: var(--ink); }
.sub-nav-link.active {
  background: var(--ink);
  color: var(--gold-pale);
  border-color: var(--ink);
}


/* ══════════════════════════════════════
   VERSE ROWS  (the core layout)
   Columns: [EN num] [EN text] [divider] [FA text] [FA num]
══════════════════════════════════════ */
.verse-row {
  display: grid;
  grid-template-columns: 2.2rem 1fr 1px 1fr 2.2rem;
  gap: 0 1.2rem;
  align-items: start;       /* all cells top-aligned */
  padding: 1.1rem 0.4rem;
  border-bottom: 1px solid rgba(184,135,42,0.22);
  transition: background 0.12s;
}
.verse-row:first-child { border-top: 1px solid rgba(184,135,42,0.22); }
.verse-row:hover       { background: rgba(240,223,168,0.28); }

/* English verse number — left side */
.verse-number {
  font-family: var(--font-title);
  font-size: 0.7rem;
  color: var(--gold);
  text-align: center;
  letter-spacing: 0.04em;
  /* nudge down to align baseline with first hem line */
  padding-top: 0.32rem;
}

/* Farsi verse number — right side */
.verse-number-fa {
  font-family: var(--font-persian);
  font-size: 0.85rem;
  color: var(--gold);
  text-align: center;
  direction: rtl;
  /* same nudge as English number so both sit level with first hem */
  padding-top: 0.32rem;
}

.verse-translation,
.verse-persian {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.verse-translation { padding-right: 0.4rem; }
.verse-persian     { padding-left:  0.4rem; direction: rtl; }

.hem {
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--ink);
}
.verse-persian .hem {
  font-family: var(--font-persian);
  font-size: 1.18rem;
  line-height: 1.85;
  color: var(--ink-soft);
}

/* thin gold divider between EN and FA columns */
.verse-divider {
  width: 1px;
  align-self: stretch;
  background: linear-gradient(180deg, transparent, var(--border), transparent);
}


/* ══════════════════════════════════════
   FOOTER NAV
══════════════════════════════════════ */
.chapter-footer-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 3rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
}
.fnav-left, .fnav-right { flex: 1; }
.fnav-right { text-align: right; }

.fnav-btn {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.92rem;
  padding: 0.45rem 1rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--ink-soft);
  transition: all 0.15s;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fnav-btn:hover { background: var(--ink); color: var(--gold-pale); border-color: var(--ink); }
.fnav-home {
  font-size: 1.6rem;
  color: var(--gold);
  transition: color 0.15s;
  flex-shrink: 0;
}
.fnav-home:hover { color: var(--crimson); }


/* ══════════════════════════════════════
   SITE FOOTER
══════════════════════════════════════ */
.site-footer {
  background: var(--ink);
  color: var(--gold-pale);
  text-align: center;
  padding: 0.9rem 1rem;
  font-family: var(--font-body);
  font-size: 0.84rem;
  font-style: italic;
  margin-top: auto;
}
.site-footer a { color: var(--gold-lt); text-decoration: underline; text-underline-offset: 3px; }
.site-footer a:hover { color: var(--gold-pale); }


/* ══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */
@media (max-width: 640px) {
  .verse-row {
    grid-template-columns: 2rem 1fr 2rem;
    grid-template-rows: auto auto;
    gap: 0.5rem 0.5rem;
  }
  /* Row 1: EN number | EN text | (FA number hidden or pushed) */
  .verse-number      { grid-column: 1; grid-row: 1; }
  .verse-translation { grid-column: 2; grid-row: 1; }
  .verse-number-fa   { grid-column: 3; grid-row: 1; display: none; }
  /* Divider spans full width between rows */
  .verse-divider {
    grid-column: 1 / -1;
    grid-row: 2;
    width: auto;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
    align-self: auto;
    margin: 0.2rem 0;
  }
  /* Row 3: FA text spans full width, right-aligned */
  .verse-persian {
    grid-column: 1 / -1;
    grid-row: 3;
    padding-left: 0;
    text-align: right;
  }

  .chapter-stats,
  .chapter-title-fa,
  .sub-title-fa { display: none; }

  .toc-main,
  .chapter-main { margin-top: 1.5rem; }
}
