/* Modern Design System for "The Burden of Seeing Clearly" */
/* Technical Documentation Meets Human Emotion */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700;900&family=JetBrains+Mono:wght@400;700&display=swap');

:root {
  /* Scientific Dark Palette (Default) */
  --void: #000000;           /* Pure black */
  --coal: rgba(0, 0, 0, 0.95);  /* Main background */
  --ash: rgba(255, 255, 255, 0.05);  /* Elevated surfaces */
  --smoke: rgba(255, 255, 255, 0.1);  /* Borders */
  --steel: rgba(255, 255, 255, 0.5);  /* Muted text */
  --pearl: rgba(255, 255, 255, 0.9);  /* Primary text */
  --light: #ffffff;          /* Pure white */
  
  /* Emotional Accents */
  --wound: #dc2626;          /* Pain points, warnings */
  --bruise: #7c3aed;         /* Trauma, depth */
  --healing: #0ea5e9;        /* Hope, progress */
  --growth: #10b981;         /* Breakthroughs */
  
  /* System States */
  --error: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --info: #3b82f6;
  
  /* Theme-specific */
  --background-body: #000000;
  --grid-color: rgba(255, 255, 255, 0.03);
  --grid-size: 20px;
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', Monaco, Consolas, monospace;
  
  /* Compact Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 0.75rem;
  --spacing-lg: 1rem;
  --spacing-xl: 1.5rem;
  --spacing-2xl: 2rem;
  
  /* Layout */
  --max-width-content: 720px;
  --max-width-wide: 1200px;
}

/* Light Theme Variables */
html[data-theme="light"] {
  /* Technical Paper Palette */
  --void: #FAFAF8;           /* Off-white paper */
  --coal: #1A1A1A;           /* Deep charcoal text */
  --ash: rgba(0, 0, 0, 0.03);  /* Subtle elevation */
  --smoke: rgba(0, 0, 0, 0.08);  /* Light borders */
  --steel: rgba(0, 0, 0, 0.6);  /* Muted text */
  --pearl: rgba(0, 0, 0, 0.85);  /* Primary text */
  --light: #000000;          /* Inverted */
  
  /* Adjusted Emotional Accents for light mode */
  --wound: #b91c1c;          /* Darker red */
  --bruise: #6d28d9;         /* Darker purple */
  --healing: #0284c7;        /* Darker blue */
  --growth: #059669;         /* Darker green */
  
  /* Theme-specific */
  --background-body: #FAFAF8;
  --grid-color: rgba(0, 0, 0, 0.04);
  --grid-size: 20px;
}

/* Starfield Background */
.starfield-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: -1;
  background: linear-gradient(180deg, #000000 0%, #0a0a0a 100%);
  pointer-events: none;
  transition: background 0.5s ease;
}

/* Grid Pattern for Light Mode */
html[data-theme="light"] .starfield-container {
  background: 
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px),
    linear-gradient(var(--background-body) 0%, var(--background-body) 100%);
  background-size: var(--grid-size) var(--grid-size), var(--grid-size) var(--grid-size), 100% 100%;
  background-position: -1px -1px, -1px -1px, 0 0;
}

html[data-theme="light"] .star-layer {
  opacity: 0;
}

.star-layer {
  position: absolute;
  width: 100%;
  height: 200%; /* Double height for continuous scrolling */
  will-change: transform;
  animation: starfall linear infinite;
  animation-duration: calc(120s / var(--layer-speed, 1));
}

@keyframes starfall {
  from {
    transform: translateY(-50%);
  }
  to {
    transform: translateY(0);
  }
}

.star {
  position: absolute;
  background: #ffffff;
  border-radius: 50%;
  animation: twinkle ease-in-out infinite;
  animation-duration: calc(3s + var(--star-x, 0) * 0.1s);
  animation-delay: calc(var(--star-y, 0) * 0.1s);
}

@keyframes twinkle {
  0%, 100% { opacity: var(--opacity, 1); }
  50% { opacity: calc(var(--opacity, 1) * 0.3); }
}

.star-glow {
  box-shadow: 
    0 0 2px rgba(255, 255, 255, 0.8),
    0 0 4px rgba(255, 255, 255, 0.4);
}

.star-error {
  background: #dc2626;
  animation: error-pulse 2s ease-in-out infinite;
}

.star-blue {
  background: #93c5fd;
  box-shadow: 0 0 2px rgba(147, 197, 253, 0.6);
}

@keyframes error-pulse {
  0%, 100% { 
    opacity: var(--opacity, 1); 
    transform: scale(1);
  }
  50% { 
    opacity: 1; 
    transform: scale(1.2);
  }
}

