/* ── Time Range Slider ─────────────────────────────────────────────────────── */

.trs-wrapper {
  width: 100%;
  padding: 0.25rem 0.75rem 0.5rem;
}

.trs-bar-wrapper {
  position: relative;
  padding-top: 1.6rem; /* vertical room for badge + arrow above the bar */
  padding-bottom: 1.8rem; /* room for Now badge below the bar */
}

/* ── Time badges — matches .timeline-time-indicator style ─────────────────── */

.trs-badge {
  position: absolute;
  top: 0.1rem;
  transform: translateX(-50%);

  --badge-bg: var(--text-color-accent);
  background: var(--badge-bg);
  color: white;
  border-radius: 999px;
  padding: 2px 9px;

  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;

  box-shadow: 0 2px 8px color-mix(in srgb, var(--badge-bg) 40%, transparent);

  cursor: pointer;
  border: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  z-index: 2;

  transition:
    transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.12s ease;
}

@media (hover: hover) {
  .trs-badge:hover {
    transform: translateX(-50%) scale(1.08);
    box-shadow: 0 4px 14px color-mix(in srgb, var(--badge-bg) 55%, transparent);
  }
}

.trs-badge:active {
  transform: translateX(-50%) scale(0.93) !important;
}

.trs-badge--dragging {
  transform-origin: bottom center;
  transform: translate(-50%, -50%) scale(1.2) !important;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--badge-bg) 60%, transparent) !important;
  font-size: 0.85rem !important;
  padding: 4px 12px !important;
  transition:
    transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.15s ease,
    font-size 0.15s ease,
    padding 0.15s ease !important;
}

/* Downward triangle arrow — matches .timeline-time-indicator::after */
.trs-badge::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--badge-bg);
}

@media (prefers-color-scheme: dark) {
  .trs-badge {
    --badge-bg: #28a745;
  }
}

/* ── Timeline bar — taller for easier touch targets ───────────────────────── */

.trs-bar {
  height: 3rem;
  border-radius: 12px;
  background: color-mix(in srgb, var(--text-color-primary) 6%, transparent);
  border: 1px solid color-mix(in srgb, var(--text-color-primary) 8%, transparent);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: visible;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: default;
}

/* ── Selected range fill ──────────────────────────────────────────────────── */

.trs-range {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 10px;

  background-color: color-mix(in srgb, var(--text-color-accent) 28%, transparent);
  background-image: none;

  box-shadow:
    inset 0 0 0 1.5px color-mix(in srgb, var(--text-color-accent) 38%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 2px 12px color-mix(in srgb, var(--text-color-accent) 16%, transparent);

  cursor: grab;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.trs-range:active {
  background-color: color-mix(in srgb, var(--text-color-accent) 36%, transparent);
  cursor: grabbing;
}

@media (prefers-color-scheme: dark) {
  .trs-range {
    background-color: color-mix(in srgb, var(--text-color-accent) 32%, transparent);
    background-image: none;
    box-shadow:
      inset 0 0 0 1.5px color-mix(in srgb, var(--text-color-accent) 45%, transparent),
      inset 0 1px 0 rgba(255, 255, 255, 0.1),
      0 4px 16px rgba(0, 0, 0, 0.25);
  }
}

/* Duration label inside the selected range */
.trs-duration {
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-color-accent);
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  opacity: 1;
  text-shadow:
    0 1px 4px rgba(255, 255, 255, 0.6),
    0 0 12px rgba(255, 255, 255, 0.3);
}

@media (prefers-color-scheme: dark) {
  .trs-duration {
    text-shadow:
      0 1px 4px rgba(0, 0, 0, 0.6),
      0 0 12px rgba(0, 0, 0, 0.3);
  }
}

/* ── Handles — edge grip tabs, secondary to the range block ───────────────── */

.trs-handle {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 28px;
  border-radius: 5px;

  background: color-mix(in srgb, var(--text-color-accent) 85%, white);
  border: 1.5px solid color-mix(in srgb, var(--text-color-accent) 95%, transparent);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);

  cursor: grab;
  touch-action: none;
  z-index: 3;
  outline: none;

  transition:
    box-shadow 0.2s ease,
    transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
    background 0.2s ease;
}

/* Both handles centered on the range edge — half inside, half outside */
.trs-handle.trs-handle--from {
  transform: translate(-50%, -50%) translateZ(0);
  border-radius: 5px;
}

