/* ---- Time Slider ---- (split from styles.css) */

.time-slider-container {
  position: relative;
}

.time-slider-icon {
  font-size: 18px;
}

.time-slider-panel {
  position: fixed;
  bottom: 4em;
  left: 50%;
  transform: translateX(-50%);
  max-width: 750px;
  width: calc(100% - 6em);
  background: var(--surface-panel-floating);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-panel);
  z-index: 1000;
  display: none;
}

.time-slider-panel.open {
  display: flex;
  flex-direction: column;
}

.time-slider-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 12px;
}

/* Shrink panel on smaller screens to avoid overlapping bottom-right legend */
@media (max-width: 1000px) {
  .time-slider-panel {
    max-width: 550px;
  }

  .time-slider-label {
    margin-left: 0;
    flex-basis: 100%;
    text-align: center;
    order: 99;
    padding-top: 2px;
  }
}

@media (max-width: 700px) {
  .time-slider-panel {
    max-width: 400px;
  }

  .time-slider-sep {
    display: none;
  }
}

.time-slider-controls .time-slider-btn {
  appearance: none;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  min-width: 28px;
  background: var(--surface-btn) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm) !important;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  cursor: pointer;
  padding: 0;
  font-size: 15px;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-primary);
}

.time-slider-controls .time-slider-btn:hover {
  background: var(--surface-btn-hover) !important;
  border-color: var(--accent) !important;
}

.time-slider-controls .time-slider-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.time-slider-controls .time-slider-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

#time-slider-loop {
  opacity: 0.4;
}

#time-slider-loop.ts-loop-active {
  opacity: 1;
  color: var(--accent);
  border-color: var(--accent) !important;
}

.time-slider-loading {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-bottom-color: transparent;
  border-radius: 50%;
  box-sizing: border-box;
  vertical-align: middle;
  animation: ts-spin 0.8s linear infinite;
}

@keyframes ts-spin {
  to {
    transform: rotate(360deg);
  }
}

.time-slider-speed {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  padding: 4px 6px;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}

/* Separator between control groups */
.time-slider-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

/* Mode toggle inline */
.time-slider-toggle {
  --toggle-text: #222;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  color: var(--toggle-text);
}

.time-slider-toggle-label {
  display: inline-block;
  min-width: max-content;
  color: var(--toggle-text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
}

.time-slider-toggle-switch {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--slider-track);
  cursor: pointer;
  box-sizing: border-box;
  transition: background-color 0.2s ease;
}

.time-slider-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  /* Theme-independent white: the knob sits on the track and on --accent. */
  background: var(--text-on-accent);
  box-shadow: var(--shadow-xs);
  transition: transform 0.2s ease;
}

.time-slider-toggle.active-hourly .time-slider-toggle-switch {
  background: var(--accent);
}

.time-slider-toggle.active-hourly .time-slider-toggle-knob {
  transform: translateX(18px);
}

.time-slider-toggle-label.active {
  color: var(--accent);
  font-weight: 600;
}

.time-slider-toggle-label:focus-visible,
.time-slider-toggle-switch:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Timestamp label — pushed right in controls row */
.time-slider-label {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  margin-left: auto;
  flex-shrink: 0;
}

.time-slider-icon-btn {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0;
  cursor: pointer;
  color: var(--text-primary);
  line-height: 1;
}

.time-slider-icon-btn:hover {
  color: var(--text-muted);
}

.time-slider-minimize-btn {
  font-size: 13px !important;
}

.time-slider-close-btn {
  font-size: 18px !important;
}

.time-slider-icon-btn:hover {
  color: var(--text-muted) !important;
}

/* Row 2: slider */
.time-slider-slider-row {
  padding: 0 16px 8px;
  overflow: visible;
}

.time-slider-slider {
  margin: 4px 10px 36px 10px;
}

#time-slider .noUi-marker.active-pip {
  background: var(--accent);
  width: 2px;
  height: 10px;
}

#time-slider .noUi-pips-horizontal .noUi-value-large {
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
  margin-top: 8px;
}

/* Overlapping pip labels are hidden (measured at build and on resize); the tick still reveals the time on hover. */
#time-slider .noUi-value.pip-label-hidden {
  display: none;
}

/* Edge pip labels align inward (left edge on start, right edge on end) so the date label never hangs off the interface. */
#time-slider .noUi-value.pip-label-edge-start {
  transform: translate(0, 50%);
}

#time-slider .noUi-value.pip-label-edge-end {
  transform: translate(-100%, 50%);
}

/* Hover tooltip for pip ticks: sits in the label row below the track. */
#time-slider .time-slider-pip-tooltip {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  transform: translateX(-50%);
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: 3px;
  box-shadow: var(--shadow-control);
  padding: 2px 6px;
  font-size: 11px;
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
}

#time-slider .time-slider-pip-tooltip.visible {
  display: block;
}

/* Range brackets + band on the time slider */
#time-slider .noUi-handle[data-handle="0"] {
  width: 10px;
  height: 22px;
  top: -4px;
  right: 0px;
  /* right (inner) edge on the value: bracket sits just left of the band */
  border-radius: 2px;
  background: var(--accent);
  border: 1px solid var(--accent-hover);
  cursor: ew-resize;
  box-shadow: none;
  /* drop the default inset blobs */
}

