/* ==========================================================================
   Historical Maps Timeline — the bottom panel:
   year readout, Play/opacity controls, timeline track, axis, playhead, scrub.
   ========================================================================== */

.hmt-timeline-wrapper .hmt-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--hmt-panel-h);
  z-index: 500;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .10), rgba(0, 0, 0, 0) 40%),
    var(--hmt-paper);
  border-top: 1px solid var(--hmt-paper-edge);
  box-shadow: var(--hmt-shadow);
  display: grid;
  grid-template-columns: minmax(150px, 210px) 1fr;
  grid-template-rows: auto 1fr;
  column-gap: 22px;
  row-gap: 6px;
  padding: 14px 20px 16px;
}

/* ---- Readout block (left, spans both rows) ---- */
.hmt-timeline-wrapper .hmt-readout {
  grid-row: 1 / span 2;
  align-self: center;
  border-right: 1px solid var(--hmt-line);
  padding-right: 18px;
}

.hmt-timeline-wrapper .hmt-readout .lbl {
  font-size: 10.5px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--hmt-ink-soft);
  font-weight: 600;
}

.hmt-timeline-wrapper .hmt-readout .year {
  font-family: "Archivo", sans-serif;
  font-weight: 800;
  color: var(--hmt-head);
  font-size: clamp(46px, 8vw, 66px);
  line-height: .9;
  letter-spacing: -.03em;
  font-variant-numeric: lining-nums tabular-nums;
  margin-top: 2px;
}

.hmt-timeline-wrapper .hmt-readout .range {
  font-size: 12px;
  color: var(--hmt-ink-soft);
  margin-top: 6px;
}

.hmt-timeline-wrapper .hmt-readout .range b {
  color: var(--hmt-ink);
  font-weight: 600;
}

/* ---- Controls row ---- */
.hmt-timeline-wrapper .hmt-controls {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.hmt-timeline-wrapper .btn-play {
  appearance: none;
  border: 1px solid var(--hmt-ink);
  background: var(--hmt-ink);
  color: var(--hmt-paper);
  font-family: inherit;
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: .04em;
  height: 34px;
  padding: 0 16px 0 13px;
  border-radius: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background .15s, color .15s, opacity .15s;
}

.hmt-timeline-wrapper .btn-play:hover { background: #000; }

.hmt-timeline-wrapper .btn-play:focus-visible {
  outline: 2px solid var(--hmt-vermilion);
  outline-offset: 2px;
}

.hmt-timeline-wrapper .btn-play svg {
  width: 13px;
  height: 13px;
  display: block;
}

.hmt-timeline-wrapper .opacity-ctl {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 170px;
}

.hmt-timeline-wrapper .opacity-ctl .lbl {
  font-size: 10.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--hmt-ink-soft);
  font-weight: 600;
  white-space: nowrap;
}

.hmt-timeline-wrapper .opacity-ctl input[type="range"] {
  flex: 1;
  min-width: 80px;
}

.hmt-timeline-wrapper .hmt-status {
  font-size: 11.5px;
  color: var(--hmt-ink-soft);
  margin-left: auto;
}

.hmt-timeline-wrapper .hmt-status.warn {
  color: var(--hmt-vermilion);
  font-weight: 600;
}

/* ---- Timeline track ---- */
.hmt-timeline-wrapper .track-wrap {
  grid-column: 2;
  position: relative;
  padding-top: 2px;
}

.hmt-timeline-wrapper .track {
  position: relative;
  background: var(--hmt-paper-2);
  border: 1px solid var(--hmt-paper-edge);
  border-radius: 3px;
  height: 100%;
  min-height: 96px;
  padding: 10px 0 22px;
  overflow: hidden;
}

/* The rows scroll when there are more lanes than fit — the auto margins on
   the first/last row keep a short list centred without clipping a long one
   (plain `justify-content: center` cuts off the top when it overflows). */
.hmt-timeline-wrapper .rows {
  position: absolute;
  left: 0; right: 0; top: 10px; bottom: 22px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 5px;
  padding: 0 2px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--hmt-paper-edge) transparent;
  /* Above .scrub so the single-year markers below can be hovered for their
     full title; everything except those markers stays click-through, so
     dragging anywhere on the track still scrubs. */
  z-index: 6;
  pointer-events: none;
}

