:root {
  --bg: #101a30;
  --bg-soft: #16223c;
  --panel: #1b2c52;
  --panel-alt: #182648;
  --accent: #d03026;
  --accent-soft: #e04a40;
  --accent-navy: #243c80;
  --gold: #c9862b;
  --teal: #4a9d8f;
  --text: #f4f5f8;
  --muted: #a7b2d1;
  --border: #2c3f70;
  --border-soft: rgba(167, 178, 209, 0.18);
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.35);
  --heading-font: 'Alatsi', Helvetica, Arial, sans-serif;
  font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

::selection { background: var(--accent); color: white; }

/* ---------- Header ---------- */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: linear-gradient(135deg, #1e3160 0%, #16223c 60%, #14203a 100%);
  border-bottom: 3px solid var(--accent);
  box-shadow: var(--shadow-sm);
}

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

header h1 {
  font-family: var(--heading-font);
  font-size: 22px;
  margin: 0;
  font-weight: 400;
  letter-spacing: 0.03em;
}
.tagline {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-soft);
  font-weight: 700;
}
#subtitle {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

.tabs { display: flex; gap: 8px; align-items: center; }
.tab {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 20px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  font-family: 'Open Sans', sans-serif;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.tab:hover { border-color: var(--muted); }
.tab:active { transform: scale(0.97); }
.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(208, 48, 38, 0.4);
}
.admin-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  margin-left: 6px;
  border: 1px solid var(--border);
  padding: 9px 16px;
  border-radius: 999px;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.admin-link:hover { color: var(--text); border-color: var(--accent); }

/* ---------- Filterbar ---------- */

#filterbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-soft);
}
#filterbar input, #filterbar select {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-family: 'Open Sans', sans-serif;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#filterbar input:focus, #filterbar select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(208, 48, 38, 0.25);
}
#filterbar input { flex: 0 1 300px; }
#filterbar input::placeholder { color: var(--muted); }
#result-count { color: var(--muted); font-size: 12px; margin-left: auto; }

/* ---------- Layout ---------- */

main { height: calc(100vh - 112px); }

.view { display: none; height: 100%; }
.view.active { display: block; }

#map { height: 100%; width: 100%; }
#timeline { height: 100%; width: 100%; padding: 14px 18px; }

/* ---------- Kaart ---------- */

#view-map { position: relative; }
#layer-toggle {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1000;
  background: rgba(27, 44, 82, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
}
#layer-toggle label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
#layer-toggle label:hover { color: white; }
#layer-toggle input { width: auto; accent-color: var(--accent); }

