/* ==========================================================================
   TIMELINE - css/components/timeline.css

   Styles the output of js/components/timeline-item.js and the <ol> built by
   js/core/section-kit.js (createTimeline):

     ol.timeline.timeline--vertical
       li.timeline__event[data-event-type] (.timeline__event--featured)
         .timeline__marker
         .timeline__content.card
           .timeline__date, .timeline__badges (.badge.timeline__type),
           h3, .timeline__description, .timeline__expand,
           .timeline__details, .timeline__actions, .timeline__image

   One vertical rail, a dot per event, and the event card offset to the right.
   The rail is a pseudo-element on the list, so an event does not need to know
   whether it is first or last.
   ========================================================================== */

.timeline {
  position: relative;
  display: grid;
  gap: var(--spacing-lg);
  margin: 0;
  padding: 0 0 0 var(--spacing-lg);
  list-style: none;
}

/* The rail. Inset from the left edge by half the marker width so the dots sit
   centred on it. */
.timeline::before {
  content: "";
  position: absolute;
  inset-block: 0.4rem 0.4rem;
  inset-inline-start: 0.3rem;
  inline-size: 2px;
  background-color: var(--color-border);
  border-radius: var(--radius-full);
}

.timeline__event {
  position: relative;
  display: grid;
  gap: var(--spacing-xs);
}

/* The dot. It is decorative: the date is in the card and is what a screen
   reader reads. */
/* The dot is positioned against the list's padding, so the negative offset is
   the padding plus half the dot: changing --spacing-lg here would silently move
   the markers off the rail. */
.timeline__marker {
  position: absolute;
  inset-block-start: 0.55rem;
  inset-inline-start: calc(-1 * var(--spacing-lg) + 0.3rem - 3px);
  inline-size: 0.65rem;
  block-size: 0.65rem;
  background-color: var(--color-surface-raised);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-full);
}

.timeline__event--featured .timeline__marker {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

/* The card is the shared card surface; the timeline only changes its density. */
.timeline__content {
  display: grid;
  gap: var(--spacing-xs);
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-md);
}

.timeline__date {
  margin: 0;
  font-size: 0.75rem;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.timeline__content > h3,
.timeline__content > h4 {
  margin: 0;
  font-size: 1.0625rem;
}

.timeline__badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline__description {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--color-text-secondary);
}

.timeline__expand {
  justify-self: start;
  padding: 0.2rem 0;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: var(--font-weight-semibold);
  color: var(--color-primary);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.timeline__details {
  display: grid;
  gap: var(--spacing-xs);
  padding-block-start: var(--spacing-xs);
  border-block-start: 1px solid var(--color-border);
  font-size: 0.9375rem;
  color: var(--color-text-secondary);
}

.timeline__details p {
  margin: 0;
}

.timeline__image {
  display: block;
  inline-size: 100%;
  max-block-size: 18rem;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.timeline__image--failed {
  display: none;
}

.timeline__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  padding-block-start: var(--spacing-xs);
}

/* Type badges keep their own colour per event type. The attribute is set by the
   component from the normalized type, so an unknown type falls back to the
   neutral badge instead of breaking the rule. */
.timeline__event[data-event-type="experience"] .timeline__type {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.timeline__event[data-event-type="project"] .timeline__type {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.timeline__event[data-event-type="certificate"] .timeline__type {
  color: var(--color-warning);
  border-color: var(--color-warning);
}

.timeline__event[data-event-type="education"] .timeline__type {
  color: var(--color-secondary);
  border-color: var(--color-secondary);
}

.timeline__event[data-event-type="learning"] .timeline__type,
.timeline__event[data-event-type="learning"] .timeline__badge {
  color: var(--color-success);
  border-color: var(--color-success);
}

/* Grouped layout (timeline--grouped sets data-group headings). */
.timeline__group {
  display: grid;
  gap: var(--spacing-sm);
}

.timeline__group > h3 {
  margin: 0;
  font-size: 0.8125rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

@media (min-width: 768px) {
  .timeline {
    padding-inline-start: var(--spacing-xl);
  }

  .timeline__marker {
    inset-inline-start: calc(-1 * var(--spacing-xl) + 0.3rem - 3px);
  }
}

/* ==========================================================================
   LIST RESET

   The component renders an <ol>; the shared reset only removes list styling
   from `[role="list"]`, so without this rule the browser paints decimal
   markers and a 40px inline start padding - a numbered, indented timeline.
   The list owns the gap so both the vertical and the grouped layout inherit
   the rhythm of their root.
   ========================================================================== */

.timeline__list {
  display: grid;
  gap: inherit;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ==========================================================================
   COMPACT LAYOUT (TIMELINE_COMPONENT.md § 5.3)

   Same rail and markers, less air: a short summary of a few events. The marker
   offset is rewritten because it is measured against the horizontal padding.
   ========================================================================== */

.timeline.timeline--compact {
  gap: var(--spacing-sm);
  padding-inline-start: var(--spacing-md);
}

.timeline--compact::before {
  inset-inline-start: 0.25rem;
}

.timeline--compact .timeline__marker {
  inset-block-start: 0.5rem;
  inset-inline-start: calc(-1 * var(--spacing-md) + 0.25rem - 3px);
  inline-size: 0.5rem;
  block-size: 0.5rem;
}

.timeline--compact .timeline__content {
  gap: 0.15rem;
  padding: var(--spacing-sm) var(--spacing-md);
}

.timeline--compact .timeline__description,
.timeline--compact .timeline__details {
  font-size: 0.875rem;
  line-height: 1.5;
}

/* ==========================================================================
   GROUPED LAYOUT (TIMELINE_COMPONENT.md § 13)

   The group wrapper already renders a heading; it only needs separation from
   the next group so two years never read as one block.
   ========================================================================== */

.timeline--grouped {
  gap: 0;
}

.timeline--grouped .timeline__list {
  gap: var(--spacing-lg);
}

.timeline--grouped .timeline__group + .timeline__group {
  margin-block-start: var(--spacing-xl);
}

.timeline--grouped .timeline__group > h3 {
  margin-block-end: var(--spacing-sm);
}

/* ==========================================================================
   HORIZONTAL LAYOUT (TIMELINE_COMPONENT.md § 5.2)

   Only from 768px up: below that the base vertical rail applies unchanged,
   which is the "alternative presentation on small screens" the spec requires.
   The rail runs across the top, the events sit under it, and the list scrolls
   in its own box so the page never gains horizontal overflow.
   ========================================================================== */

@media (min-width: 768px) {
  .timeline.timeline--horizontal {
    gap: 0;
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
  }

  .timeline--horizontal::before {
    inset-block: 0.55rem auto;
    inset-inline: 0.75rem;
    inline-size: auto;
    block-size: 2px;
  }

  .timeline--horizontal .timeline__list {
    display: flex;
    gap: var(--spacing-lg);
    min-inline-size: max-content;
    padding-block: 1.25rem 0.25rem;
  }

  .timeline--horizontal .timeline__event {
    flex: 0 0 clamp(14rem, 22vw, 19rem);
    padding-block-start: 0.75rem;
  }

  .timeline--horizontal .timeline__marker {
    inset-block-start: -1.05rem;
    inset-inline-start: 1rem;
  }

  /* A horizontal event card is as tall as its content; the grid must not
     stretch every card to the tallest one or short milestones look empty. */
  .timeline--horizontal .timeline__content {
    align-content: start;
  }
}
