/* Timeline page: a fixed stage pinned in the viewport, driven by scroll.
 * The body provides a tall scroll-track so native scroll works; the stage
 * stays in place. JS exposes --year on :root and per-element transition
 * variables used below. */

html, body {
  height: auto;
  overscroll-behavior-y: none;
}

body.page--timeline {
  /* The track height is set by JS based on year span × pixels-per-year so
   * scrolling feels right. We start with a sane default in case JS is slow. */
  min-height: 600vh;
  background: var(--color-bg-deep);
  overflow-x: hidden;
}

/* The stage is fixed and fills the viewport. */
.stage {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  isolation: isolate;
}

/* ----- Era backgrounds (lowest layer) --------------------------------- */

.era-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.era {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 600ms ease;
  will-change: opacity;
}
.era--blues      { background: radial-gradient(ellipse at 30% 30%, #2c3e60 0%, #14182b 70%); }
.era--classic    { background: radial-gradient(ellipse at 70% 40%, #c79a4a 0%, #5a2a1a 70%); }
.era--wilderness { background: radial-gradient(ellipse at 30% 70%, #2f4a4a 0%, #14201f 70%); }
.era--reunion    { background: radial-gradient(ellipse at 70% 30%, #6a3a8a 0%, #2a1838 70%); }
.era--final      { background: radial-gradient(ellipse at 50% 60%, #2a3a5a 0%, #0a1024 70%); }

/* A subtle paper / grain overlay to keep gradients from looking flat. */
.era-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 3px 3px;
  mix-blend-mode: overlay;
}

/* ----- Header (top of stage) ------------------------------------------ */

.timeline-header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem clamp(1rem, 4vw, 3rem);
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.timeline-header__title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
}
.timeline-header__title span {
  font-style: italic;
  font-weight: 400;
  opacity: 0.78;
}
.timeline-header__nav { display: flex; gap: 1.25rem; font-size: 0.95rem; }
.timeline-header__nav a { color: #fff; opacity: 0.85; }
.timeline-header__nav a:hover { opacity: 1; }

.era-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.78);
  white-space: nowrap;
  pointer-events: none;
}

/* ----- Main stage area (year + members + albums) --------------------- */

.stage__main {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: stretch;
  padding: 0 clamp(1rem, 4vw, 3rem);
  min-height: 0;
}

/* Big year display, centered vertically. */
.year-display {
  align-self: center;
  justify-self: center;
  font-family: var(--font-display);
  font-size: clamp(7rem, 22vw, 22rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 0.9;
  color: rgba(255,255,255,0.92);
  text-shadow: 0 4px 24px rgba(0,0,0,0.35);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  user-select: none;
}

/* Album drift layer occupies the same area as the year display. */
.album-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.album {
  position: absolute;
  width: clamp(120px, 18vw, 220px);
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-stage);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  padding: 0.9rem;
  color: #fff;
  font-family: var(--font-display);
  line-height: 1.05;
  /* Anchor at vertical/horizontal center; drift via --y. */
  top: 50%;
  left: var(--x);
  transform: translate(-50%, calc(-50% + var(--y, 0vh))) rotate(var(--rot, 0deg));
  opacity: var(--alpha, 0);
  background: linear-gradient(135deg, var(--colorA, #444) 0%, var(--colorB, #111) 100%);
  transition: opacity 220ms ease;
  will-change: transform, opacity;
}
.album__title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 6px rgba(0,0,0,0.45);
}
.album__subtitle {
  display: block;
  font-size: 0.78rem;
  font-style: italic;
  opacity: 0.85;
  margin-top: 0.15rem;
}
.album__year {
  position: absolute;
  top: 0.6rem;
  right: 0.8rem;
  font-size: 0.78rem;
  font-family: var(--font-body);
  letter-spacing: 0.1em;
  opacity: 0.7;
}
.album[data-hidden="true"] { display: none; }

/* Member chips row, near the bottom of the stage. */
.lineup {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 0.6rem 0.75rem;
  padding: 1rem 0 1.5rem;
  min-height: 9rem;
}

.chip {
  --slide-from: -120%;            /* L wing default; overridden for R */
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.55rem 0.95rem;
  background: var(--color-chip-bg);
  color: var(--color-chip-text);
  border-radius: 999px;
  box-shadow: 0 4px 14px var(--color-chip-shadow);
  font-family: var(--font-body);
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  transform-origin: center;
  transform: translateX(var(--slide-from)) scale(0.94);
  opacity: 0;
  transition:
    transform 600ms cubic-bezier(0.22, 0.61, 0.36, 1),
    opacity   500ms ease;
  will-change: transform, opacity;
}
.chip[data-wing="R"] { --slide-from: 120%; }

.chip__name {
  font-weight: 600;
  letter-spacing: 0.005em;
}
.chip__role {
  font-size: 0.78rem;
  color: var(--color-muted);
  font-style: italic;
}

/* Phase: present — fully on stage. */
.chip[data-phase="present"] {
  transform: translateX(0) scale(1);
  opacity: 1;
}

/* Phase: entering — quick interpolated; CSS transition handles it. */
.chip[data-phase="entering"] {
  transform: translateX(calc(var(--slide-from) * (1 - var(--t, 0)))) scale(calc(0.94 + 0.06 * var(--t, 0)));
  opacity: var(--t, 0);
}

/* Phase: exiting — slide off the opposite side. */
.chip[data-phase="exiting"] {
  transform: translateX(calc(var(--slide-from) * -1 * (1 - var(--t, 1)))) scale(calc(1 - 0.06 * (1 - var(--t, 1))));
  opacity: var(--t, 1);
}

/* Hidden states. */
.chip[data-phase="before"],
.chip[data-phase="after"] { display: none; }

/* ----- Footer (bottom of stage): progress + scroll hint --------------- */

.timeline-footer {
  position: relative;
  z-index: 5;
  padding: 0.8rem clamp(1rem, 4vw, 3rem) 1.4rem;
  color: rgba(255,255,255,0.85);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.8rem 1rem;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.progress {
  position: relative;
  height: 2px;
  background: rgba(255,255,255,0.18);
  border-radius: 2px;
  overflow: visible;
}
.progress__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--progress-pct, 0%);
  background: rgba(255,255,255,0.85);
  border-radius: 2px;
}
.progress__cursor {
  position: absolute;
  top: 50%;
  left: var(--progress-pct, 0%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.18);
  transform: translate(-50%, -50%);
}

.scroll-hint {
  position: absolute;
  bottom: 4.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.6);
  pointer-events: none;
  animation: hint-pulse 2.4s ease-in-out infinite;
}
.scroll-hint[data-hidden="true"] { display: none; }

@keyframes hint-pulse {
  0%, 100% { opacity: 0.4; transform: translate(-50%, 0); }
  50%      { opacity: 1;   transform: translate(-50%, 4px); }
}

/* Visually hidden live region for screen-reader announcements. */
.sr-live {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ----- Responsive ----------------------------------------------------- */

@media (max-width: 640px) {
  .year-display { font-size: clamp(5rem, 28vw, 9rem); }
  .timeline-header__title span { display: none; }
  .lineup { padding: 0.5rem 0 1rem; }
  .album { width: clamp(96px, 30vw, 140px); padding: 0.6rem; }
  .album__title { font-size: 0.85rem; }
}

/* ----- Reduced motion ------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .chip, .album, .era {
    transition: none;
  }
  .chip[data-phase="entering"],
  .chip[data-phase="exiting"] {
    transform: none;
    opacity: 1;
  }
  .scroll-hint { animation: none; }
}