.star-code::after {
  content: attr(data-symbol);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-size: 8px;
  color: rgba(14, 165, 233, 0.8);
  text-shadow: 0 0 3px rgba(14, 165, 233, 0.5);
}

/* Glitch Effect */
.starfield-container.glitching {
  animation: glitch-effect 0.1s linear;
}

@keyframes glitch-effect {
  0%, 100% { filter: none; }
  20% { filter: hue-rotate(90deg) saturate(1.5); transform: translateX(-1px); }
  40% { filter: hue-rotate(-90deg) saturate(1.5); transform: translateX(1px); }
  60% { filter: brightness(1.2) contrast(1.1); transform: translateY(-0.5px); }
  80% { filter: brightness(0.9) hue-rotate(180deg); transform: translateY(0.5px); }
}

/* Finale Sequence */
.starfield-container.finale-sequence .star {
  animation: form-heart 3s ease-in-out;
}

@keyframes form-heart {
  50% {
    transform: 
      translateX(calc((50 - var(--star-x, 50)) * 0.5vw))
      translateY(calc((50 - var(--star-y, 50)) * 0.5vh));
  }
}

/* Reduced Motion */
.starfield-container.reduced-motion .star-layer {
  animation-play-state: paused;
}

.starfield-container.reduced-motion .star {
  animation: none;
  opacity: var(--opacity, 1);
}

/* Text Readability Enhancement */
main {
  position: relative;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

html[data-theme="light"] main {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.chapter-content {
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(15px);
}

html[data-theme="light"] .chapter-content {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(15px);
}

/* Reset and Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

::selection {
  background-color: var(--bruise);
  color: var(--light);
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 60px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  font-feature-settings: 'ss01', 'ss02', 'cv01', 'cv02', 'tnum';
  color: var(--pearl);
  background-color: var(--background-body);
  min-height: 100vh;
  font-weight: 300;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Smooth theme transitions */
* {
  transition: background-color 0.3s ease, 
              color 0.3s ease,
              border-color 0.3s ease,
              fill 0.3s ease;
}

/* Elements that should animate position/transform */
.download-card,
.license-tier,
.btn,
.share-btn {
  transition: all 0.2s ease;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.2;
  font-weight: 700;
  margin-top: var(--spacing-xl);
  margin-bottom: var(--spacing-md);
}

h1 {
  font-weight: 200;
  font-size: clamp(1.8rem, 3.5vw, 2.5rem);
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--pearl);
  margin-bottom: var(--spacing-md);
  text-transform: uppercase;
}

h2 {
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  font-weight: 300;
  letter-spacing: 0.05em;
  color: var(--pearl);
  text-transform: uppercase;
}

h3 {
  font-size: clamp(1.4rem, 2.5vw, 1.8rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--pearl);
}

p {
  margin-bottom: var(--spacing-md);
  color: var(--pearl);
}

a {
  color: var(--healing);
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
}

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

/* Code Voice */
.code-voice, code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--healing);
  background: var(--void);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--smoke);
}

html[data-theme="light"] .code-voice,
html[data-theme="light"] code {
  background: var(--ash);
  border-color: var(--smoke);
}

/* Layout */
.container {
  max-width: var(--max-width-content);
  margin: 0 auto;
  padding: 0 24px;
}

.container-wide {
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: 0 24px;
}

/* Progress Bar */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: transparent;
  z-index: 1000;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--bruise), var(--healing));
  transition: width 0.3s ease;
  box-shadow: 0 0 10px var(--healing);
  width: 0%;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--smoke);
  transition: background 0.3s ease;
}

html[data-theme="light"] .site-header {
  background: rgba(250, 250, 248, 0.8);
  backdrop-filter: blur(20px) saturate(180%);
}

