/* ============================================
   YLLCR Valley — 星露谷风格回忆网站
   设计规范参考 docs/design-spec.md
   ============================================ */

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

:root {
  /* 配色 */
  --soil: #D4A754;
  --soil-dark: #C49A3C;
  --soil-light: #E8C97A;
  --green: #6B8E23;
  --green-dark: #4A6B14;
  --green-light: #8DC54B;
  --brown: #5D3A1A;
  --brown-dark: #3E2410;
  --brown-light: #8B5E3C;
  --cream: #FFF8DC;
  --cream-dark: #F5E6C8;
  --red: #C04040;
  --gold: #FFD700;
  --sky: #87CEEB;
  --white: #FFFEF9;

  /* 尺寸 */
  --nav-btn-width: 150px;
  --nav-btn-height: 50px;
  --border-width: 4px;

  /* 字体 */
  --font-pixel: 'Press Start 2P', monospace;
}

html, body {
  width: 100%;
  min-height: 100vh;
  font-family: var(--font-pixel);
  color: var(--brown-dark);
  overflow-x: hidden;
  /* 天空渐变背景 */
  background: linear-gradient(
    to bottom,
    var(--sky) 0%,
    #B0D4F1 30%,
    #C8DFA6 60%,
    var(--soil) 75%,
    var(--green) 90%,
    var(--green-dark) 100%
  );
  background-attachment: fixed;
}

/* 农田纹理叠加层（用伪元素实现像素点阵） */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.08;
  background:
    /* 像素点阵纹理 - 模拟农田格子 */
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(93, 58, 26, 0.3) 3px,
      rgba(93, 58, 26, 0.3) 4px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 3px,
      rgba(93, 58, 26, 0.3) 3px,
      rgba(93, 58, 26, 0.3) 4px
    );
}

/* ===== 导航栏 ===== */
.nav-bar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px 16px;
  background: var(--green);
  border-bottom: 6px solid var(--brown);
  box-shadow: 0 4px 0 var(--brown-dark);
  position: sticky;
  top: 0;
  z-index: 100;
  /* 木纹纹理 */
  background-image:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 8px,
      rgba(0,0,0,0.05) 8px,
      rgba(0,0,0,0.05) 10px
    );
  background-color: var(--green);
}

/* 木头按钮 */
.nav-btn {
  font-family: var(--font-pixel);
  font-size: 12px;
  color: var(--brown-dark);
  background: var(--soil-dark);
  border: var(--border-width) solid var(--brown);
  padding: 12px 20px;
  cursor: pointer;
  position: relative;
  /* 像素凸起效果 */
  box-shadow:
    inset -3px -3px 0 0 var(--brown-light),
    inset 3px 3px 0 0 var(--soil-light);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  image-rendering: pixelated;
}

.nav-btn:hover {
  transform: translateY(-3px);
  box-shadow:
    inset -3px -3px 0 0 var(--brown-light),
    inset 3px 3px 0 0 var(--soil-light),
    0 4px 0 var(--brown-dark);
}

.nav-btn:active,
.nav-btn.active {
  transform: translateY(0);
  box-shadow:
    inset 3px 3px 0 0 var(--brown-dark),
    inset -3px -3px 0 0 var(--brown-light);
  background: var(--brown-light);
  color: var(--cream);
}

/* ===== 页面区域 ===== */
.page {
  display: none;
  padding: 40px 20px 120px;
  min-height: calc(100vh - 200px);
}

.page.active {
  display: block;
  animation: pageFadeIn 0.4s ease-out;
}

@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== 首页 ===== */
.main-title {
  font-size: 36px;
  text-align: center;
  margin-top: 60px;
  color: var(--brown-dark);
  text-shadow:
    3px 3px 0 var(--soil-light),
    -1px -1px 0 var(--brown);
  letter-spacing: 4px;
  animation: titleBreath 2s ease-in-out infinite;
  position: relative;
  z-index: 1;
}

@keyframes titleBreath {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.7; }
}

.subtitle {
  text-align: center;
  font-size: 12px;
  color: var(--brown-light);
  margin-top: 16px;
  letter-spacing: 2px;
  position: relative;
  z-index: 1;
}

/* 欢迎对话框 */
.welcome-dialog {
  margin-top: 50px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.welcome-dialog p {
  margin-bottom: 8px;
}

.welcome-dialog p:last-child {
  margin-bottom: 0;
}

/* 像素装饰 */
.pixel-decorations {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.pixel-heart,
.pixel-star {
  position: absolute;
  font-size: 20px;
  animation: floatUpDown 3s ease-in-out infinite;
}

.pixel-heart-1 { top: 80px; left: 15%; animation-delay: 0s; }
.pixel-heart-2 { top: 120px; right: 15%; animation-delay: 1.5s; }
.pixel-star-1  { top: 60px; left: 30%; animation-delay: 0.7s; font-size: 16px; }
.pixel-star-2  { top: 140px; right: 25%; animation-delay: 2.2s; font-size: 18px; }

@keyframes floatUpDown {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-12px); }
}

