/* PivArk gallery — 默认兜底样式（随插件 zip 分发）
 * 真源：weapp/doc_gallery/assets/css/gallery.css
 * 加载：{pv:doc_gallery} → GalleryFrontAssets → {pv:frontassets /}
 * 主题 template/*/assets 仅可做皮肤覆盖（颜色/圆角/间距），禁止复制或替代本文件。 */
.pv-gallery {
  position: relative;
  margin: 1rem 0;
}

.pv-gallery--grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.pv-gallery--masonry {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  grid-auto-rows: 8px;
  gap: 0.75rem;
}

.pv-gallery--masonry .pv-gallery-item {
  margin: 0;
  /* span 由 masonry.js 按真实高度写入；禁止主题写死同一 span */
  grid-row-end: span 24;
}

.pv-gallery--masonry .pv-gallery-item img {
  width: 100%;
  height: auto;
  aspect-ratio: auto;
  object-fit: cover;
  display: block;
}

/* 同源图也拉开高度差，瀑布流才看得出层次（masonry.js 再按真实高度算 span） */
.pv-gallery--masonry .pv-gallery-item:nth-child(3n + 1) img {
  min-height: 140px;
  max-height: 180px;
}

.pv-gallery--masonry .pv-gallery-item:nth-child(3n + 2) img {
  min-height: 200px;
  max-height: 260px;
}

.pv-gallery--masonry .pv-gallery-item:nth-child(3n + 3) img {
  min-height: 280px;
  max-height: 340px;
}

.pv-gallery-carousel-shell {
  position: relative;
  margin: 1rem 0;
}

.pv-gallery-carousel-shell .pv-gallery--carousel {
  margin: 0;
}

.pv-gallery--carousel {
  display: flex;
  flex-wrap: nowrap;
  gap: 1rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  padding: 0.25rem 2.5rem;
}

.pv-gallery--carousel .pv-gallery-item {
  flex: 0 0 min(85%, 640px);
  scroll-snap-align: start;
}

.pv-gallery--carousel .pv-gallery-item img {
  width: 100%;
  max-height: 480px;
  object-fit: contain;
}

.pv-gallery--filmstrip {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.5rem 0.25rem 0.75rem;
  border-top: 1px solid color-mix(in srgb, currentColor 12%, transparent);
  border-bottom: 1px solid color-mix(in srgb, currentColor 12%, transparent);
  background: color-mix(in srgb, currentColor 4%, transparent);
  scrollbar-width: thin;
}

.pv-gallery--filmstrip .pv-gallery-item {
  flex: 0 0 120px;
  position: relative;
}

.pv-gallery--filmstrip .pv-gallery-item::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 3px;
  background: color-mix(in srgb, currentColor 35%, transparent);
  border-radius: 2px;
  opacity: 0.55;
}

