/* ===================================================================
   pattern.css —— 纹样展示页样式
   全黑主题，黑底白纹，极简藏品风格
   参考：wenzang.cn（纹藏）的克制排版与网格布局
   =================================================================== */

/* ========== 变量 ========== */
:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #111111;
  --bg-card: #181818;
  --bg-card-hover: #222222;
  --text-primary: #f0f0f0;
  --text-secondary: #999999;
  --text-muted: #555555;
  --accent: #ffffff;
  --accent-dim: rgba(255,255,255,0.12);
  --border-color: rgba(255,255,255,0.06);
  --border-hover: rgba(255,255,255,0.15);
  --font-sans-cn: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-serif-cn: "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --font-mono: "SF Mono", "Fira Code", "Consolas", monospace;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --pad-x: clamp(20px, 5vw, 80px);
  --header-h: 64px;
}

/* ========== 锁定滚动 ========== */
html.is-locked, body.is-locked { overflow: hidden; }

/* ========== Reset ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans-cn);
  font-size: 15px;
  line-height: 1.7;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ========== 页面布局 ========== */
.page {
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--header-h) var(--pad-x);
  position: relative;
}

/* ========== Header ========== */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--pad-x);
  background: rgba(10,10,10,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  transition: border-color 400ms var(--ease-out);
}

.site-logo {
  font-family: var(--font-serif-cn);
  font-size: 1.3rem;
  letter-spacing: 0.08em;
  transition: opacity 300ms var(--ease-out);
}
.site-logo:hover { opacity: 0.7; }
.logo-sub { color: var(--text-secondary); font-size: 0.8em; }

.site-nav { display: flex; gap: 32px; }
.site-nav a {
  font-size: 0.78rem;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  transition: color 400ms var(--ease-out);
  position: relative;
}
.site-nav a::after {
  content: '';
  position: absolute; bottom: -4px; left: 0; right: 0;
  height: 1px; background: var(--text-primary);
  transform: scaleX(0);
  transition: transform 400ms var(--ease-out);
  transform-origin: right center;
}
.site-nav a:hover { color: var(--text-primary); }
.site-nav a:hover::after { transform: scaleX(1); transform-origin: left center; }
.site-nav a.is-current { color: var(--text-primary); }
.site-nav a.is-current::after { transform: scaleX(1); }

/* 汉堡按钮 */
.nav-toggle {
  display: none;
  flex-direction: column; gap: 5px;
  width: 28px; padding: 4px 0;
  cursor: pointer;
}
.nav-toggle-line {
  display: block; width: 100%; height: 1.5px;
  background: var(--text-primary);
  transition: transform 400ms var(--ease-out), opacity 300ms;
  transform-origin: center;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-line:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-line:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-line:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* ========== Hero 首屏 ========== */
.page-hero {
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(255,255,255,0.03) 0%, transparent 70%),
    var(--bg-primary);
}
.hero-bg-pattern {
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 40px, rgba(255,255,255,0.012) 40px, rgba(255,255,255,0.012) 41px),
    repeating-linear-gradient(90deg, transparent, transparent 40px, rgba(255,255,255,0.012) 40px, rgba(255,255,255,0.012) 41px);
  opacity: 0.5;
}

.hero-content {
  position: relative; z-index: 1;
  text-align: center;
  max-width: 680px;
}

.eyebrow {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.4em;
  color: var(--text-secondary);
  margin-bottom: 32px;
  text-transform: uppercase;
}

.hero-title {
  font-family: var(--font-serif-cn);
  font-weight: 500;
  line-height: 0.82;
  margin-bottom: 36px;
}
.hero-title-line {
  display: block;
  font-size: clamp(7rem, 28vw, 28rem);
  letter-spacing: -0.05em;
  white-space: nowrap;
}
.hero-title-line-sub {
  color: var(--text-secondary);
  font-size: 0.38em;
  letter-spacing: 0.6em;
  margin-top: -0.1em;
}

.hero-tagline {
  font-size: clamp(0.9rem, 1.6vw, 1.15rem);
  color: var(--text-secondary);
  line-height: 1.9;
  margin-bottom: 48px;
  letter-spacing: 0.05em;
}

.hero-cta {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 14px 36px;
  border: 1px solid var(--border-hover);
  border-radius: 100px;
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  transition: all 500ms var(--ease-out);
}
.hero-cta:hover {
  background: var(--text-primary);
  color: var(--bg-primary);
  border-color: var(--text-primary);
}
.hero-cta-arrow {
  display: inline-block;
  transition: transform 400ms var(--ease-out);
}
.hero-cta:hover .hero-cta-arrow { transform: translateX(6px); }

.scroll-hint {
  position: absolute; bottom: 32px; left: 50%; transform: translateX(-50%);
  font-size: 0.7rem; letter-spacing: 0.2em; color: var(--text-muted);
  animation: scrollPulse 2.4s var(--ease-out) infinite;
}
@keyframes scrollPulse {
  0%, 100% { opacity: 0.35; transform: translate(-50%, 0); }
  50% { opacity: 1; transform: translate(-50%, 8px); }
}