.hmt-timeline-wrapper .rows > .row:first-child { margin-top: auto; }
.hmt-timeline-wrapper .rows > .row:last-child  { margin-bottom: auto; }

.hmt-timeline-wrapper .rows::-webkit-scrollbar        { width: 7px; }
.hmt-timeline-wrapper .rows::-webkit-scrollbar-thumb  { background: var(--hmt-paper-edge); border-radius: 4px; }
.hmt-timeline-wrapper .rows::-webkit-scrollbar-track  { background: transparent; }

.hmt-timeline-wrapper .row {
  position: relative;
  height: 20px;
  flex: none;
}

/* A shared lane holding several single-year markers */
.hmt-timeline-wrapper .row.lane {
  height: 13px;
}

.hmt-timeline-wrapper .row .span {
  position: absolute;
  top: 0; bottom: 0;
  border-radius: 2px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  overflow: hidden;
  white-space: nowrap;
  border: 1px solid currentColor;
  color: var(--hmt-ink-soft);
  background: transparent;
  transition: background .25s ease, color .25s ease, box-shadow .25s ease, opacity .25s ease;
  opacity: .5;
}

.hmt-timeline-wrapper .row .span .name {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
}

.hmt-timeline-wrapper .row .span.active {
  opacity: 1;
  color: #fff;
  background: var(--c);
  border-color: var(--c);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .12), inset 0 0 0 1px rgba(255, 255, 255, .18);
}

/* single-year marker (service with a from-year only) */
.hmt-timeline-wrapper .row .span.point {
  border: 0;
  background: transparent !important;
  overflow: visible;
  padding: 0 0 0 16px;
  box-shadow: none;
  color: var(--c);
}

.hmt-timeline-wrapper .row .span.point::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 10px;
  height: 10px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: transparent;
  border: 1.5px solid currentColor;
  border-radius: 1px;
  transition: background .2s ease, box-shadow .2s ease;
}

/* Invisible click pad centred on the diamond. The label must not be part of
   the target — labels overlap their neighbours, and everything that is not a
   marker has to stay click-through so dragging the track still scrubs. Sized
   to MARKER_GAP_PX in timeline.js so two pads never overlap. */
.hmt-timeline-wrapper .row .span.point::after {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 15px;
  height: 15px;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
}

.hmt-timeline-wrapper .row .span.point:focus-visible {
  outline: none;
}

/* Ring the diamond itself. Deliberately `outline` and not `box-shadow`: the
   .muted rule below resets box-shadow, which would swallow the focus ring on
   precisely the markers a keyboard user tabs to in order to switch back on. */
.hmt-timeline-wrapper .row .span.point:focus-visible::before {
  outline: 2px solid var(--hmt-vermilion);
  outline-offset: 2px;
}

.hmt-timeline-wrapper .row .span.point .name    { color: var(--hmt-ink-soft); }
.hmt-timeline-wrapper .row .span.point.active   { opacity: 1; }

/* Switched off: hollow dashed diamond, never filled even in its own year */
.hmt-timeline-wrapper .row .span.point.muted::before {
  background: transparent;
  border-style: dashed;
  box-shadow: none;
}

.hmt-timeline-wrapper .row .span.point.muted .name {
  text-decoration: line-through;
  opacity: .7;
}

/* Markers sharing a lane sit too close for permanent labels, so the name is
   revealed only for the year in view (or on hover) and lifted above its
   neighbours while it shows. */
.hmt-timeline-wrapper .row.lane .span.point .name { display: none; }

.hmt-timeline-wrapper .row.lane .span.point.active .name,
.hmt-timeline-wrapper .row.lane .span.point:hover .name { display: inline; }

