/*
 * Qantar 2022 — Documentary Chronicle Platform
 * Brutalist documentary aesthetic — dark header, red accent, stencil-inspired
 * Oswald (display) + Inter (body), Red accent (#a83232), Gold documentary (#8a6914)
 */

/* ==============================
   1. VARIABLES & RESET
   ============================== */

:root {
  /* Core palette — light */
  --bg: #fafaf8;
  --bg-warm: #f5f2ed;
  --surface: #ffffff;
  --surface-elevated: #fdfcfa;
  --text: #1a1714;
  --text-secondary: #4a4540;
  --text-muted: #7a7570;
  --accent: #a83232;
  --accent-hover: #c43b3b;
  --accent-muted: rgba(168,50,50,0.08);
  --border: #e5e2dd;
  --border-light: #edeae6;

  /* Documentary palette */
  --gold: #8a6914;
  --gold-light: rgba(138,105,20,0.08);
  --red-accent: #8b2020;
  --red-muted: rgba(139,32,32,0.12);

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.03);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);

  /* Radii */
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Transitions */
  --transition: 0.18s ease;
  --transition-slow: 0.3s cubic-bezier(0.4,0,0.2,1);

  /* Semantic */
  --success: #38a169;
  --warning: #d69e2e;
  --danger: #e53e3e;
  --info: #4299e1;

  /* Fonts */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Oswald', 'Arial Narrow', sans-serif;
  --font-serif: 'Source Serif 4', 'Georgia', 'Times New Roman', serif;

  /* Layout */
  --header-h: 60px;
  --max-w: 1200px;
  --content-w: 800px;
  --page-px: clamp(1rem, 3vw, 2rem);

  /* Footer */
  --footer-bg: #1a1714;
  --footer-text: #a09c97;
}

[data-theme="dark"] {
  --bg: #0c0b09;
  --bg-warm: #12110e;
  --surface: #1a1815;
  --surface-elevated: #201e1a;
  --text: #e8e5e0;
  --text-secondary: #a09c97;
  --text-muted: #6b6660;
  --accent-hover: #d44a4a;
  --accent-muted: rgba(168,50,50,0.18);
  --border: #2a2722;
  --border-light: #22201c;
  --gold: #c8a84e;
  --gold-light: rgba(200,168,78,0.12);
  --red-muted: rgba(139,32,32,0.25);
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.25);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.35);
  --footer-bg: #08080a;
  --footer-text: #6b6660;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }
ul, ol { list-style: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
.skip-link {
  position: absolute; top: -9999px; left: -9999px;
  background: var(--accent); color: #fff; padding: 0.5rem 1rem;
  z-index: 9999;
}
.skip-link:focus { top: 0; left: 0; }


/* ==============================
   2. HEADER & NAVIGATION
   ============================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(20,18,15,0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  height: var(--header-h);
}
[data-theme="dark"] .site-header {
  background: rgba(8,8,6,0.96);
  border-bottom-color: rgba(255,255,255,0.04);
}
.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--page-px);
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

/* Logo */
.site-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.logo-img {
  height: 38px;
  width: auto;
  object-fit: contain;
  transition: opacity var(--transition);
}
.site-logo:hover .logo-img {
  opacity: 0.85;
}

/* Main nav */
.main-nav { flex: 1; overflow: hidden; }
.nav-list {
  display: flex;
  gap: 0.15rem;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-list::-webkit-scrollbar { display: none; }
.nav-link {
  display: block;
  padding: 0.35rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: var(--transition);
}
.nav-link:hover {
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.06);
}
.nav-link.active {
  color: #fff;
  background: rgba(168,50,50,0.25);
  font-weight: 600;
}

/* Language switcher */
.lang-switch {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.lang-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255,255,255,0.4);
  border-radius: 3px;
  transition: var(--transition);
  letter-spacing: 0.02em;
}
.lang-btn:hover { color: rgba(255,255,255,0.8); }
.lang-btn.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

/* Theme toggle */
.theme-toggle {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.08);
  transition: var(--transition);
  flex-shrink: 0;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.6);
}
.theme-toggle:hover { background: rgba(255,255,255,0.15); color: #fff; }

/* Hamburger */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  flex-shrink: 0;
}
.hamburger-line {
  width: 20px; height: 2px;
  background: rgba(255,255,255,0.7);
  border-radius: 1px;
  transition: var(--transition);
}
.nav-toggle.is-active .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(4px, 4px);
}
.nav-toggle.is-active .hamburger-line:nth-child(2) { opacity: 0; }
.nav-toggle.is-active .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(4px, -4px);
}


