:root {
  --bg: #05060f;
  --text: #e8ecff;
  --muted: #9aa3c7;
  --accent: #7dd3fc;
  --accent-2: #c4b5fd;
  --glow: rgba(125, 211, 252, 0.35);
  --panel: rgba(8, 10, 24, 0.72);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Outfit", system-ui, sans-serif;
  overflow: hidden;
}

.hsm-page {
  position: relative;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#timeline-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  background: var(--bg);
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  padding: 1.1rem 1.5rem;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(5, 6, 15, 0.55), rgba(5, 6, 15, 0));
}
.topbar .brand {
  pointer-events: auto;
  font-family: "Orbitron", sans-serif;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-decoration: none;
  color: var(--text);
  text-shadow: 0 1px 2px rgba(5, 6, 15, 0.9), 0 0 12px rgba(5, 6, 15, 0.75), 0 0 20px var(--glow);
}
.topbar .brand:hover { color: var(--accent); }
.topbar .page-title {
  position: absolute;
  left: 50%;
  top: 0.85rem;
  transform: translateX(-50%);
  margin: 0;
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
  color: var(--text);
  text-shadow: 0 1px 2px rgba(5, 6, 15, 0.9), 0 0 14px rgba(5, 6, 15, 0.75), 0 0 24px var(--glow);
}

/* Museum placard */
.placard {
  position: fixed;
  z-index: 4;
  left: 1.25rem;
  right: 1.25rem;
  top: 4.25rem;
  max-width: 28rem;
  padding: 1.15rem 1.25rem 1.25rem;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid rgba(232, 236, 255, 0.12);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.45s ease;
}

.placard-chapter {
  font-family: "Orbitron", sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.45rem;
}

.placard-time {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 300;
  margin-bottom: 0.55rem;
  line-height: 1.4;
}

.placard-title {
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  font-size: clamp(1.15rem, 3.2vw, 1.55rem);
  letter-spacing: 0.03em;
  line-height: 1.2;
  text-shadow: 0 0 24px var(--glow);
  margin-bottom: 0.7rem;
}

.placard-body {
  font-size: clamp(0.88rem, 2.1vw, 0.98rem);
  font-weight: 300;
  line-height: 1.55;
  color: rgba(232, 236, 255, 0.88);
}

/* Scrubber */
.scrubber {
  position: fixed;
  z-index: 5;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem calc(0.9rem + var(--safe-bottom));
  background: linear-gradient(180deg, transparent, rgba(5, 6, 15, 0.85) 35%, rgba(5, 6, 15, 0.95));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.transport {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
}
.nav-btn,
.play-btn {
  flex: 0 0 auto;
  font-family: "Outfit", system-ui, sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(232, 236, 255, 0.28);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.nav-btn:hover,
.play-btn:hover,
.play-btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: rgba(125, 211, 252, 0.12);
  box-shadow: 0 0 18px rgba(125, 211, 252, 0.25);
}
.nav-btn:active,
.play-btn:active {
  transform: translateY(1px);
}

.scrub-wrap {
  flex: 1;
  position: relative;
  padding-top: 1.35rem;
}

.scrub-eras {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1.1rem;
  pointer-events: none;
}
.era {
  position: absolute;
  transform: translateX(-50%);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(154, 163, 199, 0.7);
  white-space: nowrap;
  max-width: 6.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scrub-track {
  position: relative;
  height: 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(232, 236, 255, 0.14);
  cursor: grab;
  touch-action: none;
  outline: none;
}
.scrub-track:active { cursor: grabbing; }
.scrub-track:focus-visible {
  box-shadow: 0 0 0 2px rgba(125, 211, 252, 0.55);
}

.scrub-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.35), rgba(129, 140, 248, 0.55));
  pointer-events: none;
}

.scrub-ticks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.tick {
  position: absolute;
  top: 6px;
  bottom: 6px;
  width: 2px;
  transform: translateX(-50%);
  background: rgba(232, 236, 255, 0.45);
  border-radius: 1px;
}

.scrub-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.55);
  pointer-events: none;
  border: 2px solid rgba(255, 255, 255, 0.85);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .topbar { padding: 0.9rem 0.85rem 0.4rem; }
  .topbar .brand { font-size: 0.78rem; }
  .topbar .page-title {
    position: static;
    transform: none;
    margin-top: 0.4rem;
    font-size: 1.05rem;
  }
  .placard {
    top: 5.1rem;
    left: 0.75rem;
    right: 0.75rem;
    padding: 0.95rem 1rem 1.05rem;
    max-width: none;
  }
  .era { font-size: 0.48rem; max-width: 3.2rem; letter-spacing: 0.01em; }
  /* Drop even-indexed era labels on narrow screens to reduce overlap */
  .era:nth-child(even) { display: none; }
  /* Thin checkpoint ticks — every other mark — so ~46 ticks stay readable */
  .tick:nth-child(even) { opacity: 0.25; height: 0.35rem; }
  .scrubber { gap: 0.5rem; padding-left: 0.65rem; padding-right: 0.65rem; }
  .nav-btn, .play-btn { padding: 0.5rem 0.7rem; font-size: 0.78rem; }
  .transport { gap: 0.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  .placard { transition: none; }
}

@media (min-width: 641px) and (max-width: 940px) {
  .topbar .page-title {
    position: static;
    transform: none;
    margin-top: 0.45rem;
    font-size: 1.15rem;
  }
  .placard { top: 5.4rem; }
}
