html {
  scroll-behavior: smooth;
}

/* Anchor target: slide from down → up */
@keyframes vs-anchor-up {
  from {
    opacity: 0.35;
    transform: translateY(1.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.vs-anchor-motion,
:target {
  animation: vs-anchor-up 0.65s ease-out;
}

/* Hide always-visible Windows scrollbars on sidebars (wheel scroll still works). */
.md-sidebar__scrollwrap {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.md-sidebar__scrollwrap::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* Image lightbox (used by image-lightbox.js) */
.md-typeset img {
  cursor: zoom-in;
}

.md-content .md-typeset a:hover:not(.md-button) {
  text-decoration: underline;
}

/* Left nav + right TOC: selected page/section only (not section headers) */
.md-sidebar--primary .md-nav__link--active,
.md-sidebar--secondary .md-nav__link--active {
  color: var(--md-accent-fg-color);
  font-weight: 600;
}

.md-sidebar--primary .md-nav__link--active code,
.md-sidebar--secondary .md-nav__link--active code {
  color: var(--md-accent-fg-color);
}

/* Nest pages under section headers so they read as children */
.md-sidebar--primary .md-nav__item--nested > .md-nav > .md-nav__list,
.md-sidebar--primary .md-nav__item--section > .md-nav > .md-nav__list {
  margin-left: 0.6rem;
  padding-left: 0.55rem;
}

.md-typeset th {
  background-color: var(--md-default-fg-color--lightest);
}

/* Admonitions: accent on the left only (not full box border) */
.md-typeset .admonition,
.md-typeset details {
  border-width: 0 0 0 0.15rem;
}

.vs-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(28, 32, 38, 0.92);
  padding: 2rem;
  overscroll-behavior: contain;
}

html.vs-lightbox-scroll-lock {
  overflow: hidden !important;
  height: 100%;
}

.vs-lightbox.is-open {
  display: flex;
}

.vs-lightbox__img {
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  transform-origin: center center;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  z-index: 1;
  cursor: zoom-in;
  /* SVG charts are transparent; give them a light backdrop on the dark overlay */
  background: #fff;
}

.vs-lightbox__close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  padding: 0.15rem 0.65rem;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1.2;
  cursor: pointer;
  z-index: 3;
}

.vs-lightbox__controls {
  position: absolute;
  top: 0.9rem;
  left: 1rem;
  display: flex;
  gap: 0.5rem;
  z-index: 3;
}

.vs-lightbox__control {
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  min-width: 3rem;
  padding: 0.2rem 0.55rem;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.vs-lightbox__hint {
  position: absolute;
  left: 1rem;
  bottom: 0.75rem;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.85rem;
  z-index: 3;
}

/* Header: documentation issue CTA instead of repo stars/forks badge */
.md-header .md-source__facts {
  display: none;
}

.md-header__source {
  width: auto;
  max-width: none;
}

.md-header .md-source__repository {
  max-width: none;
  overflow: visible;
  text-overflow: unset;
  white-space: nowrap;
}

/* Explainer films */
.vs-film { margin: 1.2em 0 1.6em; }
.vs-film video { width: 100%; border-radius: 6px; background: #0f1724; display: block; aspect-ratio: 16 / 9; }
.vs-film figcaption { font-size: .78rem; color: var(--md-default-fg-color--light); margin-top: .5em; text-align: left; max-width: none; }

/* Home: stat cards */
.md-typeset .vs-stats > ul > li > p:first-child strong { font-size: 1.35rem; color: var(--md-primary-fg-color); letter-spacing: -.01em; }
[data-md-color-scheme="slate"] .md-typeset .vs-stats > ul > li > p:first-child strong { color: #9caedb; }

/* Home: film strip */
.vs-filmstrip { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; margin: .4rem 0 1.4rem; }
.vs-filmstrip a { display: block; border-radius: 6px; overflow: hidden; background: #0f1724; color: #fff !important; position: relative; }
.vs-filmstrip img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; opacity: .85; transition: opacity .15s; }
.vs-filmstrip a:hover img { opacity: 1; }
.vs-filmstrip span { display: block; font-size: .62rem; padding: .35rem .5rem; line-height: 1.3; }
.vs-filmstrip span strong { display: block; font-size: .68rem; }

/* Home: how-it-works flow */
.vs-flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr; gap: .4rem; align-items: stretch; margin: 1rem 0 1.2rem; }
.vs-flow__col { border: 1px solid var(--md-default-fg-color--lightest); border-radius: 8px; padding: .7rem .8rem; font-size: .68rem; background: var(--md-default-bg-color); }
.vs-flow__col--accent { border-color: #fc8462; box-shadow: 0 0 0 1px #fc8462 inset; }
.vs-flow__head { font-weight: 700; color: var(--md-primary-fg-color); margin-bottom: .4rem; font-size: .72rem; }
[data-md-color-scheme="slate"] .vs-flow__head { color: #9caedb; }
.md-typeset .vs-flow ul { margin: 0; padding-left: 1rem; }
.md-typeset .vs-flow li { margin: .15rem 0; }
.vs-flow__arrow { align-self: center; color: #fc8462; font-size: 1.2rem; font-weight: 700; }
@media (max-width: 900px) {
  .vs-flow { grid-template-columns: 1fr; }
  .vs-flow__arrow { transform: rotate(90deg); justify-self: center; line-height: 1; }
}

/* Stage diagram on the time-slice page */
.vs-stage { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin: 1rem 0; }
.vs-stage > div { border: 1px solid var(--md-default-fg-color--lightest); border-radius: 8px; padding: .6rem .7rem; font-size: .66rem; }
.vs-stage b.t { display:block; font-size: .7rem; color: var(--md-primary-fg-color); margin-bottom: .3rem; }
[data-md-color-scheme="slate"] .vs-stage b.t { color: #9caedb; }
@media (max-width: 900px) { .vs-stage { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .vs-stage { grid-template-columns: 1fr; } }
.vs-res__band { border: 1px dashed var(--md-default-fg-color--lighter); border-radius: 8px; padding: .55rem .8rem; font-size: .68rem; margin: -.4rem 0 1.2rem; }
.md-typeset .vs-flow code { font-size: .58rem; white-space: nowrap; word-break: normal; padding: 0 .2em; }
.vs-flow { column-gap: .3rem; }
.vs-flow__col { padding: .6rem .6rem; }
.md-typeset .vs-flow ul { padding-left: .8rem; }
