/* Timeline tracker (prototype, Nov 11 2026). See timeline-tracker.js. */

.timeline-rail-shell.has-timeline-tracker {
  display: grid !important;
  grid-template-rows: auto auto minmax(0, 1fr) !important;
  grid-template-columns: minmax(0, 1fr) !important;
  --tt-dock-h: 64px;
  --tt-bar-w: 18px;
  --tt-red: var(--accent-red, #d62828);
  position: relative;
}

/* The era bar replaces the rail's own scrollbar */
html body .timeline-page .timeline-rail-shell.has-timeline-tracker > .timeline-rail-scroll {
  scrollbar-width: none;
  grid-row: 3 !important;
  padding-top: 20px !important; /* breathing room below the dock */
  padding-right: calc(var(--tt-bar-w) + 6px) !important;
}
.has-timeline-tracker .timeline-rail-scroll::-webkit-scrollbar {
  display: none;
}

/* ---------- dock ---------- */
.tt-dock {
  position: relative;
  grid-row: 2;
  z-index: 5;
  height: var(--tt-dock-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 12px 0 20px;
  background: #111; /* same as the rail panel, fully opaque */
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 12px -6px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  font-family: "D-DIN-PRO", "Puroresu DIN Macrons", "DIN Next", "Barlow Condensed", "Arial Narrow", sans-serif;
  color: var(--text-primary, #f2f2f2);
}

.tt-dock__year {
  font-size: 40px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--tt-red);
  font-variant-numeric: tabular-nums;
  min-width: 2.6em;
}

.tt-dock__meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding-left: 16px;
  border-left: 1px solid rgba(255, 255, 255, 0.14);
}

.tt-dock__era {
  position: relative;
  align-self: flex-start;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1.1;
}

.tt-dock__era::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 2px;
  background: var(--tt-red);
  transform: scaleX(0);
  transform-origin: left center;
}

.tt-dock__line {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary, rgba(242, 242, 242, 0.62));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

/* prev/next arrows moved here from the hidden heading row */
.tt-dock__controls {
  margin-left: auto;
  display: flex !important;
  gap: 8px;
  pointer-events: auto;
  flex-shrink: 0;
}
.tt-dock__meta { flex: 1 1 auto; }
@media (max-width: 768px) {
  /* phones swipe; the arrows are disabled there by script.js anyway */
  html body .timeline-page .tt-dock__controls--site { display: none !important; }
}

.tt-dock__sep {
  margin: 0 0.5em;
  opacity: 0.5;
}

