/* ── Map Wrap ── */
#map-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-height: calc(100vh - 8px - var(--page-pad));
  width: calc(100vw - var(--left-pad) - var(--sidebar-gap) - var(--page-pad) * 2);
  padding-top: 0;
}

/* ── Map Container ── */
#map-container {
  position: relative;
  aspect-ratio: 1817 / 1080;
  width: 100%;
  max-height: 100%;
  flex-shrink: 1;
  min-height: 0;
  background-image: url('../images/background.jpg');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-color: #000000;
  overflow: hidden;
  border-radius: 6px;
}

#map-container.edit-mode {
  outline: 3px dashed var(--accent);
  outline-offset: -3px;
}

/* ── Map Header ── */
#map-header {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
}

html.light #page-subtitle { color: #111; }

#page-subtitle {
  color: #fff;
  font-size: 10px;
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1;
  text-transform: uppercase;
  border: none;
}

#map-title-block {
  background: #000;
  padding: 12px 10px 2px;
}

html.light #map-title-block { background: #fff; }

html.light #map-controls button {
  background: #fff;
  color: #111;
  border-color: rgba(0,0,0,0.3);
}
html.light #map-controls button:hover { background: #f0f0f0; }

/* ── Map Controls ── */
#map-controls {
  display: flex;
  gap: 6px;
}

#map-controls button {
  font-family: var(--font-body);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 10px;
  line-height: 1;
  background: #000;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.5);
  cursor: pointer;
}

#map-controls button:hover {
  background: #222;
}

/* ── SVG Arrow Layer ── */
#arrow-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* ── Buttons Layer ── */
#buttons-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}

/* ── Point Button ── */
.point-button {
  position: absolute;
  width: 25px;
  height: 25px;
  font-size: 10px;
  margin-left: -15px;
  margin-top: -15px;
  border-radius: 50%;
  background: #000;
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.45);
  cursor: default;
  user-select: none;
  transition: transform 0.1s;
}

.point-button:hover {
  transform: scale(1.15);
}

.edit-mode .point-button {
  cursor: grab;
}

.edit-mode .point-button.dragging {
  cursor: grabbing;
  transform: scale(1.2);
  box-shadow: 0 2px 8px rgba(0,0,0,.6);
  z-index: 10;
}

.point-start,
.point-end {
  width: 38px;
  height: 38px;
  margin-left: -19px;
  margin-top: -19px;
  font-size: 11px;
  border: 2px solid #fff;
}

.point-start {
  background: hsl(240, 100%, 50%);
}

.point-end {
  background: hsl(0, 100%, 45%);
}

.point-start::after,
.point-end::after {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 4px;
  font-family: var(--font-body);
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.8);
}

.point-start::after {
  content: 'START';
}

.point-end::after {
  content: 'END';
}

/* ── Preview ── */
#preview-wrap {
  position: absolute;
  pointer-events: none;
  z-index: 6;
  display: none;
}

#preview-title {
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  padding: 6px 10px;
  border-radius: 6px 6px 0 0;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-bottom: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#preview-title:empty {
  display: none;
}

#preview {
  height: var(--preview-height);
  width: auto;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 0 0 6px 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,.5);
}

#preview-title:empty ~ #preview {
  border-radius: 6px;
}

/* ── Legend ── */
#legend {
  position: absolute;
  bottom: 10px;
  left: 10px;
  width: 150px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#legend-labels {
  display: flex;
  justify-content: space-between;
}

#legend-bar {
  width: 100%;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(to right,
    hsl(240, 100%, 50%),
    hsl(180, 100%, 50%),
    hsl(120, 100%, 50%),
    hsl(60, 100%, 50%),
    hsl(0, 100%, 50%)
  );
}

.legend-label {
  color: #fff;
  font-family: var(--font-body);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* ── Timeline Slider ── */
#timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  flex-shrink: 0;
}

/* ── Timeline track wrap ── */
#timeline-track-wrap {
  position: relative;
  width: 100%;
  height: 32px;
  display: flex;
  align-items: center;
}

#timeline-markers {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.timeline-marker {
  position: absolute;
  top: 50%;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.55);
  color: #fff;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateX(-50%) translateY(-50%);
  pointer-events: none;
}

#timeline-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right,
    hsl(240, 100%, 50%),
    hsl(180, 100%, 50%),
    hsl(120, 100%, 50%),
    hsl(60, 100%, 50%),
    hsl(0, 100%, 50%)
  );
  outline: none;
  cursor: pointer;
}

/* Hide native thumb — replaced by #timeline-thumb */
#timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  opacity: 0;
}

#timeline-slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  opacity: 0;
  border: none;
}

#timeline-thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  transform: translateX(0px) translateY(-50%);
  pointer-events: none;
  mix-blend-mode: difference;
}

#timeline-slider::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right,
    hsl(240, 100%, 50%),
    hsl(180, 100%, 50%),
    hsl(120, 100%, 50%),
    hsl(60, 100%, 50%),
    hsl(0, 100%, 50%)
  );
}

/* ── Timeline controls row ── */
#timeline-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#timeline-step-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ── Unified button style ── */
#timeline-play,
#timeline-prev,
#timeline-next,
#walk-mode-btn,
#auto-preview-btn,
#auto-animate-btn {
  font-family: var(--font-body);
  font-size: 12px;
  background: #fff;
  color: #000;
  border: 1.5px solid rgba(0, 0, 0, 0.15);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

/* Icon buttons — circular */
#timeline-play,
#timeline-prev,
#timeline-next {
  width: 46px;
  height: 46px;
  padding: 0;
  font-size: 20px;
  border-radius: 50%;
  line-height: 1;
}

/* Text buttons — pill */
#walk-mode-btn,
#auto-preview-btn,
#auto-animate-btn {
  height: 46px;
  padding: 0 20px;
  border-radius: 23px;
  font-size: 13px;
  white-space: nowrap;
  letter-spacing: 0.3px;
  min-width: 110px;
}

#walk-mode-btn { width: 130px; }

#timeline-play:hover,
#timeline-prev:hover,
#timeline-next:hover,
#walk-mode-btn:hover,
#auto-preview-btn:hover,
#auto-animate-btn:hover {
  background: #eee;
  border-color: rgba(0, 0, 0, 0.3);
}


#walk-mode-btn.active,
#auto-preview-btn.active,
#auto-animate-btn.active {
  background: #fff;
  color: #000;
  border-color: rgba(0, 0, 0, 0.3);
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .point-button {
    width: 26px;
    height: 26px;
    margin-left: -13px;
    margin-top: -13px;
    font-size: 11px;
  }
}

@media (max-width: 768px) {
  .point-button {
    width: 22px;
    height: 22px;
    margin-left: -11px;
    margin-top: -11px;
    font-size: 10px;
  }

  #preview-title {
    font-size: 11px;
    padding: 4px 8px;
  }
}

@media (max-width: 480px) {
  .point-button {
    width: 18px;
    height: 18px;
    margin-left: -9px;
    margin-top: -9px;
    font-size: 8px;
  }
}
