/* ============================================
   三圃居画室 — 东方雅集风格
   ============================================ */

:root {
  --bg: #F8F5F0;
  --card-bg: #FFFFFF;
  --text-primary: #1A1A1A;
  --text-muted: #888888;
  --accent: #8B7355;
  --accent-light: #C4A882;
  --shadow: rgba(0, 0, 0, 0.08);
  --shadow-md: rgba(0, 0, 0, 0.12);
  --border: rgba(0, 0, 0, 0.06);
  --font-serif: 'Noto Serif SC', 'STSong', 'SimSun', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --gap: 20px;
  --radius: 4px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ───────────────────────────────── */
.site-header {
  position: relative;
  text-align: center;
  padding: 60px 24px 40px;
}

.language-switch {
  position: absolute;
  top: 18px;
  right: 24px;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
}

.language-btn {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  min-width: 48px;
  padding: 5px 10px;
  transition: background 0.2s ease, color 0.2s ease;
}

.language-btn:hover,
.language-btn.active {
  background: var(--accent);
  color: #fff;
}

.site-title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.12em;
  margin-bottom: 12px;
}

.site-subtitle {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--accent);
  letter-spacing: 0.3em;
}

/* ── Filter Bar ───────────────────────────── */
.filter-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  transition: box-shadow 0.2s ease;
}

.filter-bar.scrolled {
  box-shadow: 0 2px 16px var(--shadow-md);
}

.filter-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.filter-btn {
  background: transparent;
  border: 1px solid var(--accent-light);
  color: var(--accent);
  font-family: var(--font-serif);
  font-size: 0.9rem;
  padding: 6px 20px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.05em;
}

.filter-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.filter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.filter-chip {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 4px 14px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.03em;
}

.filter-chip:hover {
  border-color: var(--accent-light);
  color: var(--accent);
}

.filter-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.theme-filters {
  opacity: 1;
  transition: opacity 0.2s ease;
}

.theme-filters.dimmed {
  opacity: 0.35;
  pointer-events: none;
}

/* ── Gallery Grid ─────────────────────────── */
.gallery {
  flex: 1;
  padding: 40px 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.gallery-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 2px 12px var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  opacity: 0;
  transform: translateY(16px);
}

.gallery-card.visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.5s ease, transform 0.5s ease, box-shadow 0.25s ease;
}

.gallery-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 28px var(--shadow-md);
}

.gallery-card-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--bg);
}

.gallery-card-body {
  padding: 16px;
}

.gallery-card-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.gallery-card-size {
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* ── Footer ───────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 32px 24px;
  color: var(--text-muted);
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

/* ── Lightbox ──────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.lightbox.open {
  opacity: 1;
  pointer-events: all;
}

.lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 18, 14, 0.88);
  backdrop-filter: blur(4px);
}

.lightbox-content {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  width: 95vw;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
}

.lightbox-close {
  position: absolute;
  top: -46px;
  right: -2px;
  background: rgba(255,255,255,0.06);
  border: none;
  border-radius: 50%;
  color: rgba(255,255,255,0.8);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  padding: 8px 14px;
  transition: background 0.2s, color 0.2s;
  z-index: 2;
}

.lightbox-close:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.lightbox-body {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  max-height: 90vh;
}

.lightbox-image-wrap {
  flex: 0 0 72%;
  position: relative;
  min-height: 300px;
}

.lightbox-image {
  width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius);
  display: block;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.15);
  border: none;
  color: rgba(255,255,255,0.9);
  font-size: 2.6rem;
  line-height: 1;
  padding: 12px 16px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.2s;
  backdrop-filter: blur(4px);
}

.lightbox-nav:hover {
  background: rgba(255,255,255,0.25);
}

.lightbox-nav:disabled {
  opacity: 0;
  pointer-events: none;
}

.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }

.lightbox-info {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  max-height: 85vh;
}

.lightbox-title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 600;
  color: #F8F5F0;
  margin-bottom: 10px;
  line-height: 1.35;
}

.lightbox-meta {
  font-size: 0.85rem;
  color: var(--accent-light);
  margin-bottom: 16px;
  letter-spacing: 0.05em;
}

.lightbox-desc {
  font-size: 0.9rem;
  color: rgba(248, 245, 240, 0.75);
  line-height: 1.8;
  padding-right: 4px;
}

/* ── Desktop Fullscreen Toggle ── */
.lightbox-fit {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 4px;
  color: rgba(255,255,255,0.7);
  font-size: 1rem;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.2s;
  opacity: 0;
}

.lightbox-image-wrap:hover .lightbox-fit {
  opacity: 1;
}

/* ── Responsive ─────────────────────────────── */
@media (max-width: 900px) {
  .gallery {
    grid-template-columns: repeat(2, 1fr);
  }
  .lightbox {
    align-items: flex-end;
  }
  .lightbox-content {
    max-width: 100vw;
    width: 100vw;
    max-height: 100vh;
  }
  .lightbox-body {
    flex-direction: column;
    gap: 12px;
    max-height: 95vh;
  }
  .lightbox-image-wrap {
    flex: 0 0 auto;
    min-height: auto;
    width: 100%;
  }
  .lightbox-image {
    max-height: 60vh;
    width: 100%;
  }
  .lightbox-info {
    max-height: 30vh;
    padding: 0 16px 20px;
  }
  .lightbox-close {
    top: 12px;
    right: 12px;
    background: rgba(0,0,0,0.4);
    font-size: 1.6rem;
    padding: 6px 12px;
  }
  .lightbox-prev { left: 8px; }
  .lightbox-next { right: 8px; }
  .lightbox-nav {
    background: rgba(0,0,0,0.45);
    font-size: 2rem;
    padding: 10px 12px;
  }
}

@media (max-width: 560px) {
  .gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 24px 16px;
  }
  .site-header {
    padding: 58px 16px 28px;
  }
  .language-switch {
    left: 50%;
    right: auto;
    top: 14px;
    transform: translateX(-50%);
  }
  .language-btn {
    min-width: 42px;
    padding: 4px 8px;
  }
  .filter-bar {
    padding: 12px 16px;
  }
  .filter-btn {
    font-size: 0.82rem;
    padding: 5px 14px;
  }
  .filter-chip {
    font-size: 0.76rem;
    padding: 3px 10px;
  }
}