.main-nav {
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: var(--spacing-sm) var(--spacing-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 48px;
}

.nav-wrapper {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
}

.nav-home, .nav-toc, .nav-downloads, .nav-support, .nav-licensing, .nav-read {
  color: var(--steel);
  font-weight: 500;
  transition: color 0.2s ease;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-home:hover, .nav-toc:hover, .nav-downloads:hover, 
.nav-support:hover, .nav-licensing:hover, .nav-read:hover {
  color: var(--pearl);
}

.nav-read {
  color: var(--healing);
  border: 1px solid var(--healing);
  padding: 4px 12px;
  margin-left: var(--spacing-sm);
}

.nav-read:hover {
  background: var(--healing);
  color: var(--void);
}

html[data-theme="light"] .nav-read:hover {
  background: var(--healing);
  color: white;
}

/* Hero Section */
.hero {
  text-align: center;
  padding: var(--spacing-lg) 0;
  animation: fadeInUp 0.6s ease;
}

.subtitle {
  font-size: 1.5rem;
  color: var(--healing);
  margin-bottom: var(--spacing-sm);
  font-weight: 300;
  letter-spacing: -0.02em;
}

.tagline {
  font-size: 1.25rem;
  color: var(--steel);
  margin-bottom: var(--spacing-sm);
  font-weight: 500;
}

.author {
  color: var(--steel);
  font-style: italic;
  margin-bottom: var(--spacing-xs);
}

.publisher {
  color: var(--steel);
  font-size: 0.9rem;
  margin-bottom: var(--spacing-xl);
}

.publisher a {
  color: var(--healing);
  text-decoration: none;
  transition: color 0.2s ease;
}

.publisher a:hover {
  color: var(--light);
  text-decoration: underline;
}

.hero-actions {
  display: flex;
  gap: var(--spacing-md);
  justify-content: center;
  flex-wrap: wrap;
  margin-top: var(--spacing-xl);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: 8px 20px;
  border-radius: 0;
  font-weight: 400;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-primary {
  background: var(--healing);
  color: var(--void);
  border: 1px solid var(--healing);
}

.btn-primary:hover {
  background: transparent;
  color: var(--healing);
}

html[data-theme="light"] .btn-primary {
  background: var(--healing);
  color: white;
}

html[data-theme="light"] .btn-primary:hover {
  background: transparent;
  color: var(--healing);
  border-color: var(--healing);
}

.btn-secondary {
  background: transparent;
  color: var(--steel);
  border: 1px solid var(--smoke);
}

.btn-secondary:hover {
  background: var(--healing);
  color: var(--coal);
  transform: translateY(-2px);
}

html[data-theme="light"] .btn-secondary:hover {
  background: var(--healing);
  color: white;
}

/* Chapter Cards */
.chapter-card {
  background: transparent;
  border: 1px solid var(--smoke);
  border-radius: 0;
  padding: var(--spacing-sm);
  margin-bottom: 1px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  display: block;
  text-decoration: none;
}

.chapter-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--healing), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.chapter-card:hover::before {
  transform: translateX(100%);
}

.chapter-card:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--healing);
}

.chapter-card h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--pearl);
}

.chapter-card .chapter-number {
  font-family: var(--font-mono);
  color: var(--steel);
  font-size: 0.9rem;
}

/* Table of Contents */
.table-of-contents {
  margin: var(--spacing-2xl) 0;
}

.toc-part {
  margin-bottom: var(--spacing-xl);
}

.toc-part h3 {
  color: var(--steel);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--spacing-md);
  font-weight: 600;
}

.chapter-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.chapter-list li {
  position: relative;
}

.chapter-list a {
  display: block;
  padding: var(--spacing-sm) var(--spacing-md);
  background: transparent;
  border-radius: 0;
  color: var(--steel);
  transition: all 0.2s ease;
  border-left: 2px solid transparent;
  font-size: 0.9rem;
}

.chapter-list a:hover {
  background: var(--ash);
  border-color: var(--healing);
  transform: translateX(4px);
  color: var(--pearl);
}

html[data-theme="light"] .chapter-list a {
  border-left: 2px solid transparent;
}

html[data-theme="light"] .chapter-list a:hover {
  background: var(--ash);
  border-color: var(--healing);
  color: var(--coal);
}

/* Special Content Blocks */
.pain-point {
  border-left: 1px solid var(--wound);
  background: rgba(220, 38, 38, 0.02);
  padding: var(--spacing-sm) var(--spacing-md);
  margin: var(--spacing-md) 0;
  font-weight: 300;
  font-size: 0.9em;
}

html[data-theme="light"] .pain-point {
  background: rgba(220, 38, 38, 0.05);
  border-left-color: var(--wound);
}

.breakthrough {
  background: rgba(14, 165, 233, 0.02);
  border: 1px solid rgba(14, 165, 233, 0.2);
  border-radius: 0;
  padding: var(--spacing-sm);
  margin: var(--spacing-md) 0;
  position: relative;
}

html[data-theme="light"] .breakthrough {
  background: rgba(14, 165, 233, 0.05);
  border: 1px solid rgba(14, 165, 233, 0.3);
}

.breakthrough::after {
  content: '↗';
  position: absolute;
  top: var(--spacing-lg);
  right: var(--spacing-lg);
  color: var(--growth);
  font-size: 24px;
}

