/*
 * bands.css — the geared band stack, drawn over the map (§4.2, §4.3).
 *
 * One rule this sheet lives by: it never styles a property bands.js writes
 * per frame. Band top and height, card width (`--cw`) and every transform
 * belong to the loop, and a transition arguing with a rAF over one
 * property is what made the old view glitch. Colour and opacity swaps the
 * loop never writes are still transitions here, because they are not
 * geometry.
 *
 * The stack covers the map rather than replacing it: the map is
 * underneath the whole time, dimmed behind an arrived card, and §4.3
 * lifts the bands off to show it.
 */

/* ---------- the map, behind ---------- */

/* The map fades out behind a card that has arrived, and snaps back the
   instant a hold asks for it. Only one direction is a transition, which is
   why this is two states of one class rather than a spring. */
body.vp-map-dim #vp-map { opacity: 0; transition: opacity 200ms linear; }

/* ---------- the field ---------- */

#vp-bands {
  inset: 0;
  z-index: 4;
  overflow: hidden;
  background: transparent;
  font-family: var(--font-mono, 'IBM Plex Mono', 'SF Mono', Menlo, Consolas, monospace);
  -webkit-user-select: none;
  user-select: none;
  /* Sideways is a card, up and down is a level, holding is the map, two
     fingers is out. None of them is a scroll. */
  touch-action: none;
}

#vp-bands .vp-stack {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* ---------- the bands ---------- */

#vp-bands .vp-band {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--vp-canvas);
  border-top: 1px solid rgba(233, 237, 242, 0.14);
  border-bottom: 1px solid rgba(233, 237, 242, 0.14);
  will-change: transform, opacity;
}

#vp-bands .vp-strip {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* The reader's line is the LEFT edge, not the middle: the current card
   sits flush left and what is coming stands in line to the right of it.
   The row's origin is therefore the band's left edge. */
#vp-bands .vp-row {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0;
  transition: opacity 200ms linear;
  /* Scaled from its top-left corner while the band morphs (bands.js): the
     cards keep their rest size and are composited, not repainted. */
  transform-origin: 0 0;
  will-change: transform;
}

/* Cards are ALWAYS square: the width is the strip's height, handed down
   per frame as --cw. No radius, no per-level width anywhere. */
#vp-bands .vp-card {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: var(--cw, 200px);
  border-left: 1px solid rgba(233, 237, 242, 0.1);
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
  will-change: transform;
  transition: box-shadow 140ms linear;
}

#vp-bands .vp-card-cover {
  position: absolute;
  inset: 0;
  display: block;
}

#vp-bands .vp-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* A cover already says what the tile is — it is the tile's own drawing of
   itself. So the caption is a FALLBACK: it appears on a card with no cover
   to show, and on one whose cover has not arrived yet, where the
   alternative is a blank square. The cover fades in over it. */
#vp-bands .vp-card-name { display: none; }
#vp-bands .vp-card-cover img { opacity: 0; transition: opacity 160ms ease; }
#vp-bands .vp-card.is-ready .vp-card-cover img { opacity: 1; }

#vp-bands .vp-card:not(.is-ready) .vp-card-name,
#vp-bands .vp-card.no-cover .vp-card-name {
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 6px 10px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  color: rgba(233, 237, 242, 0.7);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A document's card: as wide as the band, and empty — the document itself
   is the one iframe laid over it (below). */
#vp-bands .vp-card.is-doc { width: 100%; background: #fff; }
#vp-bands .vp-card.is-doc .vp-card-name { display: none; }

/* The document: one sandboxed frame, positioned by the loop over whichever
   card is the doc's, in the band below or in focus or on the whole screen. */
#vp-bands .vp-docband {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 5;
  background: #fff;
  overflow: hidden;
}
#vp-bands .vp-docband .vp-doc-frame { display: block; width: 100%; height: 100%; border: 0; }
/* Below the focus or at two thirds the document is looked at, not used:
   the finger goes through it to the stack. On the whole screen it is the
   page's own. */
#vp-bands .vp-docband { pointer-events: none; }
#vp-bands .vp-docband.is-full { pointer-events: auto; }

/* The card under the reader's line: a hairline ring, inset. */
#vp-bands .vp-card[data-here] { box-shadow: 0 0 0 1px #da291c inset; }

/* A preview is the tile below's own picture, dimmer, as on the map. */
#vp-bands .vp-card[data-preview] { opacity: 0.82; }

/* A layer the map does not have: empty space, keeping its share of the
   field so the focus slot stays put. */
#vp-bands .vp-band.is-void { background: transparent; border-color: transparent; }

/* While a tile is flying in, the focus band is an empty frame: the card it
   will hold has not arrived yet, and drawing it twice is what a cross-fade
   is for. */
#vp-bands .vp-band.window { background: transparent; }
#vp-bands .vp-band.window .vp-row { opacity: 0; }

/* ---------- travel ---------- */

/* The aim preview: while the hold has the map out, the candidate under the
   crosshair stands in this card — its own cover and name, big enough to
   read over the zoomed-out map. */
#vp-bands .vp-aim {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  width: 148px;
  background: var(--vp-canvas);
  border: 1px solid rgba(233, 237, 242, 0.35);
  pointer-events: none;
  display: none;
}

#vp-bands .vp-aim.on { display: block; }

#vp-bands .vp-aim img {
  width: 100%;
  height: 148px;
  object-fit: cover;
  display: block;
}

#vp-bands .vp-aim img[hidden] { display: none; }

#vp-bands .vp-aim .vp-aim-name {
  display: block;
  padding: 6px 10px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  text-align: center;
  color: #e9edf2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- no motion ---------- */

@media (prefers-reduced-motion: reduce) {
  #vp-bands *, body.vp-map-dim #vp-map { transition-duration: 1ms !important; }
}
