/* Legacy class aliases — redirect to shared .block-card / .block-card-header.
   Kept for any remaining references; new code uses .block-card directly. */
.lab-timeline-section { /* now use .block-card */ }
.lab-timeline-header { /* now use .block-card-header */ }
.lab-tl-controls { display: flex; gap: 0.5rem; align-items: center; }
/* ── Timeline filter dropdown (reuses .trend-picker from trends.css) ── */
.block-card-header .trend-picker { min-width: 200px; }
/* Two side-by-side facet dropdowns (e.g. By Body System + By Type). */
.block-card-header .tl-filter-group { display: inline-flex; gap: 0.4rem; align-items: center; }
.block-card-header .tl-filter-group .trend-picker { min-width: 150px; }
.block-card-header .trend-picker-dropdown { width: max-content; min-width: 100%; right: 0; left: auto; }
.block-card-header .trend-dd-option { white-space: nowrap; padding-top: 0; padding-bottom: 0; line-height: 1.2; }
.block-card-header .trend-picker-dropdown { padding: 0.15rem 0; }
.tl-dd-parent {
  font-weight: 600;
}
.block-card-header .tl-dd-child {
  padding-left: 2.4rem;
}
/* Standalone "All events / Only key events" quick toggle in the header. */
.block-card-header .tl-quick-filter {
  margin-left: 0.5rem;
  font-size: 0.8rem;
  padding: 3px 6px;
  border: 1px solid var(--gray-100);
  border-radius: 5px;
  background: var(--white);
  color: var(--text);
  cursor: pointer;
}

/* Zoom controls + slider — verbatim port of legacy .wbh-trend-zoom from
   legacy app-wbh.css:32-85, used by both timeline and trends. */
.wbh-trend-zoom {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1.2rem 0.6rem;
}
.wbh-trend-zoom-btns {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}
.wbh-trend-zoom-btns button {
  width: 28px;
  height: 24px;
  border: 1px solid var(--gray-100);
  border-radius: 5px;
  background: var(--white);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: background 0.15s;
  font-family: inherit;
}
.wbh-trend-zoom-btns button:hover { background: var(--bg-subtle); }
.wbh-trend-slider-wrap {
  flex: 1;
  min-width: 0;
  padding: 4px 0;
}
.wbh-trend-slider-track {
  position: relative;
  height: 10px;
  background: var(--gray-100);
  border-radius: 5px;
  cursor: pointer;
}
.wbh-trend-slider-thumb {
  position: absolute;
  top: 0;
  height: 100%;
  min-width: 20px;
  background: var(--primary);
  opacity: 0.35;
  border-radius: 5px;
  cursor: grab;
  transition: opacity 0.15s;
}
.wbh-trend-slider-thumb:hover,
.wbh-trend-slider-thumb.dragging { opacity: 0.55; cursor: grabbing; }

.timeline-container {
  /* Horizontal gutter so the first/last dots + their centered labels don't
     clip against the overflow:hidden .block-card edge (was --space-2). */
  padding: var(--space-4) var(--space-12);
  position: relative;
}
.timeline-axis {
  position: relative;
  height: 2px;
  background: var(--color-border);
  margin: 60px 0 60px 0;
}
.timeline-axis-label {
  position: absolute;
  top: -22px;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--color-text-subtle);
  white-space: nowrap;
}
.timeline-axis-today {
  color: var(--color-accent);
  font-weight: 600;
}
.timeline-today-line {
  position: absolute;
  top: -50px;
  bottom: -50px;
  width: 2px;
  background: var(--color-accent);
  opacity: 0.4;
  pointer-events: none;
}
.timeline-dot-area {
  position: absolute;
  inset: 0;
  /* The full-height overlay must not swallow clicks meant for the zoom
     buttons / legend underneath it; markers re-enable pointer events below. */
  pointer-events: none;
}
/* The single-row (non-track) dot-area is absolutely positioned from the
   container's padding box, so it ignores the horizontal gutter above. Inset it
   to match the axis labels + tracks. Track dot-areas already inset via the
   container padding and keep inset:0. */
.timeline-container > .timeline-dot-area {
  left: var(--space-12);
  right: var(--space-12);
}
.timeline-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  z-index: 2;
  pointer-events: auto;
}
.timeline-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--dot-color, var(--color-primary));
  border: 2px solid var(--color-bg-raised);
  /* Soft-chip halo (Step B 2026-05-13) — outer color-tinted ring gives the dot
     more visual weight and makes it readable on dense timelines. */
  box-shadow:
    var(--shadow-sm),
    0 0 0 4px color-mix(in srgb, var(--dot-color, var(--color-primary)) 28%, transparent);
  transition: transform 0.15s;
}
.timeline-marker:hover .timeline-dot { transform: scale(1.3); }
.timeline-label {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--color-text-muted);
  white-space: nowrap;
  pointer-events: none;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.timeline-label-top { bottom: 100%; margin-bottom: 2px; }
.timeline-label-bottom { top: 100%; margin-top: 2px; }
.timeline-legend {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  justify-content: center;
  margin-top: var(--space-3);
  font-size: var(--text-size-sm);
  color: var(--color-text-muted);
}
/* Step B 2026-05-13 — bottom-centered variant adds visual separation from
   the dot area. Same flex layout; explicit top border. */
.timeline-legend.bottom-centered {
  margin-top: var(--space-5);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}
.timeline-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.timeline-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: var(--space-1);
  vertical-align: middle;
}
/* ===== Major Events directives (Step B 2026-05-13) ===== */
.timeline-marker.ring-icon {
  width: 28px;
  height: 28px;
  border: 3px solid var(--event-color, var(--color-primary));
  border-radius: 50%;
  background: var(--color-bg-raised);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  box-shadow: var(--shadow-sm);
  /* Ring markers use a larger negative offset for label positioning since
     the marker itself is bigger than a 14px dot. */
  margin-left: -14px;
  margin-top: -14px;
}
.timeline-marker.ring-icon .timeline-marker-icon {
  font-size: 14px;
  line-height: 1;
  user-select: none;
}

.timeline-track {
  position: relative;
  min-height: 70px;
  border-bottom: 1px dashed var(--color-border);
  padding-top: 22px;
}
.timeline-track:last-child {
  border-bottom: none;
}
.timeline-track-label {
  position: absolute;
  left: 0;
  top: 4px;
  font-size: 0.72rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  pointer-events: none;
}

/* Tracked timeline (per-l2 lanes): reserve a left gutter for the system
   subtitle so it never overlays the leftmost events. The axis + dot lanes
   shift right by the gutter; the subtitle sits in the gutter, vertically
   centered. Non-tracked timelines (no .has-tracks) are unaffected. */
.timeline-container.has-tracks {
  --tl-track-gutter: 104px;
}
.timeline-container.has-tracks .timeline-axis {
  margin-left: var(--tl-track-gutter);
}
.timeline-container.has-tracks .timeline-track .timeline-dot-area {
  left: var(--tl-track-gutter);
}
.timeline-container.has-tracks .timeline-track-label {
  top: 50%;
  transform: translateY(-50%);
  max-width: calc(var(--tl-track-gutter) - 10px);
  white-space: normal;
  line-height: 1.15;
}

.timeline-undated-footer {
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg-subtle);
  border-left: 3px solid var(--warning);
  font-size: 0.85rem;
  color: var(--color-text);
}

.timeline-empty {
  text-align: center;
  padding: var(--space-6);
  color: var(--color-text-muted);
}
.timeline-zoom-controls {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  align-items: center;
}
.timeline-zoom-controls button {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-size-sm);
}