.chapter-quote {
  border-left: 1px solid var(--bruise);
  padding-left: var(--spacing-md);
  margin: var(--spacing-lg) 0;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--steel);
  opacity: 0.8;
}

/* Documentation Blocks */
.documentation {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--smoke);
  border-radius: 0;
  padding: var(--spacing-md);
  font-family: var(--font-mono);
  font-size: 12px;
  overflow-x: auto;
  margin: var(--spacing-md) 0;
  line-height: 1.8;
}

html[data-theme="light"] .documentation {
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--smoke);
  color: var(--coal);
}

/* Chapter Content */
.chapter-content {
  max-width: var(--max-width-content);
  margin: 0 auto;
  padding: var(--spacing-xl) var(--spacing-lg);
  animation: fadeInUp 0.6s ease;
}

.chapter-header {
  margin-bottom: var(--spacing-lg);
  text-align: center;
}

.reading-time {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  color: var(--steel);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  margin-top: var(--spacing-md);
}

.chapter-body {
  font-size: 0.95rem;
  line-height: 1.65;
  font-weight: 300;
}

.chapter-body ul,
.chapter-body ol {
  margin: var(--spacing-md) 0;
  padding-left: 2rem;
}

.chapter-body li {
  margin-bottom: var(--spacing-sm);
}

.chapter-body h2 {
  color: var(--healing);
  margin-top: var(--spacing-2xl);
  margin-bottom: var(--spacing-lg);
}

/* Chapter Navigation */
.chapter-navigation {
  display: flex;
  justify-content: space-between;
  gap: var(--spacing-md);
  margin: var(--spacing-lg) 0;
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--smoke);
}

.nav-prev, .nav-next {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-xs) var(--spacing-md);
  background: transparent;
  border-radius: 0;
  color: var(--steel);
  font-weight: 300;
  transition: all 0.2s ease;
  border: 1px solid var(--smoke);
  font-size: 0.9rem;
}

.nav-prev:hover, .nav-next:hover {
  background: rgba(255, 255, 255, 0.02);
  border-color: var(--healing);
  transform: none;
  color: var(--healing);
}

html[data-theme="light"] .nav-prev:hover,
html[data-theme="light"] .nav-next:hover {
  background: var(--ash);
  border-color: var(--healing);
  color: var(--healing);
}

/* Theme Toggle */
.theme-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  border-radius: 0;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid var(--smoke);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 100;
  backdrop-filter: blur(10px);
}

html[data-theme="light"] .theme-toggle {
  background: rgba(255, 255, 255, 0.8);
  border-color: var(--smoke);
}

.theme-toggle:hover {
  background: var(--smoke);
  transform: rotate(180deg);
}

html[data-theme="light"] .theme-toggle:hover {
  background: var(--ash);
}

.theme-icon {
  font-size: 20px;
}

/* Reading Controls */
.reading-controls {
  position: fixed;
  bottom: 20px;
  left: 20px;
  display: flex;
  gap: 2px;
  background: rgba(0, 0, 0, 0.8);
  padding: 2px;
  border-radius: 0;
  border: 1px solid var(--smoke);
  z-index: 100;
  backdrop-filter: blur(10px);
}

html[data-theme="light"] .reading-controls {
  background: rgba(255, 255, 255, 0.8);
  border-color: var(--smoke);
}

.reading-controls button {
  background: transparent;
  border: none;
  color: var(--steel);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  transition: all 0.2s ease;
}

.reading-controls button:hover {
  background: var(--smoke);
  color: var(--pearl);
}

/* Coming Soon */
.coming-soon {
  background: transparent;
  border: 1px solid var(--smoke);
  border-radius: 0;
  padding: var(--spacing-md);
  text-align: center;
  margin: var(--spacing-lg) 0;
  font-size: 0.85rem;
}

.coming-soon h3 {
  color: var(--steel);
  margin-bottom: var(--spacing-sm);
}

.coming-soon p {
  color: var(--steel);
  margin: 0;
}

/* Footer */
.site-footer {
  margin-top: var(--spacing-lg);
  padding: var(--spacing-md) 0;
  border-top: 1px solid var(--smoke);
  text-align: center;
  color: var(--steel);
  font-size: 0.75rem;
}

.site-footer .quote {
  font-style: italic;
  margin-top: var(--spacing-md);
  color: var(--steel);
}

.footer-links {
  margin: var(--spacing-md) 0;
  font-size: 0.9rem;
}

.footer-links a {
  color: var(--healing);
  text-decoration: none;
  transition: all 0.2s ease;
}

.footer-links a:hover {
  color: var(--pearl);
  text-decoration: underline;
}


