@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&family=Share+Tech+Mono&display=swap');

/* ===== 基础变量 ===== */
:root {
  --c-bg: #f5e6c8;
  --c-accent: #d4a574;
  --c-ink: #262117;
  --c-ink-2: #4a3c28;
  --c-ink-3: #7a6040;
  --c-accent-dark: #b8835a;
  --c-surface: #ede0c4;
  --c-surface-2: #e2d0a8;
  --font-mono: 'Share Tech Mono', 'Fira Code', 'Courier New', monospace;
  --bottom-nav-h: 56px;
  --header-h: 52px;
  --max-w: 1100px;
  --section-scroll-margin: calc(var(--bottom-nav-h) + 8px);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  font-size: 16px;
  background: var(--c-bg);
  color: var(--c-ink);
}
body {
  font-family: var(--font-mono);
  line-height: 1.7;
  min-height: 100vh;
  background: var(--c-bg);
  padding-bottom: calc(var(--bottom-nav-h) + 16px);
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--c-accent-dark); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--c-ink); }
ul, ol { list-style: none; }
h1,h2,h3,h4 { font-family: var(--font-mono); line-height: 1.3; color: var(--c-ink); }

/* ===== 胶片噪点层 ===== */
.grain-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-repeat: repeat;
  mix-blend-mode: overlay;
}

/* ===== 漏光动画 ===== */
.light-leak {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  height: 340px;
  pointer-events: none;
  z-index: 9998;
  background: radial-gradient(ellipse at top right, rgba(212,165,116,0.22) 0%, transparent 70%);
  animation: leak-pulse 8s ease-in-out infinite alternate;
}
@keyframes leak-pulse {
  0%   { opacity: 0.6; transform: scale(1) translateX(0); }
  100% { opacity: 1;   transform: scale(1.15) translateX(-20px); }
}
@media (prefers-reduced-motion: reduce) {
  .light-leak { animation: none; }
}

/* ===== 顶部页头 ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--c-ink);
  border-bottom: 2px solid var(--c-accent);
  height: var(--header-h);
}
.site-header__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
}
.site-logo {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--c-accent);
  text-decoration: none;
  letter-spacing: 0.08em;
  white-space: nowrap;
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 0 4px;
}
.site-logo:hover { color: var(--c-bg); }
.site-header__tagline {
  font-size: 0.72rem;
  color: var(--c-ink-3);
  display: none;
}
@media (min-width: 640px) {
  .site-header__tagline { display: block; }
}

/* ===== Hero ===== */
.hero {
  position: relative;
  height: 45vh;
  min-height: 240px;
  max-height: 520px;
  background: var(--c-ink);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}
.hero__media {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.hero__media img.hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: sepia(0.4) contrast(1.1) saturate(0.75) brightness(0.88);
}
.hero__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(38,33,23,0.2) 0%, rgba(38,33,23,0.72) 80%);
}
.hero__content {
  position: relative;
  z-index: 2;
  padding: 28px 24px;
  max-width: 680px;
}
.hero__badge {
  display: inline-block;
  background: var(--c-accent);
  color: var(--c-ink);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 3px 10px;
  margin-bottom: 10px;
  clip-path: polygon(6px 0%, 100% 0%, calc(100% - 6px) 100%, 0% 100%);
}
.hero__title {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  color: var(--c-bg);
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  text-shadow: 1px 2px 8px rgba(38,33,23,0.6);
}
.hero__sub {
  font-size: 0.9rem;
  color: var(--c-surface-2);
  line-height: 1.6;
}
/* 斜切底边 */
.hero__clip {
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 48px;
  background: var(--c-bg);
  clip-path: polygon(0 100%, 100% 0, 100% 100%);
  z-index: 3;
}

/* VHS 扫描线动画 */
@keyframes vhs-tracking {
  0%   { transform: translateY(0)   skewX(0deg);     opacity: 0.8; }
  18%  { transform: translateY(3px) skewX(-0.4deg);  opacity: 1; }
  36%  { transform: translateY(0)   skewX(0.3deg);   opacity: 0.9; }
  100% { transform: translateY(0)   skewX(0deg);     opacity: 0.8; }
}
@media (prefers-reduced-motion: reduce) {
  @keyframes vhs-tracking { 0%,100% { transform: none; opacity:1; } }
}

/* ===== 主内容区 ===== */
.site-main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 16px;
}
.content-section {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto;
  gap: 0 32px;
  padding: 32px 0 48px;
  position: relative;
}
@media (min-width: 800px) {
  .content-section {
    grid-template-columns: 1fr 280px;
    grid-template-areas:
      "vhs  aside"
      "body aside";
  }
  .vhs-frame  { grid-area: vhs; }
  .content-body { grid-area: body; }
  .content-aside { grid-area: aside; }
}