/* ==============================
   3. PAGE HEADER (hero sections)
   ============================== */

.page-header {
  background: #1a1714;
  border-bottom: 3px solid var(--accent);
  padding: 3rem 0 2.5rem;
  margin-bottom: 2rem;
}
.page-header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--page-px);
}
.page-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #f0ece6;
  margin-bottom: 0.5rem;
}
.page-subtitle {
  font-size: 1rem;
  color: rgba(240,236,230,0.5);
  max-width: 560px;
  line-height: 1.5;
}


/* ==============================
   4. STATISTICS DASHBOARD
   ============================== */

.stats-dashboard {
  max-width: var(--max-w);
  margin: 0 auto 2rem;
  padding: 0 var(--page-px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
.stat-item {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
  transition: var(--transition);
}
.stat-item:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.stat-number {
  display: block;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
  margin-bottom: 0.25rem;
}
.stat-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}


/* ==============================
   5. DAY NAVIGATION TABS
   ============================== */

.day-tab-nav {
  max-width: var(--max-w);
  margin: 0 auto 1.5rem;
  padding: 0 var(--page-px);
}
.day-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
}
.day-tabs::-webkit-scrollbar { height: 3px; }
.day-tabs::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.day-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
  min-width: 52px;
  flex-shrink: 0;
}
.day-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-muted);
}
.day-tab.active,
.day-tab[aria-current="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.day-tab-num {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1;
}
.day-tab-month {
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}


/* ==============================
   6. SEARCH & FILTERS
   ============================== */

.search-bar {
  max-width: var(--max-w);
  margin: 0 auto 1rem;
  padding: 0 var(--page-px);
  position: relative;
}
.search-bar input {
  width: 100%;
  padding: 0.7rem 1rem;
  padding-right: 3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.9rem;
  color: var(--text);
  transition: var(--transition);
  font-family: var(--font-body);
}
.search-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-clear {
  position: absolute;
  right: calc(var(--page-px) + 0.75rem);
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2rem;
  color: var(--text-muted);
  display: none;
  padding: 0.25rem;
}
.search-count {
  position: absolute;
  right: calc(var(--page-px) + 2.5rem);
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Filter bar */
.filter-bar {
  max-width: var(--max-w);
  margin: 0 auto 1.5rem;
  padding: 0 var(--page-px);
}
.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.filter-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 0.25rem;
}
.filter-pill {
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 2rem;
  transition: var(--transition);
  white-space: nowrap;
}
.filter-pill:hover {
  border-color: var(--border);
  color: var(--text);
  background: var(--surface-elevated);
}
.filter-pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Year nav (backward compat) */
.year-nav {
  max-width: var(--max-w);
  margin: 0 auto 1rem;
  padding: 0 var(--page-px);
  display: flex;
  gap: 0.75rem;
}
.year-link {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
}
.year-link:hover, .year-link.active {
  color: var(--accent);
  background: var(--accent-muted);
}


/* ==============================
   7. TIMELINE — Main content
   ============================== */

.timeline-layout {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--page-px) 3rem;
}

.date-section {
  margin-bottom: 2.5rem;
}

.date-header {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text);
  padding: 0.75rem 0;
  border-bottom: 2px solid var(--accent);
  margin-bottom: 1rem;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.event-count {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}
.date-link-btn {
  margin-left: auto;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent);
}
.date-link-btn:hover { text-decoration: underline; }

/* Timeline cards */
.timeline-item {
  margin-bottom: 0.75rem;
}

.timeline-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--red-accent);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  transition: var(--transition);
}
.timeline-card:hover {
  border-color: var(--border);
  border-left-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* Card header */
.card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

/* Category badge */
.category-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
  border-radius: 3px;
  line-height: 1.4;
}
.category-badge--sm {
  font-size: 0.62rem;
  padding: 0.1rem 0.45rem;
}

/* Timeline date/time */
.timeline-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}
.event-time {
  font-weight: 600;
  color: var(--gold);
  margin-left: 0.35rem;
}
.importance-badge {
  color: var(--red-accent);
  font-size: 0.6rem;
}

