/* ── base ────────────────────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --panel: rgba(13, 20, 34, 0.82);
  --panel-border: rgba(140, 170, 220, 0.18);
  --text: #e8edf6;
  --text-dim: #9fb0c8;
  --accent: #ffd45e;
  --font-he: "Frank Ruhl Libre", "David Libre", "Noto Serif Hebrew", Georgia, serif;
  --font-ui: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html { scroll-behavior: auto; }
body {
  font-family: var(--font-ui);
  color: var(--text);
  background: radial-gradient(120% 90% at 50% 0%, #16233c 0%, #0d1626 55%, #080e19 100%);
  overflow-x: hidden;
}
html[lang="he"] body { font-family: var(--font-he), var(--font-ui); }

#track { width: 1px; }

#osmap { position: fixed; inset: 0; z-index: 1; background: #0d1626; }
.evt-label {
  position: absolute; top: 0; left: 0;
  pointer-events: auto; cursor: pointer;
  font-size: 12px; line-height: 1.1;
  color: #fff;
  background: rgba(10, 16, 28, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 20px;
  padding: 3px 10px;
  white-space: nowrap;
  text-shadow: 0 1px 3px #000;
  transition: opacity 0.2s;
  will-change: transform;
}
.evt-label.selected {
  background: rgba(255, 212, 94, 0.16);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ── HUD ─────────────────────────────────────────────────────────────────── */
#hud {
  position: fixed; top: 0; inset-inline: 0;
  z-index: 10;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 14px 18px;
  pointer-events: none;
}
#hud-left { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
#brand { display: none; }
#brand-hidden-orig {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 8px 14px;
  backdrop-filter: blur(8px);
}

/* Google-Maps-style search — fixed on the corner opposite the title */
/* lives at the top of the side panel (on phones the panel opens via 📜) */
#searchbox {
  pointer-events: auto;
  position: relative; flex: none;
  margin: 10px 10px 2px;
  z-index: 6;
}
#search-input {
  width: 100%; height: 38px;
  background: var(--panel) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="%239fb0c8" stroke-width="2.4" stroke-linecap="round"><circle cx="11" cy="11" r="7"/><line x1="21" y1="21" x2="16.4" y2="16.4"/></svg>') no-repeat left 14px center;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 0 16px 0 38px;
  outline: none;
  backdrop-filter: blur(8px);
}
html[lang="he"] #search-input { background-position: right 14px center; padding: 0 38px 0 16px; }
#search-input:focus { border-color: var(--accent); }
#search-input::placeholder { color: var(--text-dim); }
#search-results {
  position: absolute; top: calc(100% + 6px); inset-inline: 0;
  background: rgba(13, 20, 34, 0.96);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  overflow: hidden;
  display: none;
  max-height: 320px; overflow-y: auto;
  z-index: 30;
}
#search-results.open { display: block; }
.sr-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  background: none; border: none;
  color: var(--text);
  font-family: inherit; font-size: 13px;
  text-align: start;
  padding: 8px 12px;
  cursor: pointer;
}
.sr-item:hover { background: rgba(255, 255, 255, 0.08); }
.sr-item .sr-kind { font-size: 11px; color: var(--text-dim); margin-inline-start: auto; }
.sr-item .sr-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--cat, #8aa); }
#app-title { font-weight: 700; letter-spacing: 0.02em; }
#lang-btn {
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--panel-border); border-radius: 8px;
  padding: 2px 8px; cursor: pointer; font-size: 12px;
}
#lang-btn:hover { color: var(--accent); border-color: var(--accent); }
/* mobile hamburger: opens the side-panel drawer (hidden on desktop) */
#panel-btn {
  display: none;
  pointer-events: auto;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 12px; padding: 8px 12px;
  font-size: 15px; line-height: 1; cursor: pointer;
  backdrop-filter: blur(8px);
}
#panel-btn:hover { color: var(--accent); border-color: var(--accent); }
/* standalone chip, no longer inside the title box */
#hud-left { flex-direction: row; align-items: center; gap: 8px; }
#hud-left #lang-btn {
  pointer-events: auto; flex: none;
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 50%; padding: 0;
  font-size: 12px; font-weight: 700;
  backdrop-filter: blur(8px);
}

