/**
 * @file
 * APU theme · Timeline Graphic component package.
 *
 * Editorial timeline component inspired by NYT data graphics.
 *
 * VERSION: 2026-05-02 update (revision 2)
 * Changes from previous version:
 *   - Headlines explicitly set text-transform: none (was inheriting
 *     uppercase from global theme rules)
 *   - Accent system renamed to impact-driven semantics:
 *       --accent-gold   →  --accent-bad   (red/crimson — federal pressure,
 *                                          closures, withdrawals)
 *       --accent-teal   →  --accent-good  (positive partnerships, growth)
 *       --accent-ink    →  --accent-neutral (default, milestones)
 *       --accent-muted   removed (not used in writer's three-state model)
 *   - New --tl-crimson token added locally (component-scoped, not theme-global)
 *   - Date column widened from 152px to 192px to add breathing room
 *     between the date text and the spine
 *   - Date column padding-right increased from 20px to 32px (further
 *     separation from spine)
 *   - Body padding-left increased from 20px to 28px (matching breathing room)
 *   - Closing pull-quote left border explicitly set to ink (was gold)
 *     since the closing block is editorial commentary, not an event accent
 *   - Decorative dots (event + legend) marked pointer-events: none —
 *     prevents hover artifacts during text selection
 *   - Print rendering of horizontal rails switched from grid to block
 *     for compatibility with print engines that have inconsistent
 *     grid support
 *
 * STRUCTURE — the four blocks
 *   .timeline                — root container
 *   .timeline__masthead      — title block (kicker, title, dek, meta, byline)
 *   .timeline__rail          — vertical/horizontal/numbered rail
 *   .timeline__event         — event card with date, dot, body
 *   .timeline__closing       — final summary block
 *
 * RAIL VARIANTS (apply to .timeline__rail)
 *   .timeline__rail--vertical     — default; spine runs top-to-bottom
 *   .timeline__rail--horizontal   — spine runs left-to-right (carousel-style)
 *   .timeline__rail--numbered     — vertical, dots replaced with step numbers
 *   .timeline__rail--dotted       — modifier; spine becomes dotted line
 *   .timeline__rail--solid        — modifier; spine becomes 2px solid
 *
 * EVENT MODIFIERS (impact-driven semantic colors)
 *   .timeline__event--accent-neutral  — milestones, announcements, statistics
 *   .timeline__event--accent-good     — positive partnerships, growth, wins
 *   .timeline__event--accent-bad      — closures, pressure, policy reversals
 *
 * USAGE
 *   The apu_timeline module's preprocess transformer produces this nested
 *   structure from the writer's flat CKEditor 5 markup. Authors writing
 *   HTML directly need only follow the BEM class structure.
 */

/* =============================================================
   Root container & local tokens
   ============================================================= */
.timeline {
  /* Local crimson token — kept component-scoped (not promoted to
     theme :root) so timelines can own their accent colors without
     polluting the global token namespace. */
  --tl-crimson:      #a02230;

  --tl-spine:        var(--fg-hairline);
  --tl-spine-thick:  var(--fg-ink);
  --tl-dot-neutral:  var(--fg-ink);
  --tl-dot-good:     var(--fg-teal);
  --tl-dot-bad:      var(--tl-crimson);
  --tl-content-max:  980px;

  max-width: var(--tl-content-max);
  margin: 48px auto;
  color: var(--fg-ink-soft);
  font-family: Georgia, 'Times New Roman', serif;
}

.timeline *,
.timeline *::before,
.timeline *::after {
  box-sizing: border-box;
}

/* =============================================================
   Masthead — kicker, title, dek, meta, byline
   ============================================================= */
.timeline__masthead {
  border-top: 2px solid var(--fg-ink);
  border-bottom: 0.5px solid var(--fg-hairline);
  padding: 28px 0 24px;
}

.timeline__kicker {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--fg-gold-dark);
  margin: 0 0 14px;
}

.timeline__title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(1.75rem, 1.2rem + 2vw, 2.6rem);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--fg-ink);
  margin: 0 0 14px;
  text-transform: none;
}

