/* ==========================================================================
   开元棋盘会馆 · 共享样式 /assets/site.css
   蓝图网格 / 矿物色 / 棋盘落点
   ========================================================================== */

:root {
  --green: #0F3B33;
  --green-deep: #071E1A;
  --gold: #C7A34A;
  --gold-light: #E8D6A9;
  --coral: #C1523C;
  --lapis: #2C4C8A;
  --board: #B7B0A3;
  --stone: #6E6A62;
  --clay: #A9714E;
  --rice: #F7F2E7;
  --ink: #12171A;

  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", serif;
  --sans: "Noto Sans SC", "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --shell-x: 40px;
  --hard-shadow: 6px 6px 0 rgba(7, 30, 26, 0.16);
  --hairline: rgba(110, 106, 98, 0.3);
  --gold-line: rgba(199, 163, 74, 0.3);
}

/* ---------- 1. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body, h1, h2, h3, h4, h5, p, ul, ol, li, figure, blockquote, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg, video { display: block; max-width: 100%; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
button, input, select, textarea { font: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }
a { color: var(--lapis); text-decoration: none; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- 2. 基础排版 ---------- */
body {
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.85;
  color: var(--ink);
  background-color: var(--rice);
  min-height: 100vh;
}

h1, h2, h3, h4, h5 {
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1.28;
  letter-spacing: 0.02em;
  color: var(--green-deep);
}
h1 { font-size: clamp(32px, 5.2vw, 60px); }
h2 { font-size: clamp(24px, 3.2vw, 34px); }
h3 { font-size: 22px; }
h4 { font-size: 18px; font-weight: 600; }

.num,
[data-year] { font-family: var(--mono); letter-spacing: 0.06em; }

/* ---------- 3. 容器与栅格 ---------- */
.shell {
  width: min(1200px, calc(100% - var(--shell-x) * 2));
  margin-inline: auto;
}

.grid { display: grid; gap: 28px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1000px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- 4. 页头 ---------- */
.skip-link {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 60;
  padding: 10px 20px;
  background: var(--gold);
  color: var(--green-deep);
  font-size: 14px;
  font-weight: 600;
  border: 2px solid var(--green-deep);
  transform: translate(-50%, -130%);
  transition: transform 0.18s ease;
}
.skip-link:focus { transform: translate(-50%, 0); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 80;
  background: var(--green);
}

.masthead {
  background: var(--green);
  border-bottom: 2px solid var(--green-deep);
}
.masthead__inner {
  position: relative;
  padding: 30px 0 26px;
  text-align: center;
  transition: padding 0.22s ease;
}
.masthead__tagline {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  color: var(--gold-light);
  margin-bottom: 12px;
}
.masthead__brand {
  display: inline-block;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(30px, 4.6vw, 48px);
  line-height: 1.15;
  letter-spacing: 0.14em;
  text-indent: 0.14em;
  color: var(--rice);
  border-bottom: 2px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease, font-size 0.22s ease;
}
.masthead__brand:hover {
  color: var(--gold-light);
  border-bottom-color: var(--gold);
}
.masthead__now {
  position: absolute;
  right: 0;
  bottom: 26px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--gold-light);
  transition: opacity 0.2s ease;
}
.masthead__siege {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  background: linear-gradient(var(--gold), var(--gold)) center / 55% 55% no-repeat;
  flex: none;
}
.masthead__now-label { color: var(--board); }

@media (max-width: 1040px) {
  .masthead__now {
    position: static;
    justify-content: center;
    margin-top: 14px;
  }
}

/* 导航条 */
.site-nav {
  background: var(--green-deep);
  border-bottom: 2px solid var(--gold);
}
.site-nav__inner {
  display: flex;
  align-items: center;
  justify-content: center;
}
.site-nav__list {
  display: flex;
  align-items: stretch;
}
.site-nav__item { display: flex; }
.site-nav__link {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 16px 26px 16px 20px;
  color: var(--gold-light);
  font-size: 15px;
  letter-spacing: 0.04em;
  border-left: 1px solid rgba(199, 163, 74, 0.18);
  transition: color 0.2s ease, background 0.2s ease, padding 0.22s ease;
}
.site-nav__item:last-child .site-nav__link {
  border-right: 1px solid rgba(199, 163, 74, 0.18);
}
.site-nav__link::after {
  content: "";
  position: absolute;
  right: 11px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  opacity: 0;
  transform: translateY(-50%) scale(0.4);
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
}
.site-nav__link:hover {
  color: var(--rice);
  background: rgba(199, 163, 74, 0.1);
}
.site-nav__link:hover::after {
  opacity: 0.7;
  transform: translateY(-50%) scale(1);
}
.site-nav__link[aria-current="page"] {
  color: var(--rice);
  background: rgba(199, 163, 74, 0.16);
  box-shadow: inset 0 3px 0 var(--gold);
}
.site-nav__link[aria-current="page"]::after {
  opacity: 1;
  background: var(--gold);
  transform: translateY(-50%) scale(1);
}
.site-nav__num {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--gold);
}

