/* The timeline tip: one pill badge above the slider, two short parts with an
   accent icon each. Tinted from --accent so it follows every theme. */
.map-time-hint {
  display: flex;
  align-items: center;
  gap: .25rem;
  width: fit-content;
  max-width: calc(100% - 2rem);
  margin: .75rem auto 0;
  padding: .3rem .3rem .3rem .9rem;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 9%, var(--bg));
  color: var(--text);
  font-size: .82rem;
  font-weight: 600;
  line-height: 1.3;
  box-shadow: var(--sh-sm, 0 1px 3px rgba(0,0,0,.08));
  animation: map-time-hint-in .45s cubic-bezier(.2,.8,.2,1) both;
}
.map-time-hint[hidden] { display: none; }
.map-time-hint p {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: .9rem;
  row-gap: .2rem;
  margin: 0;
}
.map-time-hint p, .map-time-hint__part { min-width: 0; }
.map-time-hint__part {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  text-wrap: balance;
}
.map-time-hint__part + .map-time-hint__part::before {
  content: "";
  width: 4px;
  height: 4px;
  margin-right: .5rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 45%, transparent);
}
.map-time-hint svg {
  width: 1.05rem;
  height: 1.05rem;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.map-time-hint button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  margin-left: .35rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  position: relative;
}
/* 44px touch target around the small visible circle. */
.map-time-hint button::after { content: ""; position: absolute; inset: -6px; }
.map-time-hint button svg { width: .9rem; height: .9rem; stroke: currentColor; }
.map-time-hint button:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--text); }
.map-time-hint button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@keyframes map-time-hint-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
@media (max-width: 560px) {
  .map-time-hint { border-radius: 1.1rem; padding-left: .75rem; font-size: .76rem; }
  .map-time-hint__part + .map-time-hint__part::before { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .map-time-hint { animation: none; }
}

/* Bare slider row — same padding as topbar so edges align */
.map-slider-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem clamp(1.25rem, 4vw, 3rem);
  max-width: 1440px;
  margin: 0 auto;
}

.map-slider-row .time-track {
  flex: 1;
  /* room above the track for the year pill (label sits at 100% + 8px) */
  margin: 2.1rem 0 1rem;
}

.slider-year {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.map-time-reset {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 2rem;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}

.map-time-reset:hover { color: var(--text); border-color: var(--text); }

.route-start-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 2rem;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--text);
  color: var(--bg);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s, background 0.15s;
}

.route-start-btn:hover {
  transform: translateY(-1px);
  background: color-mix(in srgb, var(--text) 88%, var(--accent));
}

.route-start-icon {
  font-size: 0.9rem;
  line-height: 1;
}

.route-start-count {
  display: inline-grid;
  place-items: center;
  min-width: 1.2rem;
  height: 1.2rem;
  padding: 0 0.25rem;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--bg) 18%, transparent);
  font-size: 0.58rem;
}

/* ===== TIME SLIDER (inline in WHEN segment) ===== */
.ab-when-slider {
  flex: 2;
  gap: 0.25rem;
  padding: 0.55rem 1.25rem 0.55rem;
}

.ab-when-range {
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: none;
  margin-left: 0.4em;
}

.ab-time-track-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.3rem 0 0.15rem;
}

.ab-time-year {
  font-family: var(--font);
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.ab-when-slider .time-handle-label { display: none; }

.ab-time-reset {
  align-self: center;
  margin: 0 0.75rem;
  flex-shrink: 0;
}

.time-track {
  position: relative;
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--surf-2);
  margin: 1.4rem 0;
}

.time-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.35;
  pointer-events: none;
}

.time-handle {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg);
  border: 2.5px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  cursor: grab;
  transition: transform 0.12s, box-shadow 0.12s;
  touch-action: none;
  z-index: 2;
}

.time-handle:active {
  cursor: grabbing;
}

.time-handle:hover,
.time-handle:focus {
  outline: none;
  transform: translate(-50%, -50%) scale(1.15);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 15%, transparent);
}

.time-handle-label {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  /* --label-shift is set by timeline.js to keep the year on screen. */
  transform: translateX(calc(-50% + var(--label-shift, 0px)));
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}