/* Downloads Section */
.downloads {
  margin: var(--spacing-lg) 0;
  padding: var(--spacing-lg) 0;
}

.download-header {
  text-align: center;
  margin-bottom: var(--spacing-lg);
}

.download-header h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  color: var(--pearl);
  margin-bottom: var(--spacing-xs);
  font-weight: 300;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.download-subtitle {
  color: var(--healing);
  font-size: 1.1rem;
  font-weight: 300;
}

.download-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--spacing-lg);
  max-width: 1000px;
  margin: 0 auto;
}

.download-card {
  position: relative;
  background: transparent;
  border: 1px solid var(--smoke);
  border-radius: 0;
  padding: var(--spacing-md);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all 0.2s ease;
  overflow: hidden;
  cursor: pointer;
}

.download-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, transparent 0%, var(--healing) 50%, transparent 100%);
  opacity: 0;
  transform: translateX(-100%);
  transition: all 0.6s ease;
}

.download-card:hover::before {
  opacity: 0.1;
  transform: translateX(100%);
}

.download-card:hover {
  background: rgba(255, 255, 255, 0.02);
  border-color: var(--healing);
}

html[data-theme="light"] .download-card {
  background: rgba(255, 255, 255, 0.8);
  border-color: var(--smoke);
}

html[data-theme="light"] .download-card:hover {
  background: var(--ash);
  border-color: var(--healing);
  transform: translateY(-2px);
}

.download-icon {
  font-size: 2rem;
  margin-bottom: var(--spacing-sm);
  transition: transform 0.2s ease;
  opacity: 0.8;
}

.download-card:hover .download-icon {
  transform: scale(1.1) rotate(5deg);
}

.download-format {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--pearl);
  margin-bottom: var(--spacing-xs);
  letter-spacing: -0.02em;
}

.download-note {
  font-size: 0.9rem;
  color: var(--steel);
  font-weight: 400;
}

.nested-note {
  display: inline;
  font-size: 0.8rem;
  color: var(--steel);
  opacity: 0.8;
}

/* Download card specific hover effects */
.download-card[data-format="pdf"]:hover {
  border-color: var(--wound);
  box-shadow: 0 20px 40px rgba(220, 38, 38, 0.2);
}

.download-card[data-format="epub"]:hover {
  border-color: var(--bruise);
  box-shadow: 0 20px 40px rgba(124, 58, 237, 0.2);
}

.download-card[data-format="markdown"]:hover {
  border-color: var(--growth);
  box-shadow: 0 20px 40px rgba(16, 185, 129, 0.2);
}

.download-card[data-format="text"]:hover {
  border-color: var(--pearl);
  box-shadow: 0 20px 40px rgba(228, 228, 231, 0.1);
}

.download-card[data-format="json"]:hover {
  border-color: var(--healing);
  box-shadow: 0 20px 40px rgba(14, 165, 233, 0.2);
  animation: glitch 0.3s ease;
}

.download-card[data-format="latex"]:hover {
  border-color: var(--warning);
  box-shadow: 0 20px 40px rgba(245, 158, 11, 0.2);
}

html[data-theme="light"] .download-card[data-format="pdf"]:hover {
  box-shadow: 0 10px 30px rgba(220, 38, 38, 0.15);
}

html[data-theme="light"] .download-card[data-format="epub"]:hover {
  box-shadow: 0 10px 30px rgba(124, 58, 237, 0.15);
}

html[data-theme="light"] .download-card[data-format="markdown"]:hover {
  box-shadow: 0 10px 30px rgba(16, 185, 129, 0.15);
}

