/* Import premium typography from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400&family=Outfit:wght@300;400;500;600;700&display=swap');

/* Color system and variables */
:root {
  --bg-primary: #140d08;
  --bg-secondary: #1b1208;
  --bg-sidebar: rgba(20, 13, 8, 0.92);
  --bg-card: rgba(43, 29, 13, 0.6);
  --bg-card-hover: rgba(51, 34, 15, 0.8);
  --border-color: rgba(201, 162, 75, 0.14);
  --border-hover: rgba(201, 162, 75, 0.32);
  --text-primary: #efe1be;
  --text-secondary: #c8b189;
  --text-muted: #97835f;
  
  /* Category colors — heritage palette */
  --color-prophets: #c9a24b;      /* Antique Gold */
  --color-sahaba: #3f7a62;        /* Patina Green */
  --color-righteous: #5c7080;     /* Muted Slate */
  --color-other: #b25e42;         /* Terracotta */

  /* Category glow effects */
  --glow-prophets: rgba(201, 162, 75, 0.35);
  --glow-sahaba: rgba(63, 122, 98, 0.35);
  --glow-righteous: rgba(92, 112, 128, 0.35);
  --glow-other: rgba(178, 94, 66, 0.35);
  
  --font-arabic: 'Amiri', serif;
  --font-sans: 'Outfit', sans-serif;
  --font-serif: 'Cormorant Garamond', serif;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
}

/* Scrollbar customization */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-sahaba);
}

/* Main Layout */
.app-container {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
}

/* Sidebar Styling */
.sidebar {
  width: 440px;
  min-width: 440px;
  height: 100%;
  background: var(--bg-sidebar);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: var(--transition-smooth);
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
  position: relative;
}

/* Header Section */
.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(180deg, rgba(201, 162, 75, 0.07) 0%, rgba(0,0,0,0) 100%);
}

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

.brand-icon {
  font-size: 28px;
  color: var(--color-prophets);
  filter: drop-shadow(0 0 8px var(--glow-prophets));
}

.brand-info h1 {
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(120deg, #ffffff 30%, #e0bd6a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
  margin-top: 2px;
}

/* Search and Filters Scroll Container */
.sidebar-controls {
  padding: 20px 24px 10px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Search Box */
.search-wrapper {
  position: relative;
}

.search-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 16px 12px 42px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: var(--transition-smooth);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-prophets);
  box-shadow: 0 0 12px rgba(201, 162, 75, 0.18);
  background: rgba(0, 0, 0, 0.5);
}

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.95rem;
  pointer-events: none;
}

/* Accordion Filters */
.filters-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition-smooth);
}

.filters-toggle:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.1);
}

.filters-toggle i {
  transition: transform 0.3s ease;
}

.filters-toggle.active i {
  transform: rotate(180deg);
}

.filters-content {
  display: none;
  flex-direction: column;
  gap: 16px;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-top: none;
  padding: 16px;
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
  margin-top: -12px;
}

.filters-content.show {
  display: flex;
}

.filter-section h3 {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

/* Category Filter Chips */
.category-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.category-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.category-option:hover {
  background: rgba(255, 255, 255, 0.05);
}

.category-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.category-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-prophets { background-color: var(--color-prophets); box-shadow: 0 0 6px var(--color-prophets); }
.dot-sahaba { background-color: var(--color-sahaba); box-shadow: 0 0 6px var(--color-sahaba); }
.dot-righteous { background-color: var(--color-righteous); box-shadow: 0 0 6px var(--color-righteous); }
.dot-other { background-color: var(--color-other); box-shadow: 0 0 6px var(--color-other); }

.category-count {
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 20px;
  color: var(--text-secondary);
}

/* Checked states styled in JS */
.category-option.active {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}
.category-option.active .category-label {
  color: var(--text-primary);
  font-weight: 500;
}

/* Inactive categories stay selectable but lose their visual emphasis. */
.category-option:not(.active) {
  background: rgba(255, 255, 255, 0.012);
  border-color: rgba(255, 255, 255, 0.07);
}
.category-option:not(.active) .category-label,
.category-option:not(.active) .category-count { color: #665b4b; }
.category-option:not(.active) .category-dot {
  background-color: #665b4b;
  box-shadow: none;
  opacity: 0.55;
}

/* Governorate Filter Badges Grid */
.governorate-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.gov-badge {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 4px;
  text-align: center;
  font-size: 0.72rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition-smooth);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gov-badge:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.gov-badge.active {
  background: rgba(201, 162, 75, 0.15);
  border-color: var(--color-prophets);
  color: var(--text-primary);
  font-weight: 500;
}

/* Stats Summary Row */
.stats-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 24px;
  margin-bottom: 12px;
}

.stat-item {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 6px;
  text-align: center;
}

.stat-val {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-prophets);
  filter: drop-shadow(0 0 6px rgba(201, 162, 75, 0.25));
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* Sites List Section */
.sites-list-wrapper {
  flex-grow: 1;
  overflow-y: auto;
  padding: 10px 24px 24px 24px;
}

.sites-count-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: block;
}

