@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --faint: #86868b;
  --line: #d2d2d7;
  --line-soft: rgba(0, 0, 0, 0.08);
  --surface: #ffffff;
  --surface-alt: #f5f5f7;
  --brand: #005EA2;
  --brand-soft: rgba(0, 94, 162, 0.08);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --topbar-height: 68px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

.tl-app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Top bar (hidden when framed inside the Hugo page) ---------- */
.tl-topbar {
  height: var(--topbar-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--line-soft);
}
.tl-topbar-title { margin: 0; font-size: 1.25rem; font-weight: 600; letter-spacing: -0.02em; }
.tl-topbar-subtitle { margin: 0.2rem 0 0; font-size: 0.8125rem; color: var(--muted); }
.tl-back {
  font-family: var(--font);
  font-size: 0.84375rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface-alt);
  border-radius: 980px;
  padding: 0.5rem 1rem;
  text-decoration: none;
}
.tl-back:hover { background: #ebebef; }

/* ---------- Era chips ---------- */
.tl-eras-row {
  flex-shrink: 0;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line-soft);
}
.tl-era-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font);
  font-size: 0.84375rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  padding: 0.5rem 1rem 0.5rem 0.8rem;
  border-radius: 980px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.tl-era-chip::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--era-color, var(--brand));
  flex-shrink: 0;
}
.tl-era-chip:hover { border-color: var(--era-color, var(--brand)); background: var(--surface-alt); }
.tl-era-chip .tl-era-range { font-weight: 400; color: var(--muted); }
.tl-hint {
  margin-left: auto;
  font-size: 0.76rem;
  color: var(--faint);
}

/* ---------- Play tour button ---------- */
.tl-play-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font);
  font-size: 0.84375rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  padding: 0.5rem 1rem 0.5rem 0.85rem;
  border-radius: 980px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #ffffff;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.tl-play-btn svg { width: 12px; height: 12px; flex-shrink: 0; }
.tl-play-btn:hover { background: #004a82; }
.tl-play-btn:active { transform: scale(0.96); }
.tl-play-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.tl-play-btn.is-playing { background: var(--surface); color: var(--ink); border-color: var(--line); }
.tl-play-btn.is-playing:hover { background: var(--surface-alt); }

/* ---------- Stage (horizontal scroll timeline) ---------- */
.tl-stage { flex: 1; min-height: 0; position: relative; padding-bottom: 22px; }

.tl-track-wrap {
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  cursor: grab;
  /* The custom .tl-scrubber below is the one scroll affordance we want —
     it always follows "drag the thumb toward where you want to go", so
     the platform scrollbar (whose drag direction can read as reversed
     once our own pointer-drag-to-pan is layered on the same element) is
     hidden rather than left to conflict with it. */
  scrollbar-width: none;
}
.tl-track-wrap::-webkit-scrollbar { display: none; }
.tl-track-wrap.is-dragging { cursor: grabbing; scroll-behavior: auto; }

.tl-track {
  position: relative;
  height: 100%;
  min-width: 100%;
}

.tl-era-band {
  position: absolute;
  top: 0;
  bottom: 0;
  background: linear-gradient(180deg, var(--band-tint-strong) 0%, var(--band-tint-soft) 55%, transparent 100%);
  border-right: 1px solid var(--line-soft);
  overflow: hidden;
}
.tl-era-band-label {
  position: absolute;
  top: 1.25rem;
  left: 1.5rem;
  right: 1.5rem;
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--band-color);
  opacity: 0.16;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.tl-axis-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 52%;
  height: 2px;
  background: var(--line);
}

.tl-tick {
  position: absolute;
  top: 52%;
  transform: translate(-50%, -1px);
  width: 1px;
  height: 14px;
  background: var(--line);
}
.tl-tick-label {
  position: absolute;
  top: calc(52% + 12px);
  transform: translateX(-50%);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--faint);
  white-space: nowrap;
}

.tl-event {
  position: absolute;
  transform: translate(-50%, -50%);
  top: 52%;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tl-event::after {
  content: '';
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 3px solid var(--surface);
  background: var(--event-color, var(--brand));
  box-shadow: 0 0 0 1px var(--line);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.tl-event:hover::after { transform: scale(1.3); }
.tl-event.is-active::after {
  box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--event-color, var(--brand));
}
.tl-event:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 50%; }

/* A quiet invitation to click the very first moment, shown once the
   entrance animation settles and cleared the instant the reader interacts
   with the timeline at all (see dismissPulseHint in timeline-engine.js). */
@keyframes tlPulseRing {
  0% { box-shadow: 0 0 0 0 var(--event-color, var(--brand)); opacity: 0.35; }
  70% { box-shadow: 0 0 0 11px var(--event-color, var(--brand)); opacity: 0; }
  100% { box-shadow: 0 0 0 11px var(--event-color, var(--brand)); opacity: 0; }
}
.tl-event.tl-pulse::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--event-color, var(--brand));
  animation: tlPulseRing 1.8s cubic-bezier(0.16, 1, 0.3, 1) infinite;
  pointer-events: none;
}

/* Leader line from the dot to its card — always drawn, in the event's
   own era color, so a card that's been pushed out to a further tier
   still reads as belonging to a specific dot instead of floating loose. */
.tl-connector {
  position: absolute;
  width: 2px;
  transform: translateX(-1px);
  background: var(--event-color, var(--brand));
  opacity: 0.42;
  border-radius: 1px;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.15s ease;
}
.tl-connector.is-active { opacity: 0.85; }

/* First-render-only stagger: dots pop in, cards rise into place just after
   their dot, connectors fade in alongside — walking the reader's eye left
   to right across the whole story once, on load. See the animateIn guard
   in renderTrack() (never replayed on resize). */
