@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@300;400;500;600;700&family=Noto+Sans:wght@300;400;500;600;700&display=swap');

/* ===== 变量 ===== */
:root {
  --c-bg: #f5e6c8;
  --c-amber: #d4a574;
  --c-ink: #262117;
  --c-ink-soft: #4a3c28;
  --c-amber-dark: #b8885a;
  --c-amber-pale: #f0d4a8;
  --c-amber-faint: #f8f0e0;
  --c-white: #fffdf7;
  --c-border: #d4a574;
  --font-main: 'Be Vietnam Pro', 'Noto Sans', system-ui, sans-serif;
  --radius: 10px;
  --max-content: 900px;
  --max-wide: 1200px;
  --grain-opacity: 0.06;
}

/* ===== SVG 颗粒 filter ===== */
svg.grain-svg { position: fixed; width: 0; height: 0; }

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background-color: var(--c-bg);
  color: var(--c-ink);
  font-family: var(--font-main);
  font-size: 17px;
  line-height: 1.7;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--c-amber-dark); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--c-ink); }
h1, h2, h3, h4 { font-weight: 700; line-height: 1.3; color: var(--c-ink); }
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); margin-bottom: 0.5em; }
h2 { font-size: clamp(1.25rem, 3vw, 1.7rem); margin-bottom: 0.4em; }
h3 { font-size: 1.1rem; margin-bottom: 0.4em; }
p { margin-bottom: 1em; }
hr {
  border: none;
  border-top: 1.5px solid var(--c-amber);
  margin: 1.2em 0 1.4em;
  opacity: 0.7;
}
time { font-size: 0.88rem; color: var(--c-ink-soft); }

/* ===== Grain overlay ===== */
.grain-overlay {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 9998;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23g)' opacity='0.12'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  opacity: var(--grain-opacity);
  animation: grain-shift 0.8s steps(2) infinite;
}
@keyframes grain-shift {
  0%   { background-position: 0 0; }
  25%  { background-position: 40px -20px; }
  50%  { background-position: -30px 15px; }
  75%  { background-position: 20px 40px; }
  100% { background-position: -10px -30px; }
}

/* ===== Light leak ===== */
.light-leak {
  pointer-events: none;
  position: fixed;
  top: -20%;
  right: -15%;
  width: 55%;
  height: 70%;
  z-index: 9997;
  background: radial-gradient(ellipse at 70% 30%, rgba(212,165,116,0.18) 0%, rgba(245,230,200,0.06) 50%, transparent 75%);
  animation: leak-drift 12s ease-in-out infinite alternate;
}
@keyframes leak-drift {
  from { transform: translate(0, 0) scale(1); opacity: 0.8; }
  to   { transform: translate(-4%, 6%) scale(1.06); opacity: 1; }
}

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 500;
  background: var(--c-bg);
  border-bottom: 2px solid var(--c-amber);
  filter: sepia(0.08) contrast(1.02) saturate(0.9);
}
.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--c-amber-pale);
  gap: 1rem;
}
.brand-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.brand-logo-img { width: 36px; height: 36px; object-fit: contain; border-radius: 4px; }
.brand-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--c-ink);
  text-decoration: none;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.brand-name:hover { color: var(--c-amber-dark); }
.brand-tagline {
  font-size: 0.78rem;
  color: var(--c-ink-soft);
  font-weight: 300;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}
.header-cta {
  background: var(--c-ink);
  color: var(--c-bg);
  text-decoration: none;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border: 1.5px solid var(--c-ink);
  transition: background 0.2s, color 0.2s;
}
.header-cta:hover {
  background: var(--c-amber-dark);
  color: var(--c-white);
  border-color: var(--c-amber-dark);
}

/* 导航：header > nav > p > a */
.main-nav {
  padding: 0 1.5rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }
.main-nav > p {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  align-items: stretch;
  min-height: 44px;
  margin: 0;
}
.main-nav > p > a {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 0.85rem;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--c-ink-soft);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  min-height: 44px;
}
.main-nav > p > a:hover { color: var(--c-ink); border-bottom-color: var(--c-amber); }
.main-nav > p > a[aria-current="page"] { color: var(--c-ink); border-bottom-color: var(--c-ink); font-weight: 700; }

