/* ============================================
   Photos Page - Minimal B&W Gallery
   ============================================ */

/* ---- Photos Hero ---- */
.photos-hero {
  padding: 128px 40px 42px;
  position: relative;
  z-index: 1;
}
.photos-hero .container {
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}
.photos-title {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}
.photos-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}
.photos-edition {
  display: block;
  margin-top: 18px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Photos page: wider mask than the shared default in style.css */
.hero-bg-effect {
  mask-image: radial-gradient(ellipse 120% 120% at 50% 40%, white 0%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 120% 120% at 50% 40%, white 0%, transparent 100%);
}

/* ---- Series Quick Nav ---- */
.series-nav {
  position: sticky;
  top: 60px;
  z-index: 50;
  padding: 18px 40px;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.series-nav .container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.series-nav-link {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: color var(--transition);
  cursor: pointer;
}
.series-nav-link:hover { color: var(--text-secondary); }
.series-nav-link.active { color: var(--ember); }
.series-nav-divider {
  color: var(--text-muted);
  opacity: 0.4;
  font-size: 0.75rem;
}
.series-nav-more {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.5;
}

/* ---- Series Section ---- */
.series-section {
  padding: 48px 40px 80px;
  position: relative;
  z-index: 1;
}
.series-section .container { max-width: 1200px; margin: 0 auto; }
.series-section + .series-section { padding-top: 40px; }

.series-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.series-header-left {
  display: flex;
  align-items: flex-end;
  gap: 20px;
}
.series-chapter {
  align-self: flex-start;
  font-family: var(--font-mono);
  color: var(--ember);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  padding-top: 5px;
}
.series-title-block { display: flex; flex-direction: column; gap: 4px; }
.series-name {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.series-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.series-desc {
  font-size: 0.92rem;
  color: var(--text-secondary);
  max-width: 340px;
  text-align: right;
  line-height: 1.6;
  padding-bottom: 6px;
}

/* ---- Gallery Grid ---- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-flow: row;
  align-items: start;
  column-gap: 12px;
  row-gap: clamp(40px, 5vw, 72px);
}

.gallery-item {
  position: relative;
  grid-column: span 3;
  min-width: 0;
  align-self: start;
  isolation: isolate;
  background: transparent;
  cursor: pointer;
  border: 1px solid transparent;
  box-shadow:
    0 0 0 var(--bg-primary),
    0 0 0 rgba(0, 0, 0, 0);
}

/*
 * 卡片也使用全站的滚动入场类。这里显式合并两套过渡，避免全站规则
 * 覆盖 hover 的边框与阴影动画，造成底边瞬间切换和重复重绘。
 */
.gallery-item,
.gallery-item.animate-on-scroll {
  transition:
    opacity var(--motion-slow) var(--motion-ease),
    border-color var(--transition),
    transform var(--motion-slow) var(--motion-ease),
    box-shadow var(--motion-slow) var(--motion-ease);
}

/* 题注移到图外后须始终清晰；仅照片淡入，卡片仍保留原有位移与悬停过渡。 */
.js .gallery-item.animate-on-scroll {
  opacity: 1;
}

.gallery-item--wide,
.gallery-item--feature-wide,
.gallery-item--opening {
  grid-column: span 6;
}

.gallery-item--feature {
  grid-column: span 6;
}

.gallery-item:hover {
  z-index: 2;
  border-color: transparent;
}

/* 照片保留原始比例，题注参与正常排版，避免竖图被裁切和文字压图。 */
.gallery-image {
  position: relative;
  overflow: hidden;
  aspect-ratio: var(--photo-ratio);
  background: var(--bg-card);
}

@media (prefers-reduced-motion: no-preference) {
  .js .gallery-item.animate-on-scroll .gallery-image {
    transition: opacity var(--motion-slow) var(--motion-ease);
  }
  .js .gallery-item.animate-on-scroll:not(.visible) .gallery-image {
    opacity: 0;
  }
}

.gallery-item img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  filter: grayscale(28%);
  transform: scale(1.001);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: filter var(--transition), transform var(--motion-slow) var(--motion-ease);
}
.gallery-item img.is-lightbox-source { visibility: hidden; filter: grayscale(0%); }
.gallery-item:hover img {
  filter: grayscale(0%);
}

.gallery-view {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(10, 10, 10, 0.72);
  color: var(--text-primary);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--transition), transform var(--transition);
}
.gallery-item:hover .gallery-view,
.gallery-item:focus-visible .gallery-view { opacity: 1; transform: none; }

/* Overlay */
.gallery-overlay {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 16px 0 0;
  opacity: 1;
}
.gallery-item:hover .gallery-overlay { opacity: 1; }
.gallery-item:focus-visible .gallery-overlay { opacity: 1; }

.gallery-number {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ember);
  letter-spacing: 0.12em;
  flex: 0 0 auto;
}
.gallery-caption-copy { min-width: 0; }
.gallery-overlay h3 {
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.gallery-overlay p {
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-top: 5px;
}

/* Placeholder slot */
.gallery-placeholder {
  background: var(--bg-card);
  border-style: dashed;
}
.gallery-empty {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 8px;
  transition: all var(--transition);
}
.gallery-empty span {
  font-size: 2rem;
  font-weight: 200;
  line-height: 1;
}
.gallery-empty small {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.gallery-item:hover .gallery-empty span,
.gallery-item:hover .gallery-empty small { color: var(--text-secondary); }

/* ---- Lightbox ---- */
.lightbox {
  position: fixed;
  inset: 0;
  height: 100dvh;
  z-index: 9999;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 2vh, 24px);
  padding: clamp(56px, 6vh, 76px) clamp(72px, 7vw, 140px) max(24px, 3vh);
  box-sizing: border-box;
  overflow: hidden;
  opacity: 1;
  pointer-events: none;
  cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: rgba(5, 5, 5, 0.96);
  opacity: 0;
  transition: opacity 240ms ease;
}
.lightbox.active::before { opacity: 1; }
.lightbox.active {
  pointer-events: auto;
}

.lightbox-content {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  width: 100%;
  max-width: 85vw;
  max-height: none;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  touch-action: pan-y pinch-zoom;
}
.lightbox-content img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: default;
  pointer-events: auto;
  touch-action: pan-y pinch-zoom;
  user-select: none;
  -webkit-user-select: none;
  filter: none;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.lightbox.is-closing .lightbox-content img { box-shadow: none; }
.lightbox.is-closing .lightbox-info,
.lightbox.is-closing .lightbox-close,
.lightbox.is-closing .lightbox-prev,
.lightbox.is-closing .lightbox-next { opacity: 0; transition-duration: 120ms; }

/* 放大后的横向拖动属于浏览器平移，不能继续限制为竖向手势。 */
.lightbox.is-zoomed .lightbox-content,
.lightbox.is-zoomed .lightbox-content img { touch-action: auto; }

.lightbox-close {
  position: absolute;
  top: 32px; right: 36px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 2rem;
  z-index: 10;
  opacity: 0.5;
  transition: opacity var(--transition);
  cursor: pointer;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.lightbox-close:hover { opacity: 1; }

.lightbox-prev, .lightbox-next {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  background: none;
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 1.8rem;
  padding: 16px 14px;
  opacity: 0.4;
  transition: opacity var(--transition), border-color var(--transition);
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
}
.lightbox-prev:hover, .lightbox-next:hover {
  opacity: 1;
  border-color: var(--border-hover);
}
.lightbox-prev { left: 24px; }
.lightbox-next { right: 24px; }

.lightbox-info {
  position: static;
  flex: 0 0 auto;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: opacity 160ms ease;
}
.lightbox-title {
  font-size: 0.88rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}
.lightbox-counter {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}
.lightbox-status {
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-secondary);
}
.lightbox-status:empty { display: none; }
.lightbox.is-dragging .lightbox-content img { cursor: grabbing; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .photos-hero { padding: 90px 24px 26px; }
  .photos-title { font-size: clamp(2.1rem, 10vw, 3.1rem); line-height: 1.15; margin-bottom: 12px; }
  .photos-subtitle { font-size: 0.82rem; line-height: 1.8; letter-spacing: 0; }
  .photos-edition { font-size: 0.6rem; margin-top: 12px; letter-spacing: 0.07em; }
  .series-nav { padding: 4px 24px; top: 56px; }
  .series-nav .container { gap: 10px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .series-nav .container::-webkit-scrollbar { display: none; }
  .series-nav-link, .series-nav-divider { flex-shrink: 0; }
  .series-nav-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  .series-section { padding: 28px 24px 48px; }
  .series-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 18px;
  }
  .series-name { font-size: 1.8rem; }
  .series-header-left { gap: 14px; }
  .series-meta { font-size: 0.65rem; }
  .series-desc { text-align: left; max-width: 100%; font-size: 0.8rem; padding-bottom: 0; }
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 34px 8px;
  }
  .gallery-item {
    grid-column: span 1;
  }
  .gallery-item--wide,
  .gallery-item--feature-wide,
  .gallery-item--opening {
    grid-column: span 2;
  }
  .gallery-item--feature {
    grid-column: span 2;
  }
  .gallery-overlay { padding: 12px 0 0; gap: 8px; }
  .gallery-number { font-size: 0.6rem; }
  .gallery-overlay h3 { font-size: 0.76rem; line-height: 1.5; }
  .gallery-overlay p { font-size: 0.7rem; line-height: 1.6; }
  .gallery-view { opacity: 1; transform: none; width: 26px; height: 26px; right: 8px; bottom: 8px; }
  .lightbox {
    gap: 12px;
    padding: max(68px, env(safe-area-inset-top)) 18px max(76px, calc(env(safe-area-inset-bottom) + 64px));
  }
  .lightbox-content { max-width: 100%; }
  .lightbox-prev, .lightbox-next { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); transform: none; padding: 8px 12px; font-size: 1.4rem; }
  .lightbox-prev { left: calc(50% - 52px); }
  .lightbox-next { right: calc(50% - 52px); }
  .lightbox-close { top: 20px; right: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .lightbox, .lightbox::before, .lightbox-info, .lightbox-content img, .gallery-item img, .gallery-view { transition: none; }
}
