/* Gallery page (pages/en_US/gallary.html). Runs on the wiki's tokens
   (wiki.css defines :root, the taskbar, and the base type), and adds the
   three showcase layouts: video left / video right / video center. */

.gallery {
  max-width: 1560px;
  margin: 0 auto;
}

/* Title block: big title at the left, no sub-line, hairline under it. */
.gallery-head {
  padding: calc(110 * var(--unit)) 6vw calc(56 * var(--unit));
  text-align: left;
  border-bottom: 1px solid var(--wiki-line);
}
.gallery-title {
  margin: 0;
  font-size: calc(120 * var(--unit));
  font-weight: normal;
  letter-spacing: .04em;
}

/* The items. Each is a full-width band; no hairlines between items
   (user rule 2026-11-25: no split line between videos). */
.gallery-status {
  padding: calc(40 * var(--unit)) 6vw;
  color: var(--wiki-muted);
  font-size: calc(17 * var(--unit));
}
.gallery-item {
  display: grid;
  align-items: center;
  column-gap: calc(56 * var(--unit));
  row-gap: calc(28 * var(--unit));
  padding: calc(72 * var(--unit)) 6vw;
}
/* 1: video left, text right. DOM order is media, copy. */
.item-video-left { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
/* 2: video right, text left. DOM order is copy, media. */
.item-video-right { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
/* 3: video big in the middle, text below it. */
.item-video-center {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  text-align: center;
}

.gallery-media { position: relative; }
.gallery-media video {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--wiki-line);
  background: #000;
}
.item-video-center .gallery-media { width: min(100%, 960px); }

/* Fullscreen toggle: icon button over the video's top-right corner, always
   visible at a soft opacity and full on hover/focus; the contract icon
   replaces the expand icon while fullscreen. */
.gallery-fullscreen {
  position: absolute;
  top: calc(12 * var(--unit));
  right: calc(12 * var(--unit));
  z-index: 2;
  display: grid;
  place-items: center;
  width: calc(36 * var(--unit));
  height: calc(36 * var(--unit));
  padding: 0;
  border: 1px solid var(--wiki-line);
  border-radius: calc(8 * var(--unit));
  background: rgba(0, 0, 0, .55);
  color: var(--wiki-foreground);
  cursor: pointer;
  opacity: .55;
  transition: opacity .18s ease;
}
.gallery-media:hover .gallery-fullscreen,
.gallery-fullscreen:focus-visible {
  opacity: .95;
}
.gallery-fullscreen svg { width: 16px; height: 16px; }
.gallery-fullscreen .fs-contract { display: none; }
.gallery-fullscreen.is-fullscreen .fs-expand { display: none; }
.gallery-fullscreen.is-fullscreen .fs-contract { display: block; }

.gallery-copy h2 {
  margin: 0 0 calc(14 * var(--unit));
  font-size: calc(32 * var(--unit));
  font-weight: normal;
}
.gallery-copy p {
  margin: 0;
  color: var(--wiki-muted);
  font-size: calc(18 * var(--unit));
  line-height: 1.65;
}
.item-video-center .gallery-copy { width: min(100%, 720px); }

/* Scroll reveal: each item is one bound unit — it fades in and shifts up
   when scrolled into view, and its parts stagger per layout (see the delay
   rules below). gallery.js adds .is-revealed when the item intersects. */
.gallery-item .gallery-media,
.gallery-item .gallery-copy,
.gallery-grid {
  opacity: 0;
  transform: translateY(calc(28 * var(--unit)));
  transition: opacity .7s ease, transform .7s ease;
}
.gallery-item.is-revealed .gallery-media,
.gallery-item.is-revealed .gallery-copy,
.gallery-grid.is-revealed {
  opacity: 1;
  transform: none;
}
/* Horizontal layouts: the text enters first, the video lags 300 ms. */
.item-video-left .gallery-media,
.item-video-right .gallery-media { transition-delay: 300ms; }
/* Vertical layout: the video enters first, the text lags 300 ms. */
.item-video-center .gallery-copy { transition-delay: 300ms; }

/* The current page in the taskbar nav reads muted, like a hover. */
.wiki-nav a[aria-current="page"] { opacity: .65; cursor: default; }

/* Bilibili-style video grid: 4 per row filling the line, no text — just the
   16:9 cell, the corner duration badge, hover-to-play and dblclick fullscreen. */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: calc(16 * var(--unit));
  padding: calc(72 * var(--unit)) 6vw;
}
.grid-cell {
  position: relative;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--wiki-line);
  border-radius: calc(8 * var(--unit));
  background: #000;
  overflow: hidden;
  cursor: pointer;
}
.grid-cell video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* The poster cover hides the always-playing video until hover (CSS :hover
   works everywhere — play() from mouseenter is rejected by Safari). */
.grid-cover {
  position: absolute;
  inset: 0;
  background: #000 center / cover no-repeat;
  transition: opacity .2s ease;
}
.grid-cell:hover .grid-cover { opacity: 0; }
.grid-duration {
  position: absolute;
  z-index: 1;
  right: calc(8 * var(--unit));
  bottom: calc(8 * var(--unit));
  padding: calc(2 * var(--unit)) calc(8 * var(--unit));
  border-radius: calc(4 * var(--unit));
  background: rgba(0, 0, 0, .6);
  color: #fff;
  font-size: calc(14 * var(--unit));
  pointer-events: none;
}

@media (max-width: 720px) {
  .gallery-item,
  .item-video-left,
  .item-video-right,
  .item-video-center {
    grid-template-columns: minmax(0, 1fr);
    justify-items: stretch;
    text-align: left;
  }
  .item-video-center .gallery-media,
  .item-video-center .gallery-copy { width: 100%; }
  .gallery-title { font-size: clamp(40px, 13vw, 72px); }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-item .gallery-media,
  .gallery-item .gallery-copy,
  .gallery-grid {
    opacity: 1;
    transform: none;
    transition: none;
  }
}