html[data-theme="light"] .download-card[data-format="text"]:hover {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

html[data-theme="light"] .download-card[data-format="json"]:hover {
  box-shadow: 0 10px 30px rgba(14, 165, 233, 0.15);
}

html[data-theme="light"] .download-card[data-format="latex"]:hover {
  box-shadow: 0 10px 30px rgba(245, 158, 11, 0.15);
}

@keyframes glitch {
  0%, 100% { transform: translateY(-4px) scale(1.02); }
  20% { transform: translateY(-4px) scale(1.02) translateX(-2px); }
  40% { transform: translateY(-4px) scale(1.02) translateX(2px); }
  60% { transform: translateY(-4px) scale(1.02) translateX(-1px); }
  80% { transform: translateY(-4px) scale(1.02) translateX(1px); }
}

.download-hover-effect {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: var(--healing);
  opacity: 0.3;
  transform: translate(-50%, -50%);
  transition: width 0.6s ease, height 0.6s ease;
}

.download-card:active .download-hover-effect {
  width: 300px;
  height: 300px;
}

/* Support Section */
.support {
  background: transparent;
  border: 1px solid var(--smoke);
  padding: var(--spacing-md);
  border-radius: 0;
  text-align: center;
  margin: var(--spacing-lg) 0;
}

html[data-theme="light"] .support {
  background: rgba(255, 255, 255, 0.5);
  border-color: var(--smoke);
}

/* Official Notice */
.official-notice {
  background: rgba(220, 38, 38, 0.05);
  border: 1px solid rgba(220, 38, 38, 0.3);
  padding: var(--spacing-lg);
  margin: var(--spacing-lg) 0;
  text-align: center;
}

html[data-theme="light"] .official-notice {
  background: rgba(220, 38, 38, 0.03);
  border-color: rgba(220, 38, 38, 0.2);
}

.official-notice h2 {
  color: var(--wound);
  margin-bottom: var(--spacing-sm);
}

.official-notice strong {
  color: var(--healing);
  font-family: var(--font-mono);
}

/* Licensing Section */
.licensing {
  margin: var(--spacing-2xl) 0;
  padding: var(--spacing-lg) 0;
}

.license-tiers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--spacing-md);
  margin: var(--spacing-lg) 0;
}

.license-tier {
  background: transparent;
  border: 1px solid var(--smoke);
  padding: var(--spacing-lg);
  text-align: center;
  transition: all 0.2s ease;
}

.license-tier:hover {
  background: rgba(255, 255, 255, 0.02);
  border-color: var(--healing);
}

html[data-theme="light"] .license-tier {
  background: rgba(255, 255, 255, 0.5);
  border-color: var(--smoke);
}

html[data-theme="light"] .license-tier:hover {
  background: var(--ash);
  border-color: var(--healing);
  transform: translateY(-2px);
}

.license-tier h3 {
  font-size: 1rem;
  margin-bottom: var(--spacing-sm);
  color: var(--pearl);
  font-weight: 500;
}

.license-price {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--healing);
  margin-bottom: var(--spacing-sm);
  font-family: var(--font-mono);
}

.license-desc {
  font-size: 0.85rem;
  color: var(--steel);
  margin-bottom: var(--spacing-md);
}

.btn-license {
  display: inline-block;
  padding: var(--spacing-xs) var(--spacing-md);
  background: transparent;
  color: var(--healing);
  border: 1px solid var(--healing);
  text-decoration: none;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.2s ease;
}

.btn-license:hover {
  background: var(--healing);
  color: var(--void);
}

html[data-theme="light"] .btn-license {
  color: var(--healing);
  border-color: var(--healing);
}

html[data-theme="light"] .btn-license:hover {
  background: var(--healing);
  color: white;
}

.license-contact {
  text-align: center;
  margin-top: var(--spacing-lg);
  color: var(--steel);
}

.license-updates {
  text-align: center;
  margin: var(--spacing-md) 0;
  padding: var(--spacing-md);
  background: rgba(14, 165, 233, 0.05);
  border: 1px solid rgba(14, 165, 233, 0.3);
  border-radius: 0;
  color: var(--healing);
}

html[data-theme="light"] .license-updates {
  background: rgba(14, 165, 233, 0.08);
  border-color: rgba(14, 165, 233, 0.4);
}

.license-notice {
  margin-top: var(--spacing-sm);
  font-size: 0.8rem;
  line-height: 1.5;
}

.license-notice p {
  margin: var(--spacing-xs) 0;
  color: var(--steel);
}

.support-buttons {
  margin-top: var(--spacing-lg);
  display: flex;
  gap: var(--spacing-md);
  justify-content: center;
  flex-wrap: wrap;
}