@keyframes tlEnterDot {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.35); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes tlEnterCard {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes tlEnterConnector {
  from { opacity: 0; }
  to { opacity: 0.42; }
}
.tl-event.tl-enter { opacity: 0; animation: tlEnterDot 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }
.tl-event-card.tl-enter { opacity: 0; animation: tlEnterCard 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }
.tl-connector.tl-enter { opacity: 0; animation: tlEnterConnector 0.4s ease both; }
@media (prefers-reduced-motion: reduce) {
  .tl-event.tl-enter, .tl-event-card.tl-enter, .tl-connector.tl-enter { animation: none; opacity: 1; }
  .tl-event.tl-pulse::before { animation: none; display: none; }
}

.tl-event-card {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 190px;
  height: 60px;
  padding: 0.4rem 0.65rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.15rem;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  z-index: 2;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.tl-event-card:hover, .tl-event-card:focus-visible {
  border-color: var(--event-color, var(--brand));
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
  outline: none;
  transform: translateX(-50%) translateY(-2px);
}
.tl-event-card.is-active {
  border-color: var(--event-color, var(--brand));
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--event-color, var(--brand));
}
.tl-event-card-date {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--event-color, var(--brand));
  padding-right: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-event-card-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding-right: 1rem;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
}
.tl-info-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.45rem;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--event-color, var(--brand));
  color: #ffffff;
  font-size: 0.62rem;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, 'Times New Roman', serif;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Scrubber (replaces the platform scrollbar) ---------- */
.tl-scrubber {
  position: absolute;
  left: 1.5rem;
  right: 1.5rem;
  bottom: 6px;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-alt);
  cursor: pointer;
  z-index: 4;
}
.tl-scrubber-thumb {
  position: absolute;
  top: 0;
  left: 0;
  height: 8px;
  min-width: 40px;
  border-radius: 999px;
  background: var(--faint);
  cursor: grab;
  transition: background 0.15s ease;
}
.tl-scrubber-thumb:hover, .tl-scrubber-thumb:active { background: var(--brand); cursor: grabbing; }

/* ---------- Detail bubble (eases open near the top of the stage) ---------- */
.tl-bubble {
  position: absolute;
  top: 1rem;
  left: 50%;
  width: min(640px, calc(100% - 2.5rem));
  max-height: calc(100% - 2rem);
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.16);
  padding: 1.6rem 1.9rem 1.5rem;
  z-index: 5;
  opacity: 0;
  transform: translate(-50%, -14px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.32s cubic-bezier(0.16, 1, 0.3, 1), transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
.tl-bubble.is-open {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  pointer-events: auto;
}
.tl-bubble-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tl-bubble-close:hover { background: var(--line); color: var(--ink); }

/* A real, licensed photo (kept rare — see the `image` field note in
   data.js) bleeds to the bubble's own edges as a header banner. Source
   photos are a mix of portraits (taller than wide) and landscapes, and
   this banner is short and wide — `cover` used to scale a portrait up to
   banner-width and then crop nearly all of its height away, cutting faces
   out of frame entirely. `contain` guarantees the whole photo is always
   visible (letterboxed on a neutral fill when its aspect ratio doesn't
   match the banner) at the cost of not always filling the full width. */
.tl-bubble-image {
  position: relative;
  margin: -1.6rem -1.9rem 1.1rem;
  height: 210px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  border-radius: 20px 20px 0 0;
  background-color: var(--surface-alt);
}
.tl-bubble-image-credit {
  position: absolute;
  right: 0.6rem;
  bottom: 0.6rem;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  z-index: 1;
  font-size: 0.64rem;
  color: rgba(255, 255, 255, 0.92);
}

.tl-bubble-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--icon-color, var(--brand)) 12%, white);
  color: var(--icon-color, var(--brand));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.9rem;
}
.tl-bubble-icon svg { width: 22px; height: 22px; }

.tl-detail-eyebrow {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.tl-detail-eyebrow-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dot-color, var(--brand)); }
.tl-bubble-title {
  margin: 0 0 1rem;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ink);
}
.tl-bubble-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 2rem;
}
.tl-detail-block-label {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 0.3rem;
}
.tl-detail-block-text { margin: 0; font-size: 0.9rem; line-height: 1.58; color: var(--ink); }
.tl-bubble-citation {
  margin: 1.1rem 0 0;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line-soft);
  font-size: 0.78rem;
  color: var(--faint);
}
.tl-bubble-citation a { color: var(--brand); font-weight: 500; text-decoration: none; }
.tl-bubble-citation a:hover { text-decoration: underline; }

/* ---------- Bubble prev/next (step through events without closing) ---------- */
.tl-bubble-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.1rem;
}
.tl-bubble-citation + .tl-bubble-nav { margin-top: 0.9rem; }
.tl-bubble-nav-btn {
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-soft);
  border: none;
  border-radius: 980px;
  padding: 0.45rem 0.95rem;
  cursor: pointer;
  transition: background 0.15s ease;
}
.tl-bubble-nav-btn:hover:not(:disabled) { background: rgba(0, 94, 162, 0.16); }
.tl-bubble-nav-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.tl-bubble-nav-btn:disabled { opacity: 0.32; cursor: default; }
.tl-bubble-nav-count { font-size: 0.72rem; color: var(--faint); font-weight: 500; flex-shrink: 0; }

@media (max-width: 700px) {
  .tl-bubble-grid { grid-template-columns: 1fr; }
  .tl-bubble { top: 0.6rem; padding: 1.3rem 1.4rem 1.2rem; }
  .tl-event-card { display: none; }
  .tl-eras-row .tl-hint { display: none; }
}