/* 移动端栏目开关 */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 15px 4px;
  color: var(--gold-light);
  font-size: 15px;
  letter-spacing: 0.14em;
}
.nav-toggle__bars {
  display: grid;
  gap: 4px;
  width: 22px;
  flex: none;
}
.nav-toggle__bars i {
  display: block;
  height: 2px;
  background: var(--gold);
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.site-nav[data-open="true"] .nav-toggle__bars i:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.site-nav[data-open="true"] .nav-toggle__bars i:nth-child(2) { opacity: 0; }
.site-nav[data-open="true"] .nav-toggle__bars i:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 900px) {
  .site-nav__inner {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
  }
  .nav-toggle { display: flex; }
  .site-nav__list {
    display: none;
    flex-direction: column;
    width: 100%;
    border-top: 1px solid var(--gold-line);
  }
  .site-nav[data-open="true"] .site-nav__list { display: flex; }
  .site-nav__item { display: block; }
  .site-nav__link {
    justify-content: flex-start;
    padding: 15px 20px;
    border-left: 0;
    border-bottom: 1px solid rgba(199, 163, 74, 0.14);
  }
  .site-nav__item:last-child .site-nav__link { border-right: 0; }
  .site-nav__link::after { right: 20px; }
  .site-nav__link[aria-current="page"] { box-shadow: inset 3px 0 0 var(--gold); }
}

/* 快速入口条 */
.quickbar {
  background-color: var(--rice);
  background-image:
    linear-gradient(45deg, rgba(183, 176, 163, 0.16) 25%, transparent 25%, transparent 75%, rgba(183, 176, 163, 0.16) 75%),
    linear-gradient(45deg, rgba(183, 176, 163, 0.16) 25%, transparent 25%, transparent 75%, rgba(183, 176, 163, 0.16) 75%);
  background-size: 32px 32px;
  background-position: 0 0, 16px 16px;
  border-bottom: 1px solid var(--hairline);
}
.quickbar__inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}
.quickbar__label {
  margin-right: auto;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--stone);
}
.quickbar__link {
  font-size: 13px;
  color: var(--green);
  padding: 4px 12px;
  background: rgba(247, 242, 231, 0.85);
  border: 1.5px solid rgba(15, 59, 51, 0.4);
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.quickbar__link:hover {
  background: var(--green);
  color: var(--rice);
  border-color: var(--green);
}

@media (max-width: 720px) {
  .quickbar { display: none; }
}

/* 页头收缩态 */
.site-header.is-compact .masthead__inner { padding: 8px 0; }
.site-header.is-compact .masthead__tagline { display: none; }
.site-header.is-compact .masthead__brand { font-size: 22px; letter-spacing: 0.18em; }
.site-header.is-compact .masthead__now { opacity: 0; visibility: hidden; }
.site-header.is-compact .site-nav__link { padding-top: 11px; padding-bottom: 11px; }

@media (max-width: 1040px) {
  .site-header.is-compact .masthead__now { display: none; }
}

/* 返回顶部 */
.to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 90;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--green);
  color: var(--gold-light);
  border: 2px solid var(--gold);
  font-size: 12px;
  letter-spacing: 0.04em;
  box-shadow: 4px 4px 0 rgba(7, 30, 26, 0.3);
  transition: transform 0.18s ease, background 0.2s ease;
}
.to-top:hover { transform: translateY(-3px); background: var(--green-deep); }
.to-top[hidden] { display: none; }

