/* ==========================================================================
   SURCROISSANCE DE LA CHINE — DESIGN SYSTEM & STYLESHEET
   Style Didactique, Éditorial & Moderne
   ========================================================================== */

:root {
  /* Palette Chromatique - Thème Sombre par Défaut */
  --bg-primary: #0a0d14;
  --bg-secondary: #121722;
  --bg-tertiary: #1a2233;
  --bg-card: rgba(22, 29, 44, 0.75);
  --bg-card-hover: rgba(28, 38, 58, 0.9);
  --bg-glass: rgba(18, 23, 34, 0.85);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(225, 46, 46, 0.3);
  --border-focus: rgba(245, 158, 11, 0.5);

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-highlight: #ffffff;

  /* Couleurs Sémantiques & Accents */
  --accent-red: #ef4444;
  --accent-red-glow: rgba(239, 68, 68, 0.25);
  --accent-crimson: #dc2626;
  --accent-amber: #f59e0b;
  --accent-amber-glow: rgba(245, 158, 11, 0.2);
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-purple: #8b5cf6;

  /* Typographie */
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-serif: 'Newsreader', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Rayons et Ombres */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 35px rgba(239, 68, 68, 0.2);

  --transition-fast: 0.18s ease;
  --transition-normal: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Mode Clair (Commutable) */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-tertiary: #e2e8f0;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.98);
  --bg-glass: rgba(255, 255, 255, 0.85);

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-accent: rgba(220, 38, 38, 0.2);
  --border-focus: rgba(217, 119, 6, 0.4);

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
  --text-highlight: #020617;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 35px rgba(239, 68, 68, 0.12);
}

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

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.7;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 10%, rgba(239, 68, 68, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 85% 60%, rgba(6, 182, 212, 0.04) 0%, transparent 45%);
  background-attachment: fixed;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Barre de progression de lecture */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-red), var(--accent-amber), var(--accent-cyan));
  z-index: 1000;
  transition: width 0.1s ease-out;
}

/* Header & Navigation Sticky */
.navbar {
  position: sticky;
  top: 0;
  z-index: 900;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border-subtle);
  transition: var(--transition-normal);
}

.nav-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-highlight);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.nav-brand-badge {
  background: linear-gradient(135deg, var(--accent-red), var(--accent-crimson));
  color: #fff;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 8px var(--accent-red-glow);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.nav-links a:hover, .nav-links a.active {
  color: var(--text-highlight);
  background: var(--bg-tertiary);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-icon {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-amber);
  color: var(--accent-amber);
}

/* Hero Section */
.hero {
  padding: 4.5rem 1.5rem 3.5rem;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border-subtle);
}

.hero-container {
  max-width: 1200px;
  margin: 0 auto;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-red {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-amber {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-cyan {
  background: rgba(6, 182, 212, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.hero-title {
  font-family: var(--font-sans);
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 1.25rem;
  color: var(--text-highlight);
}

.hero-title span {
  background: linear-gradient(135deg, #ef4444 0%, #f59e0b 60%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-style: italic;
  color: var(--text-muted);
  max-width: 860px;
  margin-bottom: 2rem;
  line-height: 1.6;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.9rem;
  color: var(--text-dim);
}

.hero-meta-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hero-meta-item strong {
  color: var(--text-main);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: linear-gradient(135deg, var(--accent-red), var(--accent-crimson));
  color: #ffffff;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: var(--transition-normal);
  box-shadow: 0 4px 16px var(--accent-red-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.4);
}

/* Grille de Chiffres Clés (Didactique) */
.stats-section {
  padding: 3rem 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

.stats-grid {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-red);
  opacity: 0.6;
}

.stat-card:nth-child(2)::before { background: var(--accent-amber); }
.stat-card:nth-child(3)::before { background: var(--accent-cyan); }
.stat-card:nth-child(4)::before { background: var(--accent-purple); }
.stat-card:nth-child(5)::before { background: var(--accent-emerald); }

.stat-card:hover {
  transform: translateY(-4px);
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
}

.stat-value {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-highlight);
  margin-bottom: 0.4rem;
}

.stat-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.3rem;
}

.stat-desc {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.4;
}

/* Conteneur Principal Didactique (2 Colonnes) */
.main-layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2.5rem;
  align-items: start;
}

@media (max-width: 992px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

/* Sommaire Latéral Didactique (Sticky) */
.sidebar-toc {
  position: sticky;
  top: 5.5rem;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

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

.toc-title {
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.toc-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition-fast);
}

.toc-link:hover, .toc-link.active {
  color: var(--accent-red);
  background: var(--bg-tertiary);
  transform: translateX(4px);
}

.toc-link.active {
  font-weight: 700;
  border-left: 3px solid var(--accent-red);
}

/* Contenu Central */
.content-area {
  min-width: 0;
}

/* Boîtes Pédagogiques & Callouts */
.callout {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--accent-cyan);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  margin: 1.75rem 0;
  backdrop-filter: blur(8px);
}

.callout-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-highlight);
  margin-bottom: 0.5rem;
}

.callout-red {
  border-left-color: var(--accent-red);
}

.callout-amber {
  border-left-color: var(--accent-amber);
}

/* Sections & Titres */
.section-block {
  margin-bottom: 4rem;
  scroll-margin-top: 5rem;
}

.section-tag {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-amber);
  margin-bottom: 0.5rem;
}