#time-slider .noUi-handle[data-handle="2"] {
  width: 10px;
  height: 22px;
  top: -4px;
  right: -10px;
  /* left (inner) edge on the value: bracket sits just right of the band */
  border-radius: 2px;
  background: var(--accent);
  border: 1px solid var(--accent-hover);
  cursor: ew-resize;
  box-shadow: none;
  /* drop the default inset blobs */
}

/* Playhead: a clean vertical marker instead of noUiSlider's default white box (whose "||" grip lines bled outside). */
#time-slider .noUi-handle[data-handle="1"] {
  width: 8px;
  height: 28px;
  top: -7px;
  right: -4px;
  border-radius: 2px;
  background: var(--playhead-bg);
  border: 1px solid var(--playhead-border);
  cursor: ew-resize;
  box-shadow: var(--shadow-xs);
}

/* Kill the default "||" grip marks painted on every noUiSlider handle. */
#time-slider .noUi-handle::before,
#time-slider .noUi-handle::after {
  display: none;
}

#time-slider .noUi-connect {
  background: var(--accent-soft);
}

/* Range-adjuster date labels: shown only while hovering or dragging/focusing the handle. */
#time-slider .noUi-tooltip {
  display: none;
}

#time-slider .noUi-handle:hover .noUi-tooltip,
#time-slider .noUi-active .noUi-tooltip {
  display: block;
}

/* Centre bracket date labels on the bracket's value (each bracket is offset outward by half its 10px width). */
#time-slider .noUi-handle[data-handle="0"] .noUi-tooltip {
  left: calc(50% + 5px);
}

#time-slider .noUi-handle[data-handle="2"] .noUi-tooltip {
  left: calc(50% - 5px);
}

/* ---- Mini Floating Player for time slider ---- */

.time-slider-mini {
  display: none;
  position: fixed;
  background: var(--surface-panel);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-panel);
  padding: 6px 10px;
  align-items: center;
  gap: 6px;
  z-index: 1000;
  cursor: grab;
  user-select: none;
}

.time-slider-mini.open {
  display: flex;
}

.time-slider-mini.dragging {
  cursor: grabbing;
}

.time-slider-mini-btn {
  appearance: none;
  width: 28px;
  height: 28px;
  background: var(--surface-btn) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm) !important;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}

.time-slider-mini-btn:hover {
  background: var(--surface-btn-hover) !important;
  border-color: var(--accent) !important;
}

.time-slider-mini-label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  margin-left: 4px;
  pointer-events: none;
}

.time-slider-mini-expand {
  width: 22px;
  height: 22px;
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 2px;
}

.time-slider-mini-expand:hover {
  color: var(--text-muted) !important;
}

/* Pulsing clock button when minimized with active animation */

#time-slider-panel-toggle.ts-active {
  background-color: var(--accent-tint) !important;
  border-color: var(--accent) !important;
  color: var(--accent);
}

/* Dark mode */

body.dark-mode .time-slider-panel {
  background: var(--surface-panel-floating);
  box-shadow: var(--shadow-panel);
  color: var(--text-primary);
}

body.dark-mode .time-slider-controls .time-slider-btn {
  background: var(--surface-control-floating) !important;
  border-color: var(--border) !important;
  color: var(--text-primary);
}

body.dark-mode .time-slider-controls .time-slider-btn:hover {
  background: var(--surface-btn-hover) !important;
}

body.dark-mode .time-slider-speed {
  background: var(--surface-control-floating);
  border-color: var(--border);
  color: var(--text-primary);
}

body.dark-mode .time-slider-label {
  color: var(--text-secondary);
}

body.dark-mode .time-slider-toggle {
  --toggle-text: var(--text-primary);
}

body.dark-mode .time-slider-toggle-label {
  color: var(--toggle-text);
}

body.dark-mode .time-slider-toggle-label.active {
  color: var(--accent);
}

body.dark-mode .time-slider-toggle-switch {
  background: var(--slider-track);
}

body.dark-mode .time-slider-toggle.active-hourly .time-slider-toggle-switch {
  background: var(--accent);
}

body.dark-mode .time-slider-icon-btn {
  color: var(--text-primary);
}

body.dark-mode .time-slider-icon-btn:hover {
  color: var(--text-muted);
}

body.dark-mode .time-slider-mini {
  background: var(--surface-panel);
  box-shadow: var(--shadow-panel);
}

body.dark-mode .time-slider-mini-btn {
  background: var(--surface-control-floating) !important;
  border-color: var(--border) !important;
  color: var(--text-primary);
}

body.dark-mode .time-slider-mini-btn:hover {
  background: var(--surface-btn-hover) !important;
}

body.dark-mode .time-slider-mini-label {
  color: var(--text-secondary);
}

body.dark-mode .time-slider-mini-expand {
  color: var(--text-primary);
}

body.dark-mode .time-slider-mini-expand:hover {
  color: var(--text-muted);
}

body.dark-mode #time-slider-panel-toggle.ts-active {
  background-color: var(--accent-tint) !important;
  border-color: var(--accent) !important;
  color: var(--accent);
}

.time-slider-static-note {
  margin: 0 12px 10px;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.4;
  border-radius: 4px;
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

body.dark-mode .time-slider-static-note {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}