/* The window a card of the catalogue opens: the version's pictures on the
   left, and its state, name, author, note, detailed introduction and
   download button on the right, over the lightbox's mask. The script
   fills #vdCard from the card's template, adds `open` to show the window
   and `text-only` when the version has no picture. */
.vdetail {
  /* The units of .light, which size the mark and the button inside. */
  --u: calc(min(var(--container), 100vw - 48px) / 1900);
  --k: calc(min(100vw, 2560px) / 2560);
  position: fixed; inset: 0;
  z-index: 90;
  display: flex; align-items: center; justify-content: center;
  padding: 56px 72px;
  background: rgba(4, 5, 8, 0.86);
  opacity: 0;
  transition: opacity .2s ease;
}
.vdetail.open { opacity: 1; }
/* A closing window lets clicks through, as the other overlays do. */
.vdetail:not(.open) { pointer-events: none; }
.vdetail > .lb-close, .vdetail > .lb-arrow { z-index: 2; }
.vdetail > .lb-close:focus-visible, .vdetail > .lb-arrow:focus-visible { outline-color: #FFFFFF; }

.vd-card {
  position: relative;
  display: flex;
  width: min(1180px, 100%);
  height: min(700px, 100%);
  border-radius: 20px;
  overflow: hidden;
  background: #FFFFFF;
  color: var(--ink);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.06);
  transform: scale(0.97);
  transition: transform .24s cubic-bezier(.2, .9, .3, 1.15);
}
.vdetail.open .vd-card { transform: none; }
/* Without a picture the card is the text alone, as tall as it needs up
   to the same limit. */
.vdetail.text-only .vd-card {
  flex-direction: column;
  width: min(620px, 100%);
  height: auto;
  max-height: min(700px, 100%);
}

/* The pictures, each shown whole on a light ground that fades to the
   white of the text beside it: the count over the one shown and a strip
   of the others under it. */
.vd-stage {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex; flex-direction: column;
  gap: 14px;
  padding: 22px 24px;
  background: linear-gradient(90deg, var(--track), #FFFFFF);
}
.vd-count {
  font-size: 13px;
  line-height: 1;
  letter-spacing: 2px;
  color: #333333;
  font-variant-numeric: tabular-nums;
}
.vd-shot { position: relative; flex: 1 1 auto; min-height: 0; }
/* The shadow follows the picture rather than its box, so a picture with
   light edges still has an edge on the light ground. */
.vd-shot img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(var(--wash), 0.2));
}
/* The padding keeps the ring of the current picture and the focus ring
   inside the strip, which clips what it scrolls. */
.vd-thumbs {
  flex: none;
  display: flex; gap: 10px;
  margin: -5px;
  padding: 5px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--wash), 0.25) transparent;
}
.vd-thumb {
  flex: none;
  width: 60px; height: 60px;
  border-radius: 8px;
  overflow: hidden;
  opacity: 0.55;
  box-shadow: 0 0 0 1px var(--track);
  transition: opacity .15s ease;
}
.vd-thumb:hover { opacity: 0.8; }
.vd-thumb[aria-current="true"] { opacity: 1; box-shadow: 0 0 0 2px var(--purple); }
.vd-thumb:focus-visible { outline-color: var(--purple); outline-offset: 2px; }
.vd-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* The text: the heading lines, then the detail, which scrolls on its own
   between them and the download button. */
