/* Timeline Enhanced CSS (D2 - Family Timelines) */

/* Milestone dot on lifespan bar */
.timeline-milestone {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid white;
  z-index: 10;
  cursor: pointer;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.timeline-milestone:hover {
  transform: translate(-50%, -50%) scale(1.5);
  z-index: 20;
}

/* Milestone tooltip */
.timeline-milestone-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: white;
  font-size: 0.75rem;
  line-height: 1.2;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 30;
  max-width: 250px;
  white-space: normal;
}

.timeline-milestone-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1f2937;
}

.timeline-milestone:hover .timeline-milestone-tooltip {
  opacity: 1;
}

/* Historical event band behind timeline */
.timeline-historical-band {
  position: absolute;
  top: 0;
  height: 100%;
  border-left: 1px solid;
  border-right: 1px solid;
  z-index: 1;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.timeline-historical-band:hover {
  pointer-events: auto;
}

/* Historical event label */
.timeline-historical-label {
  position: absolute;
  top: -18px;
  left: 2px;
  font-size: 0.6rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 25;
  pointer-events: none;
}

.timeline-historical-band:hover .timeline-historical-label {
  opacity: 1;
  pointer-events: auto;
}

/* Historical bands container */
.timeline-historical-container {
  position: relative;
  height: 100%;
}

/* Category filter pills */
.timeline-category-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid;
  transition: all 0.15s ease;
  user-select: none;
}

.timeline-category-pill.active {
  color: white;
}

.timeline-category-pill:not(.active) {
  opacity: 0.5;
}

.timeline-category-pill:hover {
  opacity: 1;
}

/* Comparison panel */
.timeline-comparison {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  background: #f9fafb;
}

.timeline-comparison-row {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid #e5e7eb;
  position: relative;
}

.timeline-comparison-row:last-child {
  border-bottom: none;
}

.timeline-comparison-name {
  width: 120px;
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 500;
  color: #374151;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.timeline-comparison-bar-container {
  flex: 1;
  position: relative;
  height: 28px;
}

.timeline-comparison-bar {
  position: absolute;
  top: 2px;
  height: 24px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  padding: 0 8px;
}

/* Overlap highlight in comparison */
.timeline-comparison-overlap {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(16, 185, 129, 0.15);
  border-left: 2px dashed rgba(16, 185, 129, 0.5);
  border-right: 2px dashed rgba(16, 185, 129, 0.5);
  z-index: 5;
}

/* Comparison checkbox */
.timeline-compare-check {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid #d1d5db;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  margin-right: 6px;
}

.timeline-compare-check.selected {
  background: #14b8a6;
  border-color: #14b8a6;
  color: white;
}

/* Toggle buttons in header */
.timeline-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #d1d5db;
  background: white;
  color: #374151;
  transition: all 0.15s ease;
}

.timeline-toggle-btn:hover {
  border-color: #9ca3af;
}

.timeline-toggle-btn.active {
  background: #14b8a6;
  border-color: #14b8a6;
  color: white;
}

/* Life events section in person modal */
.life-event-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px;
  padding: 8px;
  background: #f9fafb;
  border-radius: 8px;
  margin-bottom: 8px;
}

.life-event-row select,
.life-event-row input {
  font-size: 0.85rem;
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: white;
  color: #1f2937;
}

.life-event-row .life-event-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

/* Responsive: stack comparison on mobile */
@media (max-width: 640px) {
  .timeline-comparison-name {
    width: 80px;
    font-size: 0.7rem;
  }

  .life-event-row {
    grid-template-columns: 1fr;
  }

  .life-event-row .life-event-fields {
    grid-template-columns: 1fr;
  }

  .timeline-category-pill {
    font-size: 0.65rem;
    padding: 2px 8px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .timeline-milestone,
  .timeline-milestone-tooltip,
  .timeline-historical-label,
  .timeline-category-pill,
  .timeline-toggle-btn {
    transition: none;
  }

  .timeline-milestone:hover {
    transform: translate(-50%, -50%);
  }
}