/* ===== ERA-BANDED MAP TIMELINE =====
   The map view's time track shows the six eras as material-colored bands
   (flint, bronze, laurel, lapis, porcelain, rose). Band stops follow
   yearToTimelinePct() of TIME_ERA_LIMITS in time-model.js:
   -3000 -> 28%, -500 -> 48%, 600 -> 64%, 1400 -> 83.2%, 1800 -> 93.5%. */
:root {
  --era-prehistoric: #93856f;
  --era-ancient: #c08435;
  --era-classical: #7d9b52;
  --era-medieval: #5271cf;
  --era-early-modern: #2b9fb3;
  --era-modern: #f43f5e;
}

[data-theme="dark"] {
  --era-prehistoric: #a89a83;
  --era-ancient: #d4964a;
  --era-classical: #93b168;
  --era-medieval: #6f8ce0;
  --era-early-modern: #3fb4c8;
  --era-modern: #ff6b81;
}

/* timeline.js sets data-era on #timeTrack while scrubbing */
[data-era="prehistoric"]  { --era-c: var(--era-prehistoric); }
[data-era="ancient"]      { --era-c: var(--era-ancient); }
[data-era="classical"]    { --era-c: var(--era-classical); }
[data-era="medieval"]     { --era-c: var(--era-medieval); }
[data-era="early-modern"] { --era-c: var(--era-early-modern); }
[data-era="modern"]       { --era-c: var(--era-modern); }

.map-slider-row .time-track {
  height: 10px;
  cursor: pointer;
  margin: 2.1rem 0 1.55rem;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--era-prehistoric) 34%, var(--bg)) 0 28%,
    color-mix(in srgb, var(--era-ancient) 34%, var(--bg)) 28% 48%,
    color-mix(in srgb, var(--era-classical) 34%, var(--bg)) 48% 64%,
    color-mix(in srgb, var(--era-medieval) 34%, var(--bg)) 64% 83.2%,
    color-mix(in srgb, var(--era-early-modern) 34%, var(--bg)) 83.2% 93.5%,
    color-mix(in srgb, var(--era-modern) 34%, var(--bg)) 93.5% 100%);
}

/* elapsed time = the same spectrum at full saturation, clipped at the handle */
.map-slider-row .time-track::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  pointer-events: none;
  clip-path: inset(0 calc(100% - var(--tpct, 52%)) 0 0 round 999px);
  background: linear-gradient(90deg,
    var(--era-prehistoric) 0 28%,
    var(--era-ancient) 28% 48%,
    var(--era-classical) 48% 64%,
    var(--era-medieval) 64% 83.2%,
    var(--era-early-modern) 83.2% 93.5%,
    var(--era-modern) 93.5% 100%);
}

.map-slider-row .time-fill { display: none; }

.map-slider-row .time-handle {
  width: 44px;
  height: 44px;
  background: transparent;
  border: 0;
  box-shadow: none;
  transition: transform 0.12s;
}

.map-slider-row .time-handle::before {
  content: "";
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--era-c, var(--accent));
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  transition: box-shadow 0.12s, border-color 0.2s;
}

.map-slider-row .time-handle:hover,
.map-slider-row .time-handle:focus {
  box-shadow: none;
}

.map-slider-row .time-handle:hover::before,
.map-slider-row .time-handle:focus::before {
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--era-c, var(--accent)) 18%, transparent);
}

.map-slider-row .time-handle-label {
  bottom: calc(50% + 19px);
  opacity: 1;
  background: var(--bg);
  border: 1px solid color-mix(in srgb, var(--era-c, var(--accent)) 60%, var(--border));
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  transition: border-color 0.2s;
}

.time-eras {
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  right: 0;
  pointer-events: none;
}

.time-eras span {
  position: absolute;
  left: var(--l);
  transform: translateX(-50%);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.time-eras .time-era-end {
  left: auto;
  right: 0;
  transform: none;
}

@media (max-width: 900px) {
  .time-eras { display: none; }
}

.time-reset {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}

.time-reset:hover {
  color: var(--text);
  border-color: var(--text);
}

@media (max-width: 680px) {
  .map-slider-row {
    flex-wrap: wrap;
  }

  .map-slider-row .time-track {
    flex-basis: 100%;
    order: 3;
  }

  .route-start-btn {
    margin-left: auto;
  }
}