#year-box {
  pointer-events: auto;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 10px 26px 12px;
  backdrop-filter: blur(8px);
  min-width: 240px;
}
/* desktop: the year sits centered at the top of the screen */
@media (min-width: 901px) {
  #year-box {
    position: fixed;
    top: 14px; left: 50%;
    transform: translateX(-50%);
  }
}
#year-big { display: flex; gap: 14px; align-items: baseline; justify-content: center; direction: rtl; }
html[lang="en"] #year-big { direction: ltr; }
#year-heb {
  font-family: var(--font-he);
  font-size: 44px; font-weight: 700;
  color: var(--accent);
  line-height: 1.05;
  text-shadow: 0 0 24px rgba(255, 212, 94, 0.35);
  direction: rtl;
}
#year-digits {
  font-size: 38px; font-weight: 700;
  color: var(--accent);
  line-height: 1.05;
  text-shadow: 0 0 24px rgba(255, 212, 94, 0.35);
  font-variant-numeric: tabular-nums;
  direction: ltr;
}
#year-sub { display: flex; gap: 12px; justify-content: center; color: var(--text-dim); font-size: 12px; margin-top: 4px; flex-wrap: wrap; }
#era-name { margin-top: 6px; font-size: 15px; font-weight: 600; color: #cfe0ff; }

/* ── events panel ────────────────────────────────────────────────────────── */
#evt-panel {
  /* taller now that the search lives inside it */
  position: fixed; top: 64px; bottom: 44px; inset-inline-end: 16px;
  z-index: 9;
  width: 300px;
  /* fixed height (top+bottom pinned) regardless of how many results */
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 12px;
  backdrop-filter: blur(8px);
}
/* tabs + title stay pinned; only the list below them scrolls */
#panel-tabs, #triad-hint, #evt-panel-head { flex: none; }
#evt-list { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
#panel-tabs {
  display: flex; gap: 4px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 10px;
}
.ptab {
  flex: 1;
  background: transparent;
  border: none; border-radius: 8px;
  color: var(--text-dim);
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  padding: 6px 0;
  cursor: pointer;
}
.ptab:hover { color: var(--text); }
.ptab.active { background: rgba(255, 212, 94, 0.14); color: var(--accent); }
#triad-hint {
  font-size: 10.5px;
  color: var(--text-dim);
  text-align: center;
  padding: 2px 6px 8px;
  line-height: 1.4;
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 10px;
}
#evt-panel.people-mode #evt-panel-head #list-mode-btn { display: none; }
#evt-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
#evt-panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); }
html[lang="he"] #evt-panel h2 { letter-spacing: 0; }
#list-mode-btn {
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--panel-border); border-radius: 8px;
  padding: 2px 10px; cursor: pointer; font-size: 11.5px; font-family: inherit;
}
#list-mode-btn:hover, #list-mode-btn.active { color: var(--accent); border-color: var(--accent); }
/* the chain-of-Yisrael filter: chain-only vs every story */
#chain-btn {
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--panel-border); border-radius: 8px;
  padding: 2px 10px; cursor: pointer; font-size: 11px; font-family: inherit;
  white-space: nowrap;
}
#chain-btn:hover { color: var(--text); }
#chain-btn.active { color: var(--accent); border-color: var(--accent); background: rgba(255, 212, 94, 0.08); }
/* importance rating: how large a piece of the nation's story it is */
.imp { color: var(--accent); font-size: 9px; letter-spacing: 1px; opacity: 0.9; white-space: nowrap; }
.evt-meta .imp { font-size: 8.5px; }
.era-heading {
  font-size: 11.5px; font-weight: 700; color: #cfe0ff;
  margin: 12px 2px 6px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 3px;
}
.era-heading:first-child { margin-top: 2px; }
#people-btn {
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--panel-border); border-radius: 8px;
  padding: 2px 8px; cursor: pointer; font-size: 12px;
}
#people-btn:hover, #people-btn.active { color: var(--accent); border-color: var(--accent); }