.btn-donate {
  background: transparent;
  color: var(--healing);
  padding: 8px 24px;
  border-radius: 0;
  text-decoration: none;
  font-weight: 400;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: none;
  border: 1px solid var(--healing);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-donate:hover {
  background: var(--healing);
  color: var(--void);
  transform: none;
  box-shadow: none;
}

html[data-theme="light"] .btn-donate {
  color: var(--healing);
  border-color: var(--healing);
}

html[data-theme="light"] .btn-donate:hover {
  background: var(--healing);
  color: white;
}

/* Share Buttons */
.chapter-share {
  text-align: center;
  margin: var(--spacing-lg) 0;
}

.chapter-share p {
  margin-bottom: var(--spacing-md);
  color: var(--steel);
  font-size: 0.9rem;
}

.share-buttons {
  display: flex;
  justify-content: center;
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--smoke);
  color: var(--steel);
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

.share-btn:hover {
  color: var(--pearl);
  border-color: var(--healing);
  background: rgba(255, 255, 255, 0.02);
}

html[data-theme="light"] .share-btn {
  background: rgba(255, 255, 255, 0.5);
  border-color: var(--smoke);
  color: var(--steel);
}

html[data-theme="light"] .share-btn:hover {
  background: var(--ash);
  border-color: var(--healing);
  color: var(--coal);
}

.share-twitter:hover {
  border-color: #1DA1F2;
  color: #1DA1F2;
}

.share-linkedin:hover {
  border-color: #0077B5;
  color: #0077B5;
}

.share-email:hover {
  border-color: var(--healing);
  color: var(--healing);
}

.share-copy:hover {
  border-color: var(--growth);
  color: var(--growth);
}

.share-copy.copied {
  border-color: var(--growth);
  color: var(--growth);
  background: rgba(16, 185, 129, 0.1);
}

.share-copy.copied::after {
  content: '✓';
  position: absolute;
  font-size: 12px;
  top: -8px;
  right: -8px;
  background: var(--growth);
  color: var(--void);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Healing Gradient */
.healing-gradient {
  background: linear-gradient(180deg, 
    rgba(220, 38, 38, 0.2) 0%, 
    rgba(124, 58, 237, 0.2) 33%, 
    rgba(14, 165, 233, 0.2) 66%, 
    rgba(16, 185, 129, 0.2) 100%
  );
  height: 2px;
  width: 100%;
  margin: var(--spacing-lg) 0;
  border-radius: 0;
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading State */
.loading {
  background: linear-gradient(90deg, var(--ash), var(--smoke), var(--ash));
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

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

/* Glitch Effect */
.glitch {
  position: relative;
}

/* Mobile Navigation */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.menu-icon {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--steel);
  position: relative;
  transition: all 0.3s ease;
}

.menu-icon::before,
.menu-icon::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 2px;
  background: var(--steel);
  transition: all 0.3s ease;
}

.menu-icon::before {
  top: -8px;
}

.menu-icon::after {
  top: 8px;
}

/* Cookie Banner */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--smoke);
  padding: var(--spacing-lg);
  z-index: 1000;
  animation: slideUp 0.3s ease;
}

html[data-theme="light"] .cookie-banner {
  background: rgba(250, 250, 248, 0.98);
  border-top-color: var(--smoke);
}

.cookie-content {
  max-width: var(--max-width-content);
  margin: 0 auto;
  text-align: center;
}

.cookie-content p {
  margin-bottom: var(--spacing-md);
  color: var(--pearl);
  font-size: 0.9rem;
}

html[data-theme="light"] .cookie-content p {
  color: var(--coal);
}

.cookie-actions {
  display: flex;
  gap: var(--spacing-md);
  justify-content: center;
  flex-wrap: wrap;
}

.cookie-accept,
.cookie-decline {
  padding: var(--spacing-sm) var(--spacing-lg);
  border: 1px solid var(--smoke);
  background: var(--ash);
  color: var(--pearl);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.cookie-accept {
  background: var(--healing);
  border-color: var(--healing);
  color: var(--void);
}

.cookie-decline {
  background: var(--ash);
  border-color: var(--smoke);
  color: var(--pearl);
}

.cookie-accept:hover {
  background: var(--growth);
  border-color: var(--growth);
  color: var(--void);
  transform: translateY(-1px);
}

.cookie-decline:hover {
  background: var(--wound);
  border-color: var(--wound);
  color: var(--light);
  transform: translateY(-1px);
}

html[data-theme="light"] .cookie-accept,
html[data-theme="light"] .cookie-decline {
  background: var(--ash);
  color: var(--coal);
  border-color: var(--smoke);
}

html[data-theme="light"] .cookie-accept {
  background: var(--healing);
  border-color: var(--healing);
  color: white;
}

html[data-theme="light"] .cookie-decline {
  background: white;
  border: 1px solid var(--smoke);
  color: var(--coal);
}

html[data-theme="light"] .cookie-accept:hover {
  background: var(--growth);
  color: white;
  transform: translateY(-1px);
}

html[data-theme="light"] .cookie-decline:hover {
  background: var(--wound);
  color: white;
  transform: translateY(-1px);
}

.cookie-learn-more {
  display: inline-flex;
  align-items: center;
  color: var(--healing);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}

.cookie-learn-more:hover {
  color: var(--pearl);
  text-decoration: underline;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Legal Pages */
.last-updated {
  color: var(--steel);
  font-style: italic;
  margin-bottom: var(--spacing-xl);
}

/* Responsive Design */
@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }
  
  .nav-wrapper {
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    flex-direction: column;
    padding: var(--spacing-lg);
    gap: var(--spacing-md);
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    z-index: 99;
    border-bottom: 1px solid var(--smoke);
  }
  
  html[data-theme="light"] .nav-wrapper {
    background: rgba(250, 250, 248, 0.95);
  }
  
  .nav-wrapper.active {
    transform: translateY(0);
  }
  
  .nav-wrapper a {
    width: 100%;
    text-align: center;
    padding: var(--spacing-sm) 0;
  }
  
  .nav-read {
    margin-left: 0;
    margin-top: var(--spacing-sm);
  }
  
  .download-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--spacing-md);
  }
  
  .license-tiers {
    grid-template-columns: 1fr;
  }
  
  .support-buttons {
    flex-direction: column;
    width: 100%;
  }
  
  .btn-donate {
    width: 100%;
  }
  
  .hero-actions {
    flex-direction: column;
    width: 100%;
  }
  
  .btn {
    width: 100%;
  }
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.glitch::before {
  animation: glitch-1 0.5s infinite;
  color: var(--wound);
  z-index: -1;
}

