/* ---------- Progress track (book pages) ---------- */

/* Horizontal-zoomable viewport: .track-zoom's width is set by JS (100%-800%);
   pinch on touch, +/- buttons elsewhere. pan-x pan-y keeps native scrolling
   but hands two-finger pinches to our JS. */
.track-viewport {
  overflow-x: auto;
  touch-action: pan-x pan-y;
  /* leave headroom so chapter tooltips aren't clipped by the scroll container */
  padding-top: 0.25rem;
}

.track-zoom {
  min-width: 100%;
  width: 100%;
}

.track-scale {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
  font-size: 0.65rem;
  color: #a8a29e;
}

.track-lane {
  padding: 0.35rem 0;
}

/* Sticky so the reader's name stays visible while the zoomed track scrolls.
   The header must span the VISIBLE width, not the zoomed content width, so
   long labels wrap on-screen instead of running off. --zoom is set by the
   zoom JS; dividing by it turns "100% of the zoomed track" back into exactly
   one viewport width — which stays correct on resize with no JS involved. */
.lane-header {
  position: sticky;
  left: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.35rem;
  width: calc(100% / var(--zoom, 1));
  margin-bottom: 0.2rem;
}

.lane-name {
  font-weight: 600;
  font-size: 0.8rem;
}

.lane-percent {
  font-size: 0.7rem;
  color: #a8a29e;
}

.lane-chapter {
  font-size: 0.7rem;
  color: #92400e;
}

.lane-road {
  position: relative;
  height: 2.75rem;
  /* fore-edge of a closed book: a stack of thin page edges */
  background: repeating-linear-gradient(
    90deg,
    #fdfaf3 0px,
    #fdfaf3 4px,
    #eee5d0 5px,
    #f7f2e5 6px
  );
  border: 1px solid #ded3ba;
  border-radius: 0.375rem;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.07);
}

/* Once chapter borders exist they carry the "pages" metaphor alone —
   the fine page-edge texture would just be noise underneath them. */
.track-has-chapters .lane-road {
  background: #fdfaf3;
}

.lane-road::after {
  /* the book's back cover: reaching it means you finished */
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 0.7rem;
  border-radius: 0 0.3rem 0.3rem 0;
  background: linear-gradient(180deg, #7f5539, #5e3f2a);
  box-shadow: inset 2px 0 0 rgba(255, 255, 255, 0.15);
}

.lane-fill {
  /* pages already read: warm tint ending in a bookmark line at the current page */
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  background: linear-gradient(90deg, rgba(217, 119, 6, 0.1), rgba(217, 119, 6, 0.28));
  border-right: 2px solid rgba(180, 83, 9, 0.5);
  border-radius: 0.375rem 0 0 0.375rem;
  pointer-events: none;  /* let the band underneath take the hover */
  z-index: 1;
}

/* Lane stacking, bottom to top: bands (0) < fill (1) < milestones (2)
   < runner (4). A hovered band jumps to 20 so its tooltip, which lives in
   the band's own stacking context, escapes over the lane above. */
.chapter-band {
  position: absolute;
  top: 0;
  bottom: 0;
  cursor: help;
  z-index: 0;
}

.chapter-band-alt {
  background: rgba(146, 64, 14, 0.07);
}

.chapter-band:hover {
  background: rgba(146, 64, 14, 0.16);
  z-index: 20;
}

.chapter-band::after {
  /* display (not opacity) so hidden tooltips don't widen the scroll area */
  content: attr(data-title);
  display: none;
  position: absolute;
  bottom: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  background: #1c1917;
  color: #fef3c7;
  font-size: 0.65rem;
  line-height: 1.2;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 30;
}

.chapter-band:hover::after {
  display: block;
}

/* Every 5th chapter gets a numbered line — read "just past 20" without hovering. */
.chapter-milestone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1.5px;
  margin-left: -0.75px;
  background: rgba(146, 64, 14, 0.45);
  pointer-events: none;
  z-index: 2;
}

.milestone-num {
  position: absolute;
  top: 1px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.55rem;
  font-weight: 700;
  color: rgba(146, 64, 14, 0.65);
  background: rgba(253, 250, 243, 0.85);
  padding: 0 3px;
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
}

.goal-marker {
  /* the club's target chapter end: a green finish flag across the lane */
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #16a34a;
  z-index: 3;
}

.goal-marker::before {
  content: "🎯";
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  line-height: 1;
}

.lane-runner {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  transition: left 0.6s ease;
}

.lane-runner img {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 9999px;
  object-fit: cover;
  border: 3px solid #d97706;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  background: #fff;
}

.track-lane-me .lane-runner img {
  border-color: #22c55e;
}

.track-lane-me .lane-name::after {
  content: " (you)";
  font-weight: 400;
  color: #a8a29e;
}

/* ---------- Mobile tab bar ---------- */
/* The bar's dark background extends the whole way down behind the Android
   gesture pill / iPhone home indicator, while this padding keeps the labels
   clear of it. Needs viewport-fit=cover in the viewport meta, or the inset
   resolves to 0 and the strip below shows the page background instead. */
.tabbar {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Content clears the bar, gesture strip included. */
.has-tabbar {
  padding-bottom: calc(7rem + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 640px) {
  .has-tabbar {
    padding-bottom: 2rem;
  }
}

/* ---------- HTMX ---------- */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: block; }

/* ---------- Misc ---------- */
summary::-webkit-details-marker { display: none; }
