:root {
  --parchment:   #f4ecd9;
  --parchment-2: #efe4cb;
  --ink:         #2e2620;
  --ink-soft:    #5c5246;
  --line:        #d9cbac;
  --gold:        #b08a3e;
  --card:        #fbf6e9;
  --shadow:      0 1px 3px rgba(60, 45, 20, 0.12);
  --serif: "Spectral", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.5;
}

/* ---------- Hero ---------- */
.hero {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.35), rgba(255,255,255,0) 60%),
    var(--parchment);
  border-bottom: 2px solid var(--line);
  padding: 1.4rem clamp(1rem, 4vw, 3rem) 0.9rem;
}
.hero-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 2rem;
  max-width: 1500px;
  margin: 0 auto;
}
.hero h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3.4vw, 2.7rem);
  font-weight: 700;
  letter-spacing: 0.01em;
}
.hero-sub {
  margin: 0.2rem 0 0;
  color: var(--ink-soft);
  font-style: italic;
  font-size: clamp(0.92rem, 1.6vw, 1.05rem);
}
.hero-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.6rem; }

.scholar-picker { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--ink-soft); }
.scholar-picker select {
  font-family: var(--serif); font-size: 0.9rem; padding: 0.2rem 0.4rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 4px; color: var(--ink);
}

.stats { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; }
.chip {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  white-space: nowrap;
}
.chip .num { font-size: 1.15rem; font-weight: 700; color: var(--ink); }
.chip .lbl { font-size: 0.74rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-soft); }
.chip.headline { background: #efe2c2; border-color: var(--gold); }

.method-toggle {
  margin: 0.7rem auto 0;
  display: block;
  background: none;
  border: none;
  color: var(--gold);
  font-family: var(--serif);
  font-size: 0.85rem;
  font-style: italic;
  cursor: pointer;
  text-decoration: underline dotted;
}
.method-note {
  max-width: 760px;
  margin: 0.5rem auto 0.2rem;
  font-size: 0.84rem;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.7rem 0.9rem;
}
.method-note ul { margin: 0.3rem 0 0; padding-left: 1.1rem; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr);
  gap: 0;
  height: calc(100vh - 132px);
  min-height: 480px;
}
.map-wrap { position: relative; min-height: 360px; }
#map {
  width: 100%;
  height: 100%;
  background: #e9e0c8;
}
/* warm the basemap to parchment tones */
.leaflet-tile-pane { filter: sepia(38%) saturate(85%) brightness(1.03) contrast(0.92); }
.leaflet-container { font-family: var(--serif); background: #e9e0c8; }

/* ---------- Map labels & markers ---------- */
.place-label {
  background: rgba(251, 246, 233, 0.82);
  border: none;
  box-shadow: none;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0 3px;
  white-space: nowrap;
}
.place-label::before { display: none; }      /* drop tooltip caret */
.place-label.region { font-style: italic; color: var(--ink-soft); }
.place-label .badge {
  display: inline-block;
  margin-left: 3px;
  background: var(--ink);
  color: var(--parchment);
  border-radius: 999px;
  font-size: 0.62rem;
  padding: 0 5px;
}
.arrowhead { color: var(--ink-soft); font-size: 1.1rem; line-height: 1; text-shadow: 0 0 2px var(--parchment); }

.leaflet-popup-content-wrapper { background: var(--card); border-radius: 6px; }
.leaflet-popup-content { margin: 0.7rem 0.85rem; font-size: 0.85rem; }
.popup-place { font-weight: 700; font-size: 0.98rem; margin-bottom: 0.1rem; }
.popup-modern { color: var(--ink-soft); font-style: italic; font-size: 0.78rem; margin-bottom: 0.4rem; }
.popup-evt { padding: 0.25rem 0; border-top: 1px solid var(--line); }
.popup-evt .d { font-weight: 600; }

/* ---------- Legend ---------- */
.legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 500;
  background: rgba(251, 246, 233, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0.6rem 0.75rem;
  font-size: 0.74rem;
  max-width: 230px;
}
.legend h4 { margin: 0 0 0.4rem; font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); }
.legend .row { display: flex; align-items: center; gap: 0.5rem; margin: 0.22rem 0; }
.legend .swatch { width: 16px; height: 12px; border-radius: 3px; flex: none; }
.legend .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; border: 2px solid var(--ink); }
.legend .dot.hollow { background: transparent !important; }
.legend .dot.region { border-style: dashed; border-radius: 50%; background: rgba(120,110,80,0.18); }
.legend .glyph { width: 16px; text-align: center; flex: none; color: var(--ink-soft); }

