/* ==========================================================================
   THE FOUNDING THESIS — DESIGN SYSTEM & STYLESHEET (ALL 45 SPREADS)
   ========================================================================== */

:root {
  /* Color Tokens */
  --bg-obsidian: #07080C;
  --bg-card: #0F1118;
  --bg-card-hover: #151822;
  --text-primary: #F3F4F6;
  --text-secondary: #9CA3AF;
  --text-muted: #6B7280;
  
  --gold-primary: #D4AF37;
  --gold-light: #F3E5AB;
  --gold-dark: #9A7B1C;
  --gold-glow: rgba(212, 175, 55, 0.12);
  --gold-border: rgba(212, 175, 55, 0.28);
  
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(255, 255, 255, 0.15);

  /* Font Tokens */
  --font-serif: 'Cinzel', 'Cormorant Garamond', Georgia, serif;
  --font-editorial: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  
  /* Layout Tokens */
  --header-height: 64px;
  --footer-height: 60px;
  --border-radius: 16px;
  --transition-smooth: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-obsidian);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  position: relative;
}

/* Top Navigation Bar */
.top-nav {
  height: var(--header-height);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(7, 8, 12, 0.88);
  backdrop-filter: blur(12px);
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-mark {
  color: var(--gold-primary);
  font-size: 1.25rem;
}

.brand-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  color: var(--gold-light);
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding-left: 8px;
  border-left: 1px solid var(--border-subtle);
  letter-spacing: 0.05em;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.nav-btn.primary-gold {
  background: var(--gold-glow);
  border-color: var(--gold-border);
  color: var(--gold-light);
}

.nav-btn.primary-gold:hover {
  background: rgba(212, 175, 55, 0.25);
  box-shadow: 0 0 16px rgba(212, 175, 55, 0.2);
}

/* Sidebar Drawer */
.toc-drawer {
  position: fixed;
  top: 0;
  right: -420px;
  width: 420px;
  height: 100%;
  background: #0B0D14;
  border-left: 1px solid var(--border-subtle);
  z-index: 200;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  transition: var(--transition-smooth);
}

.toc-drawer.open {
  right: 0;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.6);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-header h3 {
  font-family: var(--font-serif);
  color: var(--gold-light);
  font-size: 1.1rem;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.toc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
}

.toc-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-secondary);
  transition: var(--transition-smooth);
  border: 1px solid transparent;
  font-size: 0.85rem;
}

.toc-link:hover, .toc-link.active {
  background: rgba(212, 175, 55, 0.08);
  border-color: var(--gold-border);
  color: var(--gold-light);
}

.toc-link .num {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  color: var(--gold-primary);
  min-width: 28px;
}

.toc-link .title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-smooth);
}

.drawer-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Reader Viewport */
.reader-viewport {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  overflow: hidden;
  position: relative;
}

.book-container {
  width: 100%;
  max-width: 1350px;
  height: 100%;
  max-height: 740px;
  position: relative;
}

/* Spread Card Layout */
.spread-card {
  display: none;
  width: 100%;
  height: 100%;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.spread-card.active {
  display: grid;
  opacity: 1;
  transform: translateY(0);
}

/* Single Page View Option */
.book-container.single-mode .spread-card {
  grid-template-columns: 1fr;
  max-width: 850px;
  margin: 0 auto;
}

.book-container.single-mode .page-right {
  display: none;
}

/* Page Styling */
.page {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius);
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.page-left {
  background: linear-gradient(150deg, #12141D 0%, #090A0E 100%);
  border-color: rgba(212, 175, 55, 0.18);
  justify-content: center;
}

.chapter-tag {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: var(--gold-primary);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  font-weight: 600;
}

.spread-badge {
  font-family: var(--font-serif);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.head-title {
  font-family: var(--font-serif);
  font-size: 1.85rem;
  line-height: 1.3;
  font-weight: 700;
  color: var(--gold-light);
}

.page-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 6px;
}

.body-p {
  font-size: 0.98rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

.body-bullet {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
  border-left: 2px solid var(--gold-primary);
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
}

.arabic-highlight {
  font-size: 1.6rem;
  color: var(--gold-primary);
  text-align: center;
  margin: 1rem 0;
  line-height: 1.8;
}

.quote-banner {
  border-left: 2px solid var(--gold-primary);
  padding-left: 1rem;
  color: var(--gold-light);
  font-family: var(--font-editorial);
  font-size: 1.2rem;
  font-style: italic;
  margin: 1rem 0;
}

.page-footer {
  font-family: var(--font-serif);
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
  text-align: right;
}

/* Bottom Toolbar */
.bottom-bar {
  height: var(--footer-height);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  background: rgba(7, 8, 12, 0.88);
  backdrop-filter: blur(12px);
  z-index: 100;
}

.ctrl-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.ctrl-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.ctrl-btn:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-hover);
}

.page-nav-center {
  display: flex;
  align-items: center;
  gap: 16px;
}

.spread-select {
  background: #0E1017;
  border: 1px solid var(--border-subtle);
  color: var(--gold-light);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}

.page-indicator {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  color: var(--text-muted);
}

#current-spread {
  color: var(--gold-light);
  font-weight: 700;
}

/* ==========================================================================
   PRINT STYLES FOR HIGH QUALITY PDF GENERATION (ALL 45 SPREADS)
   ========================================================================== */
@media print {
  body {
    background: #000000 !important;
    color: #FFFFFF !important;
    overflow: visible !important;
  }
  .print-hide {
    display: none !important;
  }
  .reader-viewport {
    padding: 0 !important;
    overflow: visible !important;
  }
  .book-container {
    max-width: 100% !important;
    max-height: none !important;
  }
  .spread-card {
    display: grid !important;
    page-break-after: always;
    opacity: 1 !important;
    transform: none !important;
    margin-bottom: 2rem;
  }
  .page {
    border: 1px solid #333 !important;
    box-shadow: none !important;
    background: #0B0D12 !important;
  }
}