.glitch::after {
  animation: glitch-2 0.5s infinite;
  color: var(--healing);
  z-index: -2;
}

@keyframes glitch-1 {
  0%, 100% { clip-path: inset(0 0 0 0); transform: translate(0); }
  20% { clip-path: inset(20% 0 30% 0); transform: translate(-2px, 2px); }
}

@keyframes glitch-2 {
  0%, 100% { clip-path: inset(0 0 0 0); transform: translate(0); }
  20% { clip-path: inset(60% 0 10% 0); transform: translate(2px, -2px); }
}

/* Bookmark Indicator */
.bookmark-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.95);
  border: 1px solid var(--smoke);
  padding: var(--spacing-sm) var(--spacing-lg);
  border-radius: 0;
  box-shadow: none;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  color: var(--pearl);
  font-weight: 300;
}

.bookmark-indicator.show {
  opacity: 1;
  visibility: visible;
}

/* Starfield Mobile Optimizations */
@media (max-width: 768px) {
  .star-layer:nth-child(3),
  .star-layer:nth-child(4) {
    display: none; /* Reduce star layers on mobile */
  }
  
  .star {
    animation-duration: calc(6s + var(--star-x, 0) * 0.1s); /* Slower animations */
  }
}

/* Mobile Responsive */
@media (max-width: 768px) {
  body { 
    font-size: 16px; 
  }
  
  .container, .container-wide { 
    padding: 0 16px; 
  }
  
  h1 {
    font-size: 2rem;
  }
  
  .hero {
    padding: var(--spacing-xl) 0;
  }
  
  .hero-actions {
    flex-direction: column;
    width: 100%;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
  
  .chapter-navigation {
    flex-direction: column;
    gap: var(--spacing-sm);
  }
  
  .nav-prev, .nav-next {
    width: 100%;
    justify-content: center;
  }
  
  .theme-toggle {
    bottom: 80px;
  }
  
  .reading-controls {
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
  }
  
  .pain-point {
    margin-left: 0;
    margin-right: 0;
    border-radius: 8px;
  }
  
  .download-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
  }
  
  .download-card {
    padding: var(--spacing-lg) var(--spacing-md);
  }
  
  .download-icon {
    font-size: 2.5rem;
  }
}

/* Menu Toggle (Mobile) */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--spacing-xs);
}

.menu-icon {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--pearl);
  position: relative;
  transition: all 0.3s ease;
}

.menu-icon::before,
.menu-icon::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: var(--pearl);
  left: 0;
  transition: all 0.3s ease;
}

.menu-icon::before { top: -8px; }
.menu-icon::after { top: 8px; }

@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }
  
  .nav-wrapper {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--coal);
    border-bottom: 1px solid var(--smoke);
    flex-direction: column;
    padding: var(--spacing-md);
  }
  
  .nav-wrapper.active {
    display: flex;
  }
}

/* Font size modifiers */
body.font-size-small { font-size: 15px; }
body.font-size-large { font-size: 19px; }
body.font-size-xlarge { font-size: 21px; }

/* Line height modifiers */
body.line-height-expanded .chapter-body {
  line-height: 2;
}

/* Print styles */
@media print {
  body {
    background: white;
    color: black;
  }
  
  .site-header,
  .site-footer,
  .chapter-navigation,
  .chapter-feedback,
  .support-cta,
  .progress-bar,
  .reading-controls,
  .theme-toggle {
    display: none;
  }
}