/* 站点骨架：header / footer / container / 文章双栏 */

.site {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 24px;
}

.site-header {
  padding: 32px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 48px;
}

.site-header .container {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--fg);
  border-bottom: 0;
  letter-spacing: -0.01em;
}
.brand:hover { color: var(--accent); border-bottom: 0; }

.nav {
  display: flex;
  gap: 20px;
  align-items: center;
  font-size: 0.95rem;
}
.nav a { color: var(--fg-muted); border-bottom: 0; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--fg); }

/* 汉堡按钮：默认隐藏，仅在窄屏显示 */
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 6px;
  border-radius: 4px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}
.nav-toggle:hover { border-color: var(--fg-muted); }

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  padding: 6px 12px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  min-height: 32px;
  transition: color 150ms ease, border-color 150ms ease;
}
.theme-toggle:hover { color: var(--fg); border-color: var(--fg-muted); }

.site-footer {
  margin-top: 96px;
  padding: 32px 0;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--fg-muted);
}
.site-footer .container {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

main { flex: 1; }

/* 文章双栏 */
.post-layout {
  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    minmax(auto, var(--content-width))
    minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}
.post-layout > article { grid-column: 2; min-width: 0; }
.post-layout > .toc {
  grid-column: 3;
  width: var(--toc-width);
  position: sticky;
  top: 32px;
  font-size: 0.85rem;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

.toc-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-subtle);
  margin: 0 0 12px;
  font-weight: 600;
}
.toc ul { list-style: none; padding: 0; margin: 0; }
.toc li { margin: 6px 0; line-height: 1.5; }
.toc li.lvl-3 { padding-left: 14px; }
.toc a {
  color: var(--fg-muted);
  border-bottom: 0;
  transition: color 150ms ease;
  display: block;
}
.toc a:hover { color: var(--fg); }
.toc a.active { color: var(--accent); }

@media (max-width: 1024px) {
  .post-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .post-layout > article {
    grid-column: 1;
    max-width: var(--content-width);
    margin: 0 auto;
  }
  .post-layout > .toc { display: none; }
}

@media (max-width: 640px) {
  body { font-size: 16px; letter-spacing: 0.005em; }
  .container { padding: 0 16px; }
  .site-header { padding: 16px 0 14px; margin-bottom: 24px; }
  .site-header .container { gap: 12px; flex-wrap: nowrap; }

  /* 顶部导航折叠为汉堡：nav 默认隐藏，展开时全宽下拉 */
  .nav-toggle { display: inline-flex; }
  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--bg);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px 14px;
    z-index: 50;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
  }
  .site-header { position: relative; }
  .nav.is-open { display: flex; }
  .nav a {
    padding: 12px 4px;
    border-bottom: 1px solid var(--border);
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .nav a:last-of-type { border-bottom: 0; }
  .nav .theme-toggle { margin-top: 10px; align-self: flex-start; }
}