/* people list & person page */
.p-avatar {
  flex: none; width: 36px; height: 36px;
  border-radius: 50%; object-fit: cover; object-position: top;
  border: 1px solid var(--panel-border);
  background: rgba(127, 181, 255, 0.08);
}
.p-avatar-ph {
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; opacity: 0.7;
}
.person-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: start;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent; border-radius: 10px;
  color: var(--text); padding: 8px 10px; margin-bottom: 6px;
  cursor: pointer; font-family: inherit;
}
.person-row:hover { background: rgba(255, 255, 255, 0.08); }
.person-row > span:not(.p-ring):not(.p-count) { flex: 1; min-width: 0; }
.person-row .p-count { flex: none; }
.person-row .p-name { font-size: 13.5px; font-weight: 600; }
.person-row .p-dates { font-size: 11.5px; color: var(--text-dim); }
.person-row .p-inf { display: block; font-size: 11px; color: var(--accent); opacity: 0.9; }
.person-row .p-age { font-size: 11px; color: var(--accent); font-weight: 600; margin-inline-start: 6px; }
/* life progress as a ring around the face: conic fill driven by --p */
.p-ring, .ph-ring, .pm-ring {
  flex: none;
  display: inline-flex; border-radius: 50%; padding: 3px;
  background: conic-gradient(var(--accent) var(--p, 0%), rgba(159, 176, 200, 0.22) 0);
}
.p-ring.off, .ph-ring.off, .pm-ring.off { background: rgba(159, 176, 200, 0.14); }
.pm-ring { padding: 2px; }
.pm-ring .pm-face { border: none; }

/* ── the year rail: time travel lives here; the map stays free ────────────
   Pinned to the physical RIGHT edge like a scrollbar (it replaces the
   native one); everything on it extends inward, over the map. */
html { scrollbar-width: none; }
body::-webkit-scrollbar, html::-webkit-scrollbar { display: none; }
#year-rail {
  position: fixed; z-index: 15;
  right: 0; top: 0; bottom: 26px;
  width: 184px;
  touch-action: none; cursor: grab;
  /* a clearly visible time-strip: this band scrolls the years; the map is free */
  background: rgba(13, 20, 34, 0.72);
  border-inline-start: 1px solid var(--panel-border);
  backdrop-filter: blur(6px);
}
#year-rail:active { cursor: grabbing; }
/* type a year, jump to it */
#yr-input {
  position: absolute; top: 8px; left: 10px; right: 10px;
  height: 30px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  color: var(--text); font-family: inherit; font-size: 12px;
  text-align: center; font-variant-numeric: tabular-nums; direction: ltr;
  outline: none;
}
#yr-input:focus { border-color: var(--accent); }
#yr-input::placeholder { color: var(--text-dim); }
#yr-track {
  position: absolute; top: 48px; bottom: 10px; right: 56px;
  width: 12px;
  background: rgba(127, 181, 255, 0.35);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
}
@media (max-width: 900px) {
  #year-rail { width: 164px; }
}
#yr-thumb {
  /* centered on the 12px track (thumb is 24px wide) */
  position: absolute; right: -6px;
  transform: translateY(-50%);
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0b1120;
  box-shadow: 0 0 12px rgba(255, 212, 94, 0.5);
  pointer-events: none;
}
#yr-thumb-year {
  position: absolute; left: 26px; right: auto; top: 50%;
  transform: translateY(-50%);
  font-size: 10px; font-weight: 700; color: var(--accent);
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 1px 4px;
  white-space: nowrap; font-variant-numeric: tabular-nums;
  direction: ltr;
}
/* keep the edge-hugging UI clear of the rail */
#hud { padding-right: 196px; }
/* desktop only: keep the boxes clear of the year rail (on phones this
   clearance pushed them off-screen) */
@media (min-width: 901px) {
  html[lang="he"] #detail, html[lang="he"] #entity-detail { inset-inline-start: 198px; }
}
html[lang="en"] #evt-panel { inset-inline-end: 194px; }

/* ── on-map event flags: title + thumb + live progress at the event's spot ── */
.evt-flag {
  position: relative; /* containing block for the stem */
  pointer-events: auto; cursor: pointer;
  display: block; width: 96px;
  background: rgba(13, 20, 34, 0.9);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 5px 5px 6px;
  font-family: inherit; color: var(--text); text-align: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}
.evt-flag::after { /* stem down to the location */
  content: ''; position: absolute; left: 50%; bottom: -6px;
  transform: translateX(-50%);
  border: 6px solid transparent; border-bottom: none;
  border-top-color: rgba(13, 20, 34, 0.9);
}
.evt-flag .ef-title {
  display: block; font-size: 9.5px; font-weight: 600; line-height: 1.25;
  max-height: 2.6em; overflow: hidden; margin-bottom: 4px;
}
.evt-flag img { display: block; width: 100%; height: 44px; object-fit: cover; border-radius: 6px; }
.evt-flag .ef-bar {
  display: block; height: 4px; margin-top: 5px;
  background: rgba(255, 255, 255, 0.14); border-radius: 3px; overflow: hidden;
}
.evt-flag .ef-bar b { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; }
.evt-flag:hover, .evt-flag.sel { border-color: var(--accent); }

