/* ============================================================
   墨墨成长记 - 基础样式（布局 / 通用组件 / 交互状态）
   主题差异由 theme-*.css 通过 CSS 变量覆盖
   ============================================================ */

/* ---------- 设计令牌（默认值，主题文件会覆盖） ---------- */
:root {
  --bg: #fff8ec;
  --bg-alt: #fff1d6;
  --surface: #ffffff;
  --text: #3a2e1f;
  --text-muted: #8a7a63;
  --primary: #ff8a3d;
  --primary-soft: #ffd9b8;
  --accent: #4fc3f7;
  --accent-soft: #d6f0fd;
  --success: #66bb6a;
  --danger: #e57373;
  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --shadow-sm: 0 2px 8px rgba(90, 60, 20, 0.08);
  --shadow-md: 0 8px 24px rgba(90, 60, 20, 0.12);
  --shadow-lg: 0 16px 48px rgba(90, 60, 20, 0.18);
  --font-display: "YouYuan", "幼圆", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-body: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --header-h: 64px;
}

/* ---------- 基础重置 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background 0.5s var(--ease-out), color 0.5s var(--ease-out);
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- 顶部导航 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: color-mix(in oklch, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid color-mix(in oklch, var(--text) 8%, transparent);
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-badge {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.brand-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
}

.nav-links {
  margin-left: auto;
  display: flex;
  gap: 4px;
}
.nav-links a {
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  transition: color 0.25s var(--ease-out), background 0.25s var(--ease-out);
}
.nav-links a:hover { color: var(--text); background: var(--primary-soft); }

.theme-switcher {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.theme-btn {
  width: 40px; height: 40px;
  border: none;
  border-radius: 999px;
  background: transparent;
  font-size: 18px;
  display: grid; place-items: center;
  transition: transform 0.25s var(--ease-out), background 0.25s var(--ease-out);
}
.theme-btn:hover { transform: translateY(-2px) scale(1.08); }
.theme-btn.is-active { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(64px, 10vw, 120px) 20px clamp(56px, 8vw, 96px);
  text-align: center;
}
.hero-deco { position: absolute; inset: 0; pointer-events: none; }
/* 场景装饰元素：默认全部隐藏，由各主题 CSS 按需显示 */
.hero-deco .deco { display: none; }
.hero-inner { position: relative; max-width: 720px; margin: 0 auto; }

.hero-kicker {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 6px 16px;
  border-radius: 999px;
  margin-bottom: 20px;
}
.hero-title {
  font-family: var(--font-display);
  font-size: clamp(34px, 6vw, 60px);
  line-height: 1.2;
  font-weight: 700;
  margin-bottom: 14px;
}
.hero-sub {
  font-size: clamp(16px, 2.4vw, 20px);
  color: var(--text-muted);
  margin-bottom: 30px;
}
.hero-sub strong { color: var(--primary); font-size: 1.15em; }

.hero-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 26px;
  border: none;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 700;
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out), background 0.2s var(--ease-out);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-md); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.btn-ghost:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* ---------- 通用区块 ---------- */
.section-head { text-align: center; max-width: 640px; margin: 0 auto 36px; }
.section-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 4.5vw, 40px);
  font-weight: 700;
  margin-bottom: 10px;
}
.section-desc { color: var(--text-muted); font-size: 16px; }

.gallery, .guestbook { padding: clamp(48px, 8vw, 88px) 20px; }
.gallery { background: var(--bg); }
.guestbook { background: var(--bg-alt); }