/* ===== 页面标题 ===== */
.page-title {
  font-size: 20px;
  text-align: center;
  margin-bottom: 30px;
  color: var(--brown-dark);
  padding: 16px;
  background: var(--cream);
  border: var(--border-width) solid var(--brown);
  box-shadow: inset -3px -3px 0 0 var(--cream-dark);
  display: inline-block;
}

/* ===== 照片格子布局 ===== */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 130px);
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}

/* ===== 视频网格 ===== */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

/* ===== 纪念日时间线 ===== */
.timeline {
  margin-top: 20px;
}

.countdown-box {
  text-align: center;
  padding: 20px;
  background: var(--cream);
  border: var(--border-width) solid var(--brown);
  box-shadow: inset -3px -3px 0 0 var(--cream-dark);
  margin-bottom: 30px;
}

/* ===== 信件列表 ===== */
.letters-list {
  margin-top: 20px;
}

/* ===== 筛选按钮栏 ===== */
.filter-bar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.filter-btn {
  font-family: var(--font-pixel);
  font-size: 10px;
  padding: 8px 16px;
  background: var(--cream);
  border: 2px solid var(--brown);
  color: var(--brown-dark);
  cursor: pointer;
}

.filter-btn:hover,
.filter-btn.active {
  background: var(--soil);
  border-color: var(--brown-dark);
}

/* ===== 云朵层 ===== */
.clouds-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}

.pixel-cloud {
  position: absolute;
  image-rendering: pixelated;
  /* 像素云朵用 box-shadow 绘制 */
  width: 16px;
  height: 16px;
  background: var(--white);
  opacity: 0.85;
}

.pixel-cloud::before,
.pixel-cloud::after {
  content: '';
  position: absolute;
  background: var(--white);
}

/* 云朵形状通过不同尺寸组合 */
.cloud-sm { transform: scale(2); }
.cloud-md { transform: scale(3); }
.cloud-lg { transform: scale(4); }

/* 云朵飘过动画 */
@keyframes cloudDrift {
  from { transform: translateX(110vw); }
  to   { transform: translateX(-200px); }
}

/* ===== 底部草丛 ===== */
.grass-area {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: var(--green);
  border-top: 4px solid var(--green-dark);
  z-index: 50;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  overflow: hidden;
}

/* 像素草丛叶片 */
.grass-blade {
  width: 12px;
  background: var(--green-light);
  border-radius: 1px;
  animation: grassSway 2s ease-in-out infinite;
  transform-origin: bottom center;
  position: relative;
}

.grass-blade::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 50%;
  background: var(--green-dark);
  border-radius: 1px;
}

.grass-blade-1 { height: 28px; animation-delay: 0s; }
.grass-blade-2 { height: 36px; animation-delay: 0.2s; }
.grass-blade-3 { height: 24px; animation-delay: 0.5s; }
.grass-blade-4 { height: 40px; animation-delay: 0.3s; }
.grass-blade-5 { height: 30px; animation-delay: 0.7s; }
.grass-blade-6 { height: 34px; animation-delay: 0.1s; }
.grass-blade-7 { height: 26px; animation-delay: 0.4s; }
.grass-blade-8 { height: 38px; animation-delay: 0.6s; }

@keyframes grassSway {
  0%, 100% { transform: rotate(-3deg); }
  50%      { transform: rotate(3deg); }
}

