/* Life Map — timeline band styles
 * Loaded after app.css so timeline-specific rules can override base layout.
 */

.timeline-band {
  border-top: 1px solid var(--line);
  background: var(--paper);
  padding: 5px 38px 6px;
  min-height: 158px;
  position: relative;
  overflow: hidden;
}

.timeline-count-summary {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px 8px;
  min-height: 36px;
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-count-summary[hidden],
.timeline-count-summary[aria-hidden="true"] {
  display: none;
}

.timeline-count-summary strong {
  color: var(--ink);
}

.timeline-availability-jumps {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.timeline-frame-months {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.timeline-jump,
.timeline-month-chip {
  border: 1px solid var(--soft-line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 7%, var(--paper));
  color: var(--ink);
  padding: 2px 7px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.timeline-month-chip {
  border-color: color-mix(in srgb, var(--accent-2) 42%, var(--line));
  background: color-mix(in srgb, var(--accent-2) 16%, var(--paper));
  font-weight: 800;
}

.timeline-month-more {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.timeline-jump:hover,
.timeline-jump:focus-visible,
.timeline-month-chip:hover,
.timeline-month-chip:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  outline: none;
}

.timeline-track {
  position: relative;
  height: 78px;
}

.episode-marker-layer {
  display: none;
  position: absolute;
  inset: 0 0 auto;
  height: 40px;
  z-index: 12;
  pointer-events: none;
}

.episode-marker {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 1px;
  border: 0;
  background: transparent;
  color: var(--ink);
  width: 58px;
  min-height: 40px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  pointer-events: auto;
}

.episode-pin {
  width: 13px;
  height: 20px;
  border-radius: 999px 999px 4px 4px;
  background: color-mix(in srgb, var(--accent) 72%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--paper) 72%, transparent), 0 3px 9px var(--shadow);
}

.episode-marker.search-hit .episode-pin {
  background: var(--accent);
}

.episode-marker.active .episode-pin,
.episode-marker:focus-visible .episode-pin {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 34%, transparent), 0 4px 12px var(--shadow);
}

.episode-label {
  position: absolute;
  top: 24px;
  left: 50%;
  min-width: 104px;
  max-width: 174px;
  border: 1px solid var(--soft-line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  color: var(--muted);
  padding: 3px 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 120ms ease, transform 120ms ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
}

.episode-badges {
  display: none !important;
}

.episode-badge {
  display: none !important;
}

.episode-marker.near-left .episode-label {
  left: 0;
  transform: translateX(0);
}

.episode-marker.near-right .episode-label {
  right: 0;
  left: auto;
  transform: translateX(0);
  opacity: 0;
}

.episode-marker.near-right .episode-badges {
  display: none !important;
}

.episode-marker:hover .episode-label,
.episode-marker:focus-visible .episode-label {
  opacity: 1;
  max-width: 220px;
  transform: translateX(-50%) translateY(-1px);
}

.episode-marker.near-left:hover .episode-label,
.episode-marker.near-left:focus-visible .episode-label,
.episode-marker.near-right:hover .episode-label,
.episode-marker.near-right:focus-visible .episode-label {
  transform: translateX(0) translateY(-1px);
}

.scope-overlay {
  position: absolute;
  top: 3px;
  height: 54px;
  z-index: 22;
  border: 1px solid color-mix(in srgb, #78BFE8 66%, transparent);
  border-radius: 8px;
  background: linear-gradient(180deg, color-mix(in srgb, #4B9AC9 24%, transparent), color-mix(in srgb, #28658F 29%, transparent));
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, #B9E2F6 20%, transparent),
    0 0 0 1px color-mix(in srgb, #1E4F84 10%, transparent),
    0 2px 8px color-mix(in srgb, #1E4F84 12%, transparent);
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  transition: opacity 140ms ease, background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.timeline-track.spotlight-mode .scope-overlay {
  opacity: 0;
  pointer-events: none;
}

.scope-overlay.dragging {
  cursor: grabbing;
  border-color: color-mix(in srgb, #A6DDF7 84%, transparent);
  background: linear-gradient(180deg, color-mix(in srgb, #52A9D8 34%, transparent), color-mix(in srgb, #28658F 39%, transparent));
  box-shadow: 0 0 0 3px color-mix(in srgb, #78BFE8 18%, transparent), 0 3px 11px color-mix(in srgb, #1E4F84 18%, transparent);
}

.scope-overlay::before,
.scope-overlay::after {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, #C7EBFB 62%, transparent);
}

.scope-overlay::before {
  left: 5px;
}

.scope-overlay::after {
  right: 5px;
}

.current-marker {
  position: absolute;
  top: 2px;
  height: 56px;
  z-index: 26;
  width: 0;
  border-left: 1px solid var(--accent);
  opacity: 1;
  pointer-events: auto;
  cursor: ew-resize;
  touch-action: none;
  transition: opacity 140ms ease, border-color 140ms ease;
}

.timeline-track.range-mode .current-marker {
  opacity: 0;
  pointer-events: none;
}

.current-marker.dragging {
  border-left-width: 2px;
}

.current-marker::before {
  content: none;
}

.current-marker::after {
  content: "";
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: -4px;
  width: 8px;
}

.current-marker.dragging::before {
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 25%, transparent);
}

.current-marker span {
  display: none;
}

.current-marker.near-right span {
  right: 10px;
  left: auto;
}

.current-marker.near-left span {
  left: 10px;
  right: auto;
}

.bucket-strip {
  height: 63px;
  border-bottom: 0;
  padding-bottom: 5px;
  overflow: hidden;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18px;
  z-index: 2;
  pointer-events: none;
}

.bucket {
  position: absolute;
  bottom: 5px;
  min-width: 2px;
  background: linear-gradient(180deg, var(--bucket-highlight, var(--accent-2)), var(--bucket-fill, var(--accent-2)) 68%, var(--bucket-edge, var(--accent-2)));
  opacity: 0.42;
  border-radius: 2px 2px 0 0;
  pointer-events: auto;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--bucket-highlight, #fff) 10%, transparent),
    0 0 0 1px color-mix(in srgb, var(--bucket-rim, var(--paper)) 18%, transparent);
}

.bucket.selected-hit {
  min-width: 4px;
}

.bucket.frame-hit {
  opacity: 0.66;
  border-radius: 4px 4px 0 0;
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--bucket-highlight, #fff) 16%, transparent),
    0 0 0 1px color-mix(in srgb, var(--bucket-rim, var(--ink)) 28%, transparent);
}

.timeline-track.spotlight-mode .bucket {
  pointer-events: none;
}

.bucket.journal-hit {
  background: linear-gradient(180deg, #9BCDE8, #6395B4 64%, #3E6E8B);
  opacity: 0.58;
  box-shadow: 0 -2px 0 color-mix(in srgb, #9BCDE8 18%, transparent);
}

.bucket:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.range-controls {
  position: relative;
  height: 78px;
  z-index: 28;
  pointer-events: none;
}

.range-controls input[type="range"] {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  background: transparent;
  pointer-events: none;
  appearance: none;
  height: 78px;
  opacity: 0;
}

.range-controls input[type="range"]::-webkit-slider-thumb {
  pointer-events: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--muted);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--muted) 14%, transparent), 0 1px 7px var(--shadow);
  cursor: ew-resize;
}

.range-controls .current-range::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  background: var(--accent);
  border: 3px solid var(--paper);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent), 0 1px 8px var(--shadow);
}

.range-controls .range-start::-webkit-slider-thumb {
  border-color: var(--accent-2);
}

.range-controls .range-end::-webkit-slider-thumb {
  border-color: var(--accent);
}

.range-controls input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: transparent;
  border-radius: 999px;
}

.range-controls::before {
  content: none;
}

.timeline-handle {
  --handle-color: var(--accent);
  --handle-shift: 0px;
  position: absolute;
  top: 5px;
  width: 20px;
  height: 20px;
  transform: translateX(calc(-50% + var(--handle-shift)));
  z-index: 12;
  display: none;
  place-items: center;
  border: 1px solid var(--handle-color);
  border-radius: 999px;
  background: var(--paper);
  color: var(--handle-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--handle-color) 14%, transparent), 0 2px 7px var(--shadow);
  cursor: ew-resize;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.timeline-track.range-mode .start-handle,
.timeline-track.range-mode .end-handle,
.timeline-track.spotlight-mode .current-handle {
  display: grid;
}

.timeline-handle:hover,
.timeline-handle:focus-visible,
.timeline-handle.dragging {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--handle-color) 24%, transparent), 0 4px 12px var(--shadow);
  outline: none;
}

.timeline-handle.clustered {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--handle-color) 18%, transparent), 0 3px 10px var(--shadow);
}

.timeline-handle::after {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 999px;
}

.start-handle {
  --handle-color: var(--accent-2);
  --handle-shift: 0px;
  top: 8px;
}

.current-handle {
  --handle-color: var(--accent);
  top: 17px;
  width: 24px;
  height: 24px;
  z-index: 14;
}

.end-handle {
  --handle-color: var(--focus);
  --handle-shift: 0px;
  top: 8px;
  z-index: 13;
}

.timeline-handle.near-left {
  --handle-shift: 11px;
}

.timeline-handle.near-right {
  --handle-shift: -11px;
}

.timeline-handle.start-handle.near-left {
  --handle-shift: 11px;
}

.timeline-handle.current-handle.near-left {
  --handle-shift: 13px;
}

.timeline-handle.end-handle.near-left {
  --handle-shift: 11px;
}

.timeline-handle.start-handle.near-right {
  --handle-shift: -11px;
}

.timeline-handle.end-handle.near-right {
  --handle-shift: -11px;
}

.timeline-handle.current-handle.near-right {
  --handle-shift: -13px;
}


.handle-code {
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
}

.handle-label {
  position: absolute;
  left: 50%;
  top: 26px;
  min-width: max-content;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 4px 12px var(--shadow);
  padding: 3px 7px;
  font-size: 10px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.handle-label strong {
  color: var(--handle-color);
}

.timeline-handle:hover .handle-label,
.timeline-handle:focus-visible .handle-label,
.timeline-handle.dragging .handle-label {
  opacity: 1;
}

.timeline-meta {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 4px 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  min-height: 42px;
  overflow: visible;
}

.timeline-meta > span {
  min-width: 0;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#startLabel {
  order: 1;
}

#currentLabel {
  display: none;
}

#endLabel {
  order: 2;
  margin-left: auto;
  text-align: right;
}

.current-label {
  display: none;
}

.timeline-track.spotlight-mode ~ .timeline-meta .current-label {
  display: none;
}

.timeline-control-clusters {
  order: 0;
  flex: 0 0 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 9px;
  overflow: visible;
  scrollbar-width: none;
}

.timeline-control-clusters::-webkit-scrollbar {
  display: none;
}

.timeline-control-cluster {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  min-height: 36px;
  padding: 4px 7px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 72%, var(--paper));
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--paper) 72%, transparent);
}