.timeline__dek {
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--fg-ink-soft);
  max-width: 64ch;
  margin: 0 0 18px;
}

.timeline__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 28px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--fg-ink-muted);
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline__meta li {
  position: relative;
}

.timeline__meta li + li::before {
  content: "·";
  position: absolute;
  left: -16px;
  color: var(--fg-hairline);
}

.timeline__byline {
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 0.875rem;
  color: var(--fg-ink-muted);
  margin: 14px 0 0;
}

.timeline__byline-name {
  color: var(--fg-ink);
  font-style: normal;
  font-weight: 500;
}

/* =============================================================
   Legend — optional, for category-coded events
   ============================================================= */
.timeline__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
  padding: 18px 0 26px;
  margin: 0;
  list-style: none;
  border-bottom: 0.5px solid var(--fg-hairline);
}

.timeline__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--fg-ink);
}

.timeline__legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--tl-dot-neutral);
  flex-shrink: 0;
  /* Decorative — the colored dot pairs with a text label that already
     conveys the meaning. Mark as ignored for pointer interactions; if a
     legend is rendered server-side, the markup should also include
     aria-hidden="true" on the dot span to skip it for screen readers. */
  pointer-events: none;
}

.timeline__legend-dot--neutral { background: var(--tl-dot-neutral); }
.timeline__legend-dot--good    { background: var(--tl-dot-good); }
.timeline__legend-dot--bad     { background: var(--tl-dot-bad); }

/* =============================================================
   Rail — base (vertical default)
   ============================================================= */
.timeline__rail {
  position: relative;
  list-style: none;
  padding: 32px 0 16px;
  margin: 0;
}

.timeline__rail--vertical::before,
.timeline__rail:not([class*="timeline__rail--"])::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--tl-spine);
  left: 208px;
}

.timeline__rail--solid::before {
  width: 2px;
  background: var(--tl-spine-thick);
}

.timeline__rail--dotted::before {
  background-image: linear-gradient(
    to bottom,
    var(--fg-ink) 0,
    var(--fg-ink) 4px,
    transparent 4px,
    transparent 8px
  );
  background-size: 1px 8px;
  background-repeat: repeat-y;
  background-color: transparent;
}

.timeline__rail--numbered::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--tl-spine);
  left: 208px;
}

.timeline__rail--horizontal {
  display: grid;
  grid-template-columns: repeat(var(--tl-cols, auto-fill), minmax(220px, 1fr));
  gap: 0;
  padding: 36px 0 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.timeline__rail--horizontal::before {
  content: "";
  position: absolute;
  top: 60px;
  left: 0;
  right: 0;
  height: 1px;
  width: 100%;
  background: var(--tl-spine);
}

.timeline__rail--horizontal.timeline__rail--solid::before {
  height: 2px;
  background: var(--tl-spine-thick);
}

.timeline__rail--horizontal.timeline__rail--dotted::before {
  background-image: linear-gradient(
    to right,
    var(--fg-ink) 0,
    var(--fg-ink) 4px,
    transparent 4px,
    transparent 8px
  );
  background-size: 8px 1px;
  background-repeat: repeat-x;
  background-color: transparent;
  height: 1px;
  width: 100%;
}

/* =============================================================
   Event — vertical default
   ============================================================= */
.timeline__event {
  position: relative;
  display: grid;
  grid-template-columns: 192px 32px 1fr;
  padding: 26px 0 28px;
  border-bottom: 0.5px solid var(--fg-hairline);
}

.timeline__event:last-child {
  border-bottom: 0;
}

.timeline__event-date {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--fg-ink);
  padding: 4px 32px 0 0;
  text-align: right;
  line-height: 1.4;
}

.timeline__event-date-day {
  display: block;
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--fg-ink);
  line-height: 1;
  margin-bottom: 4px;
}

.timeline__event-spine {
  position: relative;
  display: flex;
  justify-content: center;
}