.sites-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.biography-photo {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 10px;
}

.photo-credit {
  display: block;
  color: var(--text-muted);
  font-size: 0.62rem;
  line-height: 1.3;
  margin: -6px 0 8px;
}

.photo-credit a { color: var(--color-prophets); }

/* Site Cards */
.site-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.site-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: var(--text-muted);
}

.site-card.category-prophets::before { background-color: var(--color-prophets); }
.site-card.category-sahaba::before { background-color: var(--color-sahaba); }
.site-card.category-righteous::before { background-color: var(--color-righteous); }
.site-card.category-other::before { background-color: var(--color-other); }

.site-card:hover {
  transform: translateY(-2px);
  background: var(--bg-card-hover);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.site-card.active {
  background: rgba(30, 41, 59, 0.4);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.05);
}

.site-card.active.category-prophets { border-color: var(--color-prophets); }
.site-card.active.category-sahaba { border-color: var(--color-sahaba); }
.site-card.active.category-righteous { border-color: var(--color-righteous); }
.site-card.active.category-other { border-color: var(--color-other); }

.card-header-info {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary);
  transition: var(--transition-smooth);
}

.site-card:hover .card-title {
  color: #ffffff;
}

.card-category-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.badge-prophets { background: rgba(201, 162, 75, 0.12); color: var(--color-prophets); border: 1px solid rgba(201, 162, 75, 0.28); }
.badge-sahaba { background: rgba(63, 122, 98, 0.12); color: var(--color-sahaba); border: 1px solid rgba(63, 122, 98, 0.28); }
.badge-righteous { background: rgba(92, 112, 128, 0.12); color: var(--color-righteous); border: 1px solid rgba(92, 112, 128, 0.28); }
.badge-other { background: rgba(178, 94, 66, 0.12); color: var(--color-other); border: 1px solid rgba(178, 94, 66, 0.28); }

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.card-gov-info {
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-gov-info i {
  color: var(--text-muted);
}

.card-actions {
  display: flex;
  gap: 10px;
  opacity: 0.7;
  transition: var(--transition-smooth);
}

.site-card:hover .card-actions {
  opacity: 1;
}

.action-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition-smooth);
}

.action-btn:hover {
  color: var(--color-prophets);
  background: rgba(255, 255, 255, 0.05);
}

.action-btn.bio-action-btn:hover {
  color: var(--color-righteous);
  background: rgba(92, 112, 128, 0.12);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  gap: 12px;
}

.empty-state i {
  font-size: 3rem;
  color: rgba(255, 255, 255, 0.05);
}

/* Map Container */
.map-container {
  flex-grow: 1;
  height: 100%;
  position: relative;
  background-color: #140d08;
}

#map {
  width: 100%;
  height: 100%;
  z-index: 50;
}

/* Custom Marker Styling */
.custom-div-icon {
  background: transparent;
  border: none;
}

.marker-pin {
  width: 32px;
  height: 32px;
  border-radius: 50% 50% 50% 0;
  position: absolute;
  transform: rotate(-45deg);
  left: 50%;
  top: 50%;
  margin: -16px 0 0 -16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  transition: var(--transition-smooth);
}

