/**
 * Timeline styles
 * @countermeasure/web-components/visualization/timeline
 */

/* ============================================================================
   Base
   ============================================================================ */
.cmm-timeline {
  position: relative;
  font-family: system-ui, -apple-system, sans-serif;
  color: hsl(var(--foreground));
}

/* ============================================================================
   Vertical orientation
   ============================================================================ */
.cmm-timeline--vertical {
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
}

.cmm-timeline--vertical .cmm-timeline__line {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: hsl(var(--border));
  transform: translateX(-50%);
  z-index: 0;
}

.cmm-timeline--vertical .cmm-timeline__event {
  position: relative;
  display: flex;
  align-items: flex-start;
  width: 100%;
  padding: 0.75rem 0;
  z-index: 1;
}

.cmm-timeline--vertical .cmm-timeline__event--left {
  flex-direction: row;
  justify-content: flex-end;
  padding-right: calc(50% + 1.5rem);
}

.cmm-timeline--vertical .cmm-timeline__event--right {
  flex-direction: row;
  justify-content: flex-start;
  padding-left: calc(50% + 1.5rem);
}

/* ============================================================================
   Dot indicator
   ============================================================================ */
.cmm-timeline__dot {
  position: absolute;
  left: 50%;
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 50%;
  background: hsl(var(--primary));
  border: 2px solid hsl(var(--background));
  box-shadow: 0 0 0 2px hsl(var(--border));
  transform: translateX(-50%);
  z-index: 2;
  flex-shrink: 0;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.cmm-timeline__event:hover .cmm-timeline__dot {
  transform: translateX(-50%) scale(1.25);
  box-shadow: 0 0 0 3px hsl(var(--primary));
}

/* ============================================================================
   Content card
   ============================================================================ */
.cmm-timeline__content {
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  max-width: 20rem;
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.cmm-timeline__content:hover {
  border-color: hsl(var(--primary));
  box-shadow: 0 2px 8px hsl(0 0% 0% / 0.08);
}

.cmm-timeline__content:focus-visible {
  outline: 2px solid hsl(var(--focus-ring));
  outline-offset: 2px;
}

.cmm-timeline__title {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 0;
  color: hsl(var(--foreground));
}

.cmm-timeline__description {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: hsl(var(--muted-foreground));
  margin: 0.25rem 0 0;
}

.cmm-timeline__timestamp {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.375rem;
}

.cmm-timeline__icon {
  display: inline-flex;
  align-items: center;
  margin-right: 0.375rem;
  font-size: 0.875rem;
}

.cmm-timeline__metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin-top: 0.375rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.cmm-timeline__metadata-key {
  font-weight: 500;
}

.cmm-timeline__metadata-value {
  color: hsl(var(--foreground));
}

/* ============================================================================
   Group headers (groupByDate)
   ============================================================================ */
.cmm-timeline__group {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0;
  z-index: 1;
}

.cmm-timeline__group-label {
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

/* ============================================================================
   Horizontal orientation
   ============================================================================ */
.cmm-timeline--horizontal {
  display: flex;
  flex-direction: column;
  overflow-x: auto;
  padding: 1rem 0;
}

.cmm-timeline--horizontal .cmm-timeline__track {
  display: flex;
  align-items: flex-start;
  position: relative;
  min-width: max-content;
  padding: 2rem 1rem;
}

.cmm-timeline--horizontal .cmm-timeline__line {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: hsl(var(--border));
  transform: translateY(-50%);
  z-index: 0;
}

.cmm-timeline--horizontal .cmm-timeline__event {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 10rem;
  position: relative;
  z-index: 1;
}

.cmm-timeline--horizontal .cmm-timeline__dot {
  position: relative;
  left: auto;
  transform: none;
  margin: 0.5rem 0;
}

.cmm-timeline--horizontal .cmm-timeline__event:hover .cmm-timeline__dot {
  transform: scale(1.25);
}

.cmm-timeline--horizontal .cmm-timeline__content {
  max-width: 12rem;
  text-align: center;
}

.cmm-timeline--horizontal .cmm-timeline__event--above .cmm-timeline__content {
  order: -1;
}

/* ============================================================================
   Responsive
   ============================================================================ */
@media (max-width: 640px) {
  .cmm-timeline--vertical .cmm-timeline__line {
    left: 1rem;
  }

  .cmm-timeline--vertical .cmm-timeline__dot {
    left: 1rem;
  }

  .cmm-timeline--vertical .cmm-timeline__event--left,
  .cmm-timeline--vertical .cmm-timeline__event--right {
    padding-left: 3rem;
    padding-right: 0;
    justify-content: flex-start;
  }
}
