/* ═══════════════════════════════════════════════════════════
   PERSIA — A LIVING HISTORY
   
   Design concept: "The Unrolling Scroll"
   Each era shifts the visual atmosphere — color, pattern, mood.
   The page itself ages as you scroll through time.
   ═══════════════════════════════════════════════════════════ */

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

:root {
  /* Shared tokens */
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Source Sans 3', 'Source Sans Pro', system-ui, sans-serif;
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 2rem;
  --space-lg: 4rem;
  --space-xl: 6rem;
  --space-2xl: 10rem;
  --max-width: 1320px;
  --sidebar-width: 340px;
  --reading-width: 68ch;
  
  /* Default palette — overridden per-era */
  --bg: #0f0d09;
  --bg-section: #141210;
  --text: #e8e0d4;
  --text-muted: #a09888;
  --accent: #c9a84c;
  --accent-glow: rgba(201, 168, 76, 0.15);
  --card-bg: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.08);
  --divider: rgba(255, 255, 255, 0.06);
}

html {
  scroll-behavior: smooth;
  font-size: clamp(15px, 1.1vw, 18px);
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

/* ── TYPOGRAPHY ───────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.15;
}

h3 {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--accent);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
  letter-spacing: 0.01em;
}

p {
  margin-bottom: 1.1em;
  max-width: var(--reading-width);
}

strong { 
  color: var(--text);
  font-weight: 600; 
}

em { font-style: italic; }

ul {
  margin: var(--space-sm) 0 var(--space-md) 1.5rem;
  max-width: var(--reading-width);
}

li {
  margin-bottom: 0.5em;
  padding-left: 0.25rem;
}

li::marker {
  color: var(--accent);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover { color: var(--text); }

blockquote {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-style: italic;
  line-height: 1.5;
  color: var(--text);
  opacity: 0.9;
}

cite {
  display: block;
  font-family: var(--font-body);
  font-style: normal;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── ERA NAV (floating sidebar dots) ─────────────────── */
.era-nav {
  position: fixed;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.era-nav__track {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 0.6rem 0.35rem;
  background: rgba(15, 13, 9, 0.6);
  backdrop-filter: blur(12px);
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.03);
}

.era-nav__dot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
}

.era-nav__dot::after {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.35;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.era-nav__dot:hover::after,
.era-nav__dot.active::after {
  opacity: 1;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
  width: 7px;
  height: 7px;
}

.era-nav__label {
  position: absolute;
  right: calc(100% + 1.2rem);
  font-family: var(--font-body);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0;
  transform: translateX(6px);
  transition: all 0.25s ease;
  white-space: nowrap;
  pointer-events: none;
}

.era-nav__dot:hover .era-nav__label,
.era-nav__dot.active .era-nav__label {
  opacity: 1;
  transform: translateX(0);
}

/* ── ERA SECTIONS (shared structure) ─────────────────── */
.era {
  position: relative;
  min-height: 100vh;
  padding: var(--space-xl) var(--space-md);
  overflow: hidden;
  transition: background-color 0.6s ease;
}

.era__pattern {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  z-index: 0;
}

.era__header {
  position: relative;
  z-index: 1;
  max-width: var(--max-width);
  margin: 0 auto var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--divider);
}

.era__date-badge {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--space-sm);
  display: inline-block;
  padding: 0.3em 0.9em;
  border: 1px solid var(--accent);
  border-radius: 2px;
  opacity: 0.8;
}

.era__title {
  font-size: clamp(2.5rem, 5vw, 4.5rem);
  line-height: 1.05;
  color: var(--text);
  letter-spacing: -0.02em;
}

.era__title em {
  display: block;
  font-size: 0.45em;
  font-weight: 300;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-top: 0.3em;
}

.era__content {
  position: relative;
  z-index: 1;
  max-width: var(--max-width);
  margin: 0 auto;
}

.era__grid {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  gap: var(--space-lg);
  align-items: start;
}

.era__narrative {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.75;
}

.era__lede {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  line-height: 1.55;
  color: var(--text);
  margin-bottom: var(--space-md);
  max-width: 58ch;
}

/* ── SIDEBAR CARDS ────────────────────────────────────── */
.era__sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  position: sticky;
  top: var(--space-md);
}

.sidebar-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  padding: var(--space-md);
  backdrop-filter: blur(4px);
}

.sidebar-card h4 {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--space-sm);
}