.marker-pin i {
  transform: rotate(45deg);
  font-size: 14px;
  color: #ffffff;
}

/* Glow Pulses */
.marker-glow {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  position: absolute;
  left: 50%;
  top: 50%;
  margin: -12px 0 0 -12px;
  animation: pulse-glow 2s infinite ease-out;
}

@keyframes pulse-glow {
  0% {
    transform: scale(0.6);
    opacity: 0.8;
  }
  100% {
    transform: scale(2.2);
    opacity: 0;
  }
}

/* Pin styles by category */
.pin-prophets { background-color: var(--color-prophets); box-shadow: 0 0 15px var(--glow-prophets); }
.pin-sahaba { background-color: var(--color-sahaba); box-shadow: 0 0 15px var(--glow-sahaba); }
.pin-righteous { background-color: var(--color-righteous); box-shadow: 0 0 15px var(--glow-righteous); }
.pin-other { background-color: var(--color-other); box-shadow: 0 0 15px var(--glow-other); }

.glow-prophets-anim { background-color: var(--color-prophets); box-shadow: 0 0 0 0 var(--color-prophets); }
.glow-sahaba-anim { background-color: var(--color-sahaba); box-shadow: 0 0 0 0 var(--color-sahaba); }
.glow-righteous-anim { background-color: var(--color-righteous); box-shadow: 0 0 0 0 var(--color-righteous); }
.glow-other-anim { background-color: var(--color-other); box-shadow: 0 0 0 0 var(--color-other); }

/* Highlight Marker on Hover/Active */
.custom-div-icon.highlighted .marker-pin {
  transform: rotate(-45deg) scale(1.25);
  z-index: 1000 !important;
  border-width: 3px;
}

/* Dark popup adjustments for Leaflet */
.leaflet-popup-content-wrapper {
  background: var(--bg-sidebar) !important;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid var(--border-color);
  color: var(--text-primary) !important;
  border-radius: 12px !important;
  padding: 6px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
}

.leaflet-popup-tip {
  background: var(--bg-sidebar) !important;
  border: 1px solid var(--border-color);
}

.leaflet-popup-close-button {
  color: var(--text-muted) !important;
  top: 10px !important;
  right: 10px !important;
  font-size: 16px !important;
  transition: var(--transition-smooth);
}

.leaflet-popup-close-button:hover {
  color: #ffffff !important;
}

.popup-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--font-sans);
  max-width: 260px;
}

.popup-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.4;
  margin-top: 4px;
}

.popup-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 8px;
  margin-top: 4px;
}

.popup-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-prophets);
  color: #1b1208;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: 6px;
  transition: var(--transition-smooth);
  width: fit-content;
}

.popup-nav-btn:hover {
  background: var(--gold-bright);
  box-shadow: 0 0 10px rgba(201, 162, 75, 0.4);
}

/* Mobile Controls */
.mobile-header {
  display: none;
  width: 100%;
  height: 60px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 150;
  position: absolute;
  top: 0;
  left: 0;
}

.menu-toggle {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 6px;
  transition: var(--transition-smooth);
}

.menu-toggle:hover {
  color: var(--color-prophets);
}

/* Floating Map Legend */
.map-legend {
  position: absolute;
  bottom: 30px;
  right: 24px;
  z-index: 1000;
  background: var(--bg-sidebar);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  max-width: 240px;
  pointer-events: auto;
  transition: var(--transition-smooth);
}

.legend-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--color-prophets);
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.legend-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.icon-prophets {
  background-color: var(--color-prophets);
  box-shadow: 0 0 8px var(--glow-prophets);
}

.icon-sahaba {
  background-color: var(--color-sahaba);
  box-shadow: 0 0 8px var(--glow-sahaba);
}

.icon-righteous {
  background-color: var(--color-righteous);
  box-shadow: 0 0 8px var(--glow-righteous);
}

.icon-other {
  background-color: var(--color-other);
  box-shadow: 0 0 8px var(--glow-other);
}