/* the generation's people, standing where they lived */
.person-marker {
  pointer-events: auto; cursor: pointer;
  display: block; width: 52px;
  background: none; border: none; padding: 0;
  font-family: inherit; text-align: center;
}
.person-marker .pm-face {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; margin: 0 auto;
  border-radius: 50%; border: 2px solid var(--accent);
  background: #20293d; overflow: hidden; font-size: 17px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}
.person-marker .pm-face img { width: 100%; height: 100%; object-fit: cover; }
.person-marker .pm-name {
  display: block; margin-top: 2px;
  font-size: 9px; line-height: 1.15; color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  max-height: 2.3em; overflow: hidden;
}
.person-marker:hover .pm-face { border-color: #fff; }
@media (max-width: 900px) {
  .evt-flag { width: 78px; }
  .evt-flag img { height: 36px; }
  /* small faces, no names — the markers must not cover the map */
  .person-marker { width: 26px; }
  .person-marker .pm-face { width: 22px; height: 22px; font-size: 11px; border-width: 1.5px; }
  .person-marker .pm-name { display: none; }
}

/* ── 📍 pin dropped on an opened place ───────────────────────────────────── */
.map-pin { pointer-events: none; }
.map-pin span {
  display: block;
  font-size: 34px; line-height: 1;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.55));
  animation: pinDrop 0.45s ease-out;
}
@keyframes pinDrop {
  0% { transform: translateY(-22px); opacity: 0; }
  60% { transform: translateY(3px); opacity: 1; }
  100% { transform: translateY(0); }
}

/* ── mobile mini-card: the auto-selected event, small at the bottom ─────── */
#mini-card {
  position: fixed; z-index: 13;
  bottom: 80px; inset-inline: 10px; /* clear of the bottom control row */
  display: none; align-items: center; gap: 10px; text-align: start;
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 12px; padding: 8px 12px;
  color: var(--text); font: inherit; cursor: pointer;
  backdrop-filter: blur(8px);
}
#mini-card.open { display: flex; }
@media (min-width: 901px) { #mini-card { display: none !important; } }
#mini-thumb { width: 52px; height: 30px; object-fit: cover; border-radius: 6px; flex: none; }
#mini-title { display: block; font-size: 13px; font-weight: 700; }
#mini-year { display: block; font-size: 11px; color: var(--text-dim); }
.person-head .ph-inf { font-size: 12px; color: var(--accent); margin-top: 4px; }
.person-head .ph-places { font-size: 12px; color: var(--text-dim); margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.ph-place-chip {
  font: inherit; font-size: 11.5px; color: #cfe0ff;
  background: rgba(127, 181, 255, 0.10);
  border: 1px solid rgba(127, 181, 255, 0.28);
  border-radius: 999px; padding: 1px 9px; cursor: pointer;
}
.ph-place-chip:hover { background: rgba(127, 181, 255, 0.22); border-color: var(--accent); }
.person-row .p-count {
  margin-inline-start: auto; font-size: 11px; color: var(--accent);
  border: 1px solid rgba(255, 212, 94, 0.4); border-radius: 12px; padding: 1px 8px;
}
.person-head {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: 12px; padding: 12px; margin-bottom: 10px;
}
.person-head .ph-ring { float: right; margin: 0 0 6px 10px; }
html[lang="he"] .person-head .ph-ring { float: left; margin: 0 10px 6px 0; }
.person-head .ph-portrait {
  display: block; width: 96px; height: 96px; object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.04);
}
.person-head .ph-ph {
  display: flex; align-items: center; justify-content: center;
  font-size: 42px; opacity: 0.6;
}
.person-head .ph-name { font-size: 17px; font-weight: 700; }
.person-head .ph-dates { font-size: 12px; color: var(--text-dim); margin-top: 2px; direction: rtl; text-align: start; }
html[lang="en"] .person-head .ph-dates { direction: ltr; }
.person-head .ph-bio { font-size: 12.5px; color: #c7d4e8; margin-top: 6px; line-height: 1.45; }
.ph-age { font-size: 11.5px; color: var(--accent); font-weight: 600; margin-top: 4px; min-height: 1.1em; }
.back-btn {
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--panel-border); border-radius: 8px;
  padding: 3px 12px; cursor: pointer; font-size: 12px; font-family: inherit;
  margin-bottom: 8px;
}
.back-btn:hover { color: var(--accent); border-color: var(--accent); }

/* detail panel: people chips, part-of, chapters */
#d-persons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.d-person-chip {
  font-size: 12px; color: #cfe0ff;
  background: rgba(127, 181, 255, 0.1);
  border: 1px solid rgba(127, 181, 255, 0.35);
  border-radius: 16px; padding: 3px 10px;
  cursor: pointer; font-family: inherit;
}
.d-person-chip:hover { background: rgba(127, 181, 255, 0.22); }
#d-partof { margin: 4px 0 6px; }
#d-partof button {
  font-size: 11.5px; color: var(--accent);
  background: rgba(255, 212, 94, 0.08);
  border: 1px dashed rgba(255, 212, 94, 0.5);
  border-radius: 14px; padding: 2px 10px;
  cursor: pointer; font-family: inherit;
}
#d-children { margin-top: 10px; }
#d-children .kids-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin-bottom: 5px; }
html[lang="he"] #d-children .kids-title { letter-spacing: 0; }
.kid-row {
  display: block; width: 100%; text-align: start;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent; border-radius: 9px;
  color: var(--text); padding: 7px 10px; margin-bottom: 5px;
  cursor: pointer; font-family: inherit;
}
.kid-row:hover { border-color: var(--accent); }
.kid-row .k-name { font-size: 12.5px; font-weight: 600; }
.kid-row .k-meta { font-size: 11px; color: var(--text-dim); }
.kid-row .k-stage { color: var(--accent); font-weight: 600; }
.kid-prog { display: block; position: relative; height: 4px; margin-top: 4px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; }
.kid-prog b { display: block; height: 100%; width: 0%; background: var(--accent); border-radius: 3px; }
.evt-card {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  text-align: start;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  padding: 8px 10px;
  margin-bottom: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.evt-card:hover { background: rgba(255, 255, 255, 0.08); }
.evt-card.selected { border-color: var(--cat); background: rgba(255, 255, 255, 0.07); }
.evt-thumb {
  flex: none;
  width: 62px; height: 36px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0d1626;
}
#d-thumb {
  display: block;
  width: calc(100% + 36px);
  margin: -16px -18px 12px;
  height: 150px;
  object-fit: cover;
  border-radius: 15px 15px 0 0;
}
.evt-card .dot {
  flex: none; width: 10px; height: 10px; border-radius: 50%;
  background: var(--cat);
  box-shadow: 0 0 8px var(--cat);
}
.evt-card-body { display: flex; flex-direction: column; min-width: 0; }
.evt-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evt-meta { font-size: 11.5px; color: var(--text-dim); direction: rtl; text-align: start; }
html[lang="en"] .evt-meta { direction: ltr; }