/* ---------- 分类切换 ---------- */
.cat-tabs {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 36px;
}
.cat-tab {
  min-height: 44px;
  padding: 0 22px;
  border: none;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s var(--ease-out);
}
.cat-tab:hover { transform: translateY(-2px); color: var(--text); }
.cat-tab.is-active { background: var(--primary); color: #fff; box-shadow: var(--shadow-md); }

/* ---------- 相册内容 ---------- */
.gallery-content { max-width: 1100px; margin: 0 auto; }

.cat-panel { display: none; }
.cat-panel.is-active { display: block; animation: fadeUp 0.5s var(--ease-out); }

.cat-panel-head { text-align: center; margin-bottom: 28px; }
.cat-panel-head h3 {
  font-family: var(--font-display);
  font-size: clamp(22px, 3.5vw, 30px);
  margin-bottom: 4px;
}
.cat-panel-head p { color: var(--text-muted); }

/* 主图（突出显示） */
.feature-photo {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  margin-bottom: 28px;
  aspect-ratio: 4 / 3;
  background: var(--primary-soft);
}
.feature-photo img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--ease-out);
}
.feature-photo:hover img { transform: scale(1.04); }
.feature-badge {
  position: absolute;
  top: 16px; left: 16px;
  background: color-mix(in oklch, var(--primary) 88%, #fff);
  color: #fff;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}

/* 缩略图网格 */
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.thumb {
  position: relative;
  border: none;
  padding: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
}
.thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.4s var(--ease-out);
}
.thumb:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.thumb:hover img { transform: scale(1.08); }

/* 加载更多 */
.load-more-wrap { text-align: center; margin-top: 28px; }
.load-more-btn {
  min-height: 48px;
  padding: 0 30px;
  border: 2px dashed var(--primary);
  border-radius: 999px;
  background: transparent;
  color: var(--primary);
  font-size: 15px;
  font-weight: 700;
  transition: all 0.25s var(--ease-out);
}
.load-more-btn:hover { background: var(--primary-soft); transform: translateY(-2px); }
.load-more-btn:disabled { opacity: 0.5; cursor: default; transform: none; }

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.empty-state .empty-icon { font-size: 44px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ---------- 留言板 ---------- */
.guestbook-layout {
  max-width: 1000px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 32px;
  align-items: start;
}
@media (max-width: 820px) {
  .guestbook-layout { grid-template-columns: 1fr; }
}

.gb-form {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.gb-field { display: flex; flex-direction: column; gap: 8px; }
.gb-field span { font-size: 14px; font-weight: 700; color: var(--text-muted); }
.gb-field input,
.gb-field textarea {
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  border: 2px solid color-mix(in oklch, var(--text) 12%, transparent);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  transition: border-color 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
}
.gb-field input:focus,
.gb-field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.gb-submit { align-self: flex-start; }
.gb-tip { font-size: 14px; min-height: 20px; }
.gb-tip.is-error { color: var(--danger); }
.gb-tip.is-ok { color: var(--success); }

.gb-list-wrap { background: var(--surface); border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow-md); }
.gb-list-title { font-family: var(--font-display); font-size: 20px; margin-bottom: 18px; }
.gb-count {
  display: inline-block;
  min-width: 26px;
  text-align: center;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 999px;
  font-size: 13px;
  padding: 2px 8px;
  margin-left: 6px;
}
.gb-list { list-style: none; display: flex; flex-direction: column; gap: 14px; max-height: 480px; overflow-y: auto; }
.gb-item {
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  animation: fadeUp 0.4s var(--ease-out);
}
.gb-item-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.gb-item-name { font-weight: 700; font-size: 15px; }
.gb-item-time { font-size: 12px; color: var(--text-muted); }
.gb-item-content { font-size: 15px; word-break: break-word; white-space: pre-wrap; }
.gb-load-more-wrap { text-align: center; margin-top: 16px; }
.gb-load-more-btn {
  border: 1px solid var(--primary);
  background: transparent;
  color: var(--primary);
  padding: 8px 22px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s var(--ease-out), color 0.2s var(--ease-out);
}
.gb-load-more-btn:hover { background: var(--primary); color: #fff; }

/* ---------- 页脚 ---------- */
.site-footer {
  text-align: center;
  padding: 40px 20px;
  background: var(--text);
  color: color-mix(in oklch, var(--bg) 80%, #fff);
}
.site-footer p { font-size: 15px; }
.footer-sub { font-size: 13px; opacity: 0.7; margin-top: 6px; }

/* ---------- 灯箱 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(20, 15, 5, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  animation: fadeIn 0.3s var(--ease-out);
}
.lightbox[hidden] { display: none; }

/* ---------- 3D 球面轮播灯箱 ---------- */
.carousel {
  position: relative;
  width: 100%;
  height: 72vh;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1400px;
  perspective-origin: 50% 50%;
}
.carousel-img {
  position: absolute;
  max-width: min(70vw, 720px);
  max-height: 64vh;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  object-fit: contain;
  cursor: pointer;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform 0.65s var(--ease-out), opacity 0.65s var(--ease-out);
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.slot-center {
  transform: rotateY(0deg) translateZ(0px);
  opacity: 1;
  z-index: 3;
}
/* 左右照片额外往两边平移，避免被中间横向大图遮挡导致点不到 */
.slot-left {
  transform: translateX(-16vw) rotateY(48deg) translateZ(-420px);
  opacity: 0.55;
  z-index: 2;
}
.slot-right {
  transform: translateX(16vw) rotateY(-48deg) translateZ(-420px);
  opacity: 0.55;
  z-index: 2;
}
@media (max-width: 768px) {
  .slot-left {
    transform: translateX(-9vw) rotateY(48deg) translateZ(-300px);
  }
  .slot-right {
    transform: translateX(9vw) rotateY(-48deg) translateZ(-300px);
  }
}
.carousel-img.slot-left:hover,
.carousel-img.slot-right:hover {
  opacity: 0.85;
}
.lightbox-caption { color: #fff; font-size: 15px; }
.lightbox-close {
  position: absolute;
  top: 20px; right: 24px;
  width: 48px; height: 48px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  transition: background 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.3); transform: rotate(90deg); }

/* ---------- 动画 ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
