/* Timeline presentation only: canonical event and image framing data stay intact. */
.timeline-page .timeline-explorer-section {
  --timeline-era-selector-height: 3.5rem;
}

/* Compact decade navigation; event images and editorial era data are independent. */
html[data-theme] .timeline-page .timeline-era-nav {
  --timeline-tab-bg: rgba(var(--text-primary-rgb), 0.04);
  --timeline-tab-border: rgba(var(--text-primary-rgb), 0.22);
  --timeline-tab-color: rgba(var(--text-primary-rgb), 0.8);
  background: transparent;
  border: 0;
}

html[data-theme="archival-dark"] .timeline-page .timeline-era-nav {
  --timeline-tab-bg: #151515;
  --timeline-tab-border: #333;
  --timeline-tab-color: #c8c4bd;
}

html[data-theme] .timeline-page .timeline-era-nav::before,
html[data-theme] .timeline-page .timeline-era-nav::after {
  display: none;
}

html[data-theme] .timeline-page .timeline-era-nav .timeline-era-filter__list {
  background: transparent;
  gap: 0.65rem;
  padding: 0;
  scroll-padding-inline: 0;
  -webkit-mask-image: none;
  mask-image: none;
}

html[data-theme] .timeline-page .timeline-era-nav .timeline-era-button:is(button, :hover, :focus-visible, [aria-pressed]) {
  align-content: center;
  background: var(--timeline-tab-bg);
  border: 1px solid var(--timeline-tab-border);
  border-radius: var(--button-radius, 8px);
  color: var(--timeline-tab-color);
  flex: 1 0 4.5rem;
  height: 3.5rem;
  min-height: 3.5rem;
  padding: 0.65rem 1rem;
  text-align: center;
}

html[data-theme] .timeline-page .timeline-era-nav .timeline-era-button:first-child {
  flex-basis: 6.25rem;
}

html[data-theme] .timeline-page .timeline-era-nav .timeline-era-button .timeline-era-button__range {
  color: inherit;
  font-size: 1.15rem;
  line-height: 1.1;
  margin: 0;
  text-shadow: none;
  white-space: nowrap;
}

.timeline-decade-label--short {
  display: none;
}

@media (max-width: 700px) {
  html[data-theme] .timeline-page .timeline-era-nav .timeline-era-filter__list {
    padding-inline: 1rem;
    scroll-padding-inline: 1rem;
  }

  .timeline-decade-label--full {
    display: none;
  }

  .timeline-decade-label--short {
    display: inline;
  }
}

html[data-theme] .timeline-page .timeline-era-nav .timeline-era-button::before {
  display: none;
}

html[data-theme] .timeline-page .timeline-era-nav .timeline-era-button::after {
  display: none;
}

html[data-theme] .timeline-page .timeline-era-nav .timeline-era-button:not(:disabled):not([aria-pressed="true"]):hover {
  background: rgba(var(--text-primary-rgb), 0.06);
  border-color: rgba(var(--text-primary-rgb), 0.45);
  color: var(--text-primary);
}

html[data-theme] .timeline-page .timeline-era-nav .timeline-era-button[aria-pressed="true"] {
  background: rgba(var(--accent-red-rgb), 0.18);
  border-color: var(--accent-red);
  color: var(--text-primary);
}

html[data-theme] .timeline-page .timeline-era-nav .timeline-era-button:focus-visible {
  outline: 2px solid var(--accent-red);
  outline-offset: -5px;
}

html[data-theme] .timeline-page .timeline-era-nav .timeline-era-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.timeline-page .timeline-rail__button:focus-visible .timeline-rail__event {
  outline: 2px solid var(--text-primary);
  outline-offset: 4px;
}

.timeline-page .timeline-rail__marker {
  color: var(--text-secondary);
}

.timeline-page .timeline-rail__item.is-active .timeline-rail__event {
  border-width: 2px;
}

.timeline-page .timeline-rail__item:not(.is-active) .timeline-rail__button:hover .timeline-rail__event {
  border-width: 2px;
  box-shadow: none;
}

/* Axis labels and row spacing are presentation; only the tile selects an event. */
.timeline-page .timeline-rail__button {
  pointer-events: none;
  cursor: default;
}

.timeline-page .timeline-rail__button .timeline-rail__event {
  pointer-events: auto;
  cursor: pointer;
}