.timeline__event-dot {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--tl-dot-neutral);
  box-shadow: 0 0 0 4px var(--fg-paper);
  z-index: 1;
  /* Decorative — the dot conveys impact via color but adds nothing
     interactive. Disabling pointer events prevents hover artifacts and
     keeps mouse text-selection clean across the spine column. */
  pointer-events: none;
}

.timeline__rail--numbered .timeline__event-dot {
  width: 28px;
  height: 28px;
  top: 2px;
  background: var(--fg-paper);
  border: 1px solid var(--fg-ink);
  box-shadow: 0 0 0 4px var(--fg-paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Georgia, serif;
  font-size: 13px;
  font-weight: 400;
  color: var(--fg-ink);
  line-height: 1;
}

.timeline__rail--numbered .timeline__event-dot::before {
  content: attr(data-step);
}

/* =============================================================
   Event accent modifiers — impact-driven semantics
   ============================================================= */
.timeline__event--accent-neutral .timeline__event-dot { background: var(--tl-dot-neutral); }
.timeline__event--accent-good    .timeline__event-dot { background: var(--tl-dot-good); }
.timeline__event--accent-bad     .timeline__event-dot { background: var(--tl-dot-bad); }

.timeline__rail--numbered .timeline__event--accent-neutral .timeline__event-dot {
  background: var(--fg-paper);
  border-color: var(--tl-dot-neutral);
  color: var(--tl-dot-neutral);
}
.timeline__rail--numbered .timeline__event--accent-good .timeline__event-dot {
  background: var(--fg-paper);
  border-color: var(--tl-dot-good);
  color: var(--tl-dot-good);
}
.timeline__rail--numbered .timeline__event--accent-bad .timeline__event-dot {
  background: var(--fg-paper);
  border-color: var(--tl-dot-bad);
  color: var(--tl-dot-bad);
}

.timeline__event-body {
  padding-left: 28px;
}

.timeline__event-tag {
  display: inline-block;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--fg-ink);
  background: var(--fg-paper-aged);
  padding: 4px 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--fg-ink);
}

.timeline__event--accent-neutral .timeline__event-tag { border-bottom-color: var(--tl-dot-neutral); }
.timeline__event--accent-good    .timeline__event-tag { border-bottom-color: var(--tl-dot-good); }
.timeline__event--accent-bad     .timeline__event-tag { border-bottom-color: var(--tl-dot-bad); }

.timeline__event-headline {
  font-family: Georgia, serif;
  font-size: 1.25rem;
  font-weight: 400;
  line-height: 1.3;
  color: var(--fg-ink);
  margin: 0 0 8px;
  letter-spacing: -0.005em;
  text-transform: none;
}

.timeline__event-summary {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--fg-ink-soft);
  margin: 0;
}

.timeline__event-summary p {
  margin: 0 0 10px;
}

.timeline__event-summary p:last-child {
  margin-bottom: 0;
}

/* ---------------------------------------------------------------
   CITATIONS — Intentionally NOT styled in this file.

   Citation rendering (the gold-dark superscript [N] links inside
   event body paragraphs) is owned by the sibling APU Citations &
   TOC module. That module's CSS handles .timeline__cite styling,
   bracket rendering, hover/focus states, and the link-to-registry
   behavior.

   This module:
   - Does NOT style .timeline__cite (citations module's territory)
   - Does NOT add pseudo-element brackets via ::before/::after
     (writers type the brackets as part of the link text "[45]")
   - DOES allowlist the timeline__cite class in TimelineFilter so
     citations within timeline body paragraphs survive filtering

   If a writer reports broken citation rendering inside a timeline,
   the issue belongs to the APU Citations & TOC module, not here.
   --------------------------------------------------------------- */

/* Inline emphasis for entity names — small caps */
.timeline__entity {
  font-variant-caps: small-caps;
  font-feature-settings: "smcp" 1;
  letter-spacing: 0.04em;
  color: var(--fg-ink);
  font-weight: 500;
}

/* =============================================================
   Horizontal variant — event layout
   ============================================================= */