.sidebar-card p {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text-muted);
}

.sidebar-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-card li {
  font-size: 0.9rem;
  padding: 0.4em 0;
  border-bottom: 1px solid var(--divider);
  padding-left: 0;
  color: var(--text-muted);
}

.sidebar-card li:last-child { border-bottom: none; }
.sidebar-card li::marker { content: none; }

.sidebar-card--quote {
  border-left: 3px solid var(--accent);
  background: var(--accent-glow);
}

.sidebar-card--quote blockquote {
  font-size: 1.1rem;
}

/* ═══════════════════════════════════════════════════════════
   HERO / PROLOGUE
   ═══════════════════════════════════════════════════════════ */
.era--prologue {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  background: radial-gradient(ellipse at 50% 40%, #1a1610 0%, #0f0d09 70%);
}

.prologue-pattern {
  background-image: 
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 80px,
      rgba(201, 168, 76, 0.03) 80px,
      rgba(201, 168, 76, 0.03) 81px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 80px,
      rgba(201, 168, 76, 0.03) 80px,
      rgba(201, 168, 76, 0.03) 81px
    );
  opacity: 0.15;
}

.hero {
  max-width: 720px;
  position: relative;
  z-index: 2;
}

.hero__epigraph {
  margin-bottom: var(--space-lg);
}

.hero__epigraph-line {
  font-family: var(--font-display);
  font-size: clamp(3rem, 8vw, 7rem);
  font-weight: 300;
  color: var(--accent);
  opacity: 0.25;
  letter-spacing: 0.1em;
  display: block;
  line-height: 1;
  animation: breathe 6s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 0.35; }
}

.hero__title {
  margin-bottom: var(--space-md);
}