.timeline-rail__image-preview {
  display: none;
}

/* Desktop detail mode; phone and portrait-tablet keep their existing rail/modal. */
@media (min-width: 1121px), (min-width: 701px) and (orientation: landscape) {
  .timeline-page .timeline-detail__photo {
    display: none;
  }

  .timeline-page .timeline-detail__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    column-gap: 0.75rem;
    row-gap: 0.65rem;
    padding: calc(1.25rem + 10px) 1.25rem 2rem;
  }

  .timeline-page .timeline-detail__meta-row {
    align-items: center;
    grid-column: 1;
    grid-row: 2;
    margin: 0;
    min-height: 0;
    padding: 0;
  }

  .timeline-page .timeline-detail__date {
    font-family: var(--display);
    font-size: 1.8rem;
    line-height: 1;
  }

  .timeline-page .timeline-detail--precursor .timeline-detail__date::after {
    display: block;
    font-size: 0.5rem;
    letter-spacing: 0;
    margin: 0.4rem 0 0;
    padding: 0.15rem;
  }

  .timeline-page .timeline-detail__body h3 {
    grid-column: 1 / -1;
    grid-row: 1;
    margin: 0;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.18);
  }

  .timeline-page .timeline-detail__copy {
    grid-column: 1 / -1;
    grid-row: 3;
    margin-top: 0;
  }

  .timeline-page .timeline-detail__meta-row > .timeline-detail__share {
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    color: var(--modal-icon-button-color);
    display: inline-flex;
    height: 2.75rem;
    justify-content: center;
    min-height: 2.75rem;
    min-width: 2.75rem;
    padding: 0;
    position: static;
    width: 2.75rem;
  }

  .timeline-page .timeline-detail__meta-row > .timeline-detail__share:is(:hover, :focus-visible) {
    background: var(--modal-icon-button-hover-bg);
    border-color: var(--modal-icon-button-hover-border);
    color: var(--modal-icon-button-hover-color);
  }

  .timeline-page .timeline-rail__image-preview {
    align-items: center;
    background: rgba(8, 8, 8, 0.88);
    border: 1px solid rgba(244, 241, 233, 0.4);
    border-radius: 8px;
    color: #f4f1e9;
    cursor: pointer;
    display: inline-flex;
    height: 2.75rem;
    justify-content: center;
    padding: 0;
    position: absolute;
    right: 0.65rem;
    top: 0.65rem;
    width: 2.75rem;
    z-index: 5;
  }

  .timeline-page .timeline-rail__image-preview:hover {
    background: #080808;
    border-color: var(--accent-red);
  }

  .timeline-page .timeline-rail__image-preview .material-symbols-outlined {
    font-size: 1.35rem;
    line-height: 1;
  }

  .timeline-page .timeline-rail__image-preview:focus-visible {
    outline: 2px solid var(--text-primary);
    outline-offset: 3px;
  }

  .timeline-page .timeline-explorer {
    box-sizing: border-box;
    width: 100%;
  }

  .timeline-page .timeline-rail-shell {
    container-name: timeline-pane;
    container-type: inline-size;
    display: grid;
    width: 100%;
    box-sizing: border-box;
  }

  .timeline-body .timeline-page.timeline-page--collapsed .timeline-explorer-section .timeline-workspace {
    box-sizing: border-box;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100%;
    overflow: hidden;
  }

  .timeline-body .timeline-page.timeline-page--collapsed .timeline-explorer,
  .timeline-body .timeline-page.timeline-page--collapsed .timeline-stage,
  .timeline-body .timeline-page.timeline-page--collapsed .timeline-rail-shell,
  .timeline-body .timeline-page.timeline-page--collapsed .timeline-detail {
    height: 100% !important;
    min-height: 0;
  }

  .timeline-body .timeline-page.timeline-page--collapsed .timeline-stage {
    grid-template-columns: minmax(0, 1fr);
  }

  .timeline-body .timeline-page .timeline-rail-scroll {
    height: 100%;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 1.5rem;
    scroll-padding: 1.5rem;
    scroll-snap-type: y proximity;
    overscroll-behavior: contain;
    -webkit-mask-image: none;
    mask-image: none;
  }

  .timeline-page .timeline-rail-scroll::-webkit-scrollbar {
    display: block;
    width: 8px;
  }

  .timeline-page .timeline-rail {
    --timeline-axis-x: 6.25rem;
    --timeline-desktop-card-size: clamp(280px, 30vh, 330px);
    display: grid;
    gap: 1.75rem;
    min-width: 0;
    width: min(100%, calc(var(--timeline-desktop-card-size) + 9rem));
    margin-inline: auto;
    padding: 0;
  }

  .timeline-page .timeline-rail::before {
    background: rgba(var(--text-primary-rgb), 0.45);
    bottom: 0;
    height: auto;
    left: calc(var(--timeline-axis-x) - 1px);
    right: auto;
    top: 0;
    width: 2px;
  }

  .timeline-page .timeline-rail__item {
    width: 100%;
    min-width: 0;
    padding: 0;
    scroll-snap-align: start;
  }

  .timeline-page .timeline-rail__button {
    align-items: center;
    gap: 0;
    grid-template-columns: 5rem 2.5rem minmax(0, 1fr);
    grid-template-rows: auto;
    padding: 0;
  }

  .timeline-page .timeline-rail__button::after,
  .timeline-page .timeline-rail__item.is-active .timeline-rail__button::after {
    background: rgba(var(--text-primary-rgb), 0.45);
    height: 1px;
    left: var(--timeline-axis-x);
    opacity: 1;
    top: 50%;
    transform: none;
    width: 2.75rem;
  }

  .timeline-page .timeline-rail__item.is-active .timeline-rail__button::after {
    background: var(--accent-red);
  }

  .timeline-page .timeline-rail__marker {
    font-size: 0.95rem;
    left: 0;
    right: auto;
    top: 50%;
    transform: translateY(-50%);
    text-align: right;
    white-space: normal;
    width: 4.5rem;
  }

  .timeline-page .timeline-rail__dot {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
  }

  .timeline-page .timeline-rail__event,
  .timeline-page .timeline-rail__item--precursor .timeline-rail__event {
    aspect-ratio: 1;
    box-sizing: border-box;
    grid-column: 3;
    grid-row: 1;
    height: auto;
    min-height: 0;
    min-width: 0;
    width: min(calc(100% - 1.5rem), var(--timeline-desktop-card-size));
    margin-left: 1.5rem;
  }

  .timeline-page .timeline-rail-shell::before,
  .timeline-page .timeline-rail-shell::after {
    display: none;
  }

  /* Reserve two comfortable card columns and a date/connector gutter. */
  @container timeline-pane (min-width: 885px) {
    .timeline-page .timeline-rail__image-preview {
      right: calc(50% + 3rem + 0.65rem);
    }

    .timeline-page .timeline-rail__item:nth-child(even) .timeline-rail__image-preview {
      right: 0.65rem;
    }

    .timeline-page .timeline-rail {
      --timeline-axis-x: 50%;
      --timeline-desktop-card-size: clamp(370.3px, 39.675vh, 436.425px);
      --timeline-desktop-card-height: clamp(322px, 34.5vh, 379.5px);
      width: min(100%, calc(2 * var(--timeline-desktop-card-size) + 6rem));
    }

    .timeline-page .timeline-rail__button {
      grid-template-columns: minmax(0, 1fr) 6rem minmax(0, 1fr);
    }

    .timeline-page .timeline-rail__event,
    .timeline-page .timeline-rail__item--precursor .timeline-rail__event {
      grid-column: 1;
      margin: 0;
      justify-self: end;
      width: min(100%, var(--timeline-desktop-card-size));
      aspect-ratio: auto;
      height: var(--timeline-desktop-card-height);
    }

    .timeline-page .timeline-rail__item:nth-child(even) .timeline-rail__event {
      grid-column: 3;
      justify-self: start;
    }

    .timeline-page .timeline-rail__button::after,
    .timeline-page .timeline-rail__item.is-active .timeline-rail__button::after {
      left: calc(50% - 3rem);
      width: 3rem;
    }

    .timeline-page .timeline-rail__item:nth-child(even) .timeline-rail__button::after {
      left: 50%;
    }

    .timeline-page .timeline-rail__marker {
      left: calc(50% + 1.25rem);
      text-align: left;
    }

    .timeline-page .timeline-rail__item:nth-child(even) .timeline-rail__marker {
      left: auto;
      right: calc(50% + 1.25rem);
      text-align: right;
    }
  }
}