/* Description */
.timeline-description {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text);
  margin-bottom: 0.5rem;
}

/* Photo gallery in events */
.event-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
  margin: 0.75rem 0;
}
.event-gallery--compact {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.4rem;
}
.gallery-item {
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-warm);
}
.gallery-item img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.gallery-item:hover img {
  transform: scale(1.03);
}
.gallery-item figcaption {
  padding: 0.3rem 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.gallery-item figcaption .credit {
  font-style: italic;
  opacity: 0.7;
}
.gallery-more {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-warm);
  border-radius: var(--radius-sm);
  min-height: 120px;
}

/* Card meta */
.card-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.meta-location { white-space: nowrap; }
.tag-list { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.tag-badge {
  padding: 0.1rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 500;
  background: var(--bg-warm);
  color: var(--text-secondary);
  border-radius: 3px;
  transition: var(--transition);
}
a.tag-badge:hover { background: var(--accent-muted); color: var(--accent); }

/* Source link */
.event-source {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 500;
}
.event-source:hover { text-decoration: underline; }

/* Event details (accordion) */
.event-details {
  margin-top: 0.5rem;
  border-top: 1px solid var(--border-light);
  padding-top: 0.5rem;
}
.event-details summary {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  padding: 0.25rem 0;
}
.event-details summary:hover { text-decoration: underline; }
.details-content {
  padding: 0.75rem 0;
}
.detail-section { margin-bottom: 0.75rem; }
.detail-section h4 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.person-list li {
  font-size: 0.85rem;
  padding: 0.15rem 0;
  color: var(--text);
}
.event-media {
  max-width: 400px;
  border-radius: var(--radius-sm);
  margin: 0.5rem 0;
}
.media-link {
  font-size: 0.85rem;
  font-weight: 500;
}
.media-caption {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state p {
  font-size: 1rem;
  margin-bottom: 1rem;
}

/* Load more */
.load-more-container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1rem var(--page-px) 2rem;
  text-align: center;
}
.load-more-btn {
  padding: 0.6rem 2rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: transparent;
  transition: var(--transition);
}
.load-more-btn:hover {
  background: var(--accent);
  color: #fff;
}


/* ==============================
   8. SECTION PAGE
   ============================== */

.section-hero {
  background: #1a1714;
  border-bottom: 3px solid var(--accent);
  padding: 3rem 0 2.5rem;
}
.section-hero-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--page-px);
}
.section-hero-icon {
  display: block;
  font-size: 2rem;
  margin-bottom: 0.75rem;
  filter: grayscale(0.3);
}
.section-hero-title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #f0ece6;
  margin-bottom: 0.5rem;
}
.section-hero-sub {
  font-size: 0.95rem;
  color: rgba(240,236,230,0.5);
  max-width: 560px;
  line-height: 1.5;
}

/* Breadcrumb */
.breadcrumb {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1rem var(--page-px);
  font-size: 0.78rem;
  color: var(--text-muted);
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb-sep { margin: 0 0.4rem; opacity: 0.5; }

/* Section layout: sidebar + content */
.section-page-layout {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--page-px) 3rem;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2rem;
}

/* Sidebar */
.sections-sidebar {
  position: sticky;
  top: calc(var(--header-h) + 1rem);
  align-self: start;
}
.sidebar-heading {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.sidebar-link:hover {
  background: var(--accent-muted);
  color: var(--text);
}
.sidebar-link.active {
  background: var(--accent-muted);
  color: var(--accent);
  font-weight: 600;
}
.sidebar-icon { font-size: 1rem; flex-shrink: 0; width: 1.2rem; text-align: center; }

/* Section content */
.section-richtext {
  max-width: var(--content-w);
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text);
}
.section-richtext p {
  margin-bottom: 1rem;
}
.section-richtext p:first-child::first-letter {
  font-family: var(--font-display);
  font-size: 3.2em;
  float: left;
  line-height: 0.8;
  margin-right: 0.1em;
  margin-top: 0.05em;
  color: var(--text);
  font-weight: 900;
}

.section-placeholder {
  padding: 2rem 0;
}
.placeholder-text {
  color: var(--text-muted);
  font-style: italic;
}