.hmt-timeline-wrapper .row.lane .span.point.active,
.hmt-timeline-wrapper .row.lane .span.point:hover { z-index: 3; }

.hmt-timeline-wrapper .row .span.point.active::before {
  background: var(--c);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent);
}

.hmt-timeline-wrapper .row .span.point.active .name { color: var(--hmt-ink); }

/* ---- Axis ticks ---- */
.hmt-timeline-wrapper .axis {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 22px;
  pointer-events: none;
}

.hmt-timeline-wrapper .tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  text-align: center;
}

.hmt-timeline-wrapper .tick .mark {
  width: 1px;
  height: 6px;
  background: var(--hmt-line);
  margin: 0 auto;
}

.hmt-timeline-wrapper .tick .lab {
  font-size: 9.5px;
  color: var(--hmt-ink-soft);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  letter-spacing: .02em;
}

/* ---- Playhead ---- */
.hmt-timeline-wrapper .playhead {
  position: absolute;
  top: 6px; bottom: 14px;
  width: 2px;
  background: var(--hmt-vermilion);
  transform: translateX(-1px);
  pointer-events: none;
  z-index: 7;   /* above .rows, which sits above .scrub */
}

.hmt-timeline-wrapper .playhead::before {
  content: "";
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--hmt-vermilion);
}

/* ---- Invisible range input stretched over the track ---- */
.hmt-timeline-wrapper .scrub {
  position: absolute;
  left: 0; right: 0; top: 0; bottom: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: ew-resize;
  z-index: 5;
}

.hmt-timeline-wrapper .scrub:focus-visible {
  outline: 2px solid var(--hmt-vermilion);
  outline-offset: 2px;
  border-radius: 3px;
}

.hmt-timeline-wrapper .scrub::-webkit-slider-runnable-track { background: transparent; height: 100%; }
.hmt-timeline-wrapper .scrub::-moz-range-track              { background: transparent; height: 100%; }
.hmt-timeline-wrapper .scrub::-webkit-slider-thumb          { -webkit-appearance: none; appearance: none; width: 18px; height: 100%; background: transparent; cursor: ew-resize; }
.hmt-timeline-wrapper .scrub::-moz-range-thumb              { width: 18px; height: 100%; background: transparent; border: 0; cursor: ew-resize; }

/* ---- Opacity slider ---- */
.hmt-timeline-wrapper input[type="range"].slim {
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: var(--hmt-ink-soft);
  border-radius: 3px;
  outline: none;
}

.hmt-timeline-wrapper input[type="range"].slim::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--hmt-ink);
  border: 2px solid var(--hmt-paper);
  cursor: pointer;
}

.hmt-timeline-wrapper input[type="range"].slim::-moz-range-thumb {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--hmt-ink);
  border: 2px solid var(--hmt-paper);
  cursor: pointer;
}

.hmt-timeline-wrapper input[type="range"].slim:focus-visible {
  box-shadow: 0 0 0 2px var(--hmt-vermilion);
}

/* ---- Mobile ---- */
@media (max-width: 680px) {
  .hmt-timeline-wrapper {
    --hmt-panel-h: 300px;
  }

  .hmt-timeline-wrapper .hmt-panel {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    padding: 10px 14px 12px;
    column-gap: 0;
    row-gap: 7px;
  }

  .hmt-timeline-wrapper .hmt-readout {
    grid-row: auto;
    border-right: 0;
    border-bottom: 1px solid var(--hmt-line);
    padding: 0 0 7px;
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
  }

  .hmt-timeline-wrapper .hmt-readout .year  { font-size: 38px; }
  .hmt-timeline-wrapper .hmt-readout .range  { margin-top: 0; }
  .hmt-timeline-wrapper .track-wrap          { grid-column: 1; }
  .hmt-timeline-wrapper .hmt-status          { margin-left: 0; flex-basis: 100%; font-size: 10.5px; }
  .hmt-timeline-wrapper .track              { min-height: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  .hmt-timeline-wrapper .row .span { transition: none; }
}