.gebeurtenis-marker {
  width: 14px; height: 14px;
  background: var(--gold);
  border: 2px solid white;
  transform: rotate(45deg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.verhaal-marker {
  width: 14px; height: 14px;
  border-radius: 4px;
  background: var(--teal);
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-md);
}
.leaflet-popup-content-wrapper { border-radius: 10px; }
.leaflet-popup-content { font-size: 13px; }
.popup-list a { display: block; margin: 3px 0; color: #8fb4f5; text-decoration: none; }
.popup-list a:hover { text-decoration: underline; }

.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large {
  background-color: rgba(208, 48, 38, 0.25);
}
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
  background-color: var(--accent-navy);
  color: white;
  font-family: 'Open Sans', sans-serif;
  font-weight: 700;
}

/* ---------- Tijdlijn ---------- */

.vis-timeline {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.vis-panel.vis-center,
.vis-panel.vis-left,
.vis-panel.vis-right,
.vis-panel.vis-top,
.vis-panel.vis-bottom {
  border-color: var(--border-soft);
}
.vis-labelset .vis-label {
  color: var(--muted);
  font-family: var(--heading-font);
  font-size: 14px;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border-soft);
}
.vis-labelset .vis-label .vis-inner { padding: 10px 12px; }
.vis-time-axis .vis-text {
  color: var(--muted);
  font-size: 12px;
}
.vis-time-axis .vis-grid.vis-minor { border-color: rgba(167, 178, 209, 0.08); }
.vis-time-axis .vis-grid.vis-major { border-color: rgba(167, 178, 209, 0.22); }
.vis-group { border-bottom: 1px solid var(--border-soft); }
.vis-current-time { background-color: transparent; }

/* Individuele personen: leesbare licht-op-donker chips */
.vis-item {
  color: var(--text);
  border-width: 1px;
}
.vis-item.vis-point {
  background: transparent;
  border: none;
}
.vis-item.person-item .vis-item-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12.5px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.vis-item.person-item .vis-dot,
.vis-item.person-item .vis-item-dot {
  border-color: var(--accent);
  background: var(--accent);
}
.vis-item.person-item.vis-selected .vis-item-content {
  border-color: var(--accent);
  background: var(--accent-navy);
}

/* Jaar- en maandbalken */
.vis-item.year-agg {
  background: var(--accent);
  border: 1px solid var(--accent-soft);
  border-radius: 8px;
  color: white;
  font-weight: 700;
  cursor: zoom-in;
  box-shadow: 0 2px 8px rgba(208, 48, 38, 0.35);
}
.vis-item.year-agg .vis-item-content { padding: 6px 14px; }
.vis-item.month-agg {
  background: var(--accent-navy);
  border: 1px solid #3a55a8;
  border-radius: 8px;
  color: white;
  font-weight: 600;
  cursor: zoom-in;
  font-size: 12px;
  box-shadow: var(--shadow-sm);
}
.vis-item.month-agg .vis-item-content { padding: 4px 10px; }

/* Gebeurtenissen op de tijdlijn */
.vis-item.event-item .vis-item-content {
  background: rgba(201, 134, 43, 0.15);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12.5px;
  color: #ecc78f;
  white-space: nowrap;
}
.vis-item.event-item .vis-dot,
.vis-item.event-item .vis-item-dot {
  border-color: var(--gold);
  background: var(--gold);
}

/* ---------- Detailpaneel ---------- */

#detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 440px;
  max-width: 94vw;
  height: 100%;
  background: rgba(27, 44, 82, 0.97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-left: 3px solid var(--accent);
  overflow-y: auto;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.5);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.3, 1);
  z-index: 1100;
  padding: 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
#detail-panel::-webkit-scrollbar { width: 8px; }
#detail-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
#detail-panel.hidden { transform: translateX(105%); }

#detail-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
#detail-close:hover { background: var(--accent); border-color: var(--accent); }

#detail-content h2 {
  font-family: var(--heading-font);
  font-weight: 400;
  margin: 6px 0 4px;
  font-size: 24px;
  letter-spacing: 0.02em;
}
#detail-content .meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.7;
}
#detail-content .story {
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-line;
}
#detail-content img.profile {
  width: 100%;
  max-width: 250px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  box-shadow: var(--shadow-md);
  cursor: zoom-in;
  transition: transform 0.15s ease;
}
#detail-content img.profile:hover { transform: scale(1.02); }
#detail-content .video-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 14px 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
#detail-content .video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
#detail-content .gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}
#detail-content .gallery img {
  width: 76px;
  height: 76px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
#detail-content .gallery img:hover {
  transform: scale(1.06);
  border-color: var(--accent);
}

/* ---------- Lightbox ---------- */

#lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(8, 12, 24, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
#lightbox.hidden { display: none; }
#lightbox figure {
  margin: 0;
  max-width: 86vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
#lb-img {
  max-width: 86vw;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.6);
}
#lb-caption {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  max-width: 80vw;
}
#lb-close, #lb-prev, #lb-next {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease;
  flex: 0 0 auto;
}
#lb-close:hover, #lb-prev:hover, #lb-next:hover { background: var(--accent); border-color: var(--accent); }
#lb-close {
  position: absolute;
  top: 18px;
  right: 22px;
  width: 42px;
  height: 42px;
  font-size: 22px;
  line-height: 1;
}
#lb-prev, #lb-next {
  width: 46px;
  height: 46px;
  font-size: 26px;
  line-height: 1;
}
#detail-content .events {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}
#detail-content .events h3 {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 8px;
}
#detail-content .events ul { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.9; }
#detail-content .events a { color: #8fb4f5; text-decoration: none; }
#detail-content .events a:hover { text-decoration: underline; }
#detail-content .links { margin-top: 16px; font-size: 13px; }
#detail-content .links a {
  color: #8fb4f5;
  display: block;
  margin-bottom: 6px;
  text-decoration: none;
}
#detail-content .links a:hover { text-decoration: underline; }
#detail-content .badge {
  display: inline-block;
  background: var(--accent);
  color: white;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
