/* MV_Timeline — full-screen "life view" overlay.
   Sits on top of the live tree (z-index just above the panel and modal-overlay
   layer) and fades in. Layout is hero on top, then a two-pane body: a sticky
   decade rail on the left and a scrolling event stream on the right.
   Below 640px the rail collapses to a sticky horizontal pill bar at the top
   of the stream. The heritage palette and serif voice match the panel; the
   timeline reads like a quiet chapter book rather than a dashboard. */

.timeline-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--color-bg);
  z-index: var(--z-modal-overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.timeline-overlay--open {
  opacity: 1;
  pointer-events: auto;
}

.timeline {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at top, var(--color-bg-tint) 0%, var(--color-bg) 60%);
}

/* ---------------- header ---------------- */

.timeline__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-lg);
  background: linear-gradient(to bottom,
    var(--color-surface) 0%,
    var(--color-surface-elevated) 100%);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.timeline__back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.timeline__back:hover,
.timeline__back:focus-visible {
  color: var(--color-text);
  background-color: var(--color-surface-alt);
}

.timeline__back-arrow {
  font-size: var(--font-size-md);
  line-height: 1;
}

.timeline__close {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  line-height: 1;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.timeline__close:hover,
.timeline__close:focus-visible {
  color: var(--color-text);
  background-color: var(--color-surface-alt);
}

/* ---------------- hero ---------------- */

.timeline__hero {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-xl) var(--space-xl);
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
  flex-shrink: 0;
}

.timeline__hero-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background-color: var(--color-accent-soft);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  color: var(--color-accent);
  font-size: 2rem;
  font-weight: var(--font-weight-bold);
  border: 2px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.timeline__hero-info {
  flex: 1;
  min-width: 0;
}

.timeline__hero-name {
  font-family: var(--font-serif);
  font-size: var(--font-size-xxl);
  font-style: italic;
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  margin: 0;
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-tight);
}

.timeline__hero-dates {
  font-size: var(--font-size-md);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

.timeline__hero-places {
  font-size: var(--font-size-sm);
  color: var(--color-text-faint);
  margin-top: var(--space-xxs);
  font-style: italic;
}

/* ---------------- layout (rail + stream) ---------------- */

.timeline__layout {
  flex: 1;
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: var(--space-xl);
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--space-xl) var(--space-xxl);
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

/* ---------------- rail (sticky decade nav) ---------------- */

.timeline__rail {
  position: sticky;
  top: var(--space-md);
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: var(--space-xxs);
  padding: var(--space-md) var(--space-md) var(--space-md) 0;
  border-right: 1px solid var(--color-border);
  font-family: var(--font-serif);
}

.timeline__rail-link {
  display: block;
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-md);
  font-style: italic;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
  text-decoration: none;
  text-align: right;
  letter-spacing: var(--letter-spacing-wide);
  border-radius: var(--radius-md);
  border-right: 2px solid transparent;
  transition:
    color var(--transition-fast),
    background-color var(--transition-fast),
    border-color var(--transition-fast);
}

.timeline__rail-link:hover,
.timeline__rail-link:focus-visible {
  color: var(--color-highlight);
  background-color: var(--color-highlight-soft);
}

.timeline__rail-link--active {
  color: var(--color-accent);
  border-right-color: var(--color-highlight);
  background-color: var(--color-accent-soft);
}

.timeline__rail-link--undated {
  font-size: var(--font-size-sm);
  font-style: normal;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wider);
  margin-top: var(--space-sm);
}

.timeline__rail-gap {
  display: block;
  padding: 0 var(--space-sm);
  text-align: right;
  color: var(--color-text-faint);
  font-size: var(--font-size-sm);
  letter-spacing: 0.4em;
  line-height: 1.2;
}

/* ---------------- stream + decade sections ---------------- */

.timeline__stream {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  padding-bottom: var(--space-xxl);
  min-width: 0;
}

.timeline__decade {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  scroll-margin-top: var(--space-md);
}

.timeline__decade-marker {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-medium);
  color: var(--color-highlight);
  margin: 0;
  padding: 0 0 var(--space-xs);
  border-bottom: 1px solid var(--color-border);
  letter-spacing: var(--letter-spacing-wide);
}

.timeline__decade-empty {
  font-size: var(--font-size-sm);
  color: var(--color-text-faint);
  font-style: italic;
  margin: 0;
}

/* ---------------- events ---------------- */

.timeline__event {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.timeline__event--moment {
  background-color: var(--color-surface-elevated);
}

.timeline__event--gallery {
  background-color: var(--color-surface-alt);
}

.timeline__event-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.timeline__event-date {
  font-size: var(--font-size-xs);
  color: var(--color-highlight);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--letter-spacing-wider);
  text-transform: uppercase;
}

.timeline__event-with {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-xxs);
}

.timeline__chip {
  display: inline-block;
  padding: 2px var(--space-sm);
  border-radius: var(--radius-pill);
  background-color: var(--color-accent-soft);
  color: var(--color-accent);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
}

.timeline__event-title {
  font-family: var(--font-serif);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  margin: 0;
  line-height: var(--line-height-tight);
}

.timeline__event-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin: 0;
  font-style: italic;
}

