/* =========================================================
   TIME-AND-SPACE — Timeline Styles
   Extends globe.css tokens. Load AFTER globe.css.
   ========================================================= */

.timeline-section {
  position: relative;
  width: 100%;
  background: #04060a;
  padding: 80px 0 120px;
  margin-top: 100vh;
  overflow: hidden;
}

/* ---- Sticky bar: header + era-nav + filters ---- */
.timeline-sticky-bar {
  position: sticky;
  top: 0;
  z-index: 15;
  background: var(--panel-bg);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid rgba(200, 169, 110, 0.25);
}

.timeline-header {
  padding: 22px 30px 14px;
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}

.timeline-controls {
  padding: 0 30px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ---- Era-jump nav ---- */
.timeline-era-nav {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.timeline-era-nav::-webkit-scrollbar {
  display: none;
}

.timeline-era-nav-btn {
  flex: 0 0 auto;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(200, 169, 110, 0.2);
  border-radius: 20px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.timeline-era-nav-btn:hover,
.timeline-era-nav-btn:focus-visible {
  color: var(--text-main);
  border-color: var(--era-nav-color, var(--gold));
  outline: none;
}

.timeline-era-nav-btn.is-current {
  color: var(--text-main);
  background: rgba(200, 169, 110, 0.12);
  border-color: var(--era-nav-color, var(--gold));
}

/* ---- Type / country filters ---- */
.timeline-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.timeline-filter-types {
  display: flex;
  gap: 6px;
}

.timeline-filter-chip {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid rgba(240, 234, 216, 0.2);
  border-radius: 20px;
  padding: 5px 10px;
  cursor: pointer;
  opacity: 0.5;
  transition: color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.timeline-filter-chip.is-active {
  opacity: 1;
}

.timeline-filter-chip[data-type="literature"].is-active {
  color: var(--gold);
  border-color: var(--gold);
}

.timeline-filter-chip[data-type="history"].is-active {
  color: var(--neon-blue);
  border-color: var(--neon-blue);
}

.timeline-filter-chip[data-type="conflict"].is-active {
  color: var(--neon-pink);
  border-color: var(--neon-pink);
}

.timeline-filter-chip[data-type="music"].is-active {
  color: var(--neon-purple);
  border-color: var(--neon-purple);
}

.timeline-filter-chip[data-type="vision"].is-active {
  color: var(--vision-green);
  border-color: var(--vision-green);
}

.timeline-filter-country {
  font-size: 11px;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(200, 169, 110, 0.25);
  border-radius: 20px;
  padding: 5px 10px;
  cursor: pointer;
}

/* ---- Minimap / scrubber ---- */
.timeline-minimap {
  position: relative;
  height: 22px;
  margin: 14px 30px 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  overflow: hidden;
}

.timeline-minimap-era {
  position: absolute;
  top: 0;
  height: 100%;
  opacity: 0.35;
}

.timeline-minimap-viewport {
  position: absolute;
  top: 0;
  height: 100%;
  min-width: 24px;
  background: rgba(240, 234, 216, 0.18);
  border: 1px solid rgba(200, 169, 110, 0.6);
  border-radius: 6px;
  cursor: grab;
  touch-action: none;
}

.timeline-minimap-viewport:active {
  cursor: grabbing;
}

.timeline-header-era {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  transition: color 0.3s ease;
}

.timeline-header-year {
  font-size: 22px;
  color: var(--text-main);
  font-weight: 600;
}

.timeline-header-hint {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

/* ---- Scroll track ---- */
.timeline-track-wrapper {
  position: relative;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 60px 0 40px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.timeline-track-wrapper::-webkit-scrollbar {
  height: 8px;
}
.timeline-track-wrapper::-webkit-scrollbar-thumb {
  background: rgba(200, 169, 110, 0.35);
  border-radius: 8px;
}
.timeline-track-wrapper::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
}

.timeline-track {
  position: relative;
  height: 220px;
  min-width: 100%;
}

/* Era bands sit behind the track as colored strata */
.timeline-era-band {
  position: absolute;
  top: 96px;
  height: 6px;
  border-radius: 3px;
  opacity: 0.55;
}

/* Era label — sits above the spine/entry points, near the top of the
   track, underlined in the era's own color so it reads as a header
   for that stretch of track rather than a caption on the band. */
.timeline-era-label {
  position: absolute;
  top: -30px;
  font-size: 20px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  padding-bottom: 10px;
  border-bottom: 4px solid transparent; /* color set inline per era */
}

/* Main horizontal line */
.timeline-spine {
  position: absolute;
  top: 99px;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(240, 234, 216, 0.18);
}

/* ---- Entry markers ---- */
.timeline-entry {
  position: absolute;
  top: 84px;
  transform: translateX(-50%);
  cursor: pointer;
}

.timeline-entry-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid #04060a;
  box-shadow: 0 0 0 0 rgba(200, 169, 110, 0);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.timeline-entry[data-type="conflict"] .timeline-entry-dot { background: var(--neon-pink); }
.timeline-entry[data-type="history"] .timeline-entry-dot { background: var(--neon-blue); }
.timeline-entry[data-type="literature"] .timeline-entry-dot { background: var(--gold); }
.timeline-entry[data-type="music"] .timeline-entry-dot { background: var(--neon-purple); }
.timeline-entry[data-type="vision"] .timeline-entry-dot { background: var(--vision-green); }

.timeline-entry:hover .timeline-entry-dot {
  transform: scale(1.4);
  box-shadow: 0 0 16px 4px currentColor;
}

/* Selected marker: a yellow highlight distinct from every type-color dot,
   so the chosen point is unmistakable at a glance instead of just glowing
   in its own (sometimes hard-to-spot) category color. */
.timeline-entry.is-active .timeline-entry-dot {
  transform: scale(1.5);
  background: #faff00;
  border-color: #faff00;
  box-shadow: 0 0 18px 6px rgba(250, 255, 0, 0.75), 0 0 0 3px rgba(250, 255, 0, 0.35);
}

.timeline-entry-year {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

.timeline-entry.is-active .timeline-entry-year {
  color: #faff00;
  font-weight: 700;
}

/* Glyph lane — sits above the main entries, own offset row */
.timeline-glyph {
  position: absolute;
  top: 40px;
  transform: translateX(-50%);
  font-size: 18px;
  color: var(--gold);
  cursor: pointer;
}

.timeline-glyph-stem {
  position: absolute;
  top: 58px;
  left: 50%;
  width: 1px;
  height: 26px;
  background: rgba(200, 169, 110, 0.4);
  transform: translateX(-50%);
}

/* ---- Cluster markers (2+ entries within CLUSTER_GAP_PX) ---- */
.timeline-cluster {
  position: absolute;
  top: 84px;
  transform: translateX(-50%);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.timeline-cluster-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--gold);
  color: #04060a;
  font-size: 11px;
  font-weight: 700;
  border: 2px solid #04060a;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.timeline-cluster:hover .timeline-cluster-badge {
  transform: scale(1.15);
  box-shadow: 0 0 16px 4px rgba(200, 169, 110, 0.5);
}

/* Selected cluster: same yellow highlight as a selected single entry. */
.timeline-cluster.is-active .timeline-cluster-badge {
  transform: scale(1.2);
  background: #faff00;
  border-color: #faff00;
  box-shadow: 0 0 18px 6px rgba(250, 255, 0, 0.75), 0 0 0 3px rgba(250, 255, 0, 0.35);
}

/* Cluster list — renders inside the same detail panel as a single entry */
.timeline-cluster-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
}

.timeline-cluster-list-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 4px;
  border-bottom: 1px solid rgba(240, 234, 216, 0.08);
  cursor: pointer;
  transition: background 0.2s ease;
}

.timeline-cluster-list-item:last-child {
  border-bottom: none;
}

.timeline-cluster-list-item:hover,
.timeline-cluster-list-item:focus-visible {
  background: rgba(200, 169, 110, 0.08);
  outline: none;
}

.timeline-cluster-list-year {
  font-size: 10px;
  color: var(--gold);
  letter-spacing: 0.06em;
}

.timeline-cluster-list-title {
  font-size: 13px;
  color: var(--text-main);
}

.timeline-cluster-list-author {
  font-size: 11px;
  color: var(--text-muted);
}

/* ---- Filtered-out state (type/country filters) ----
   Dims rather than removes — positions stay stable so the minimap and
   track width never need to recompute when a filter changes. */
.timeline-entry.is-filtered-out,
.timeline-cluster.is-filtered-out {
  opacity: 0.15;
  pointer-events: none;
}

/* ---- Detail panel (click-to-open) ---- */
.timeline-detail-panel {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 25;
  max-width: 360px;
  /* Anchored to the bottom, so unbounded growth pushes the top of a
     long card above the viewport with no way to scroll back to it —
     cap the height and scroll internally instead, on every screen
     size, not just the <768px case below. */
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 26px;
  background: var(--panel-bg);
  border-radius: 16px;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid rgba(200, 169, 110, 0.3);
  box-shadow: 0 0 40px rgba(200, 169, 110, 0.12);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.timeline-detail-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.timeline-detail-content {
  padding-right: 22px;
}

/* Close button — always pinned top-right regardless of content length,
   so the panel can never trap the user with no way out on mobile. */
.timeline-detail-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.timeline-detail-close:hover,
.timeline-detail-close:focus-visible {
  background: rgba(200, 169, 110, 0.22);
  color: var(--text-main);
  outline: none;
}

/* Second close button, appended after the body text on long/fact-dense
   entries only (see isLongEntry in timeline.js). The fixed-position panel
   grows with content, so on a long card the top-right close button can
   scroll off the top of the viewport — this gives the reader a way out
   without hunting for it. */
.timeline-detail-close-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: 18px 0 0 auto;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.timeline-detail-close-bottom:hover,
.timeline-detail-close-bottom:focus-visible {
  background: rgba(200, 169, 110, 0.22);
  color: var(--text-main);
  outline: none;
}

.timeline-detail-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 8px;
}

.timeline-detail-region-link {
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: color 0.2s ease, text-decoration 0.2s ease;
}

.timeline-detail-region-link:hover,
.timeline-detail-region-link:focus-visible {
  color: var(--text-main);
  text-decoration: underline;
}

.timeline-detail-title {
  font-size: 18px;
  color: var(--text-main);
  margin: 0 0 4px;
  font-family: 'Georgia', serif;
}

.timeline-detail-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.timeline-detail-body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0;
}

/* Inline "fly the globe here" links inside entry.descriptionHtml — only
   the MÚSICA entries use these, one per place named in the body text. */
.timeline-detail-geolink {
  display: inline;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--neon-purple);
  text-decoration: underline dotted;
  text-underline-offset: 2px;
  cursor: pointer;
}

.timeline-detail-geolink:hover,
.timeline-detail-geolink:focus-visible {
  color: var(--text-main);
  text-decoration: underline solid;
  outline: none;
}

/* Inline "jump to that other entry" links inside entry.descriptionHtml —
   e.g. Shakira's body text naming Bad Bunny. Gold instead of the geolink
   purple to read as a distinct link type: this one changes which entry
   the detail panel shows, not where the globe points. */
.timeline-detail-entrylink {
  display: inline;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--gold);
  text-decoration: underline dotted;
  text-underline-offset: 2px;
  cursor: pointer;
}