.trs-handle.trs-handle--to {
  transform: translate(-50%, -50%) translateZ(0);
  border-radius: 5px;
}

@media (prefers-color-scheme: dark) {
  .trs-handle {
    background: color-mix(in srgb, var(--text-color-accent) 75%, #1a1a1a);
    border-color: color-mix(in srgb, var(--text-color-accent) 90%, transparent);
    box-shadow:
      0 2px 8px rgba(0, 0, 0, 0.45),
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
}

/* Expanded invisible touch target */
.trs-handle::before {
  content: '';
  position: absolute;
  inset: -8px -12px;
}

/* Grip notches — triple horizontal lines */
.trs-handle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 4px;
  height: 2px;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 -4px 0 rgba(255, 255, 255, 0.75), 0 4px 0 rgba(255, 255, 255, 0.75);
  border-radius: 1px;
}

@media (prefers-color-scheme: dark) {
  .trs-handle::after {
    background: rgba(255, 255, 255, 0.55);
    box-shadow: 0 -4px 0 rgba(255, 255, 255, 0.55), 0 4px 0 rgba(255, 255, 255, 0.55);
  }
}

.trs-handle:focus-visible {
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--text-color-accent) 40%, transparent),
    0 1px 6px rgba(0, 0, 0, 0.14);
}

@media (hover: hover) {
  .trs-handle.trs-handle--from:hover,
  .trs-handle.trs-handle--to:hover {
    transform: translate(-50%, -50%) scale(1.12);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  }
}

.trs-handle.trs-handle--from.trs-handle--dragging,
.trs-handle.trs-handle--to.trs-handle--dragging {
  transform: translate(-50%, -50%) translateZ(0) scale(1.2) !important;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
  cursor: grabbing !important;
  transition: none !important;
}

/* ── Now indicator ────────────────────────────────────────────────────────── */

.trs-now-badge {
  position: absolute;
  /* 1.6rem barWrapper padding-top + 3rem bar height + 0.4rem gap */
  top: calc(1.6rem + 3rem + 0.4rem);
  transform: translateX(-50%);
  transform-origin: top center;

  background: #2196F3;
  color: white;
  border-radius: 999px;
  padding: 2px 8px;

  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.4);

  pointer-events: auto;
  user-select: none;
  cursor: pointer;
  z-index: 1;

  opacity: 0;
  animation: today-indicator-appear 0.65s linear 0.35s forwards;

  transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.12s ease;
}

@media (hover: hover) {
  .trs-now-badge:hover {
    transform: translateX(-50%) scale(1.08);
    box-shadow: 0 4px 14px rgba(33, 150, 243, 0.55);
  }
}

.trs-now-badge:active {
  transform: translateX(-50%) scale(0.93) !important;
}

/* Arrow points up toward the bar */
.trs-now-badge::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-bottom-color: #2196F3;
}

.trs-now-line {
  position: absolute;
  top: 5px;
  bottom: 5px;
  width: 2px;
  transform: translateX(-50%);
  background: #2196F3;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  animation: today-indicator-appear 0.65s linear 0.35s forwards;
}

.trs-now-line::before,
.trs-now-line::after {
  content: '';
  position: absolute;
  left: 50%;
  width: 6px;
  height: 6px;
  background: inherit;
  border-radius: 50%;
  transform: translateX(-50%);
}

.trs-now-line::before { top: -3px; }
.trs-now-line::after  { bottom: -3px; }

.trs-bar--snapping .trs-handle,
.trs-bar--snapping .trs-badge,
.trs-bar--snapping .trs-range {
  transition: 
    left 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    width 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes trs-text-update {
  from { opacity: 0.5; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

.trs-badge-text--changing {
  animation: trs-text-update 0.15s ease-out;
}

/* ── Hour snap grid lines ──────────────────────────────────────────────────── */

.trs-grid-line {
  position: absolute;
  top: 5px;
  bottom: 5px;
  width: 0;
  border-left: 1px dashed color-mix(in srgb, var(--text-color-primary) 10%, transparent);
  pointer-events: none;
  z-index: 0;
  transform: translateX(-50%);
}

/* ── Tick labels ─────────────────────────────────────────────────────────── */

.trs-ticks {
  position: absolute;
  top: 0.1rem;
  left: 0;
  right: 0;
  height: 1.4rem;
}

.trs-tick-label {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.62rem;
  font-weight: 600;
  color: color-mix(in srgb, var(--text-color-primary) 45%, transparent);
  white-space: nowrap;
}

