/**
 * layout.css — 顶栏 / 主区 / 全站页脚
 * 目录：style/layout.css；配合 include/header.php、include/footer_site.php
 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: var(--color-header);
  color: var(--color-header-text);
  border-bottom: 1px solid var(--color-border);
  overflow: visible; /* 勿裁切下拉菜单 */
}

.site-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  color: inherit;
}
/* Logo SVG（include/logo-svg.php，参照 usd 站） */
.site-logo-svg {
  display: block;
  height: 32px;
  width: auto;
}
.site-logo-text {
  fill: var(--color-header-text);
  font-family: var(--font-sans);
}
.site-logo-text-main {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.site-logo-divider {
  stroke: var(--color-header-text);
  stroke-width: 1.5;
  opacity: 0.75;
}
.site-logo-text-brand {
  fill: var(--color-logo-brand);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.site-logo-text-sub {
  font-size: 18px;
  font-weight: 500;
}

.site-nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--color-header-text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.site-nav-toggle:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
}
.site-nav-toggle-bars {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav > li {
  position: relative;
}

.site-nav > li > a,
.site-nav > li > button {
  display: inline-flex;
  align-items: center;
  gap: 6px; /* 文案与下拉三角间距 */
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--color-header-muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 6px;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
/* 仅有下拉的 button：右侧 ▼，展开/悬停时翻成 ▲ */
.site-nav > li > button::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.55;
  transition: transform 0.15s var(--ease), opacity 0.15s var(--ease);
}
.site-nav > li.is-open > button::after {
  transform: rotate(180deg);
  opacity: 0.9;
}
.site-nav > li > a:hover,
.site-nav > li > button:hover,
.site-nav > li.is-open > button {
  color: var(--color-header-text);
  background: var(--color-header-hover);
}
.site-nav > li.is-active > a {
  color: var(--color-brand);
  font-weight: 600;
}

.site-nav-sub {
  display: none;
  position: absolute;
  top: 100%; /* 紧贴触发项，避免空隙导致悬停丢失 */
  left: 0;
  width: max-content; /* 随文字收窄，勿用过大 min-width */
  min-width: 0;
  max-width: min(240px, 92vw);
  max-height: min(70vh, 480px);
  overflow: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 120;
}
.site-nav > li.is-open > .site-nav-sub {
  display: block;
}
/* 桌面：鼠标悬停 / 键盘聚焦时展开下拉（对齐原 layui 习惯） */
@media (hover: hover) and (pointer: fine) and (min-width: 1025px) {
  .site-nav > li:hover > .site-nav-sub,
  .site-nav > li:focus-within > .site-nav-sub {
    display: block;
  }
  .site-nav > li:hover > button,
  .site-nav > li:focus-within > button {
    color: var(--color-header-text);
    background: var(--color-header-hover);
  }
  .site-nav > li:hover > button::after,
  .site-nav > li:focus-within > button::after {
    transform: rotate(180deg);
    opacity: 0.9;
  }
}
.site-nav-sub a {
  display: block;
  padding: 8px 12px;
  min-height: 40px;
  color: var(--color-header-muted);
  font-size: 13px;
  border-radius: 6px;
  line-height: 1.4;
  box-sizing: border-box;
  white-space: nowrap;
}
.site-nav-sub a:hover {
  color: var(--color-header-text);
  background: var(--color-header-hover);
}

.site-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px 16px 8px; /* 底部少留白，避免大事记与页脚之间大块空区 */
}

.site-footer {
  margin-top: 10px;
  padding: 16px 16px 20px;
  text-align: center;
  color: var(--color-muted);
  font-size: 13px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}
.site-footer p {
  margin: 0 0 4px;
}
.site-footer p:last-child {
  margin-bottom: 0;
}
.site-footer a {
  color: var(--color-text);
}
.site-footer a:hover {
  color: var(--color-brand);
}

@media (max-width: 1024px) {
  .site-nav-toggle {
    display: inline-flex;
  }
  .site-nav {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow);
    max-height: calc(100dvh - var(--nav-height));
    overflow: auto;
  }
  .site-header.is-nav-open .site-nav {
    display: flex;
  }
  .site-nav > li > a,
  .site-nav > li > button {
    width: 100%;
    justify-content: flex-start;
  }
  .site-nav-sub {
    position: static;
    display: none;
    width: auto;
    min-width: 0;
    max-width: none;
    max-height: none;
    box-shadow: none;
    border: 0;
    background: var(--color-surface-2);
    margin-top: 0;
  }
  .site-nav > li.is-open > .site-nav-sub {
    display: block;
  }
}