/* ── detail panel ────────────────────────────────────────────────────────── */
#detail {
  position: fixed; inset-inline-start: 16px; bottom: 44px;
  z-index: 11;
  width: min(420px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 16px 18px;
  backdrop-filter: blur(10px);
  transform: translateY(20px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  max-height: 55vh; overflow-y: auto;
}
#detail.open { opacity: 1; transform: none; pointer-events: auto; }

/* person / place page — the same kind of box as the event detail */
#entity-detail {
  position: fixed; inset-inline-start: 16px; bottom: 44px;
  z-index: 12;
  width: min(420px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 16px 18px;
  backdrop-filter: blur(10px);
  transform: translateY(20px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  max-height: 55vh; overflow-y: auto;
}
#entity-detail.open { opacity: 1; transform: none; pointer-events: auto; }
#d-close, #ed-close {
  position: absolute; top: 8px; inset-inline-end: 10px;
  background: none; border: none; color: var(--text-dim);
  font-size: 22px; cursor: pointer; line-height: 1;
}
#d-close:hover, #ed-close:hover { color: #fff; }
#d-share {
  position: absolute; top: 10px; inset-inline-end: 38px;
  background: none; border: none; color: var(--text-dim);
  font-size: 14px; cursor: pointer; line-height: 1;
  z-index: 2;
}
#d-share:hover { color: var(--accent); }
.share-mini {
  float: inline-end;
  background: transparent; border: 1px solid var(--panel-border);
  border-radius: 8px; color: var(--text-dim);
  font-size: 11.5px; padding: 2px 8px;
  cursor: pointer; font-family: inherit;
}
.share-mini:hover { color: var(--accent); border-color: var(--accent); }
.chip {
  display: inline-block; font-size: 11px; font-weight: 700;
  color: #0b1220; border-radius: 20px; padding: 2px 10px;
  margin-bottom: 6px;
}
#d-title { font-size: 20px; line-height: 1.2; }
#d-title-alt { color: var(--text-dim); font-size: 13px; margin: 2px 0 8px; }
.d-row { font-size: 12.5px; color: #c7d4e8; margin-top: 3px; }
.d-src { font-size: 11px; color: var(--text-dim); }
.d-src a { color: var(--accent); text-decoration: none; }
.d-src a:hover { text-decoration: underline; }
#d-desc { margin-top: 10px; font-size: 14px; line-height: 1.55; color: #e2e9f5; }
#d-refs { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
#d-refs a {
  font-size: 12px; color: var(--accent);
  border: 1px solid rgba(255, 212, 94, 0.4);
  border-radius: 16px; padding: 3px 10px;
  text-decoration: none;
}
#d-refs a:hover { background: rgba(255, 212, 94, 0.12); }