/* "Chapter" moment when you cross into a new era */
.tt-dock.is-era-change .tt-dock__era::after {
  animation: tt-era-rule 1.4s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.tt-dock.is-era-change .tt-dock__era {
  animation: tt-era-text 1.4s ease both;
}

@keyframes tt-era-rule {
  0% { transform: scaleX(0); }
  35% { transform: scaleX(1); }
  75% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(1); opacity: 0; }
}
@keyframes tt-era-text {
  0% { color: var(--tt-red); }
  60% { color: var(--tt-red); }
  100% { color: var(--text-primary, #f2f2f2); }
}

/* ---------- era bar ---------- */
.tt-bar {
  position: absolute;
  right: 6px;
  width: var(--tt-bar-w);
  /* top/bottom are set to match the scroller */
  top: var(--tt-bar-top, 140px); /* set by JS */
  bottom: 10px;
  z-index: 6;
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

.tt-bar__track {
  position: absolute;
  inset: 0 3px;
  border-radius: 2px;
  overflow: visible;
}

.tt-bar__band {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid #111;
  transition: background-color 0.3s ease;
}
.tt-bar__band--a { background: rgba(255, 255, 255, 0.16); }
.tt-bar__band--b { background: rgba(255, 255, 255, 0.28); }
.tt-bar__band.is-current { background: rgba(214, 40, 40, 0.55); }

.tt-bar__band-label {
  position: absolute;
  right: calc(100% + 8px);
  top: 4px;
  font: 700 10px/1 "D-DIN-PRO", "DIN Next", "Arial Narrow", sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  color: rgba(242, 242, 242, 0.55);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.tt-bar:hover .tt-bar__band-label,
.tt-bar.is-dragging .tt-bar__band-label {
  opacity: 1;
}
.tt-bar.is-tipping .tt-bar__band-label {
  opacity: 0;
}

.tt-bar__tick {
  position: absolute;
  left: 2px;
  right: 2px;
  height: 1px;
  background: rgba(5, 5, 5, 0.55);
  pointer-events: none;
}

.tt-bar__marker {
  position: absolute;
  /* 3px wider than the visible strip on each side (desktop strip is inset 3px) */
  left: 0;
  right: 0;
  height: 5px;
  margin-top: -2px;
  background: #fff;
  box-shadow: 0 0 0 2px var(--tt-red);
  border-radius: 1px;
  pointer-events: none;
}

.tt-bar__tip {
  position: absolute;
  right: calc(100% + 6px);
  transform: translateY(-50%);
  padding: 5px 8px;
  background: #111;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 4px;
  font: 700 12px/1 "D-DIN-PRO", "DIN Next", "Arial Narrow", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: #f2f2f2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.tt-bar.is-tipping .tt-bar__tip {
  opacity: 1;
}

/* ---------- phones ---------- */
@media (max-width: 768px) {
  .timeline-rail-shell.has-timeline-tracker {
    --tt-dock-h: 54px;
  }
  .tt-dock {
    gap: 12px;
    padding-left: 14px;
  }
  .tt-dock__year { font-size: 32px; }
  .tt-dock__meta { padding-left: 12px; }
  .tt-dock__era { font-size: 13px; }
  .tt-dock__line { font-size: 10.5px; letter-spacing: 0.03em; }
  .tt-dock__sep { margin: 0 0.3em; }
  .tt-dock__year { min-width: 0; }
  /* 32px touch target that runs to the screen edge; the visible 8px strip sits ~12px in,
     clear of raised phone-case lips and the Android edge-swipe "back" gesture */
  .timeline-rail-shell.has-timeline-tracker { --tt-bar-w: 32px; }
  .tt-bar { right: 10px; } /* sits in the 10px the list gave up by shifting left */
  .tt-bar__track { left: 12px; right: 12px; }
  .tt-bar__marker { left: 9px; right: 9px; } /* stays inside the screen: strip 12px in, marker 3px wider */
  html body .timeline-page .timeline-rail-shell.has-timeline-tracker > .timeline-rail-scroll {
    padding-right: var(--tt-bar-w) !important;
  }
  .tt-bar__band-label { display: none; }
  html body .timeline-page .tt-dock__controls { gap: 6px; }
  html body .timeline-page .tt-dock__controls .timeline-rail-controls__button {
    width: 34px !important;
    height: 34px !important;
    min-width: 0 !important;
    min-height: 0 !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tt-dock.is-era-change .tt-dock__era,
  .tt-dock.is-era-change .tt-dock__era::after { animation: none; }
  .tt-bar__band, .tt-bar__tip, .tt-bar__band-label { transition: none; }
}

/* ---------- phones: move the axis to the left edge, give cards the space ---------- */
/* The small year label beside each dot repeats the card's big year (and the dock),
   so it is hidden; the line and dots move ~68px left. */
@media (max-width: 768px) {
  .timeline-page .has-timeline-tracker .timeline-rail {
    padding-left: 6px !important;
  }
  .timeline-page .has-timeline-tracker .timeline-rail::before {
    left: 18.2px !important; /* centre of the 26px dot column */
  }
  .timeline-page .has-timeline-tracker .timeline-rail__marker {
    display: none !important;
  }
  /* shift the whole list (line, dots, cards) 10px left */
  .timeline-page .has-timeline-tracker .timeline-rail {
    position: relative;
    left: -10px;
  }
}

/* The dock now shows "Event N / total", so hide the copy in the rail heading.
   Visually hidden only: screen readers still get it (the dock is aria-hidden). */
.timeline-page .has-timeline-tracker [data-timeline-rail-position] {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Hide the "TIMELINE" heading row (kept for screen readers). It comes back when an
   Archive Trail is active, because that row carries the trail title and "View Full Timeline". */
.timeline-page .has-timeline-tracker .timeline-column-heading:not(:has([data-timeline-rail-trail-meta]:not([hidden]))) {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ---------- no repeated years ----------
   The card already shows the year large, and the tracker bar shows it for the current spot.
   So: the small year beside each dot is hidden at every size, and on desktop/tablet the yellow
   year in the detail panel is hidden too (kept for screen readers). On phones the detail opens
   as a sheet that covers the cards, so the year stays there. */
.timeline-page .has-timeline-tracker .timeline-rail__marker {
  display: none !important;
}
@media (min-width: 769px) {
  body:has(.has-timeline-tracker) .timeline-detail [data-detail-date] {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }
}