.timeline-control-cluster .control-label {
  min-width: max-content;
  margin: 0;
}

.frame-cluster {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--soft-line));
}

.date-scale-cluster {
  border-color: color-mix(in srgb, var(--focus) 30%, var(--soft-line));
  transition: opacity 140ms ease, filter 140ms ease;
}

.date-scale-cluster.is-muted {
  opacity: 0.82;
}

.window-cluster {
  border-color: color-mix(in srgb, var(--accent-2) 32%, var(--soft-line));
}

.manual-range-cluster {
  border-color: var(--soft-line);
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.manual-range-cluster.single-date-mode {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--soft-line));
}

/* Blue surround while range mode is active. */
.manual-range-cluster.range-active {
  border-color: color-mix(in srgb, var(--accent) 62%, var(--soft-line));
  background: color-mix(in srgb, var(--accent) 9%, color-mix(in srgb, var(--bg) 72%, var(--paper)));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent);
}

.manual-range-cluster.range-active > .control-label {
  color: var(--accent);
}

.manual-range-controls {
  align-items: center;
  gap: 6px;
}

.range-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--paper) 88%, var(--bg));
  padding: 0 8px;
  min-height: 28px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.range-field[hidden],
.range-input-divider[hidden] {
  display: none !important;
}

.range-field-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.manual-range-controls input[type="text"] {
  width: 80px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 0;
  cursor: text;
}