.legend-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.popup-bio-btn {
  margin-top: 8px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.78rem;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.popup-bio-btn:hover {
  background: rgba(201, 162, 75, 0.15);
  border-color: rgba(201, 162, 75, 0.3);
  color: var(--color-prophets);
}

/* Biography Side Panel (right drawer) */
.biography-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s var(--transition-smooth), visibility 0.3s var(--transition-smooth);
}

.biography-modal.open {
  opacity: 1;
  visibility: visible;
}

.biography-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.biography-panel {
  position: relative;
  z-index: 1;
  width: min(460px, 92vw);
  height: 100%;
  overflow-y: auto;
  pointer-events: auto;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-color);
  padding: 30px 30px 40px;
  box-shadow: -16px 0 50px rgba(0, 0, 0, 0.55);
  transform: translateX(100%);
  transition: transform 0.38s var(--ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.biography-modal.open .biography-panel {
  transform: translateX(0);
}

.biography-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.biography-close {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.biography-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

.biography-title {
  font-family: var(--font-serif);
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.biography-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--color-prophets);
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.biography-meta i {
  color: var(--color-prophets);
}

.biography-text {
  font-family: var(--font-sans);
  font-size: 0.98rem;
  line-height: 1.75;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.biography-footer {
  display: flex;
  justify-content: flex-start;
  padding-top: 4px;
}

/* Responsive Media Queries */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  
  .mobile-header {
    display: flex;
  }
  
  .sidebar {
    width: 100%;
    min-width: 100%;
    position: absolute;
    top: 60px;
    height: calc(100% - 60px);
    transform: translateX(-100%);
    box-shadow: none;
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .map-container {
    width: 100%;
    height: calc(100% - 60px);
    margin-top: 60px;
  }
  
  /* Responsive popup sizing */
  .leaflet-popup-content-wrapper {
    max-width: 280px;
  }

  /* Mobile Legend scaling */
  .map-legend {
    bottom: 25px;
    right: 16px;
    padding: 10px 12px;
    max-width: 185px;
  }
  
  .legend-title {
    margin-bottom: 8px;
    font-size: 0.65rem;
  }
  
  .legend-text {
    font-size: 0.7rem;
  }
  
  .legend-icon {
    width: 20px;
    height: 20px;
    font-size: 0.55rem;
  }

  /* Biography side panel — full width on mobile */
  .biography-panel {
    width: 100%;
    max-width: 100%;
    padding: 24px 22px 40px;
  }
}

/* ============================================================
   DARB — Heritage landing sections (combined into index.html)
   Nav / Hero / Sahaba-Battles highlights / Sticky Map / Footer
   ============================================================ */

:root {
  --bg-ink: #140d08;
  --bg-panel: #241809;
  --bg-card-2: #33220f;
  --parchment: #e8d5a4;
  --gold: #c9a24b;
  --gold-bright: #e0bd6a;
  --copper: #a4713f;
  --patina: #3f7a62;
  --verdigris: #4a8b78;
  --terracotta: #b25e42;
  --slate: #5c7080;
  --glow-gold: rgba(201, 162, 75, 0.35);
  --glow-patina: rgba(63, 122, 98, 0.35);
  --glow-terra: rgba(178, 94, 66, 0.35);
  --glow-slate: rgba(92, 112, 128, 0.35);
  --font-serif: 'Cormorant Garamond', serif;
  --heritage-border: rgba(201, 162, 75, 0.14);
  --heritage-border-strong: rgba(201, 162, 75, 0.32);
  --gold-line: rgba(201, 162, 75, 0.55);
}

/* Body becomes a scrolling page (map app now lives inside a pinned section) */
body {
  display: block;
  height: auto;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--bg-ink);
}

/* Anchor targets clear the fixed nav */
#top, #heritage, #map-section { scroll-margin-top: 74px; }

html { scroll-behavior: smooth; }
::selection { background: rgba(201, 162, 75, 0.28); color: #fff; }

/* ------------------ Sticky top nav ------------------ */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1200;
  border-bottom: 1px solid transparent;
  transition: background 0.3s var(--transition-smooth), box-shadow 0.3s var(--transition-smooth), border-color 0.3s var(--transition-smooth);
}

.site-nav.scrolled {
  background: rgba(20, 13, 8, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-color: var(--heritage-border);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.site-nav .brand-icon {
  font-size: 26px;
  color: var(--gold);
  filter: drop-shadow(0 0 10px var(--glow-gold));
}

.brand-text {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: 1.5px;
  color: var(--parchment);
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-sub {
  font-family: var(--font-sans);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: #97835f;
  margin-top: 2px;
}

.nav-links { display: flex; gap: 28px; }

.language-toggle {
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 6px 12px;
  background: transparent;
  color: var(--gold-bright, #e0bd6a);
  font: 600 0.85rem var(--font-arabic);
  cursor: pointer;
}
.language-toggle:hover { background: rgba(201, 162, 75, 0.12); }

html[dir="rtl"] body,
body.is-arabic { font-family: var(--font-arabic), serif; }
html[dir="rtl"] .nav-inner,
html[dir="rtl"] .nav-links { direction: ltr; }
html[dir="rtl"] .footer-bottom { direction: rtl; }
html[dir="rtl"] .nav-links { align-items: center; }
html[dir="rtl"] .search-input,
html[dir="rtl"] .blog-search { padding-left: 16px; padding-right: 44px; }
html[dir="rtl"] .search-icon { left: auto; right: 15px; }
html[dir="rtl"] .sidebar { border-right: 0; border-left: 1px solid var(--border-color); box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5); }
html[dir="rtl"] .popup-meta,
html[dir="rtl"] .card-meta,
html[dir="rtl"] .biography-meta { direction: rtl; }
html[dir="rtl"] .post-back i { margin-right: 0; margin-left: 6px; }

.nav-links a {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: #c8b189;
  text-decoration: none;
  position: relative;
  transition: color 0.2s var(--transition-smooth);
}

.nav-links a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -6px;
  width: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--gold);
  transition: width 0.25s var(--transition-smooth);
}

.nav-links a:hover { color: var(--gold-bright); }
.nav-links a:hover::after { width: 100%; }

.nav-links a.nav-active { color: var(--gold-bright); }
.nav-links a.nav-active::after { width: 100%; }

.nav-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-serif);
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 10px 20px;
  background: linear-gradient(120deg, var(--gold), var(--copper));
  color: #241809;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  text-decoration: none;
  transition: transform 0.25s var(--transition-smooth), box-shadow 0.25s var(--transition-smooth);
}

.nav-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px var(--glow-gold);
}