/* Subsections grid */
.subsections-heading {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 2rem 0 1rem;
  color: var(--text);
}
.subsections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.subsection-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: var(--transition);
  color: var(--text);
}
.subsection-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  color: var(--text);
}
.subsection-icon { font-size: 1.5rem; margin-bottom: 0.5rem; display: block; }
.subsection-card h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.subsection-card p {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* Related events */
.related-heading {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin: 2rem 0 1rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--text);
}
.related-list { display: flex; flex-direction: column; gap: 2px; }
.related-item {}
.related-link {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: var(--transition);
  font-size: 0.88rem;
  line-height: 1.45;
}
.related-link:hover {
  background: var(--surface-elevated);
  color: var(--text);
}
.related-date {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gold);
  min-width: 80px;
  white-space: nowrap;
}
.related-time {
  font-weight: 500;
  margin-left: 0.3rem;
}
.related-desc {
  flex: 1;
}
.related-all-link {
  margin-top: 1rem;
  display: inline-block;
}


/* ==============================
   9. DAY PAGE
   ============================== */

/* Day hero */
.day-hero {
  background: var(--bg-warm);
  border-bottom: 1px solid var(--border-light);
  padding: 2.5rem 0 2rem;
}
.day-hero-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--page-px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.day-hero-date {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.day-hero-num {
  font-family: var(--font-display);
  font-size: clamp(3rem, 8vw, 5rem);
  font-weight: 900;
  line-height: 1;
  color: var(--text);
}
.day-hero-meta {
  display: flex;
  flex-direction: column;
}
.day-hero-month {
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  letter-spacing: 0.02em;
}
.day-hero-year {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.day-hero-weekday {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}
.day-hero-stats {
  text-align: right;
}
.day-stat {
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.day-stat strong {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--text);
  display: block;
  line-height: 1.1;
}

/* Day prev/next navigation */
.day-prev-next {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1rem var(--page-px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.day-nav-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: var(--text-secondary);
  transition: var(--transition);
  text-decoration: none;
  min-width: 100px;
}
.day-nav-btn:hover { background: var(--surface); color: var(--text); }
.day-nav-btn.prev { justify-content: flex-start; }
.day-nav-btn.next { justify-content: flex-end; text-align: right; }
.day-nav-btn.disabled { visibility: hidden; }
.nav-arrow { font-size: 1.1rem; color: var(--text-muted); }
.nav-text { display: flex; flex-direction: column; }
.nav-hint { font-size: 0.7rem; color: var(--text-muted); }
.nav-date { font-weight: 600; }

/* Day tabs inline */
.day-tabs-inline {
  display: flex;
  gap: 3px;
  flex: 1;
  justify-content: center;
  overflow-x: auto;
  scrollbar-width: none;
}
.day-tabs-inline::-webkit-scrollbar { display: none; }
.day-tab-mini {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 50%;
  transition: var(--transition);
  flex-shrink: 0;
}
.day-tab-mini:hover { background: var(--surface); color: var(--text); }
.day-tab-mini.active {
  background: var(--accent);
  color: #fff;
}

/* Day photo gallery */
.day-gallery {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.5rem var(--page-px);
}
.gallery-heading {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
}
.gallery-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
}
.gallery-strip-item {
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-warm);
}
.gallery-strip-item img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.gallery-strip-item:hover img { transform: scale(1.04); }
.gallery-strip-item figcaption {
  padding: 0.35rem 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Day events stream */
.day-events {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--page-px) 2rem;
}
.day-events-inner {
  max-width: var(--content-w);
}
.day-events-heading {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--text);
}

/* Hourly stream */
.hourly-stream { padding-left: 0; }
.hour-item {
  display: grid;
  grid-template-columns: 56px 24px 1fr;
  gap: 0;
  min-height: 60px;
  margin-bottom: 0;
}
.hour-item:last-child .hour-line { display: none; }

.hour-time {
  text-align: right;
  padding-top: 1rem;
  padding-right: 0.5rem;
}
.hour-clock {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.hour-clock--unknown { color: var(--text-muted); font-weight: 400; }

.hour-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 1.15rem;
}
.hour-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--surface);
  flex-shrink: 0;
  z-index: 1;
}
.hour-dot--major {
  background: var(--red-accent);
  width: 12px; height: 12px;
}
.hour-line {
  width: 2px;
  flex: 1;
  background: var(--border-light);
  min-height: 20px;
}