.manual-range-controls input[type="text"]:focus {
  outline: none;
}

.range-cal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: 2px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.range-cal-btn:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.range-field:hover,
.range-field:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.manual-range-cluster.range-active .range-field {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
}

.manual-range-cluster.single-date-mode .manual-range-controls input[type="text"] {
  width: 96px;
}

/* Single-date (spotlight) mode shows one field; the From/To labels would only confuse. */
.manual-range-cluster.single-date-mode .range-field-label {
  display: none;
}

.range-input-divider {
  color: color-mix(in srgb, var(--accent) 60%, var(--muted));
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.manual-range-controls input[type="text"] {
  cursor: pointer;
}

/* Custom calendar popover (replaces the native OS date picker). */
.calendar-pop {
  z-index: 60;
  width: 236px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 12px 34px var(--shadow), 0 0 0 1px var(--soft-line);
  font-size: 12px;
  color: var(--ink);
  user-select: none;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
}

.cal-nav {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: color-mix(in srgb, var(--paper) 86%, var(--bg));
  color: var(--ink);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.cal-title {
  flex: 1;
  height: 26px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.cal-nav:hover,
.cal-title:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}

.cal-weekdays span {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-grid .cal-empty {
  height: 28px;
}

.cal-day {
  position: relative;
  height: 28px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}

.cal-day.has-data {
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 38%, transparent);
}

.cal-day.has-data::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateX(-50%);
}

.cal-day:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.cal-day.sel {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}

.cal-day:disabled {
  color: color-mix(in srgb, var(--muted) 50%, transparent);
  cursor: default;
}

.cal-year-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.cal-year {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: color-mix(in srgb, var(--paper) 86%, var(--bg));
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.cal-year.has-data {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background: color-mix(in srgb, var(--accent) 9%, var(--paper));
}

.cal-year:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.cal-year.sel {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

.cal-year:disabled {
  color: color-mix(in srgb, var(--muted) 50%, transparent);
  cursor: default;
}

.timeline-meta .frame-mode,
.timeline-meta .lens,
.timeline-meta .quick-spans button {
  min-height: 28px;
  padding: 4px 8px;
}

@media (max-height: 1200px) {
  .timeline-band {
    padding-top: 6px;
    padding-bottom: 7px;
    min-height: 118px;
  }
}

@media (max-width: 760px) {
  .timeline-band {
    min-height: 286px;
    height: auto;
    padding: 6px 12px 10px;
    overflow: visible;
  }

  .timeline-control-clusters {
    justify-content: flex-start;
    gap: 6px;
  }

  .timeline-control-cluster {
    max-width: 100%;
    flex-wrap: wrap;
  }

  .manual-range-cluster {
    flex: 1 1 100%;
    justify-content: center;
  }

  .manual-range-controls {
    max-width: 100%;
    justify-content: center;
  }
}
