/* Trip day scrolly — NYT-style pinned map driven by scroll.
   Usage: <div class="trip-scrolly" data-day="20"></div> + trip-scrolly.js */

.trip-scrolly {
  position: relative;
  margin: 26px 0;
}

.ts-stage {
  display: flex;
  align-items: center;
  justify-content: center;
}

.ts-frame {
  position: relative;
  width: min(100%, 540px);
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--parchment-edge, #d0c8b5);
  box-shadow: 0 2px 10px rgba(60, 40, 20, 0.12);
  background: #f5f3ef;
}

.ts-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.ts-wide { z-index: 2; transition: opacity 0.1s linear; }

.ts-wide-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  transition: opacity 0.1s linear;
}

.ts-frame.wide-mode .ts-pill,
.ts-frame.wide-mode .ts-stop-label { opacity: 0 !important; }

.ts-here-pulse { animation: ts-pulse 2s ease-out infinite; transform-origin: center; transform-box: fill-box; }

@keyframes ts-pulse {
  0%   { transform: scale(1);   opacity: 0.9; }
  70%  { transform: scale(2.1); opacity: 0; }
  100% { transform: scale(2.1); opacity: 0; }
}

.ts-frame svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  transition: opacity 0.25s linear;
}

.ts-frame.wide-mode svg:not(.ts-wide-svg) { opacity: 0; }

.ts-frame .ts-wide-svg { z-index: 2; }

/* stat chip — mirrors the GIF */
.ts-chip {
  position: absolute;
  top: 3%;
  right: 3%;
  z-index: 4;
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  min-width: 168px;
}

.ts-chip .h {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #4a7a4e;
  margin-bottom: 6px;
}

.ts-chip .vals { display: flex; gap: 18px; }
.ts-chip .vals b { display: block; font-size: 1.05rem; color: #8B6914; font-variant-numeric: tabular-nums; }
.ts-chip .vals span { display: block; font-size: 0.62rem; color: #666; }
.ts-chip .tail { margin-top: 6px; font-size: 0.62rem; color: #666; }

/* place pills */
.ts-pill {
  position: absolute;
  z-index: 4;
  transform: translate(14px, -50%);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  padding: 5px 13px;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 2px 6px rgba(60, 45, 30, 0.15);
  white-space: nowrap;
}

.ts-pill b { display: block; font-size: 0.8rem; color: #3c4043; }
.ts-pill.emph b { color: #1a1a2e; }
.ts-pill span { display: block; font-size: 0.62rem; color: #8a8578; }
.ts-pill.hidden { opacity: 0; }
.ts-pill { transition: opacity 0.25s ease; }

/* stop labels pop in as the rig passes */
.ts-stop-label {
  position: absolute;
  z-index: 4;
  transform: translate(12px, -50%);
  background: rgba(255, 255, 255, 0.88);
  border-radius: 999px;
  padding: 2px 9px;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 0.62rem;
  color: #5f6368;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.ts-stop-label.on { opacity: 1; }
.ts-stop-label.below { transform: translate(-50%, 24px); }
.ts-stop-label b { color: #3c4043; }

.ts-replay {
  position: absolute;
  bottom: 4%;
  left: 3%;
  z-index: 4;
  font-family: -apple-system, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 1px;
  color: #3c4043;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.12);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.ts-replay.show { opacity: 1; pointer-events: auto; }
.ts-replay:hover { background: #fff; }


/* --- Top-of-post float: the drive map as a crisp modern instrument,
   deliberately contrasting the warm tilted Snapshot postcard. --- */
.trip-scrolly.ts-float {
  float: left;
  width: 340px;
  margin: 6px 28px 16px 0;
}

.ts-float .ts-stage { display: block; }

.ts-float .ts-instrument {
  background: #fff;
  border: 1px solid #b9b3a4;
  border-radius: 8px;
  padding: 8px;
  transform: rotate(-2deg);
  box-shadow: 2px 4px 12px rgba(0, 0, 0, 0.15);
}

.ts-float .ts-frame {
  width: 100%;
  border-radius: 5px;
  border: none;
  box-shadow: none;
}

.ts-float .ts-caption {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: #6b6558;
  text-align: center;
  padding: 7px 2px 2px;
}

.ts-float .ts-chip { transform: scale(0.62); transform-origin: top right; min-width: 150px; }
.ts-float .ts-pill { transform: translate(9px, -50%) scale(0.62); transform-origin: left center; }
.ts-float .ts-stop-label { transform: translate(8px, -50%) scale(0.62); transform-origin: left center; }
.ts-float .ts-stop-label.below { transform: translate(-50%, 16px) scale(0.62); }
.ts-float .ts-replay { transform: scale(0.78); transform-origin: bottom left; }

@media (max-width: 640px) {
  .trip-scrolly.ts-float {
    float: none;
    width: min(100%, 380px);
    margin: 14px auto 18px;
  }
}