/* ------------------ Hero ------------------ */
.hero {
  min-height: 100vh;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 150px 24px 90px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% -10%, #3a2711 0%, var(--bg-ink) 62%);
}

.hero-pattern {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(30deg, rgba(201,162,75,0.05) 12%, transparent 12.5%, transparent 87%, rgba(201,162,75,0.05) 87.5%),
    linear-gradient(150deg, rgba(201,162,75,0.05) 12%, transparent 12.5%, transparent 87%, rgba(201,162,75,0.05) 87.5%),
    linear-gradient(30deg, rgba(201,162,75,0.05) 12%, transparent 12.5%, transparent 87%, rgba(201,162,75,0.05) 87.5%),
    radial-gradient(circle at 1px 1px, rgba(232,213,164,0.05) 1px, transparent 0);
  background-size: 56px 56px, 56px 56px, 56px 56px, 44px 44px;
  background-position: 0 0, 0 0, 28px 28px, 0 0;
  mask-image: radial-gradient(ellipse at 50% 42%, #000 30%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 42%, #000 30%, transparent 78%);
}

.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(20,13,8,0.7) 100%);
  box-shadow: inset 0 0 160px rgba(0, 0, 0, 0.6);
}

.hero-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.3;
  pointer-events: none;
}

.hero-glow.glow-a { width: 420px; height: 420px; background: var(--glow-patina); top: 12%; left: 8%; animation: dh-float 9s ease-in-out infinite; }
.hero-glow.glow-b { width: 380px; height: 380px; background: var(--glow-terra); bottom: 8%; right: 8%; animation: dh-float 11s ease-in-out infinite reverse; }
.hero-glow.glow-c { width: 300px; height: 300px; background: var(--glow-gold); top: 52%; right: 38%; animation: dh-float 13s ease-in-out infinite; }