.hero__title-sub {
  display: block;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.hero__title-main {
  font-family: var(--font-display);
  font-size: clamp(4rem, 10vw, 9rem);
  font-weight: 300;
  letter-spacing: -0.03em;
  color: var(--text);
  display: block;
  line-height: 0.95;
  background: linear-gradient(135deg, #e8e0d4 0%, #c9a84c 50%, #e8e0d4 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 8s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.hero__desc {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 300;
  line-height: 1.7;
  color: var(--text-muted);
  max-width: 52ch;
  margin: 0 auto var(--space-xl);
}

.hero__scroll-cue {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.5;
  animation: bob 3s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(8px); }
}

/* ═══════════════════════════════════════════════════════════
   ERA-SPECIFIC PALETTES & PATTERNS
   Each era shifts the visual identity
   ═══════════════════════════════════════════════════════════ */

/* ── ELAM — Earthy, ancient, terracotta ─────────────── */
.era--elam {
  --accent: #c4763a;
  --accent-glow: rgba(196, 118, 58, 0.12);
  --bg-section: #12100d;
  background: linear-gradient(180deg, #0f0d09 0%, #12100d 10%, #12100d 100%);
}

.elam-pattern {
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0L60 30L30 60L0 30z' fill='none' stroke='%23c4763a' stroke-width='0.5' opacity='0.3'/%3E%3C/svg%3E");
  opacity: 0.06;
}

/* ── ACHAEMENID — Lapis & gold, imperial grandeur ───── */
.era--achaemenid {
  --accent: #d4a843;
  --accent-glow: rgba(212, 168, 67, 0.12);
  --bg-section: #0d0f14;
  --text: #e4ddd0;
  background: linear-gradient(180deg, #12100d 0%, #0d0f14 10%, #0d0f14 100%);
}

.achaemenid-pattern {
  background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='10' y='10' width='60' height='60' fill='none' stroke='%23d4a843' stroke-width='0.4' opacity='0.25'/%3E%3Crect x='20' y='20' width='40' height='40' fill='none' stroke='%23d4a843' stroke-width='0.4' opacity='0.2'/%3E%3Crect x='30' y='30' width='20' height='20' fill='none' stroke='%23d4a843' stroke-width='0.4' opacity='0.15'/%3E%3C/svg%3E");
  opacity: 0.08;
}

/* ── SELEUCID/PARTHIAN — Cooler, Hellenistic marble ── */
.era--seleucid {
  --accent: #8fa9b8;
  --accent-glow: rgba(143, 169, 184, 0.1);
  --bg-section: #0e1014;
  background: linear-gradient(180deg, #0d0f14 0%, #0e1014 10%, #0e1014 100%);
}

.seleucid-pattern {
  background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='50' cy='50' r='40' fill='none' stroke='%238fa9b8' stroke-width='0.3' opacity='0.2'/%3E%3Ccircle cx='50' cy='50' r='25' fill='none' stroke='%238fa9b8' stroke-width='0.3' opacity='0.15'/%3E%3Cline x1='50' y1='0' x2='50' y2='100' stroke='%238fa9b8' stroke-width='0.3' opacity='0.1'/%3E%3Cline x1='0' y1='50' x2='100' y2='50' stroke='%238fa9b8' stroke-width='0.3' opacity='0.1'/%3E%3C/svg%3E");
  opacity: 0.06;
}

/* ── SASSANID — Deep wine, fire temple warmth ────────── */
.era--sassanid {
  --accent: #b85c4a;
  --accent-glow: rgba(184, 92, 74, 0.1);
  --bg-section: #120d0d;
  background: linear-gradient(180deg, #0e1014 0%, #120d0d 10%, #120d0d 100%);
}

.sassanid-pattern {
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 5 L55 30 L30 55 L5 30 Z' fill='none' stroke='%23b85c4a' stroke-width='0.4' opacity='0.2'/%3E%3Ccircle cx='30' cy='30' r='10' fill='none' stroke='%23b85c4a' stroke-width='0.3' opacity='0.15'/%3E%3C/svg%3E");
  opacity: 0.07;
}

/* ── ISLAMIC GOLDEN AGE — Turquoise & geometry ───────── */
.era--islamic {
  --accent: #4a9e8e;
  --accent-glow: rgba(74, 158, 142, 0.1);
  --bg-section: #0d1210;
  background: linear-gradient(180deg, #120d0d 0%, #0d1210 10%, #0d1210 100%);
}

.islamic-pattern {
  background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M40 0 L80 40 L40 80 L0 40 Z' fill='none' stroke='%234a9e8e' stroke-width='0.3'/%3E%3Cpath d='M20 0 L80 20 L60 80 L0 60 Z' fill='none' stroke='%234a9e8e' stroke-width='0.2' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.06;
}

/* ── MONGOL/SELJUK — Stark, dramatic, dark amber ─────── */
.era--mongol {
  --accent: #c9944a;
  --accent-glow: rgba(201, 148, 74, 0.1);
  --bg-section: #11100d;
  background: linear-gradient(180deg, #0d1210 0%, #11100d 10%, #11100d 100%);
}

.mongol-pattern {
  background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 20 L20 0 L40 20 L20 40 Z' fill='none' stroke='%23c9944a' stroke-width='0.5' opacity='0.15'/%3E%3C/svg%3E");
  opacity: 0.08;
}

/* ── SAFAVID — Rich blue, the Isfahan palette ────────── */
.era--safavid {
  --accent: #4a7eb8;
  --accent-glow: rgba(74, 126, 184, 0.1);
  --bg-section: #0d0e14;
  background: linear-gradient(180deg, #11100d 0%, #0d0e14 10%, #0d0e14 100%);
}

.safavid-pattern {
  background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M50 10 L90 50 L50 90 L10 50 Z' fill='none' stroke='%234a7eb8' stroke-width='0.3'/%3E%3Ccircle cx='50' cy='50' r='20' fill='none' stroke='%234a7eb8' stroke-width='0.3' opacity='0.4'/%3E%3Ccircle cx='50' cy='50' r='35' fill='none' stroke='%234a7eb8' stroke-width='0.2' opacity='0.3'/%3E%3C/svg%3E");
  opacity: 0.06;
}

/* ── QAJAR — Muted rose, photography-era tones ───────── */
.era--qajar {
  --accent: #a8707a;
  --accent-glow: rgba(168, 112, 122, 0.1);
  --bg-section: #110d0e;
  background: linear-gradient(180deg, #0d0e14 0%, #110d0e 10%, #110d0e 100%);
}

.qajar-pattern {
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cellipse cx='30' cy='30' rx='25' ry='15' fill='none' stroke='%23a8707a' stroke-width='0.3' opacity='0.2'/%3E%3Cellipse cx='30' cy='30' rx='15' ry='25' fill='none' stroke='%23a8707a' stroke-width='0.3' opacity='0.2'/%3E%3C/svg%3E");
  opacity: 0.06;
}

/* ── PAHLAVI — Sharp, modernist, high contrast ──────── */
.era--pahlavi {
  --accent: #8a8a8a;
  --accent-glow: rgba(138, 138, 138, 0.08);
  --bg-section: #101010;
  background: linear-gradient(180deg, #110d0e 0%, #101010 10%, #101010 100%);
}

.pahlavi-pattern {
  background-image: 
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 40px,
      rgba(138, 138, 138, 0.06) 40px,
      rgba(138, 138, 138, 0.06) 41px
    );
  opacity: 0.1;
}

/* ── MODERN — Subtle green undertone, digital ────────── */
.era--modern {
  --accent: #5a9e6a;
  --accent-glow: rgba(90, 158, 106, 0.08);
  --bg-section: #0d100d;
  background: linear-gradient(180deg, #101010 0%, #0d100d 10%, #0d100d 100%);
}

.modern-pattern {
  background-image: 
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(90, 158, 106, 0.015) 3px,
      rgba(90, 158, 106, 0.015) 4px
    );
  opacity: 0.2;
}

/* ═══════════════════════════════════════════════════════════
   EPILOGUE
   ═══════════════════════════════════════════════════════════ */
.era--epilogue {
  --accent: #c9a84c;
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 60%, #1a1610 0%, #0f0d09 70%);
}

.epilogue-pattern {
  opacity: 0.02;
}

.epilogue {
  text-align: center;
  max-width: 600px;
}

.epilogue__ornament {
  font-size: 2rem;
  color: var(--accent);
  opacity: 0.4;
  margin-bottom: var(--space-md);
  animation: breathe 6s ease-in-out infinite;
}

.epilogue__quote {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 300;
  font-style: italic;
  color: var(--text);
  margin-bottom: var(--space-sm);
  line-height: 1.2;
}

.epilogue__attr {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
  line-height: 1.6;
}

.epilogue__note {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 300;
  color: var(--text-muted);
  line-height: 1.7;
  max-width: 48ch;
  margin: 0 auto var(--space-lg);
}

.epilogue__line {
  width: 60px;
  height: 1px;
  background: var(--accent);
  opacity: 0.3;
  margin: var(--space-lg) auto;
}

.epilogue__colophon {
  font-size: 0.8rem;
  color: var(--text-muted);
  opacity: 0.5;
  max-width: 50ch;
  margin: 0 auto;
}

/* ═══════════════════════════════════════════════════════════
   SCROLL ANIMATIONS
   ═══════════════════════════════════════════════════════════ */
.era__header,
.era__narrative > *,
.sidebar-card {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.era__header.visible,
.era__narrative > .visible,
.sidebar-card.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger sidebar cards */
.sidebar-card:nth-child(2) { transition-delay: 0.1s; }
.sidebar-card:nth-child(3) { transition-delay: 0.2s; }

/* Hero animations */
.hero__epigraph,
.hero__title,
.hero__desc,
.hero__scroll-cue {
  animation: fadeUp 1s ease both;
}

.hero__title { animation-delay: 0.3s; }
.hero__desc { animation-delay: 0.6s; }
.hero__scroll-cue { animation-delay: 0.9s; }

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .era__grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  .era__sidebar {
    position: static;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--space-sm);
  }
}

@media (max-width: 768px) {
  .era {
    padding: var(--space-lg) var(--space-sm);
  }

  .era__title {
    font-size: clamp(2rem, 8vw, 3rem);
  }

  .era__lede {
    font-size: 1.15rem;
  }

  .era-nav {
    right: 0.5rem;
  }

  .era-nav__track {
    padding: 0.5rem 0.35rem;
  }

  .era-nav__label {
    display: none;
  }

  .hero__title-main {
    font-size: clamp(3rem, 14vw, 5rem);
  }
}

@media (max-width: 640px) {
  .era-nav {
    display: none;
  }
}

/* ── REDUCED MOTION ─────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  .era__header,
  .era__narrative > *,
  .sidebar-card {
    opacity: 1;
    transform: none;
  }
}

/* ── PRINT ──────────────────────────────────────────── */
@media print {
  .era-nav,
  .hero__scroll-cue,
  .era__pattern { display: none; }

  .era { 
    min-height: auto; 
    padding: 2rem 1rem;
    background: white !important;
    color: black !important;
  }

  .era__grid { grid-template-columns: 1fr; }
}