/* ── slim footer ─────────────────────────────────────────────────────────── */
#footer {
  position: fixed; bottom: 0; inset-inline: 0;
  z-index: 10; height: 26px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  font-size: 11px; color: var(--text-dim);
  background: rgba(11, 17, 32, 0.88);
  border-top: 1px solid var(--panel-border);
  backdrop-filter: blur(6px);
}
#footer a { color: var(--text-dim); text-decoration: none; margin: 0 3px; }
#footer a:hover { color: var(--accent); }
#f-build { white-space: nowrap; font-variant-numeric: tabular-nums; }
#f-hash { direction: ltr; unicode-bidi: embed; font-family: ui-monospace, monospace; font-size: 10px; opacity: 0.8; }
@media (max-width: 720px) { #f-attr { display: none; } }

/* eras along the year rail */
#yr-eras {
  /* same insets as #yr-track so era positions line up with the ticks */
  position: absolute; top: 48px; bottom: 10px; left: 0; right: 0;
  pointer-events: none;
}
.yr-era {
  position: absolute; right: 78px;
  transform: translateY(-50%);
  pointer-events: auto;
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 9.5px; color: var(--text-dim);
  white-space: nowrap; max-width: 102px; overflow: hidden; text-overflow: ellipsis;
  padding: 1px 4px; text-align: end;
}
.yr-era::after {
  content: ''; position: absolute; right: -16px; top: 50%;
  width: 12px; height: 1px; background: var(--text-dim); opacity: 0.55;
}
.yr-era:hover { color: #fff; }
.yr-era.cur { color: var(--accent); font-weight: 700; }
/* era extent bars beside the track — each era's span at a glance */
.yr-span {
  position: absolute; right: 70px; width: 6px;
  border: none; padding: 0; cursor: pointer;
  pointer-events: auto;
  border-radius: 3px;
  background: rgba(127, 181, 255, 0.42);
}
.yr-span.alt { background: rgba(178, 148, 255, 0.42); }
.yr-span:hover { background: rgba(200, 220, 255, 0.75); }
.yr-span.cur {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(255, 212, 94, 0.5);
}
/* scale marks on the track: every 100 years, labeled every 1000 */
#yr-ticks { position: absolute; inset: 0; pointer-events: none; }
.yr-tick {
  position: absolute; right: -4px;
  width: 20px; height: 1px;
  background: rgba(159, 176, 200, 0.3);
  transform: translateY(-50%);
}
/* the millennium dividers stand out hard against the century ticks */
.yr-tick.major {
  width: 24px; right: -6px; height: 3px; border-radius: 2px;
  background: rgba(222, 234, 255, 0.95);
  box-shadow: 0 0 5px rgba(222, 234, 255, 0.45);
}
.yr-tick.major::after {
  content: attr(data-y);
  position: absolute; right: -38px; top: 50%;
  transform: translateY(-50%);
  font-size: 10px; font-weight: 700; color: #dceaff;
  font-variant-numeric: tabular-nums; direction: ltr;
}

/* ── controls & legend ───────────────────────────────────────────────────── */
/* horizontal row at the bottom of the map, above the footer
   (a side column overlays the panels) */
#controls {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 34px;
  z-index: 9;
  display: flex; flex-direction: row; gap: 6px;
}
#controls button {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 17px; cursor: pointer;
  backdrop-filter: blur(8px);
}
#controls button:hover { border-color: var(--accent); color: var(--accent); }
#controls button.active { border-color: var(--accent); color: var(--accent); background: rgba(255, 212, 94, 0.14); }
#tilt-btn { font-size: 12px !important; font-weight: 700; }