@keyframes dh-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-28px); }
}

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

.hero-eyebrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-family: var(--font-serif);
  font-size: 0.9rem;
  letter-spacing: 3.5px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 30px;
  font-weight: 600;
}

.eyebrow-line { width: 60px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold)); }
.eyebrow-line:last-child { transform: rotate(180deg); }

.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(2.6rem, 7vw, 5rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0.5px;
  color: var(--parchment);
  margin-bottom: 6px;
}

.title-gold { color: var(--gold-bright); text-shadow: 0 0 24px var(--glow-gold); }
.title-patina { color: var(--verdigris); text-shadow: 0 0 24px var(--glow-patina); }

.hero-tagline-ar {
  font-family: var(--font-arabic);
  font-size: clamp(1.3rem, 3vw, 1.9rem);
  color: #c8b189;
  font-style: italic;
  margin: 14px 0 26px;
}

.hero-intro {
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: #c8b189;
  max-width: 700px;
  margin: 0 auto 40px;
}

.hero-intro strong { color: var(--gold-bright); font-weight: 600; }

.hero-ctas {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: 0.3px;
  padding: 16px 32px;
  border-radius: 6px;
  text-decoration: none;
  transition: transform 0.25s var(--transition-smooth), box-shadow 0.25s var(--transition-smooth), border-color 0.25s var(--transition-smooth);
}

.cta-primary {
  background: linear-gradient(120deg, var(--gold), var(--copper));
  color: #241809;
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.cta-primary:hover { transform: translateY(-3px); box-shadow: 0 14px 36px var(--glow-gold); }

.cta-ghost {
  border: 1px solid var(--gold-line);
  color: var(--parchment);
  background: rgba(201, 162, 75, 0.04);
}
.cta-ghost:hover { transform: translateY(-3px); border-color: var(--gold); background: rgba(201, 162, 75, 0.1); }

.cta-lg { padding: 18px 40px; font-size: 1.15rem; }

/* ------------------ Highlights (section head + feature grid) ------------------ */
.highlights {
  padding: 100px 24px;
  background: var(--bg-ink);
}

.section-head {
  max-width: 780px;
  margin: 0 auto 56px;
  text-align: center;
  padding: 0 20px;
}

.section-kicker {
  display: inline-block;
  font-family: var(--font-serif);
  font-size: 0.86rem;
  letter-spacing: 3.5px;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 16px;
  padding: 7px 18px;
  border: 1px solid var(--gold-line);
  border-radius: 30px;
  background: linear-gradient(120deg, rgba(201,162,75,0.08), rgba(201,162,75,0.02));
}

.section-title {
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 4.5vw, 3.4rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: 0.3px;
  color: var(--parchment);
  text-shadow: 0 2px 20px rgba(201, 162, 75, 0.15);
  margin-bottom: 16px;
}

.section-sub { font-size: 1.05rem; color: #c8b189; }

.section-head::after {
  content: '';
  display: block;
  margin: 20px auto 0;
  width: 120px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.section-head::before {
  content: '◆';
  display: block;
  color: var(--gold);
  font-size: 0.9rem;
  margin: 18px auto 0;
  opacity: 0.8;
}

.feature-grid {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

.feature-col {
  background: var(--bg-panel);
  border: 1px solid var(--heritage-border);
  border-radius: 8px;
  padding: 30px;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.3);
}

.feature-col-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 22px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--heritage-border);
}

.col-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  color: #fff;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.12);
}