.hour-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 0.35rem 0;
  transition: var(--transition);
}
.hour-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.hour-item--major .hour-card {
  border-left: 3px solid var(--red-accent);
}

.hour-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.hour-card-text {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 0.4rem;
}

/* Day bottom nav */
.day-bottom-nav {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.5rem var(--page-px);
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}


/* ==============================
   10. BUTTONS
   ============================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius);
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}


/* ==============================
   11. FOOTER
   ============================== */

.site-footer {
  background: var(--footer-bg);
  color: var(--footer-text);
  padding: 3rem 0 2rem;
  margin-top: 2rem;
}
.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--page-px);
  text-align: center;
}
.footer-memorial {
  font-family: var(--font-display);
  font-size: 1rem;
  color: #c9a862;
  margin-bottom: 1.5rem;
  letter-spacing: 0.02em;
}
.memorial-mark {
  color: #c9a862;
  margin-right: 0.35rem;
  font-size: 1.15em;
}
.memorial-aya {
  display: block;
  font-family: 'Noto Naskh Arabic', 'Scheherazade New', serif;
  font-size: 0.95rem;
  color: #c9a862;
  opacity: 0.75;
  margin-top: 0.3rem;
  letter-spacing: 0;
}
.footer-nav {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.footer-nav a {
  font-size: 0.8rem;
  color: var(--footer-text);
  transition: var(--transition);
}
.footer-nav a:hover { color: #e8e5e0; }
.footer-brand {
  font-size: 0.75rem;
  color: #5a5550;
}


/* ==============================
   12. BACK TO TOP
   ============================== */

.back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: var(--transition-slow);
  z-index: 50;
}
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.back-to-top:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}


/* ==============================
   13. MINIMAP SECTION (timeline page)
   ============================== */

.minimap-section {
  max-width: var(--max-w);
  margin: 0 auto 2rem;
  padding: 0 var(--page-px);
}
.minimap-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.minimap-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.minimap-link {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 500;
}
.minimap-link:hover { text-decoration: underline; }
.minimap-container {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: relative;
}
#minimap { width: 100%; height: 260px; }
.minimap-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40px;
  background: linear-gradient(transparent, var(--bg));
  pointer-events: none;
  z-index: 500;
}

/* Leaflet popup styling */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-lg) !important;
  border: 1px solid var(--border-light) !important;
}
.leaflet-popup-content {
  margin: 10px 14px !important;
  font-size: 0.82rem;
  line-height: 1.5;
  color: #1a1a1a;
}
.minimap-popup-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
  margin: 0 0 2px;
}
.minimap-popup-count {
  font-size: 0.75rem;
  color: #666;
}


/* ==============================
   14. BOTTOM DAY NAV (section pages)
   ============================== */

.bottom-day-nav {
  background: var(--bg-warm);
  border-top: 1px solid var(--border-light);
  padding: 2rem 0;
  margin-top: 1rem;
}
.bottom-day-nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--page-px);
}
.bottom-nav-heading {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  text-align: center;
}
.day-tabs-row {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}


/* ==============================
   15. RESPONSIVE
   ============================== */