#legend {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 80px;
  z-index: 9;
  width: 250px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 14px;
  backdrop-filter: blur(8px);
  display: none;
}
#legend.open { display: block; }
#legend h3 { font-size: 13px; margin-bottom: 8px; }
#legend-cats { display: flex; flex-wrap: wrap; gap: 5px 10px; }
.legend-cat { font-size: 11.5px; color: var(--text-dim); display: inline-flex; align-items: center; gap: 5px; }
.legend-cat i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.legend-note { font-size: 11px; color: var(--text-dim); margin-top: 10px; line-height: 1.4; }
.legend-circles { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.lc {
  width: calc(var(--r) * 2); height: calc(var(--r) * 2);
  border: 1.5px solid var(--accent); border-radius: 50%;
  opacity: 0.8;
}
.lc-note { font-size: 10.5px; color: var(--text-dim); }

/* ── per-event story progress ────────────────────────────────────────────── */
/* on the detail panel (full track with stage ticks) */
#d-story { display: none; margin: 8px 0 10px; }
#d-story.on { display: block; }
#d-story-track {
  position: relative; height: 9px;
  background: rgba(255, 255, 255, 0.09);
  border-radius: 6px;
  cursor: pointer;
}
#d-story-fill {
  position: absolute; inset-block: 0; inset-inline-start: 0;
  width: 0%;
  background: linear-gradient(90deg, rgba(255, 212, 94, 0.55), var(--accent));
  border-radius: 6px;
}
html[dir="rtl"] #d-story-fill { background: linear-gradient(-90deg, rgba(255, 212, 94, 0.55), var(--accent)); }
#d-story-stage { margin-top: 6px; color: var(--accent); font-size: 13px; font-weight: 600; min-height: 1.2em; }

/* on event cards (slim bar under the title) */
.evt-prog {
  display: block; position: relative;
  height: 4px; margin-top: 5px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}
.evt-prog b {
  display: block; height: 100%; width: 0%;
  background: var(--cat, var(--accent));
  border-radius: 3px;
}
.evt-stage { color: var(--accent); font-weight: 600; }

/* on the floating map label */
.lbl-prog {
  display: block; position: relative;
  height: 3px; margin-top: 3px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 2px;
  overflow: hidden;
}
.lbl-prog b {
  display: block; height: 100%; width: 0%;
  background: var(--accent);
  border-radius: 2px;
}
.sb-tick {
  position: absolute; top: -3px; bottom: -3px;
  width: 2px; margin-inline-start: -1px;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 1px;
  cursor: pointer;
}
.sb-tick:hover { background: #fff; }
.sb-tick::after {
  content: attr(data-label);
  position: absolute; bottom: 16px; left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 16, 28, 0.92);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 11px;
  padding: 3px 8px;
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s;
}
.sb-tick:hover::after { opacity: 1; }

/* ── scroll hint ─────────────────────────────────────────────────────────── */
#scroll-hint {
  position: fixed; bottom: 68px; left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  display: flex; align-items: center; gap: 8px;
  color: var(--text-dim); font-size: 12px;
  background: rgba(10, 16, 28, 0.6);
  padding: 6px 14px; border-radius: 20px;
  pointer-events: none;
  animation: hintFloat 2.6s ease-in-out infinite;
}
.mouse {
  width: 14px; height: 22px;
  border: 1.5px solid var(--text-dim);
  border-radius: 8px;
  position: relative;
}
.mouse::after {
  content: ''; position: absolute; left: 50%; top: 4px;
  width: 2px; height: 5px; margin-left: -1px;
  background: var(--text-dim); border-radius: 2px;
  animation: wheel 1.6s ease-in-out infinite;
}
@keyframes wheel { 0%,100% { transform: translateY(0); opacity: 1; } 60% { transform: translateY(6px); opacity: 0.2; } }
@keyframes hintFloat { 0%,100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-4px); } }

/* ── intro ───────────────────────────────────────────────────────────────── */
#intro {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 10, 18, 0.78);
  backdrop-filter: blur(6px);
  transition: opacity 0.4s;
}
#intro.hidden { opacity: 0; pointer-events: none; }
#intro-card {
  max-width: 560px; margin: 20px;
  background: rgba(15, 23, 40, 0.95);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 36px 40px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