/* ===== 像素圣诞树 ===== */
.christmas-tree {
  position: fixed;
  right: 28px;
  bottom: 60px;
  width: 110px;
  height: 170px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

/* 树顶星星 */
.tree-star {
  font-size: 28px;
  z-index: 5;
  animation: starGlow 1s ease-in-out infinite;
  filter: drop-shadow(0 0 6px var(--gold));
}

@keyframes starGlow {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 6px var(--gold)); }
  50%      { transform: scale(1.2); filter: drop-shadow(0 0 14px #FFED4A); }
}

/* 树层（用 border 做三角形 + box-shadow 做像素锯齿） */
.tree-layer {
  width: 0;
  height: 0;
  border-left-style: solid;
  border-right-style: solid;
  border-bottom-style: solid;
  border-left-color: transparent;
  border-right-color: transparent;
  position: relative;
}

/* 顶层 */
.tree-top {
  border-left-width: 28px;
  border-right-width: 28px;
  border-bottom-width: 36px;
  border-bottom-color: #2D8B2D;
  margin-top: -2px;
  z-index: 3;
}

/* 中层 */
.tree-mid {
  border-left-width: 38px;
  border-right-width: 38px;
  border-bottom-width: 42px;
  border-bottom-color: #237323;
  margin-top: -8px;
  z-index: 2;
}

/* 底层 */
.tree-bot {
  border-left-width: 50px;
  border-right-width: 50px;
  border-bottom-width: 48px;
  border-bottom-color: #1A5C1A;
  margin-top: -8px;
  z-index: 1;
}

/* 树干 */
.tree-trunk {
  width: 22px;
  height: 24px;
  background: #8B5E3C;
  border-left: 2px solid #6B3F1F;
  border-right: 2px solid #6B3F1F;
  border-bottom: 3px solid #5D3A1A;
  margin-top: -4px;
  z-index: 0;
}

/* 彩色灯光 */
.tree-light {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 0;  /* 像素感：方形 */
  animation: lightBlink 1.5s steps(1) infinite;
}

.light-1 { bottom: 105px; left: 38px;  background: #FF4444; animation-delay: 0s; }
.light-2 { bottom: 115px; left: 50px;  background: #FFD700; animation-delay: 0.3s; }
.light-3 { bottom: 90px;  left: 56px;  background: #4488FF; animation-delay: 0.7s; }
.light-4 { bottom: 75px;  left: 46px;  background: #FF44FF; animation-delay: 1.1s; }
.light-5 { bottom: 60px;  left: 32px;  background: #FFD700; animation-delay: 0.5s; }
.light-6 { bottom: 50px;  left: 58px;  background: #44FF44; animation-delay: 0.9s; }

@keyframes lightBlink {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px currentColor; }
  33%       { opacity: 0.3; box-shadow: none; }
  66%       { opacity: 1; box-shadow: 0 0 6px currentColor; }
}

/* 手机上缩小树并调整位置 */
@media (max-width: 768px) {
  .christmas-tree {
    right: 8px;
    bottom: 52px;
    transform: scale(0.65);
    transform-origin: right bottom;
  }
}

/* ===== 照片放大灯箱 ===== */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(62, 36, 16, 0.9);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.lightbox.show {
  display: flex;
}

.lightbox img {
  max-width: 85vw;
  max-height: 75vh;
  border: 6px solid var(--brown);
  box-shadow: 0 0 0 4px var(--soil), 0 0 30px rgba(0,0,0,0.5);
  background: var(--cream);
  padding: 8px;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  font-family: var(--font-pixel);
  font-size: 24px;
  color: var(--cream);
  background: var(--red);
  border: 3px solid var(--brown-dark);
  width: 48px;
  height: 48px;
  cursor: pointer;
}

.lightbox-close:hover {
  background: #d04040;
}

.lightbox-caption {
  color: var(--cream);
  font-size: 12px;
  margin-top: 16px;
}

/* ===== 像素对话框（星露谷风格） ===== */
.dialog-box {
  background: var(--cream);
  border: 6px solid var(--brown);
  box-shadow:
    inset -4px -4px 0 0 var(--cream-dark),
    inset 4px 4px 0 0 var(--white),
    0 4px 0 var(--brown-dark);
  padding: 24px;
  margin: 16px auto;
  max-width: 600px;
  font-size: 12px;
  line-height: 2;
  position: relative;
}

/* 对话框底部的小三角 */
.dialog-box::after {
  content: '';
  position: absolute;
  bottom: -18px;
  left: 30px;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 14px solid var(--brown);
}

/* ===== 背包格子（照片用） ===== */
.inventory-slot {
  width: 130px;
  height: 130px;
  background: var(--cream);
  border: 3px solid var(--brown);
  box-shadow:
    inset -2px -2px 0 0 var(--brown-light),
    inset 2px 2px 0 0 var(--white);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  image-rendering: pixelated;
}

.inventory-slot:hover {
  border-color: var(--gold);
  box-shadow:
    inset -2px -2px 0 0 var(--brown-light),
    inset 2px 2px 0 0 var(--white),
    0 0 12px var(--gold);
  transform: scale(1.05);
  z-index: 10;
}

.inventory-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ===== 像素卡片（通用） ===== */
.pixel-card {
  background: var(--cream);
  border: 4px solid var(--brown);
  box-shadow:
    inset -3px -3px 0 0 var(--cream-dark),
    inset 3px 3px 0 0 var(--white),
    0 3px 0 var(--brown-dark);
  padding: 16px;
  font-size: 11px;
  line-height: 1.8;
}

/* ===== 视频卡片 ===== */
.video-card {
  background: var(--cream);
  border: 4px solid var(--brown);
  box-shadow:
    inset -3px -3px 0 0 var(--cream-dark),
    inset 3px 3px 0 0 var(--white),
    0 3px 0 var(--brown-dark);
  overflow: hidden;
}

.video-card iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  display: block;
}

.video-card .video-info {
  padding: 12px 16px;
  font-size: 11px;
}

/* ===== 纪念日节点 ===== */
.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--cream);
  border: 3px solid var(--brown);
  box-shadow:
    inset -2px -2px 0 0 var(--cream-dark),
    inset 2px 2px 0 0 var(--white);
}

.timeline-icon {
  width: 48px;
  height: 48px;
  min-width: 48px;
  background: var(--soil);
  border: 3px solid var(--brown);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.timeline-content {
  flex: 1;
}

.timeline-content .date {
  font-size: 10px;
  color: var(--brown-light);
  margin-bottom: 4px;
}

.timeline-content .title {
  font-size: 12px;
  color: var(--brown-dark);
}

/* ===== 信件信封 ===== */
.letter-envelope {
  background: var(--cream);
  border: 4px solid var(--brown);
  box-shadow:
    inset -3px -3px 0 0 var(--cream-dark),
    inset 3px 3px 0 0 var(--white);
  padding: 20px;
  margin-bottom: 16px;
  cursor: pointer;
  transition: transform 0.15s;
  position: relative;
}

.letter-envelope:hover {
  transform: scale(1.02);
}

/* 信封封口三角 */
.letter-envelope::before {
  content: '';
  position: absolute;
  top: 0;
  right: 30px;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-top: 16px solid var(--red);
}

.letter-envelope .envelope-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.letter-envelope .envelope-title {
  font-size: 12px;
}

.letter-envelope .envelope-date {
  font-size: 10px;
  color: var(--brown-light);
}

.letter-envelope .envelope-content {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px dashed var(--brown-light);
  font-size: 11px;
  line-height: 2;
}

.letter-envelope.open .envelope-content {
  display: block;
}

/* ===== 倒计时 ===== */
.countdown-digits {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

.countdown-digit {
  background: var(--brown-dark);
  color: var(--gold);
  font-size: 24px;
  padding: 8px 12px;
  border: 2px solid var(--brown);
  box-shadow: inset 0 0 8px rgba(0,0,0,0.5);
  min-width: 48px;
  text-align: center;
}

.countdown-label {
  font-size: 9px;
  color: var(--brown-light);
  text-align: center;
  margin-top: 4px;
}

/* ===== 占位文字 ===== */
.placeholder-text {
  text-align: center;
  color: var(--brown-light);
  font-size: 12px;
  padding: 40px;
  width: 100%;
  grid-column: 1 / -1;
}

/* ===== 汉堡菜单按钮 ===== */
.hamburger {
  display: none;
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 200;
  width: 44px;
  height: 36px;
  background: var(--soil-dark);
  border: 3px solid var(--brown);
  cursor: pointer;
  padding: 6px;
  flex-direction: column;
  justify-content: space-around;
  box-shadow:
    inset -2px -2px 0 0 var(--brown-light),
    inset 2px 2px 0 0 var(--soil-light);
}

.hamburger span {
  display: block;
  height: 3px;
  background: var(--brown-dark);
  border-radius: 0;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .hamburger {
    display: flex;
  }

  .nav-bar {
    gap: 4px;
    padding: 12px 8px;
    flex-direction: column;
    align-items: center;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    z-index: 150;
    display: none;
    border-bottom: 4px solid var(--brown);
    box-shadow: 0 4px 0 var(--brown-dark);
  }

  .nav-bar.show {
    display: flex;
  }

  .nav-btn {
    font-size: 10px;
    padding: 10px 14px;
    width: 80%;
    max-width: 250px;
    text-align: center;
  }

  .main-title {
    font-size: 22px;
    margin-top: 30px;
  }

  .subtitle {
    font-size: 10px;
  }

  .inventory-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .inventory-slot {
    width: 100%;
    aspect-ratio: 1;
  }

  .video-grid {
    grid-template-columns: 1fr;
  }

  .page-title {
    font-size: 14px;
  }

  .page {
    padding: 20px 10px 120px;
  }

  .dialog-box {
    margin: 12px 10px;
    padding: 16px;
    font-size: 10px;
  }

  .welcome-dialog {
    margin-top: 30px;
  }

  .pixel-heart,
  .pixel-star {
    font-size: 14px;
  }

  .timeline-item {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .lightbox img {
    max-width: 95vw;
    max-height: 70vh;
  }

  .filter-bar {
    gap: 4px;
  }

  .filter-btn {
    font-size: 8px;
    padding: 6px 10px;
  }
}

/* 极小屏 */
@media (max-width: 400px) {
  .inventory-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