@media (max-width: 768px) {
  .nav-toggle { display: flex; }

  .main-nav {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-slow);
    z-index: 99;
    padding: 0.5rem;
  }
  .main-nav.nav-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .nav-list {
    flex-direction: column;
    gap: 2px;
  }
  .nav-link {
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
  }

  .stats-dashboard {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .section-page-layout {
    grid-template-columns: 1fr;
  }
  .sections-sidebar {
    position: static;
    order: -1;
    margin-bottom: 1rem;
  }
  .sidebar-nav {
    flex-direction: row;
    gap: 0.35rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
  }
  .sidebar-link { white-space: nowrap; font-size: 0.78rem; }

  .day-hero-inner { flex-direction: column; text-align: center; }
  .day-hero-date { justify-content: center; }
  .day-hero-stats { text-align: center; }

  .day-prev-next { gap: 0.25rem; }
  .day-nav-btn { min-width: auto; padding: 0.35rem 0.5rem; font-size: 0.75rem; }

  #minimap { height: 200px; }
  .minimap-section { margin-bottom: 1.5rem; }

  .gallery-strip { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

  .hour-item { grid-template-columns: 44px 20px 1fr; }
  .hour-clock { font-size: 0.75rem; }
  .hour-card { padding: 0.65rem 0.75rem; }
}

@media (max-width: 480px) {
  .stats-dashboard {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  .stat-item { padding: 0.75rem 0.5rem; }
  .stat-number { font-size: 1.5rem; }

  .day-hero-num { font-size: 3rem; }
  .day-tabs-inline { gap: 1px; }
  .day-tab-mini { width: 28px; height: 28px; font-size: 0.68rem; }

  .section-richtext p:first-child::first-letter {
    font-size: 2.5em;
  }
}

/* Print */
@media print {
  .site-header, .site-footer, .back-to-top, .nav-toggle,
  .search-bar, .filter-bar, .minimap-section, .day-tab-nav,
  .day-prev-next, .day-tabs-inline, .theme-toggle, .lang-switch { display: none; }
  body { background: #fff; color: #000; font-size: 12px; }
  .timeline-card, .hour-card { border: 1px solid #ccc; break-inside: avoid; }
}

/* ==============================
   16. QA FIXES (ALL 24 ISSUES)
   ============================== */

/* Importance visual differentiation */
.timeline-card--important {
  border-left: 3px solid var(--red-accent) !important;
  background: var(--red-muted) !important;
}
.timeline-card--important:hover {
  border-left-color: var(--red-accent) !important;
}

/* Hidden / animation classes */
.hidden { display: none !important; }
.load-hidden { display: none !important; }
.fade-ready { opacity: 0; transform: translateY(12px); transition: opacity 0.4s ease, transform 0.4s ease; }
.fade-in { opacity: 1 !important; transform: translateY(0) !important; }

/* Photo credit */
.gallery-item figcaption .credit {
  font-style: italic;
  opacity: 0.7;
}

/* Year-nav hide if single year */
.year-nav:has(.year-link:only-child) {
  display: none;
}

/* Fix #4: mobile sidebar overflow */
.sections-sidebar {
  max-width: 100%;
  overflow-x: auto;
}
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }
  .sections-sidebar {
    width: 100%;
    max-width: 100vw;
  }
  .sidebar-nav {
    flex-wrap: nowrap;
    max-width: 100%;
  }
}

/* Fix #8: single photo wider */
.event-gallery--single {
  max-width: 100%;
}
.event-gallery--single .gallery-item img {
  height: auto;
  max-height: 300px;
}

/* Fix #13: hamburger overflow on mobile */
@media (max-width: 768px) {
  .header-inner {
    gap: 0.5rem;
    padding: 0 0.75rem;
  }
  .lang-switch {
    display: none;
  }
  .main-nav.nav-open .lang-switch-mobile {
    display: flex;
  }
  .nav-toggle {
    margin-left: auto;
  }
  /* Ensure nothing overflows */
  .site-header {
    overflow: hidden;
  }
}

/* Fix #14: dot indicator legend — show legend description */
.legend-row {
  padding: 0.5rem 0;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

/* Fix #15: "подробно" more prominent */
.event-details summary {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  padding: 0.35rem 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Fix #16: location vs topic tags identical — differentiate */
.meta-location {
  color: var(--text-muted);
  font-weight: 500;
}
.tag-badge {
  background: var(--accent-muted);
  color: var(--accent);
  font-weight: 500;
}

/* Fix #17: unbalanced photo grid */
.event-gallery {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.event-gallery--compact {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

/* Fix #20: Qantar-2022.org not clickable — CSS for footer link */
.footer-brand a {
  color: inherit;
  text-decoration: none;
  transition: var(--transition);
}
.footer-brand a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Fix #22: active lang highlight */
.lang-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: none;
}

/* Fix #18: extra spacing — tighten card spacing */
.timeline-item {
  margin-bottom: 0.5rem;
}

/* Fix: section-hero-kk kazakh subtitle style */
.section-hero-kk {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.35rem;
}

/* Language fallback marker — показывается при отсутствии перевода */
.lang-fallback {
  display: inline-block;
  font-size: 0.65em;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--border-light);
  border-radius: 3px;
  padding: 1px 4px;
  margin-right: 4px;
  vertical-align: middle;
  letter-spacing: 0.03em;
  opacity: 0.7;
}
[data-theme="dark"] .lang-fallback {
  background: var(--border);
}