.pv-gallery--filmstrip .pv-gallery-item img {
  width: 120px;
  height: 80px;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.pv-gallery--filmstrip .pv-gallery-item figcaption {
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pv-gallery--list {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.pv-gallery--list .pv-gallery-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.65rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid color-mix(in srgb, currentColor 10%, transparent);
}

.pv-gallery--list .pv-gallery-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.pv-gallery--list .pv-gallery-item img {
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  background: color-mix(in srgb, currentColor 4%, transparent);
}

@media (min-width: 768px) {
  .pv-gallery--list .pv-gallery-item {
    grid-template-columns: minmax(220px, 42%) 1fr;
    align-items: center;
    gap: 1.25rem;
  }

  .pv-gallery--list .pv-gallery-item img {
    max-height: 220px;
  }

  .pv-gallery--list .pv-gallery-item figcaption {
    font-size: 1.05rem;
    line-height: 1.5;
  }
}

.pv-gallery--justified {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  grid-auto-rows: 120px;
  gap: 0.35rem;
}

.pv-gallery--justified .pv-gallery-item {
  margin: 0;
  overflow: hidden;
  border-radius: 2px;
}

.pv-gallery--justified .pv-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s ease;
}

.pv-gallery--justified .pv-gallery-item:hover img {
  transform: scale(1.04);
}

.pv-gallery--justified .pv-gallery-item figcaption {
  display: none;
}

.pv-gallery--hero {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

@media (max-width: 640px) {
  .pv-gallery--hero {
    grid-template-columns: repeat(2, 1fr);
  }
}

.pv-gallery--hero .pv-gallery-item:first-child {
  grid-column: 1 / -1;
}

.pv-gallery--hero .pv-gallery-item:first-child img {
  width: 100%;
  max-height: 420px;
  min-height: 200px;
  object-fit: cover;
  border-radius: 4px;
}

.pv-gallery--hero .pv-gallery-item:not(:first-child) img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 3px;
  opacity: 0.96;
}

.pv-gallery--grid .pv-gallery-item img {
  aspect-ratio: 4 / 3;
  object-fit: cover;
  width: 100%;
  display: block;
}

.pv-gallery--carousel .pv-gallery-item {
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.pv-gallery-carousel-shell .pv-gallery-carousel-nav {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.pv-gallery-carousel-nav {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.pv-gallery-carousel-shell .pv-gallery-carousel-prev,
.pv-gallery-carousel-shell .pv-gallery-carousel-next,
.pv-gallery--carousel .pv-gallery-carousel-prev,
.pv-gallery--carousel .pv-gallery-carousel-next {
  pointer-events: auto;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.pv-gallery-carousel-shell .pv-gallery-carousel-prev,
.pv-gallery--carousel .pv-gallery-carousel-prev {
  left: 0.25rem;
}

.pv-gallery-carousel-shell .pv-gallery-carousel-next,
.pv-gallery--carousel .pv-gallery-carousel-next {
  right: 0.25rem;
}

.pv-gallery-carousel-shell .pv-gallery-carousel-prev:hover,
.pv-gallery-carousel-shell .pv-gallery-carousel-next:hover,
.pv-gallery--carousel .pv-gallery-carousel-prev:hover,
.pv-gallery--carousel .pv-gallery-carousel-next:hover {
  background: rgba(0, 0, 0, 0.65);
}

.pv-gallery-carousel-shell .pv-gallery-carousel-dots,
.pv-gallery-carousel-dots {
  position: absolute;
  left: 50%;
  bottom: 0.5rem;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  gap: 0.35rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
}

.pv-gallery-carousel-dot {
  width: 0.5rem;
  height: 0.5rem;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  cursor: pointer;
}

.pv-gallery-carousel-dot.is-active {
  background: #fff;
  transform: scale(1.15);
}

.pv-gallery-caption {
  margin-top: 0.35rem;
  font-size: 0.875rem;
  line-height: 1.4;
}

.pv-gallery-caption .pv-gallery-desc,
.pv-gallery-caption .pv-gallery-shot {
  display: block;
  color: #666;
  font-size: 0.8125rem;
}

.pv-gallery-item__link:not([href]),
.pv-gallery-item__link[href=''] {
  pointer-events: none;
  cursor: default;
}

.pv-gallery-ext-link:not([href]),
.pv-gallery-ext-link[href=''] {
  display: none;
}

.pv-gallery-group-block {
  margin-bottom: 2rem;
}

.pv-gallery-group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.pv-gallery-group-head .pv-gallery-group-title {
  margin: 0;
}

.pv-gallery-pack-dl {
  flex-shrink: 0;
}

.pv-gallery-group-block:last-child {
  margin-bottom: 0;
}

.pv-gallery-group-title {
  margin: 0 0 0.75rem;
  font-size: 1.125rem;
}

.pv-gallery-item {
  margin: 0;
}

.pv-gallery-item img {
  display: block;
  max-width: 100%;
  height: auto;
}

.pv-gallery-item figcaption:empty {
  display: none;
}

.pv-gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.88);
  padding: 2rem;
}

.pv-gallery-lightbox__figure {
  margin: 0;
  max-width: min(92vw, 1200px);
  max-height: 88vh;
  text-align: center;
}

.pv-gallery-lightbox__figure img {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 0.5rem;
}

.pv-gallery-lightbox__figure figcaption {
  color: #e2e8f0;
  margin-top: 0.75rem;
  font-size: 0.875rem;
}

.pv-gallery-lightbox__close,
.pv-gallery-lightbox__prev,
.pv-gallery-lightbox__next {
  position: absolute;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  border-radius: 999px;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.5rem;
  line-height: 1;
}

.pv-gallery-lightbox__close {
  top: 1rem;
  right: 1rem;
}

.pv-gallery-lightbox__prev {
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

.pv-gallery-lightbox__next {
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

body.pv-gallery-lightbox-open {
  overflow: hidden;
}

.pv-gallery-lightbox__counter {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  color: #fff;
  font-size: 0.875rem;
  background: rgba(0, 0, 0, 0.45);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
}

.pv-gallery-lightbox__thumbs {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  overflow-x: auto;
  background: rgba(0, 0, 0, 0.55);
}

.pv-gallery-lightbox__thumb {
  flex: 0 0 56px;
  width: 56px;
  height: 40px;
  border: 2px solid transparent;
  border-radius: 4px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 12px;
}

.pv-gallery-lightbox__thumb.is-active {
  border-color: #fff;
}

.pv-gallery-lightbox__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Swiper 滑动布局（carousel / filmstrip / hero） */
.pv-gallery-carousel-shell {
  position: relative;
}

.pv-gallery-swiper {
  width: 100%;
  padding-bottom: 2.25rem;
}

.pv-gallery-swiper .swiper-slide {
  box-sizing: border-box;
}

.pv-gallery-swiper--carousel .swiper-slide img,
.pv-gallery-swiper--hero .swiper-slide img {
  display: block;
  width: 100%;
  max-height: 480px;
  object-fit: cover;
  border-radius: 0.5rem;
  background: #f1f5f9;
}

.pv-gallery-swiper--filmstrip .swiper-slide {
  width: 140px;
}

.pv-gallery-swiper--filmstrip .swiper-slide img {
  display: block;
  width: 140px;
  height: 96px;
  object-fit: cover;
  border-radius: 0.4rem;
  border: 1px solid rgba(15, 23, 42, 0.12);
}

.pv-gallery-swiper__caption {
  margin-top: 0.45rem;
  font-size: 0.875rem;
  color: #475569;
  text-align: center;
}

.pv-gallery-swiper .swiper-button-prev,
.pv-gallery-swiper .swiper-button-next {
  color: #fff;
  background: rgba(15, 23, 42, 0.45);
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
}

.pv-gallery-swiper .swiper-button-prev:after,
.pv-gallery-swiper .swiper-button-next:after {
  font-size: 0.95rem;
  font-weight: 700;
}

.pv-gallery-swiper .swiper-pagination-bullet-active {
  background: #2563eb;
}

.pv-gallery-item__link {
  display: block;
  cursor: zoom-in;
}