#intro-title {
  font-family: var(--font-he);
  font-size: 42px; color: var(--accent);
  text-shadow: 0 0 30px rgba(255, 212, 94, 0.3);
}
#intro-sub { color: #cfe0ff; margin: 6px 0 18px; font-size: 15px; }
#intro-card p { color: var(--text-dim); font-size: 14px; line-height: 1.65; margin-bottom: 12px; }
#intro-begin {
  margin-top: 10px;
  background: var(--accent); color: #14181f;
  font-weight: 700; font-size: 15px; font-family: inherit;
  border: none; border-radius: 12px;
  padding: 12px 30px; cursor: pointer;
  box-shadow: 0 6px 24px rgba(255, 212, 94, 0.35);
}
#intro-begin:hover { filter: brightness(1.08); }
#intro-links { margin-top: 16px; font-size: 12.5px; color: var(--text-dim); }
#intro-links a { color: var(--text-dim); text-decoration: none; margin: 0 4px; }
#intro-links a:hover { color: var(--accent); }

/* ── responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  /* the side panel becomes a drawer hidden off the LEFT edge —
     the 📜 in the bottom nav slides it in (physical left in both languages) */
  #evt-panel {
    top: 64px; bottom: 60px;
    inset-inline: auto; left: 0; right: auto;
    width: min(320px, 84vw);
    z-index: 16;
    transform: translateX(-112%);
    transition: transform 0.28s;
  }
  #evt-panel.open { transform: none; }
  /* the year rail hides off the right — the ⏳ in the bottom nav opens it */
  #year-rail {
    bottom: 52px;
    transform: translateX(100%);
    transition: transform 0.28s;
  }
  #year-rail.open { transform: none; }
  #year-heb { font-size: 32px; }
  #year-digits { font-size: 27px; }
  #year-box { min-width: 180px; padding: 8px 14px 10px; align-self: center; }
  #hud { flex-direction: column; align-items: stretch; gap: 8px; }
  /* header row: language chip · search */
  #hud-left { width: 100%; display: flex; gap: 8px; align-items: center; }
  #hud-left #searchbox { flex: 1; margin: 0; }
  #brand { order: 2; }
  #detail, #entity-detail { bottom: 60px; max-height: 46vh; inset-inline: 10px; width: auto; }
  .tl-era span { font-size: 9px; }
}

@media (max-width: 900px) {
  /* one-finger time scroll is driven in JS — keep the browser and the
     cooperative-gesture overlay out of it; two fingers stay MapLibre's */
  .maplibregl-canvas-container, .maplibregl-canvas { touch-action: none !important; }
  .maplibregl-cooperative-gesture-screen { display: none !important; }
  /* no button row on phones: pinch zooms, the bottom nav opens the drawers */
  #controls, #legend, #footer, #panel-btn { display: none !important; }
  #mini-card { left: 10px; right: 10px; bottom: 60px; }
  #search-results { max-height: 40vh; }
}

/* ── mobile bottom navigation: 📜 panel · ⋯ menu · ⏳ timeline ───────────── */
#bottom-nav, #bn-menu-pop { display: none; }
@media (max-width: 900px) {
  #bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0;
    z-index: 20; height: 52px;
    direction: ltr; /* physical order in both languages: panel left, timeline right */
    background: rgba(11, 17, 32, 0.92);
    border-top: 1px solid var(--panel-border);
    backdrop-filter: blur(8px);
  }
  #bottom-nav button {
    flex: 1;
    background: none; border: none;
    color: var(--text); font-size: 21px; line-height: 1;
    font-family: inherit; cursor: pointer;
  }
  #bottom-nav button.active { color: var(--accent); }
  #bn-menu-pop.open {
    display: block; position: fixed; bottom: 60px; left: 50%;
    transform: translateX(-50%);
    z-index: 21; min-width: 200px;
    background: rgba(13, 20, 34, 0.96);
    border: 1px solid var(--panel-border); border-radius: 14px;
    padding: 8px 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  }
  #bn-menu-pop a {
    display: block; padding: 10px 18px;
    color: var(--text); text-decoration: none; font-size: 14px; text-align: center;
  }
  #bn-menu-pop a:active { color: var(--accent); }
  #bn-menu-pop .m-attr {
    border-top: 1px solid var(--panel-border);
    margin-top: 6px; padding: 8px 14px 2px;
    font-size: 10.5px; color: var(--text-dim); text-align: center;
  }
  #bn-menu-pop .m-attr a { display: inline; padding: 0; font-size: 10.5px; color: var(--text-dim); }
}
