/* Public /gallery/ladder page (templates/ladder.html, static/js/ladder.js).
   Loaded after gallery.css, which has the theme tokens, the header and
   .header-btn. Positions and sizes of everything inside #ladderTrack are set
   by ladder.js; this is the look. */
#ladderIntro, .ladder-tools, #ladderNote, #ladderCredit, #ladderEmpty { max-width: 1400px; margin-left: auto; margin-right: auto; }
#ladderIntro { margin-top: 0; margin-bottom: 10px; font-size: 14px; }
#ladderNote, #ladderCredit, #ladderEmpty { font-size: 12px; margin-top: 10px; }
.ladder-tools { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ladder-tools .header-btn { min-width: 34px; }
#ladderCount { font-size: 13px; }
a.header-btn { text-decoration: none; display: inline-block; }

#ladderScroller {
  max-width: 1400px; margin: 0 auto; overflow-x: auto; overflow-y: hidden; position: relative;
  border: 1px solid var(--panel-border); border-radius: 10px; background: var(--panel-bg);
  overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
}
#ladderTrack { position: relative; }

/* The top box: the section names and the method bars on one shaded block from
   Earth to the edge (ladder.js sizes it to its rows; just the section row
   while the methods are off). */
.ladder-topbox {
  position: absolute; box-sizing: border-box; background: var(--chip-bg); border: 1px solid var(--panel-border);
  border-top: 0; border-radius: 0 0 8px 8px;
}

/* Section boundaries: a vertical line each, full height; in the box it
   reads against the shade, so it is the muted text colour, softened. */
.ladder-line { position: absolute; top: 0; width: 1px; background: var(--muted-fg); opacity: 0.3; }
.ladder-section {
  position: absolute; margin: 0; padding: 1px 6px; border: 0; border-radius: 4px; background: transparent;
  color: var(--muted-fg); font: inherit; font-size: 12px; line-height: 16px; cursor: pointer; white-space: nowrap;
}
/* The pictogram: a big, faint picture behind the name's first letters
   (static/img/scale/, credits in CREDITS.md). Most have a version per colour
   scheme (<id>-light.webp: deep colours on nothing; <id>-dark.webp: bright
   on a dim disc); the pictures are the project owner's own photos, tools/
   build_scale_pictograms.py makes them. One section has a line icon (a mask
   in the text colour), another a single NASA picture. */
/* The backdrop of the section row: one faint picture per section, a frame of
   "Location of Earth" (static/img/scale/, credits in CREDITS.md and under the
   page; tools/build_scale_tiles.py cuts them). The pictures are on black:
   dark mode shows them as they are, light mode inverts them (hues kept) and
   multiplies them onto the shade, so the black becomes the shade itself. */
.ladder-tiles { position: absolute; overflow: hidden; border-radius: 0 0 8px 8px; pointer-events: none; }
.ladder-tile { position: absolute; top: 0; bottom: 0; background: var(--tile) center / cover no-repeat; opacity: 0.55; filter: invert(1) hue-rotate(180deg); mix-blend-mode: multiply; }
@media (prefers-color-scheme: dark) { .ladder-tile { opacity: 0.5; filter: none; mix-blend-mode: normal; } }
.ladder-tile-solarSystem { --tile: url(/static/img/scale/solarSystem.webp); }
.ladder-tile-solarNeighbourhood { --tile: url(/static/img/scale/solarNeighbourhood.webp); }
.ladder-tile-galactic { --tile: url(/static/img/scale/galactic.webp); }
.ladder-tile-galacticNeighbourhood { --tile: url(/static/img/scale/galacticNeighbourhood.webp); }
.ladder-tile-localGroup { --tile: url(/static/img/scale/localGroup.webp); }
.ladder-tile-galaxyGroup { --tile: url(/static/img/scale/galaxyGroup.webp); }
.ladder-tile-supercluster { --tile: url(/static/img/scale/supercluster.webp); }
.ladder-tile-largeScaleStructure { --tile: url(/static/img/scale/largeScaleStructure.webp); }
.ladder-tile-cosmological { --tile: url(/static/img/scale/cosmological.webp); }

.ladder-section { line-height: 26px; text-shadow: 0 0 3px var(--chip-bg), 0 0 6px var(--chip-bg); }
.ladder-section:hover { color: var(--fg); background: var(--panel-bg); }