.timeline__rail--horizontal .timeline__event {
  display: block;
  padding: 0 24px 16px 0;
  border-bottom: 0;
  position: relative;
}

.timeline__rail--horizontal .timeline__event-date {
  display: block;
  text-align: left;
  padding: 0 0 24px 0;
  font-size: 11px;
}

.timeline__rail--horizontal .timeline__event-date-day {
  display: inline-block;
  font-size: 14px;
  margin: 0 6px 0 0;
  vertical-align: baseline;
}

.timeline__rail--horizontal .timeline__event-spine {
  display: block;
  height: 24px;
  margin-bottom: 16px;
}

.timeline__rail--horizontal .timeline__event-dot {
  position: absolute;
  top: 50px;
  left: 0;
  transform: translateY(-50%);
}

.timeline__rail--horizontal .timeline__event-body {
  padding-left: 0;
  padding-top: 8px;
}

/* =============================================================
   Closing block
   ============================================================= */
.timeline__closing {
  margin-top: 8px;
  padding: 36px 28px 38px;
  background: var(--fg-paper-aged);
  border-top: 2px solid var(--fg-ink);
  border-bottom: 0.5px solid var(--fg-hairline);
}

.timeline__closing-kicker {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--fg-gold-dark);
  margin: 0 0 12px;
}

.timeline__closing-text {
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--fg-ink-soft);
  margin: 0;
  max-width: 64ch;
}

.timeline__closing-text p {
  margin: 0 0 12px;
}

.timeline__closing-text p:last-child {
  margin-bottom: 0;
}

/* Pull-quote within closing — left border in INK (neutral), not impact-tinted.
   Closing is editorial commentary, not an event, so it stays color-neutral
   regardless of the impact distribution of events above. */
.timeline__pullquote {
  font-family: Georgia, serif;
  font-size: 1.5rem;
  line-height: 1.3;
  font-style: italic;
  color: var(--fg-ink);
  margin: 24px 0 16px;
  padding-left: 18px;
  border-left: 2px solid var(--fg-ink);
}

/* =============================================================
   Mobile responsive
   ============================================================= */
@media (max-width: 720px) {
  .timeline {
    margin: 28px 16px;
  }

  .timeline__rail--vertical::before,
  .timeline__rail--numbered::before,
  .timeline__rail:not([class*="timeline__rail--"])::before {
    left: 14px;
  }

  .timeline__event {
    grid-template-columns: 28px 1fr;
    padding: 22px 0 24px;
  }

  .timeline__event-date {
    grid-column: 2;
    grid-row: 1;
    text-align: left;
    padding: 0 0 8px 14px;
  }

  .timeline__event-date-day {
    display: inline-block;
    font-size: 14px;
    margin: 0 8px 0 0;
  }

  .timeline__event-spine {
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  .timeline__event-dot {
    top: 4px;
  }

  .timeline__rail--numbered .timeline__event-dot {
    top: 0;
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .timeline__event-body {
    grid-column: 2;
    grid-row: 2;
    padding-left: 14px;
  }

  .timeline__event-headline {
    font-size: 1.125rem;
  }

  .timeline__event-summary {
    font-size: 0.9375rem;
    line-height: 1.6;
  }

  .timeline__rail--horizontal {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }

  .timeline__closing {
    padding: 28px 20px 30px;
  }

  .timeline__pullquote {
    font-size: 1.25rem;
  }
}

/* =============================================================
   Reduced motion + print
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .timeline *,
  .timeline *::before,
  .timeline *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .timeline {
    max-width: 100%;
    margin: 0;
  }

  .timeline__event {
    break-inside: avoid;
  }

  .timeline__event-dot {
    box-shadow: 0 0 0 2px white;
  }

  .timeline__rail--horizontal {
    /* Print engines have inconsistent grid support, especially with
       overflowing scrollable content. Stacking events vertically on
       paper matches natural reading order anyway — horizontal scroll
       doesn't translate to print. */
    display: block;
    overflow: visible;
  }
}