/* ---------- 5. 页脚 ---------- */
.site-footer {
  margin-top: 88px;
  background: var(--green-deep);
  color: var(--gold-light);
  border-top: 2px solid var(--gold);
  font-size: 14.5px;
  line-height: 1.8;
}
.site-footer a {
  color: var(--gold-light);
  border-bottom: 1px solid rgba(199, 163, 74, 0.35);
  transition: color 0.2s ease, border-color 0.2s ease;
}
.site-footer a:hover { color: var(--gold); border-bottom-color: var(--gold); }

.footer__top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 46px 0 26px;
  border-bottom: 1px solid var(--gold-line);
}
.footer__brand {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--rice);
  line-height: 1.3;
}
.footer__motto {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--gold);
  margin-top: 4px;
}
.footer__cta { flex: none; }

.footer__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 36px;
  padding: 38px 0 46px;
}
.footer__col-title {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--rice);
  padding-bottom: 10px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--gold-line);
}
.footer__list li { margin-bottom: 9px; }
.footer__contact li { margin-bottom: 12px; }
.footer__contact strong {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--gold);
  margin-bottom: 2px;
}
.footer__note {
  margin-top: 16px;
  padding-left: 12px;
  border-left: 2px solid var(--clay);
  font-size: 13px;
  line-height: 1.75;
  color: var(--board);
}

.footer__legal {
  border-top: 1px solid var(--gold-line);
  padding: 18px 0;
}
.footer__legal-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.06em;
  color: var(--board);
}

@media (max-width: 900px) {
  .footer__grid { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .footer__top { padding-top: 36px; }
}

/* ---------- 6. 通用按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--green-deep);
  background: transparent;
  border: 2px solid var(--green-deep);
  box-shadow: 4px 4px 0 rgba(7, 30, 26, 0.16);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.2s ease, color 0.2s ease;
}
.btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 rgba(7, 30, 26, 0.24);
}
.btn:active { transform: translate(0, 0); box-shadow: 2px 2px 0 rgba(7, 30, 26, 0.2); }
.btn--gold { background: var(--gold); color: var(--green-deep); }
.btn--gold:hover { background: var(--gold-light); }
.btn--solid { background: var(--green); color: var(--rice); }
.btn--solid:hover { background: var(--green-deep); }
.btn--ghost {
  border-color: var(--gold);
  color: var(--gold-light);
  box-shadow: none;
}
.btn--ghost:hover {
  background: rgba(199, 163, 74, 0.14);
  transform: none;
  box-shadow: none;
}

/* ---------- 7. 分区与标题带 ---------- */
.section { padding: 72px 0; }
.section--tight { padding: 44px 0; }
.section--dark {
  background: var(--green);
  color: var(--rice);
}
.section--dark h2,
.section--dark h3,
.section--dark h4 { color: var(--rice); }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  margin-bottom: 34px;
  border-bottom: 2px solid var(--green);
}
.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.26em;
  color: var(--stone);
  margin-bottom: 10px;
}
.section--dark .eyebrow { color: var(--gold); }

.rule {
  height: 0;
  border: 0;
  border-top: 1px solid var(--hairline);
  margin: 40px 0;
}