.vd-text {
  flex: none;
  width: min(55%, 600px);
  min-height: 0;
  display: flex; flex-direction: column;
  padding: 32px 32px 28px;
  overflow-wrap: anywhere;
}
.vdetail.text-only .vd-text { flex: 1 1 auto; width: auto; }
.vd-state { margin-bottom: 6px; font-size: 12px; letter-spacing: 2px; color: var(--red); }
.vd-name {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 6px 10px;
  font-size: 26px;
  line-height: 1.3;
  font-weight: 700;
}
.vd-name b { min-width: 0; }
.vd-name .ver-tag { padding: 0 8px; border-radius: 6px; font-size: 13px; line-height: 22px; color: #FFFFFF; }
.vd-author { margin-top: 14px; font-size: 14px; color: var(--ink); }
.vd-author span { margin-right: 10px; color: var(--ink-2); }
.vd-note { margin-top: 8px; font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.vd-about {
  display: flex; align-items: center; gap: 8px;
  margin-top: 24px;
  font-size: 15px;
  line-height: 1.4;
  font-weight: 700;
  color: var(--red);
}
/* The chevron before the heading, drawn rather than typed. */
.vd-about::before {
  content: "";
  flex: none;
  width: 7px; height: 7px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(45deg);
}
.vd-body {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  font-size: 14px;
  line-height: 1.85;
  color: #333333;
}
.vd-body p + p { margin-top: 12px; }
.vd-foot {
  flex: none;
  display: flex; align-items: center;
  margin-top: 18px;
  padding-top: 20px;
  border-top: 1px solid #ECEAF0;
}
.vd-foot:empty { display: none; }
.vd-go {
  width: auto;
  min-width: 200px;
  height: 46px;
  padding: 0 28px;
  gap: 6px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
}

/* The page under the window stays still, and a card the arrows reach is
   scrolled to clear the top bar. */
html.detail-open { overflow: hidden; scrollbar-gutter: stable; }
.ver-grid .ver-card, .ver-cards .ver-card { scroll-margin: calc(var(--topbar-h) + 16px) 0 16px; }
/* The space kept for the scrollbar shows the page's own background, which
   the mask does not cover, so it takes the mask's colour over the page and
   fades with the mask. */
html { transition: background-color .2s ease; }
html:has(.vdetail.open) { background-color: color-mix(in srgb, rgb(4 5 8) 86%, var(--bg)); }

@media (max-width: 900px) {
  .vdetail { padding: 56px; }
}
/* On a screen too short for the heading, the detail and the button
   together, the text scrolls as one column and the download button stays
   at its bottom. */
@media (min-width: 761px) and (max-height: 640px) {
  .vdetail { padding-block: 16px; }
  .vd-text {
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding-bottom: 0;
  }
  .vd-text:has(> .vd-foot:empty) { padding-bottom: 28px; }
  .vd-body { flex: none; overflow: visible; }
  .vd-foot {
    position: sticky; bottom: 0;
    padding-bottom: 28px;
    background: #FFFFFF;
  }
}
/* Under this width the window fills the screen and scrolls as one: the
   pictures over the text, the close button in the corner above them, and
   a bar at the bottom that keeps the download button between the arrows.
   The bar stays when it has no button, so the arrows never cover the
   last line. */
@media (max-width: 760px) {
  .vdetail { padding: 0; }
  .vd-card, .vdetail.text-only .vd-card {
    flex-direction: column;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .vd-stage {
    flex: none;
    gap: 12px;
    padding: 60px 0 14px;
    background: linear-gradient(180deg, var(--track), #FFFFFF);
  }
  .vd-count { position: absolute; top: 24px; left: 16px; }
  /* On a phone held sideways the picture keeps to the screen height. */
  .vd-shot {
    flex: none;
    aspect-ratio: 4 / 3;
    max-height: calc(100vh - 96px);
    max-height: calc(100svh - 96px);
  }
  .vd-thumbs { margin: 0; padding: 5px 16px; }
  /* A short text grows to the bottom of the screen, which keeps the bar
     there too. */
  .vd-text, .vdetail.text-only .vd-text { flex: 1 0 auto; width: auto; padding: 22px 16px 0; }
  .vdetail.text-only .vd-text { padding-top: 68px; }
  .vd-name { font-size: 22px; }
  .vd-body { flex: 1 0 auto; overflow: visible; }
  .vd-foot, .vd-foot:empty {
    position: sticky; bottom: 0; z-index: 1;
    display: flex; justify-content: center;
    min-height: 68px;
    margin: 20px -16px 0;
    padding: 11px 64px;
    background: #FFFFFF;
  }
  .vd-go { flex: 1; min-width: 0; max-width: 320px; height: 44px; padding: 0 16px; }
  /* The buttons sit on the light card here, not on the mask. */
  .vdetail > .lb-close, .vdetail > .lb-arrow {
    border-color: #E4E1EA;
    background: #F3F2F6;
    color: var(--ink);
  }
  .vdetail > .lb-close:hover, .vdetail > .lb-arrow:hover { background: #E9E6EF; }
  .vdetail > .lb-close:focus-visible, .vdetail > .lb-arrow:focus-visible { outline-color: var(--purple); }
  .vdetail > .lb-close { top: 12px; right: 12px; }
  .vdetail > .lb-arrow {
    top: auto; bottom: 14px;
    transform: none;
    width: 40px; height: 40px;
  }
  .vdetail > .lb-arrow.prev { left: 12px; }
  .vdetail > .lb-arrow.next { right: 12px; }
}

/* With reduced motion the card appears in place and only the mask fades. */
@media (prefers-reduced-motion: reduce) {
  .vd-card, .vdetail.open .vd-card { transform: none; transition: none; }
  .vd-thumb { transition: none; }
}
