/* ===== Theme Variables ===== */
:root {
  --bg: #faf8f5;
  --text: #2a2520;
  --text-light: #6b5e53;
  --accent: #8b6f47;
  --border: #e8e0d5;
  --card-bg: #f0ebe0;
  --overlay: rgba(10, 8, 5, 0.95);
  --hero-bg: transparent;
  --hero-overlay: transparent;
}

body.dark {
  --bg: #1a1714;
  --text: #d4cfc7;
  --text-light: #8a8075;
  --accent: #b8935a;
  --border: #2e2922;
  --card-bg: #252118;
  --overlay: rgba(5, 4, 2, 0.97);
}

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

body {
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", Georgia, serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
  position: relative;
}
body::before {
  content: '';
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background-image: var(--bg-image, none);
  background-size: cover; background-position: center;
  z-index: -1; opacity: var(--bg-overlay-opacity, 0.92);
  transition: opacity 0.5s;
}
body.dark::before { opacity: calc(var(--bg-overlay-opacity, 0.92) - 0.25); }
body[data-has-bg="true"]::before { display: block; }

a { color: inherit; text-decoration: none; }

/* ===== Theme Toggle ===== */
.theme-toggle {
  background: none; border: 1px solid var(--border); color: var(--text-light);
  padding: 0.3rem 0.6rem; border-radius: 20px; cursor: pointer; font-size: 0.85rem;
  transition: all 0.2s;
}
.theme-toggle:hover { border-color: var(--text); color: var(--text); }

/* ===== Header ===== */
.site-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 100;
}
.nav {
  max-width: 1200px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center;
}
.nav-left { display: flex; align-items: center; gap: 2rem; }
.logo { font-size: 1.3rem; font-weight: 700; letter-spacing: 0.05em; }
.nav-links { display: flex; gap: 1.8rem; }
.nav-links a { font-size: 0.95rem; color: var(--text-light); transition: color 0.2s; }
.nav-links a:hover, .nav-links a.active { color: var(--text); }

/* ===== Home ===== */
.home { max-width: 1200px; margin: 0 auto; padding: 0 2rem; }
.hero {
  padding: 6rem 0 4rem; text-align: center;
  background-image: var(--hero-bg);
  background-size: cover; background-position: center;
  position: relative;
}
.hero::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--hero-overlay);
}
.hero > * { position: relative; z-index: 1; }
.hero h1 { font-size: 3.5rem; font-weight: 700; letter-spacing: 0.05em; }
.hero .dot { color: var(--accent); }
.hero .subtitle { margin-top: 1rem; font-size: 1.1rem; color: var(--text-light); line-height: 2; }
.hero .hero-credit { margin-top: 1.5rem; font-size: 0.8rem; color: var(--text-light); opacity: 0.6; }

/* WIP badge */
.wip-badge { display: inline-block; margin-top: 1.2rem; padding: 0.4rem 1rem; border: 1px solid var(--border); border-radius: 20px; font-size: 0.85rem; color: var(--text-light); }
.wip-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #4a9; margin-right: 0.4rem; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* Sponsor CTA */
.sponsor-cta { text-align: center; padding: 2rem 2rem 4rem; }
.sponsor-cta p { color: var(--text-light); line-height: 2; margin-bottom: 1.2rem; }

.home-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; padding-bottom: 2rem; }
.home-card { display: block; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; transition: transform 0.2s, box-shadow 0.2s; }
.home-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.08); }
.card-image { height: 160px; display: flex; align-items: center; justify-content: center; }
.card-icon { font-size: 2.5rem; }
.card-text { padding: 1.2rem 1.5rem; }
.card-text h2 { font-size: 1.2rem; margin-bottom: 0.3rem; }
.card-text p { font-size: 0.85rem; color: var(--text-light); }

/* ===== Gallery Page ===== */
.gallery-page { max-width: 1200px; margin: 0 auto; padding: 2rem; }
.gallery-page h1 { font-size: 2rem; margin-bottom: 0.5rem; }
.gallery-page .section-desc { color: var(--text-light); margin-bottom: 2rem; }