/* ===== Main container ===== */
.page-main {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ===== Hero (Home) ===== */
.hero-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  align-items: center;
  min-height: 70vh;
  padding: 2rem 0;
  background-image: radial-gradient(circle, rgba(212,165,116,0.15) 1px, transparent 1px);
  background-size: 22px 22px;
  border-radius: var(--radius);
  margin-bottom: 3rem;
  padding: 2.5rem;
}
.hero-figure {
  position: relative;
  border: 2px solid var(--c-amber);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--c-amber-faint);
}
.hero-img {
  width: 100%;
  height: 420px;
  object-fit: cover;
  filter: sepia(0.25) contrast(1.05) saturate(0.85);
  display: block;
}
.hero-placeholder {
  width: 100%;
  height: 420px;
  background: linear-gradient(135deg, var(--c-amber-faint) 0%, var(--c-amber-pale) 60%, var(--c-amber) 100%);
  opacity: 0.5;
}
.hero-vhs-line {
  position: absolute;
  left: 0; right: 0;
  height: 3px;
  background: rgba(245,230,200,0.6);
  animation: vhs-scan 4s linear infinite;
  pointer-events: none;
}
@keyframes vhs-scan {
  0%   { top: -5%; opacity: 0; }
  10%  { opacity: 0.9; }
  90%  { opacity: 0.7; }
  100% { top: 105%; opacity: 0; }
}
.hero-text {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1rem;
}
.hero-text h1 { text-align: right; font-size: clamp(1.8rem, 4vw, 2.8rem); }
.hero-desc {
  font-size: 1rem;
  color: var(--c-ink-soft);
  max-width: 360px;
  text-align: right;
  margin-bottom: 0;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  background: var(--c-amber);
  color: var(--c-ink);
  text-decoration: none;
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.95rem;
  border: 2px solid var(--c-amber-dark);
  transition: background 0.2s, color 0.2s;
  min-height: 44px;
}
.btn-primary:hover { background: var(--c-ink); color: var(--c-bg); }

/* ===== Section spacing ===== */
.topics-section,
.articles-section,
.topic-intro-section,
.topic-children-section,
.article-section,
.about-section,
.privacy-section,
.tag-section,
.tag-list-section,
.child-list {
  margin-bottom: 3rem;
}

/* ===== Layout: content + aside ===== */
.topic-intro-section,
.article-section,
.about-section,
.privacy-section,
.tag-section {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 2.5rem;
  align-items: start;
}
.article-section .article-body { min-width: 0; }

/* ===== Aside ===== */
.page-aside {
  background: var(--c-amber-faint);
  border: 1.5px solid var(--c-amber);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: sticky;
  top: 120px;
}
.page-aside h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.2em; }
.aside-link {
  display: block;
  padding: 0.4rem 0;
  font-size: 0.88rem;
  color: var(--c-ink-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--c-amber-pale);
  transition: color 0.15s, padding-left 0.15s;
}
.aside-link:last-child { border-bottom: none; }
.aside-link:hover { color: var(--c-ink); padding-left: 0.3rem; }
.aside-parent { font-weight: 600; color: var(--c-amber-dark); }

/* ===== Card grid ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
.card {
  border: 1.5px solid var(--c-amber);
  border-radius: var(--radius);
  padding: 1.2rem;
  background: var(--c-white);
  transition: border-color 0.2s, transform 0.2s;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.card:hover { border-color: var(--c-ink); transform: translateY(-2px); }
.card-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--c-ink);
  text-decoration: none;
  line-height: 1.4;
}
.card-title:hover { color: var(--c-amber-dark); text-decoration: underline; }
.card-desc { font-size: 0.85rem; color: var(--c-ink-soft); line-height: 1.5; flex: 1; margin-bottom: 0; }
.card-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--c-amber-dark);
  text-decoration: none;
  align-self: flex-start;
}
.card-link:hover { text-decoration: underline; }

/* ===== Tables ===== */
.article-table,
.children-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin-top: 1rem;
}
.article-table td,
.children-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--c-amber-pale);
  vertical-align: top;
}
.article-table tr:hover td,
.children-table tr:hover td { background: var(--c-amber-faint); }
.article-table td:first-child a,
.children-table td:first-child a,
.child-title-cell a {
  font-weight: 600;
  color: var(--c-ink);
  text-decoration: none;
}
.article-table td:first-child a:hover,
.children-table td:first-child a:hover,
.child-title-cell a:hover { color: var(--c-amber-dark); text-decoration: underline; }
.child-desc-cell { color: var(--c-ink-soft); }
.child-date-cell { white-space: nowrap; font-size: 0.82rem; color: var(--c-ink-soft); }

/* ===== Prose ===== */
.prose { max-width: 680px; }
.prose h2 { margin-top: 2em; }
.prose h3 { margin-top: 1.5em; }
.prose ul, .prose ol { padding-left: 1.5em; margin-bottom: 1em; }
.prose li { margin-bottom: 0.4em; }
.prose blockquote {
  border-left: 3px solid var(--c-amber);
  margin: 1.5em 0;
  padding: 0.75em 1.25em;
  background: var(--c-amber-faint);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
  color: var(--c-ink-soft);
}
.prose code {
  background: var(--c-amber-pale);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: monospace;
}
.prose img {
  border-radius: var(--radius);
  border: 1.5px solid var(--c-amber);
  filter: sepia(0.2) contrast(1.04) saturate(0.88);
  margin: 1.5em 0;
}