/* VHS 装饰框 */
.vhs-frame {
  position: relative;
  background: var(--c-ink);
  border: 2px solid var(--c-accent);
  border-bottom: 4px solid var(--c-accent);
  padding: 14px 18px 10px;
  margin-bottom: 24px;
  overflow: hidden;
  height: 64px;
}
.vhs-lines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(212,165,116,0.06) 3px,
    rgba(212,165,116,0.06) 4px
  );
  animation: vhs-tracking 4s ease-in-out infinite;
}
.vhs-label {
  position: relative;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--c-accent);
  letter-spacing: 0.2em;
  animation: blink-rec 1.2s step-end infinite;
}
@keyframes blink-rec {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.2; }
}
@media (prefers-reduced-motion: reduce) {
  .vhs-label { animation: none; }
}

/* ===== aside 侧栏 ===== */
.content-aside {
  border-left: 3px solid var(--c-accent);
  border-bottom: 4px solid var(--c-accent);
  background: var(--c-surface);
  padding: 20px 18px;
  margin-bottom: 32px;
  align-self: start;
  position: sticky;
  top: calc(var(--header-h) + 12px);
}
.aside-eyebrow {
  display: block;
  font-size: 0.68rem;
  color: var(--c-ink-3);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.aside-title {
  font-size: 0.95rem;
  color: var(--c-ink);
  font-weight: 600;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--c-accent);
  padding-bottom: 6px;
}
.aside-nav li { margin-bottom: 6px; }
.aside-nav a {
  font-size: 0.83rem;
  color: var(--c-ink-2);
  text-decoration: none;
  display: flex;
  align-items: center;
  padding: 8px;
  min-height: 40px;
  border-left: 2px solid transparent;
  position: relative;
  line-height: 1.5;
  transition: border-color 0.15s, background 0.15s;
}
.aside-nav a:hover {
  border-left-color: var(--c-accent);
  background: var(--c-surface-2);
  color: var(--c-ink);
}
.aside-nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--c-accent);
  transition: width 0.18s ease;
}
.aside-nav a:hover::after { width: 100%; }
.aside-notice {
  margin-top: 18px;
  padding: 10px 12px;
  background: var(--c-surface-2);
  border-bottom: 3px solid var(--c-accent-dark);
}
.notice-label {
  display: block;
  font-size: 0.66rem;
  color: var(--c-ink-3);
  letter-spacing: 0.15em;
  margin-bottom: 4px;
}
.aside-notice p { font-size: 0.8rem; color: var(--c-ink-2); }

/* ===== 正文区 ===== */
.content-body {
  min-width: 0;
}
.section-eyebrow {
  display: block;
  font-size: 0.68rem;
  color: var(--c-ink-3);
  letter-spacing: 0.2em;
  margin-bottom: 4px;
}
.section-title {
  font-size: 1.2rem;
  color: var(--c-ink);
  font-weight: 700;
  margin-bottom: 20px;
  padding-bottom: 8px;
  border-bottom: 3px solid var(--c-accent);
  position: relative;
}
.section-title::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 48px;
  height: 3px;
  background: var(--c-ink);
}

/* prose 正文样式 */
.prose {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--c-ink);
}
.prose h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 2em 0 0.6em;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--c-accent);
  color: var(--c-ink);
}
.prose h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.6em 0 0.5em;
  color: var(--c-ink-2);
}
.prose p { margin-bottom: 1em; }
.prose ul, .prose ol {
  margin: 0.8em 0 1em 1.2em;
  list-style: disc;
}
.prose ol { list-style: decimal; }
.prose li { margin-bottom: 0.4em; }
.prose a { color: var(--c-accent-dark); }
.prose strong { color: var(--c-ink); font-weight: 700; }
.prose blockquote {
  border-left: 3px solid var(--c-accent);
  border-bottom: 2px solid var(--c-accent);
  padding: 10px 16px;
  margin: 1.2em 0;
  background: var(--c-surface);
  font-style: italic;
  color: var(--c-ink-2);
}
.prose article {
  scroll-margin-top: var(--section-scroll-margin);
  margin-bottom: 20px;
  padding: 20px 18px;
  background: var(--c-surface);
  border-bottom: 4px solid var(--c-accent);
  transition: border-color 0.15s;
}
.prose article:last-child { border-bottom: 4px solid var(--c-accent); }
.prose article:hover { border-bottom-color: var(--c-ink); }
.prose article h2 { margin-top: 0; }
.prose figure img {
  filter: sepia(0.2) contrast(1.05) saturate(0.85);
  border: 3px solid var(--c-surface-2);
  border-bottom: 4px solid var(--c-accent);
}

/* article scroll margin for page-level sections */
article[id] {
  scroll-margin-top: var(--section-scroll-margin);
}