.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.gallery-item { cursor: pointer; overflow: hidden; border-radius: 6px; aspect-ratio: 4/3; background: var(--card-bg); transition: transform 0.2s; }
.gallery-item:hover { transform: scale(1.02); }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-item.placeholder { display: flex; align-items: center; justify-content: center; color: var(--text-light); font-size: 0.9rem; text-align: center; line-height: 1.6; }

/* ===== Lightbox ===== */
.lightbox { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--overlay); z-index: 1000; flex-direction: column; align-items: center; justify-content: center; }
.lightbox.active { display: flex; }
.lightbox img { max-width: 90vw; max-height: 80vh; object-fit: contain; border-radius: 4px; }
.lightbox-caption { color: #ccc; margin-top: 0.8rem; font-size: 0.9rem; }
.lightbox-close { position: absolute; top: 1.5rem; right: 2rem; font-size: 2rem; color: #fff; cursor: pointer; background: none; border: none; }
.lightbox-prev, .lightbox-next { position: absolute; top: 50%; transform: translateY(-50%); font-size: 2rem; color: #fff; cursor: pointer; background: none; border: none; padding: 1rem; }
.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }
.lightbox-counter { position: absolute; bottom: 2rem; color: #999; font-size: 0.85rem; }

/* ===== Writing Page ===== */
.writing-list { max-width: 1200px; margin: 0 auto; padding: 2rem; }
.writing-list h1 { font-size: 2rem; margin-bottom: 2rem; }
.article-card { display: block; padding: 1.8rem 0; border-bottom: 1px solid var(--border); transition: opacity 0.2s; }
.article-card:hover { opacity: 0.7; }
.article-card h2 { font-size: 1.3rem; margin-bottom: 0.3rem; }
.article-card .meta { font-size: 0.85rem; color: var(--text-light); }
.article-card .excerpt { margin-top: 0.5rem; color: var(--text-light); font-size: 0.95rem; }

/* ===== Article Page ===== */
.article { max-width: 680px; margin: 0 auto; padding: 3rem 2rem; }
.article h1 { font-size: 2rem; margin-bottom: 0.5rem; }
.article .meta { color: var(--text-light); font-size: 0.9rem; margin-bottom: 2.5rem; }
.article .body { font-size: 1.05rem; line-height: 2; }
.article .body p { margin-bottom: 1.5rem; }
.article .body img { max-width: 100%; border-radius: 6px; margin: 2rem 0; }
.article .body blockquote { border-left: 3px solid var(--accent); margin: 2rem 0; padding: 0.5rem 1.5rem; color: var(--text-light); font-style: italic; }

/* ===== About Page ===== */
.about-page { max-width: 680px; margin: 0 auto; padding: 3rem 2rem; }
.about-page h1 { font-size: 2rem; margin-bottom: 2rem; }
.about-page p { margin-bottom: 1.5rem; line-height: 2; }

/* ===== Footer ===== */
.site-footer { max-width: 1200px; margin: 0 auto; padding: 2rem; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; color: var(--text-light); }
.footer-links { display: flex; gap: 1.5rem; }

/* ===== CTA ===== */
.cta-section { text-align: center; padding: 3rem 2rem; }
.cta-section p { color: var(--text-light); margin-bottom: 1rem; }
.cta-btn { display: inline-block; padding: 0.8rem 2rem; border: 1px solid var(--text); border-radius: 4px; font-size: 0.95rem; transition: all 0.2s; }
.cta-btn:hover { background: var(--text); color: var(--bg); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .home-grid { grid-template-columns: 1fr 1fr; }
  .hero h1 { font-size: 2.5rem; }
  .nav { flex-direction: column; gap: 0.5rem; }
  .nav-left { flex-direction: column; gap: 0.5rem; }
  .nav-links { gap: 1.2rem; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .article { padding: 2rem 1rem; }
}