/* ---------- Timeline ---------- */
.timeline {
  border-left: 2px solid var(--line);
  overflow-y: auto;
  padding: 1rem clamp(0.8rem, 1.6vw, 1.4rem) 2rem;
  background: linear-gradient(180deg, var(--parchment), #f0e6cf);
}
.timeline-note {
  font-size: 0.82rem;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 0 6px 6px 0;
  padding: 0.6rem 0.8rem;
  margin: 0 0 1.1rem;
}
.phase-section { margin-bottom: 1.5rem; }
.phase-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.4rem 0.2rem 0.4rem 0.7rem;
  border-left: 5px solid var(--phase, var(--gold));
  background: linear-gradient(90deg, color-mix(in srgb, var(--phase) 16%, var(--parchment)), var(--parchment));
  backdrop-filter: blur(2px);
}
.phase-head h3 { margin: 0; font-size: 1.02rem; }
.phase-head .range { font-size: 0.78rem; color: var(--ink-soft); font-style: italic; }

.evt {
  position: relative;
  margin: 0.55rem 0 0.55rem 0.7rem;
  padding: 0.55rem 0.7rem 0.6rem 0.85rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--phase, var(--line));
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  transition: box-shadow 0.12s, transform 0.12s, background 0.12s;
}
.evt:hover, .evt.active {
  box-shadow: 0 2px 10px rgba(60,45,20,0.18);
  transform: translateX(2px);
  background: #fdf9ef;
}
.evt.active { outline: 2px solid var(--gold); }
.evt-top { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.evt-place { font-weight: 700; font-size: 0.98rem; }
.evt-place .tag { font-size: 0.68rem; font-weight: 500; font-style: italic; color: var(--ink-soft); margin-left: 0.35rem; }
.evt-date { font-size: 0.82rem; white-space: nowrap; }
.evt-activity { font-size: 0.9rem; margin: 0.25rem 0 0.4rem; }
.evt-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; font-size: 0.72rem; color: var(--ink-soft); }

.pbadge {
  font-size: 0.66rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  border: 1px solid currentColor;
}
.pbadge.exact   { color: #3c6b3c; }
.pbadge.range,
.pbadge.decade  { color: #8a6d1f; }
.pbadge.before,
.pbadge.after,
.pbadge.approx  { color: #9c6b2f; }
.pbadge.unknown { color: #8a3b3b; }

.cbadge { padding: 0.05rem 0.4rem; border-radius: 4px; background: rgba(120,110,80,0.14); }
.cbadge.high { background: rgba(60,107,60,0.18); color: #2f5a2f; }
.cbadge.moderate { background: rgba(156,107,47,0.16); color: #8a5a26; }
.pages { font-style: italic; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 2px solid var(--line);
  padding: 0.9rem clamp(1rem, 4vw, 3rem);
  font-size: 0.78rem;
  color: var(--ink-soft);
  background: var(--parchment);
}
.site-footer p { margin: 0.2rem 0; max-width: 1100px; }
.footer-fine { font-style: italic; }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  #map { height: 62vh; min-height: 340px; }
  .timeline { border-left: none; border-top: 2px solid var(--line); max-height: none; }
  .hero-side { align-items: flex-start; }
  .stats { justify-content: flex-start; }
}