.section-heading {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-highlight);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.lead-p {
  font-size: 1.15rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 1.75rem;
}

/* Timeline Interactive des 6 Séquences */
.timeline {
  position: relative;
  margin: 2.5rem 0;
}

.timeline::before {
  content: '';
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 24px;
  width: 2px;
  background: linear-gradient(180deg, var(--accent-red), var(--accent-amber), var(--accent-cyan));
  opacity: 0.3;
}

.timeline-item {
  position: relative;
  padding-left: 60px;
  margin-bottom: 2rem;
}

.timeline-dot {
  position: absolute;
  left: 14px;
  top: 12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 3px solid var(--accent-red);
  box-shadow: 0 0 12px var(--accent-red-glow);
  z-index: 2;
  transition: var(--transition-fast);
}

.timeline-item:hover .timeline-dot {
  transform: scale(1.2);
  border-color: var(--accent-amber);
}

.timeline-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  transition: var(--transition-normal);
}

.timeline-card:hover {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.timeline-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.timestamp-pill {
  font-family: var(--font-mono);
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.25);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 700;
}

.timeline-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-highlight);
}

.timeline-body p {
  color: var(--text-muted);
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

/* Citations immersives */
.quote-box {
  background: rgba(0, 0, 0, 0.25);
  border-left: 3px solid var(--accent-amber);
  padding: 0.85rem 1.2rem;
  margin: 1rem 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--text-highlight);
}

.quote-author {
  display: block;
  font-family: var(--font-sans);
  font-style: normal;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.4rem;
  font-weight: 600;
}

/* Tags de personnages / lieux */
.entity-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1rem;
}

.entity-tag {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

/* Grille du Plan Directeur (Axes I à V) */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.plan-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  transition: var(--transition-normal);
  display: flex;
  flex-direction: column;
}

.plan-card:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.plan-num {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--accent-red);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.plan-card-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-highlight);
  margin-bottom: 1rem;
  line-height: 1.3;
}

.plan-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.plan-list li {
  font-size: 0.9rem;
  color: var(--text-muted);
  position: relative;
  padding-left: 1.25rem;
  line-height: 1.5;
}

.plan-list li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--accent-amber);
}

/* Tableaux Didactiques */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  margin: 2rem 0;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.custom-table th {
  background: var(--bg-tertiary);
  color: var(--text-highlight);
  font-weight: 700;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.custom-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-muted);
  line-height: 1.6;
}

.custom-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Grille du Lexique Interactif */
.glossary-controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.75rem 1.2rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-fast);
}

.search-input:focus {
  border-color: var(--accent-red);
  box-shadow: 0 0 0 3px var(--accent-red-glow);
}

.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.glossary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.4rem;
  transition: var(--transition-fast);
}

.glossary-card:hover {
  border-color: var(--border-focus);
  transform: translateY(-2px);
}

.glossary-term {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-highlight);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.3rem;
}

.glossary-pinyin {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-amber);
  margin-bottom: 0.75rem;
}

.glossary-def {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Bouton Scroll to Top (Flèche vers le haut) */
#back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-red), var(--accent-crimson));
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 6px 20px var(--accent-red-glow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: all var(--transition-normal);
  z-index: 999;
}

#back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

#back-to-top:hover {
  background: linear-gradient(135deg, #f87171, var(--accent-red));
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 10px 25px rgba(239, 68, 68, 0.45);
}

/* Footer Pédagogique Conforme aux Exigences */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  padding: 3rem 1.5rem 2rem;
  margin-top: 5rem;
  font-size: 0.9rem;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.5rem;
}

.footer-quote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 650px;
}

.footer-mandate {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-highlight);
}

.footer-mandate a {
  color: var(--accent-cyan);
  text-decoration: none;
  transition: var(--transition-fast);
}

.footer-mandate a:hover {
  text-decoration: underline;
  color: #67e8f9;
}

.footer-mandate .separator {
  color: var(--text-dim);
}

.footer-sub {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Responsive */
@media (max-width: 768px) {
  .nav-links {
    display: none;
  }
  .hero-title {
    font-size: 2rem;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .timeline::before {
    left: 15px;
  }
  .timeline-item {
    padding-left: 45px;
  }
  .timeline-dot {
    left: 5px;
  }
}