.col-icon-sahaba { background: linear-gradient(135deg, var(--patina), #2c5947); box-shadow: 0 0 20px var(--glow-patina); }
.col-icon-other { background: linear-gradient(135deg, var(--terracotta), #8f4328); box-shadow: 0 0 20px var(--glow-terra); }

.feature-col-head h3 { font-family: var(--font-serif); font-size: 1.4rem; font-weight: 700; color: var(--parchment); }
.feature-col-head p { font-size: 0.84rem; color: #97835f; margin-top: 2px; }

.person-cards { display: flex; flex-direction: column; gap: 14px; }

.person-card {
  display: block;
  background: var(--bg-card-2);
  border: 1px solid var(--heritage-border);
  border-left: 3px solid var(--gold-line);
  border-radius: 6px;
  padding: 20px;
  text-decoration: none;
  transition: transform 0.25s var(--transition-smooth), border-color 0.25s var(--transition-smooth), box-shadow 0.25s var(--transition-smooth);
}

.person-card:hover {
  transform: translateY(-3px);
  border-color: var(--heritage-border-strong);
  border-left-color: var(--gold-bright);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.person-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.person-badge {
  font-family: var(--font-serif);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 3px;
}

.person-badge.badge-sahaba { background: rgba(63, 122, 98, 0.16); color: var(--verdigris); border: 1px solid rgba(63, 122, 98, 0.4); }
.person-badge.badge-other { background: rgba(178, 94, 66, 0.16); color: #d98b67; border: 1px solid rgba(178, 94, 66, 0.4); }

.person-arrow { color: #97835f; transition: transform 0.25s var(--transition-smooth), color 0.25s var(--transition-smooth); }
.person-card:hover .person-arrow { color: var(--gold-bright); transform: translateX(4px); }

.person-name {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--parchment);
  margin-bottom: 8px;
  line-height: 1.3;
}

.person-bio { font-size: 0.87rem; color: #c8b189; margin-bottom: 14px; }

.person-gov {
  font-size: 0.78rem;
  color: #97835f;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.person-gov i { color: var(--gold); }

/* ------------------ Pinned full-screen map ------------------ */
.map-section {
  height: 100vh;
  min-height: 100vh;
  position: relative;
  top: 0;
  z-index: 40;
  background: var(--bg-primary);
}

.map-section .app-container { height: 100%; }

/* ------------------ Closing CTA ------------------ */
.closing {
  padding: 110px 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 120%, rgba(201,162,75,0.14), transparent 60%), #1b1208;
  border-top: 1px solid var(--heritage-border);
}

.closing-inner { max-width: 760px; margin: 0 auto; }

.closing h2 {
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 4.5vw, 3.2rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--parchment);
  margin-bottom: 16px;
}

.closing p { font-size: 1.12rem; color: #c8b189; margin-bottom: 36px; }

/* ------------------ Footer ------------------ */
.site-footer {
  border-top: 1px solid var(--heritage-border);
  background: var(--bg-ink);
  padding: 36px 24px 24px;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto 24px;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 32px;
}

.footer-brand { display: flex; gap: 14px; align-items: flex-start; }
.footer-brand .brand-icon { font-size: 28px; color: var(--gold); filter: drop-shadow(0 0 10px var(--glow-gold)); }
.footer-title { font-family: var(--font-serif); font-weight: 700; font-size: 1.25rem; color: var(--parchment); display: block; margin-bottom: 6px; }
.footer-brand p { font-size: 0.87rem; color: #97835f; max-width: 240px; }

.footer-col h4 {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
}

.footer-col a {
  display: block;
  font-size: 0.9rem;
  color: #c8b189;
  padding: 4px 0;
  text-decoration: none;
  transition: color 0.2s var(--transition-smooth);
}
.footer-col a:hover { color: var(--gold-bright); }

.footer-bottom {
  max-width: 1100px;
  margin: 0 auto;
  padding-top: 18px;
  border-top: 1px solid var(--heritage-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 0.82rem;
  color: #97835f;
  flex-wrap: wrap;
}

.footer-note { font-style: italic; font-family: var(--font-arabic); }

/* ------------------ Heritage responsive ------------------ */
@media (max-width: 900px) {
  .feature-grid { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .nav-links { display: flex; gap: 14px; align-items: center; }
  .nav-inner .nav-cta { display: none; }
  .nav-inner { padding: 14px 20px; }

  .hero { padding: 120px 20px 80px; }
  .hero-ctas { flex-direction: column; align-items: stretch; }
  .hero-ctas .cta { justify-content: center; }

  .footer-inner { grid-template-columns: 1fr; gap: 28px; }
  .footer-bottom { flex-direction: column; text-align: center; }
}

@media (max-width: 768px) {
  html[dir="rtl"] .sidebar { transform: translateX(100%); }
  html[dir="rtl"] .sidebar.open { transform: translateX(0); }
}

/* On phones the map and site cards are stacked in the document flow. This
   keeps the page scrollable instead of trapping the user inside a viewport. */
@media (max-width: 768px) {
  .map-section,
  .map-section .app-container { height: auto; min-height: 0; }
  .map-section .app-container { display: flex; flex-direction: column; }
  .map-section .mobile-header { display: none; }
  .map-section .map-container {
    order: 1;
    width: 100%;
    height: clamp(280px, 45vh, 400px);
    min-height: 280px;
    margin-top: 0;
  }
  .map-section .sidebar {
    order: 2;
    position: relative;
    inset: auto;
    width: 100%;
    min-width: 0;
    height: auto;
    transform: none;
    display: flex;
    border-left: 0;
    border-right: 0;
    box-shadow: none;
    visibility: visible;
    opacity: 1;
  }
  .map-section .sidebar.open { transform: none; }
  .map-section .sites-list-wrapper,
  .map-section .sites-list { display: flex; overflow: visible; }
  .map-section .sites-list-wrapper { flex-direction: column; }
  .map-section .sites-list { flex-direction: column; flex: none; }
  .map-section .map-legend { bottom: 16px; }
}

/* Leaflet coordinates and controls remain LTR; surrounding Arabic content
   keeps its natural RTL reading order. */
html[dir="rtl"] .map-container,
html[dir="rtl"] #map,
html[dir="rtl"] .leaflet-control-container { direction: ltr; }
html[dir="rtl"] .map-section .sidebar,
html[dir="rtl"] .biography-panel,
html[dir="rtl"] .popup-details { direction: rtl; text-align: right; }
html[dir="rtl"] .map-legend { right: auto; left: 24px; direction: rtl; text-align: right; }
@media (max-width: 768px) {
  html[dir="rtl"] .map-section .map-legend { right: auto; left: 16px; max-width: min(185px, calc(100% - 32px)); }
  html[dir="rtl"] .map-section .category-option { text-align: right; }
  html[dir="rtl"] .map-section,
  body.is-arabic .map-section { height: auto !important; min-height: 0 !important; }
  html[dir="rtl"] .map-section .sidebar,
  body.is-arabic .map-section .sidebar {
    position: relative !important;
    inset: auto !important;
    display: flex !important;
    height: auto !important;
    min-height: 0 !important;
    transform: none !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  html[dir="rtl"] .map-section .sites-list-wrapper,
  body.is-arabic .map-section .sites-list-wrapper { display: block !important; height: auto !important; overflow: visible !important; }
  .map-section .sidebar,
  .map-section .sites-list-wrapper,
  .map-section .sites-list { flex: 0 0 auto !important; }
  .map-section .sites-list { min-height: 1px; }
}

/* Shared site navigation collapses into a touch-friendly menu on phones. */
.nav-inner { position: relative; }
.mobile-nav-toggle { display: none; }
@media (max-width: 720px) {
  .site-nav .nav-inner { padding: 12px 16px; }
  .mobile-nav-toggle {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    margin-left: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(255,255,255,.03);
    color: var(--gold-bright, #e0bd6a);
    font-size: 1.05rem;
    cursor: pointer;
  }
  .site-nav .nav-links {
    display: none;
    position: absolute;
    top: calc(100% + 1px);
    left: 16px;
    right: 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: rgba(20, 13, 8, .98);
    box-shadow: 0 16px 34px rgba(0,0,0,.45);
  }
  .site-nav.mobile-open .nav-links { display: flex; }
  .site-nav .nav-links a {
    display: block;
    padding: 12px 10px;
    border-bottom: 1px solid rgba(201,162,75,.1);
    font-size: 1.05rem;
  }
  .site-nav .nav-links a::after { display: none; }
  .site-nav .nav-links .language-toggle { width: 100%; margin-top: 8px; padding: 10px 12px; }
  html[dir="rtl"] .site-nav .nav-links { direction: rtl; text-align: right; }
}