.timeline__event-body {
  font-size: var(--font-size-base);
  line-height: var(--line-height-loose);
  color: var(--color-text);
}

.timeline__event-body p {
  margin: 0 0 var(--space-sm);
}

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

.timeline__event-body h3 {
  font-family: var(--font-serif);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-bold);
  margin: var(--space-sm) 0 var(--space-xxs);
}

.timeline__event-body h4 {
  font-family: var(--font-serif);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  color: var(--color-text-muted);
  margin: var(--space-sm) 0 var(--space-xxs);
}

.timeline__event-body ul,
.timeline__event-body ol {
  margin: var(--space-xs) 0;
  padding-left: var(--space-lg);
}

.timeline__event-body ul { list-style: disc; }
.timeline__event-body ol { list-style: decimal; }

.timeline__event-body blockquote {
  margin: var(--space-sm) 0;
  padding: var(--space-xs) var(--space-md);
  border-left: 3px solid var(--color-highlight);
  background-color: var(--color-surface-alt);
  color: var(--color-text-muted);
  font-style: italic;
}

.timeline__event-body a {
  color: var(--color-accent);
  text-decoration: underline;
}

.timeline__event-body a:hover {
  color: var(--color-accent-hover);
}

.timeline__event-caption {
  font-size: var(--font-size-base);
  color: var(--color-text);
  font-style: italic;
  margin: 0;
  line-height: var(--line-height-normal);
}

/* Photo layouts: stories and gallery use a wrap grid; moments use a
   horizontal scroll strip so the photo-first character reads at a glance. */

.timeline__event-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-sm);
}

.timeline__event-strip {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding-bottom: var(--space-xs);
  scroll-snap-type: x proximity;
}

.timeline__event-strip .timeline__photo {
  flex: 0 0 200px;
  height: 200px;
  aspect-ratio: auto;
  scroll-snap-align: start;
}

.timeline__photo {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  background-color: var(--color-surface-alt);
  background-size: cover;
  background-position: center;
  border: 1px solid var(--color-border);
  cursor: pointer;
  padding: 0;
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
}

.timeline__photo:hover,
.timeline__photo:focus-visible {
  transform: scale(1.02);
  box-shadow: var(--shadow-md);
}

/* ---------------- empty state ---------------- */

.timeline__empty {
  text-align: center;
  padding: var(--space-xxl) var(--space-lg);
  color: var(--color-text-muted);
  max-width: 720px;
  margin: 0 auto;
}

.timeline__empty-title {
  font-family: var(--font-serif);
  font-size: var(--font-size-xl);
  font-style: italic;
  margin: 0 0 var(--space-sm);
  color: var(--color-text);
}

.timeline__empty-body {
  margin: 0 auto;
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text-muted);
}

/* ---------------- panel entry point ---------------- */

/* Small italic link rendered inside `.panel__heading` (below the dates) to
   take the user from the slide-in panel into the full timeline view. */
.panel__life-view-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xxs);
  margin-top: var(--space-xs);
  padding: 2px var(--space-xs);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--font-size-sm);
  color: var(--color-highlight);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.panel__life-view-link:hover,
.panel__life-view-link:focus-visible {
  color: var(--color-highlight-hover);
  background-color: var(--color-highlight-soft);
}

/* ---------------- responsive ---------------- */

@media (max-width: 720px) {
  .timeline__hero {
    flex-direction: column;
    text-align: center;
    gap: var(--space-md);
    padding: var(--space-lg);
  }

  .timeline__hero-avatar {
    width: 80px;
    height: 80px;
    font-size: 1.6rem;
  }

  .timeline__hero-name {
    font-size: var(--font-size-xl);
  }

  .timeline__layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0 var(--space-md) var(--space-xl);
  }

  /* Rail becomes a horizontal pill bar pinned to the top of the stream.
     Each decade becomes a tap target; "···" gaps stay between them but
     compress to a single inline dot row to save space. */
  .timeline__rail {
    position: sticky;
    top: 0;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-xs) 0;
    margin: 0 calc(-1 * var(--space-md)) var(--space-md);
    padding-left: var(--space-md);
    padding-right: var(--space-md);
    background-color: var(--color-bg);
    gap: var(--space-xs);
    z-index: 2;
  }

  .timeline__rail-link {
    flex-shrink: 0;
    text-align: center;
    padding: var(--space-xs) var(--space-md);
    border-right: none;
    border-bottom: 2px solid transparent;
  }

  .timeline__rail-link--active {
    border-right-color: transparent;
    border-bottom-color: var(--color-highlight);
  }

  .timeline__rail-link--undated {
    margin-top: 0;
  }

  .timeline__rail-gap {
    align-self: center;
    padding: 0 var(--space-xs);
    letter-spacing: 0.2em;
  }

  .timeline__event {
    padding: var(--space-md);
  }

  .timeline__event-photos {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }

  .timeline__event-strip .timeline__photo {
    flex-basis: 160px;
    height: 160px;
  }
}

/* Honour reduced motion — keep the page calm during transition, no
   smooth-scroll lurch. */
@media (prefers-reduced-motion: reduce) {
  .timeline-overlay {
    transition: none;
  }
  .timeline__layout {
    scroll-behavior: auto;
  }
  .timeline__photo {
    transition: none;
  }
}