/* ========== 通用章节头部 ========== */
.section-header {
  margin-bottom: 48px;
}
.section-num {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.section-title {
  font-family: var(--font-serif-cn);
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 400;
  letter-spacing: 0.08em;
}
.section-count {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 8px;
  font-family: var(--font-mono);
}

/* ========== 筛选条 ========== */
.filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}
.filter-btn {
  padding: 6px 18px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: 100px;
  transition: all 400ms var(--ease-out);
}
.filter-btn:hover { color: var(--text-primary); border-color: var(--border-hover); }
.filter-btn.is-active {
  color: var(--text-primary);
  border-color: var(--text-primary);
  background: var(--accent-dim);
}

/* ========== 纹样网格 ========== */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 2px;
  background: var(--bg-primary);
}

.gallery-item {
  position: relative;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  background: var(--bg-card);
  cursor: pointer;
  transition: background 500ms var(--ease-out);
}
.gallery-item:hover {
  background: var(--bg-card-hover);
}

.gallery-item-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 800ms var(--ease-out);
}
.gallery-item:hover .gallery-item-img {
  transform: scale(1.05);
}

.gallery-item-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 500ms var(--ease-out);
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 20px;
}
.gallery-item:hover .gallery-item-overlay {
  opacity: 1;
}

.gallery-item-label {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-family: var(--font-mono);
}
.gallery-item-title {
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  font-weight: 400;
}

/* 网格项入场动画 */
.gallery-item {
  opacity: 0;
  transform: translateY(24px);
  animation: itemFadeIn 600ms var(--ease-out) forwards;
}
@keyframes itemFadeIn {
  to { opacity: 1; transform: translateY(0); }
}
.gallery-item:nth-child(1) { animation-delay: 0.02s; }
.gallery-item:nth-child(2) { animation-delay: 0.06s; }
.gallery-item:nth-child(3) { animation-delay: 0.10s; }
.gallery-item:nth-child(4) { animation-delay: 0.14s; }
.gallery-item:nth-child(5) { animation-delay: 0.18s; }
.gallery-item:nth-child(6) { animation-delay: 0.22s; }
.gallery-item:nth-child(7) { animation-delay: 0.26s; }
.gallery-item:nth-child(8) { animation-delay: 0.30s; }
.gallery-item:nth-child(9) { animation-delay: 0.34s; }
.gallery-item:nth-child(10) { animation-delay: 0.38s; }

/* ========== 关于页面 ========== */
.page-about {
  display: flex; flex-direction: column; justify-content: center;
}
.about-content {
  max-width: 640px;
  margin-top: 24px;
}
.about-text {
  font-size: clamp(0.95rem, 1.5vw, 1.1rem);
  color: var(--text-secondary);
  line-height: 2;
  letter-spacing: 0.04em;
  margin-bottom: 24px;
}
.about-stats {
  display: flex; gap: 48px;
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border-color);
}
.stat { display: flex; flex-direction: column; gap: 8px; }
.stat-num {
  font-family: var(--font-mono);
  font-size: 2.4rem;
  color: var(--text-primary);
  line-height: 1;
}
.stat-label {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

/* ========== Lightbox ========== */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.95);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.lightbox[hidden] { display: none; }

.lightbox-close {
  position: absolute; top: 24px; right: 28px;
  font-size: 2rem; color: var(--text-primary);
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 50%;
  transition: background 400ms var(--ease-out);
  z-index: 1;
}
.lightbox-close:hover { background: rgba(255,255,255,0.1); }

.lightbox-prev, .lightbox-next {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 3rem; color: var(--text-primary);
  width: 64px; height: 64px;
  display: grid; place-items: center;
  border-radius: 50%;
  transition: background 400ms var(--ease-out);
  z-index: 1;
}
.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }
.lightbox-prev:hover, .lightbox-next:hover { background: rgba(255,255,255,0.08); }

.lightbox-image-wrap {
  display: flex; flex-direction: column; align-items: center;
  max-width: 80vw; max-height: 80vh;
}

.lightbox-img {
  max-width: 80vw;
  max-height: 72vh;
  object-fit: contain;
  box-shadow: 0 20px 80px rgba(0,0,0,0.6);
}

.lightbox-info {
  display: flex; gap: 16px;
  margin-top: 20px;
  align-items: center;
}
.lightbox-title {
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  color: var(--text-primary);
}
.lightbox-index {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ========== 响应式 ========== */
@media (max-width: 900px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
  .lightbox-prev, .lightbox-next {
    width: 48px; height: 48px; font-size: 2rem;
  }
  .lightbox-prev { left: 8px; }
  .lightbox-next { right: 8px; }
}

@media (max-width: 720px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
  }
  .nav-toggle { display: flex; }
  .site-nav {
    position: fixed; top: var(--header-h); left: 0; right: 0;
    flex-direction: column; gap: 0;
    background: rgba(10,10,10,0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 400ms var(--ease-out), opacity 300ms;
    pointer-events: none;
  }
  .site-nav.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .site-nav a {
    padding: 16px var(--pad-x);
    border-bottom: 1px solid var(--border-color);
  }
  .site-nav a::after { display: none; }
  .lightbox-img { max-width: 92vw; max-height: 60vh; }
  .hero-title-line { font-size: clamp(5rem, 22vw, 10rem); }
  .filter-bar { gap: 6px; }
  .filter-btn { font-size: 0.7rem; padding: 5px 14px; }
}

@media (min-width: 1400px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

/* ========== 无障碍：reduced motion ========== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .gallery-item { opacity: 1; transform: none; }
}

/* ========== No JS 兜底 ========== */
.gallery-grid:empty::after {
  content: '加载中…';
  display: block;
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  letter-spacing: 0.15em;
}