/* ---------- 8. 正文长文 ---------- */
.prose { max-width: 70ch; font-size: 17px; }
.prose > * + * { margin-top: 1.05em; }
.prose h2 { margin-top: 2em; }
.prose h3 { margin-top: 1.6em; }
.prose ul,
.prose ol { padding-left: 1.4em; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li { margin-bottom: 0.45em; }
.prose a,
main a {
  color: var(--lapis);
  text-decoration: underline;
  text-decoration-color: rgba(44, 76, 138, 0.45);
  text-underline-offset: 3px;
}
.prose a:hover,
main a:hover {
  color: var(--coral);
  text-decoration-color: currentColor;
}

/* ---------- 9. 卡片 / 标签 / 横带 ---------- */
.card {
  position: relative;
  padding: 26px 24px;
  background: var(--rice);
  border: 2px solid rgba(15, 59, 51, 0.28);
}
.card--flat { box-shadow: none; }
a.card,
.card--interactive {
  display: block;
  color: inherit;
  border-color: var(--green-deep);
  box-shadow: var(--hard-shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
a.card:hover,
.card--interactive:hover {
  transform: translate(-3px, -3px);
  box-shadow: 9px 9px 0 rgba(7, 30, 26, 0.2);
}
a.card:hover .card__title,
.card--interactive:hover .card__title { color: var(--clay); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  border: 1px solid currentColor;
  color: var(--stone);
}
.tag--coral { color: var(--coral); }
.tag--lapis { color: var(--lapis); }
.tag--gold {
  background: var(--gold-light);
  border-color: var(--gold);
  color: var(--green-deep);
}
.tag--clay {
  background: var(--clay);
  border-color: var(--clay);
  color: var(--rice);
}

.band {
  padding: 26px 0;
  background: var(--green);
  color: var(--rice);
  border-top: 2px solid var(--gold);
  border-bottom: 2px solid var(--gold);
}
.band--light {
  background: var(--gold-light);
  color: var(--green-deep);
  border-color: var(--green-deep);
}

.board-bg {
  background-color: var(--rice);
  background-image:
    linear-gradient(45deg, rgba(183, 176, 163, 0.18) 25%, transparent 25%, transparent 75%, rgba(183, 176, 163, 0.18) 75%),
    linear-gradient(45deg, rgba(183, 176, 163, 0.18) 25%, transparent 25%, transparent 75%, rgba(183, 176, 163, 0.18) 75%);
  background-size: 44px 44px;
  background-position: 0 0, 22px 22px;
}

/* ---------- 10. 面包屑 ---------- */
.breadcrumb {
  padding-top: 20px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--stone);
}
.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.breadcrumb li::after {
  content: "/";
  margin-left: 8px;
  color: var(--board);
}
.breadcrumb li:last-child::after { content: ""; }
.breadcrumb a { color: var(--lapis); }
.breadcrumb a:hover { border-bottom: 1px solid currentColor; }

/* ---------- 11. 章节索引布局 ---------- */
.index-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 52px;
  align-items: start;
}
.toc {
  position: sticky;
  top: 152px;
  padding-left: 18px;
  border-left: 2px solid var(--green);
}
.toc__title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--stone);
  margin-bottom: 14px;
}
.toc__list li { margin-bottom: 4px; }
.toc__link {
  position: relative;
  display: block;
  padding: 5px 0 5px 20px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--stone);
  transition: color 0.2s ease;
}
.toc__link::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--board);
  transform: translateY(-50%);
  transition: background 0.2s ease, border-color 0.2s ease;
}
.toc__link:hover { color: var(--green); }
.toc__link[aria-current="true"] { color: var(--green-deep); font-weight: 500; }
.toc__link[aria-current="true"]::before {
  background: var(--gold);
  border-color: var(--gold);
}

[data-toc-section],
section[id] { scroll-margin-top: 150px; }

@media (max-width: 900px) {
  .index-layout { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .toc {
    position: static;
    padding: 14px 16px;
    border-left: 0;
    border-top: 2px solid var(--green);
    background: rgba(183, 176, 163, 0.14);
  }
  .toc__list { display: flex; flex-wrap: wrap; gap: 4px 18px; }
  .toc__list li { margin-bottom: 0; }
}

/* ---------- 12. 图片容器 ---------- */
.img-frame {
  position: relative;
  overflow: hidden;
  background: var(--green);
  border: 2px solid var(--green-deep);
}
.img-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
.img-frame--16x9 { aspect-ratio: 16 / 9; }
.img-frame--4x3 { aspect-ratio: 4 / 3; }
.img-frame--1x1 { aspect-ratio: 1 / 1; }
.img-frame--3x4 { aspect-ratio: 3 / 4; }

/* ---------- 13. 显现动效 ---------- */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.28s ease, transform 0.28s ease;
}
.js [data-reveal].is-visible {
  opacity: 1;
  transform: none;
}

/* ---------- 14. 响应式收口 ---------- */
@media (max-width: 900px) {
  :root { --shell-x: 22px; }
  .section { padding: 52px 0; }
  .section--tight { padding: 34px 0; }
  .section-head { margin-bottom: 24px; }
  .site-footer { margin-top: 60px; }
}

@media (max-width: 640px) {
  body { font-size: 16px; line-height: 1.8; }
  .footer__brand { font-size: 24px; }
  .btn { padding: 11px 20px; font-size: 14px; }
  .to-top { right: 14px; bottom: 14px; width: 50px; height: 50px; font-size: 11px; }
}

/* ---------- 15. 动效降级 ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .js [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
  }
}