.ladder-axis { position: absolute; height: 2px; background: var(--muted-fg); border-radius: 1px; }
.ladder-earth { position: absolute; text-align: right; font-size: 12px; line-height: 18px; color: var(--fg); font-weight: 600; }

.ladder-landmark-line { position: absolute; width: 0; border-left: 1px dotted var(--muted-fg); opacity: 0.55; }
.ladder-landmark { position: absolute; font-size: 11px; line-height: 16px; color: var(--muted-fg); white-space: nowrap; }

/* The rulers sit on the axis: distance above it, redshift below. A label
   has the panel background and a z-index above the landmark lines and stems,
   so a line passing behind it is interrupted instead of struck through. */
.ladder-rule-tick { position: absolute; z-index: 1; width: 1px; background: var(--muted-fg); opacity: 0.7; }
.ladder-rule-label {
  position: absolute; z-index: 1; padding: 0 2px; background: var(--panel-bg);
  font-size: 11px; line-height: 14px; color: var(--muted-fg); white-space: nowrap;
}
.ladder-rule-name { position: absolute; text-align: right; font-size: 11px; line-height: 14px; color: var(--muted-fg); font-weight: 600; }
/* The redshift ruler in the link colour, so the two read as separate scales. */
.ladder-rule-z.ladder-rule-tick { background: var(--link); }
.ladder-rule-z.ladder-rule-label, .ladder-rule-z.ladder-rule-name { color: var(--link); }

.ladder-method {
  position: absolute; z-index: 1; margin: 0; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border: 1px solid var(--panel-border); border-radius: 5px; background: var(--panel-bg); color: var(--chip-fg);
  font: inherit; font-size: 12px; line-height: 20px; text-align: left; cursor: pointer;
}
.ladder-method:hover { border-color: var(--link); }
.ladder-method.active { background: var(--link); border-color: var(--link); color: #fff; }
.ladder-method-name { position: absolute; text-align: right; font-size: 12px; line-height: 20px; color: var(--muted-fg); font-weight: 600; }
/* The picked method's range, behind the images; the images outside it fade. */
.ladder-range { position: absolute; z-index: 0; background: var(--link); opacity: 0.12; pointer-events: none; }
.ladder-dim { opacity: 0.3; }

#ladderMethodPanel {
  max-width: 1400px; margin: 10px auto 0; padding: 12px 16px; position: relative;
  border: 1px solid var(--panel-border); border-radius: 10px; background: var(--panel-bg); font-size: 14px; line-height: 1.5;
}
#ladderMethodPanel h2 { margin: 0 70px 6px 0; font-size: 17px; font-weight: 600; }
#ladderMethodPanel p { margin: 6px 0; }
#ladderMethodPanel p:last-child { margin-bottom: 0; }
#ladderMethodPanel a { word-break: break-word; }
.ladder-method-close { position: absolute; top: 10px; right: 12px; }

.ladder-stem { position: absolute; width: 1px; background: var(--muted-fg); opacity: 0.6; }
.ladder-item {
  position: absolute; z-index: 2; display: block; overflow: hidden; border-radius: 6px;
  border: 1px solid var(--panel-border); background: var(--chip-bg);
}
.ladder-item img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ladder-item:hover, .ladder-item:focus-visible { z-index: 3; outline: 2px solid var(--link); outline-offset: 1px; }

/* Arriving from an image's "Show on distance ladder" link: one pulse. The
   JS removes the class after HIGHLIGHT_MS (ladder.js). */
.ladder-item.highlight { z-index: 3; outline: 3px solid #fbbf24; outline-offset: 2px; animation: ladder-pulse 1.3s ease-out 2; }
@keyframes ladder-pulse {
  0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.85); }
  100% { box-shadow: 0 0 0 22px rgba(251, 191, 36, 0); }
}
@media (prefers-reduced-motion: reduce) { .ladder-item.highlight { animation: none; } }

#ladderCard {
  position: fixed; z-index: 10; max-width: 260px; padding: 8px 10px; border-radius: 8px; pointer-events: none;
  background: var(--panel-bg); color: var(--fg); border: 1px solid var(--panel-border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); font-size: 13px; line-height: 1.35;
}
#ladderCard strong { display: block; }
#ladderCard span { color: var(--muted-fg); font-size: 12px; }

@media (max-width: 600px) {
  #ladderIntro { font-size: 13px; }
}