.timeline-detail-entrylink:hover,
.timeline-detail-entrylink:focus-visible {
  color: var(--gold-light);
  text-decoration: underline solid;
  outline: none;
}

.timeline-detail-flag {
  display: inline-block;
  margin-top: 10px;
  margin-right: 6px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--neon-pink);
  border: 1px solid rgba(255, 47, 176, 0.4);
  border-radius: 6px;
  padding: 3px 8px;
}

.timeline-detail-flag-latam {
  color: var(--neon-green);
  border-color: rgba(57, 255, 106, 0.4);
}

.timeline-detail-flag-africa {
  color: var(--neon-purple);
  border-color: rgba(166, 77, 255, 0.4);
}

.timeline-detail-flag-spain {
  color: var(--neon-pink);
  border-color: rgba(255, 47, 176, 0.4);
}

.timeline-detail-flag-other {
  color: #ff3b3b;
  border-color: rgba(255, 59, 59, 0.4);
}

.timeline-detail-flag-us {
  color: var(--neon-blue);
  border-color: rgba(77, 166, 255, 0.4);
}

.timeline-detail-flag-navegando {
  color: var(--neon-purple);
  border-color: rgba(166, 77, 255, 0.4);
}

/* Personal note — distinct register from the curatorial description */
.timeline-detail-personal {
  margin-top: 14px;
  padding: 12px 14px;
  border-left: 2px solid var(--gold);
  border-radius: 0;
  background: rgba(200, 169, 110, 0.06);
}