/* ===== 页脚 ===== */
.site-footer {
  background: var(--c-ink);
  color: var(--c-surface);
  border-top: 3px solid var(--c-accent);
  margin-top: 40px;
  padding: 18px 0;
}
.site-footer__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-logo a {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--c-accent);
  text-decoration: none;
  white-space: nowrap;
  min-height: 40px;
  display: flex;
  align-items: center;
}
.footer-logo a:hover { color: var(--c-bg); }
.footer-nav {
  flex: 1;
}
.footer-nav ol {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  list-style: none;
}
.footer-nav ol li a {
  font-size: 0.75rem;
  color: var(--c-ink-3);
  text-decoration: none;
  min-height: 40px;
  padding: 0 4px;
  display: flex;
  align-items: center;
}
.footer-nav ol li a:hover { color: var(--c-accent); }
.footer-copy {
  font-size: 0.72rem;
  color: var(--c-ink-3);
  white-space: nowrap;
}

/* ===== 底部固定导航条 ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 500;
  height: var(--bottom-nav-h);
  background: var(--c-ink);
  border-top: 2px solid var(--c-accent);
  display: flex;
  align-items: center;
  gap: 0;
  overflow: hidden;
}
.bottom-nav__brand {
  flex-shrink: 0;
  padding: 0 14px;
  border-right: 1px solid rgba(212,165,116,0.3);
  height: 100%;
  display: flex;
  align-items: center;
}
.bottom-nav__brand a {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--c-accent);
  text-decoration: none;
  white-space: nowrap;
  min-height: 40px;
  padding: 0 2px;
  display: flex;
  align-items: center;
}
.bottom-nav__brand a:hover { color: var(--c-bg); }
.bottom-nav__list {
  flex: 1;
  display: flex;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
  height: 100%;
  list-style: none;
}
.bottom-nav__list::-webkit-scrollbar { display: none; }
.bottom-nav__list li {
  flex-shrink: 0;
}
.bottom-nav__list li a {
  display: flex;
  align-items: center;
  height: var(--bottom-nav-h);
  min-height: 40px;
  padding: 0 12px;
  font-size: 0.73rem;
  color: var(--c-surface);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.04em;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.bottom-nav__list li a:hover {
  color: var(--c-accent);
  border-bottom-color: var(--c-accent);
  background: rgba(212,165,116,0.08);
}
.bottom-nav__search {
  flex-shrink: 0;
  padding: 0 10px;
  border-left: 1px solid rgba(212,165,116,0.3);
  height: 100%;
  display: flex;
  align-items: center;
}
.bottom-search-input {
  background: rgba(212,165,116,0.1);
  border: 1px solid var(--c-accent);
  color: var(--c-bg);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 6px 10px;
  width: 110px;
  outline: none;
  border-radius: 0;
  height: 34px;
  transition: background 0.15s, width 0.2s;
}
.bottom-search-input::placeholder { color: var(--c-ink-3); }
.bottom-search-input:focus {
  background: rgba(212,165,116,0.18);
  border-color: var(--c-bg);
  width: 150px;
}

/* ===== 动效：淡入 + 错落 ===== */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
.hero__content,
.content-section,
.vhs-frame {
  animation: fade-up 0.55s ease both;
}
.content-aside  { animation: fade-up 0.55s 0.12s ease both; }
.content-body   { animation: fade-up 0.55s 0.2s ease both; }
@media (prefers-reduced-motion: reduce) {
  .hero__content,
  .content-section,
  .vhs-frame,
  .content-aside,
  .content-body { animation: none; }
}

/* ===== 响应式 ===== */
@media (max-width: 799px) {
  .content-section { grid-template-columns: 1fr; }
  .content-aside {
    position: static;
    border-left: none;
    border-top: 3px solid var(--c-accent);
    margin-bottom: 24px;
  }
  .hero { height: 42vh; }
  .hero__clip { height: 32px; }
  .site-footer__inner { flex-direction: column; align-items: flex-start; gap: 10px; }
  .footer-nav ol { gap: 2px 8px; }
}
@media (max-width: 479px) {
  .bottom-search-input { width: 80px; }
  .bottom-search-input:focus { width: 100px; }
  .hero__title { font-size: 1.4rem; }
}

/* ===== VHS stagger on list items ===== */
.aside-nav li:nth-child(1) { animation: fade-up 0.4s 0.05s both; }
.aside-nav li:nth-child(2) { animation: fade-up 0.4s 0.10s both; }
.aside-nav li:nth-child(3) { animation: fade-up 0.4s 0.15s both; }
.aside-nav li:nth-child(4) { animation: fade-up 0.4s 0.20s both; }
.aside-nav li:nth-child(5) { animation: fade-up 0.4s 0.25s both; }
.aside-nav li:nth-child(6) { animation: fade-up 0.4s 0.30s both; }
.aside-nav li:nth-child(7) { animation: fade-up 0.4s 0.35s both; }
@media (prefers-reduced-motion: reduce) {
  .aside-nav li { animation: none; }
}