/* ===== Date line ===== */
.date-line {
  font-size: 0.85rem;
  color: var(--c-ink-soft);
  margin-bottom: 1.2em;
  display: flex;
  gap: 0.5em;
  flex-wrap: wrap;
}

/* ===== Article meta ===== */
.article-meta {
  font-size: 0.85rem;
  color: var(--c-ink-soft);
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em;
  align-items: center;
}
.article-meta a { font-size: 0.85rem; }

/* ===== Tags ===== */
.article-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem; }
.tag-chip {
  background: var(--c-amber-pale);
  border: 1px solid var(--c-amber);
  border-radius: 20px;
  padding: 0.25rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--c-ink);
  text-decoration: none;
}
.tag-chip:hover { background: var(--c-amber); color: var(--c-ink); }

/* ===== Hero figures (non-home) ===== */
.topic-hero-figure,
.article-hero-figure {
  position: relative;
  border: 2px solid var(--c-amber);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.topic-hero-img,
.article-hero-img {
  width: 100%;
  max-height: 340px;
  object-fit: cover;
  filter: sepia(0.2) contrast(1.04) saturate(0.88);
}
.article-hero-figure figcaption {
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  color: var(--c-ink-soft);
  background: var(--c-amber-faint);
  border-top: 1px solid var(--c-amber-pale);
}

/* ===== About stamp ===== */
.about-stamp {
  display: inline-block;
  border: 3px double var(--c-amber);
  border-radius: 6px;
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--c-amber-faint);
  filter: sepia(0.3) saturate(0.8);
  transform: rotate(-1.5deg);
}
.stamp-inner {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--c-amber-dark);
  text-transform: uppercase;
}

/* ===== Footer ===== */
.site-footer {
  margin-top: 4rem;
  padding: 2.5rem 1.5rem 1.5rem;
  border-top: 2px solid var(--c-amber);
  text-align: center;
  background: var(--c-bg);
}
.site-footer > p.footer-brand {
  font-size: clamp(2rem, 6vw, 4rem);
  font-weight: 700;
  color: var(--c-ink);
  letter-spacing: 0.04em;
  opacity: 0.12;
  line-height: 1;
  margin-bottom: 1rem;
  user-select: none;
}
.site-footer > small {
  display: block;
  font-size: 0.82rem;
  color: var(--c-ink-soft);
  margin-top: 0.5rem;
}
.site-footer > small a { color: var(--c-amber-dark); }

/* ===== Stagger animation ===== */
@media (prefers-reduced-motion: no-preference) {
  .card { animation: fade-up 0.4s ease both; }
  .card:nth-child(1) { animation-delay: 0s; }
  .card:nth-child(2) { animation-delay: 0.07s; }
  .card:nth-child(3) { animation-delay: 0.14s; }
  .card:nth-child(4) { animation-delay: 0.21s; }
  .card:nth-child(5) { animation-delay: 0.28s; }
  .card:nth-child(6) { animation-delay: 0.35s; }

  .hero-text { animation: fade-in 0.6s ease 0.2s both; }
  .hero-figure { animation: fade-in 0.6s ease 0s both; }

  @keyframes fade-up {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  @keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
}
@media (prefers-reduced-motion: reduce) {
  .grain-overlay, .light-leak, .hero-vhs-line { animation: none !important; }
}

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .topic-intro-section,
  .article-section,
  .about-section,
  .privacy-section,
  .tag-section {
    grid-template-columns: 1fr;
  }
  .page-aside { position: static; }
  .hero-section {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 1.5rem;
  }
  .hero-text { align-items: flex-start; text-align: left; }
  .hero-text h1 { text-align: left; }
  .hero-desc { text-align: left; }
  .hero-img, .hero-placeholder { height: 260px; }
}

@media (max-width: 600px) {
  body { font-size: 16px; }
  .page-main { padding: 1.25rem 1rem; }
  .brand-row { padding: 0.6rem 1rem; }
  .main-nav { padding: 0 0.5rem; }
  .main-nav > p > a { padding: 0.5rem 0.55rem; font-size: 0.78rem; }
  .card-grid { grid-template-columns: 1fr; }
  .article-table td:nth-child(2),
  .children-table .child-desc-cell { display: none; }
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.2rem; }
  .site-footer > p.footer-brand { font-size: 2rem; }
  .hero-section { padding: 1rem; gap: 1.5rem; }
}