.timeline-detail-personal-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 6px;
}

.timeline-detail-personal-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-main);
  margin: 0;
  font-style: italic;
}

.timeline-detail-personal-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  color: var(--neon-blue);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.timeline-detail-personal-link:hover {
  text-decoration: underline;
}

/* ---- Butterfly Effect panel ---- */
.timeline-butterfly {
  margin: 50px auto 0;
  max-width: 640px;
  padding: 28px 30px;
  background: var(--panel-bg);
  border: 1px solid rgba(200, 169, 110, 0.3);
  border-radius: 16px;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  transition: opacity 0.25s ease;
}

/* Hidden by the detail panel's close button; reappears automatically
   the next time an entry is selected or the track is scrolled. */
.timeline-butterfly.is-hidden {
  display: none;
}

.timeline-butterfly-eyebrow {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--neon-green);
  margin: 0 0 10px;
}

.timeline-butterfly-prompt {
  font-size: 16px;
  color: var(--text-main);
  margin: 0 0 14px;
  font-style: italic;
}

.timeline-butterfly-answer {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-muted);
  margin: 0;
}

/* ---- Keyboard focus visibility (accessibility floor) ---- */
.timeline-entry:focus-visible .timeline-entry-dot,
.timeline-cluster:focus-visible .timeline-cluster-badge,
.timeline-glyph:focus-visible {
  outline: 2px solid var(--neon-blue);
  outline-offset: 4px;
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .timeline-track-wrapper { scroll-behavior: auto; }
  .timeline-entry-dot,
  .timeline-detail-panel {
    transition: none;
  }
}

/* ---- Mobile ---- */
@media (max-width: 768px) {
  .timeline-header {
    padding: 16px 18px 10px;
  }
  .timeline-header-year {
    font-size: 18px;
  }
  .timeline-controls {
    padding: 0 18px 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .timeline-filters {
    justify-content: space-between;
  }
  .timeline-minimap {
    margin: 10px 18px 0;
  }
  .timeline-detail-panel {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
    max-height: 65vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .timeline-butterfly {
    margin: 30px 16px 0;
    padding: 22px 20px;
  }
}