/* 明末史事库 —— 水墨古风样式（无外部依赖） */
:root {
  --ink:        #14100a;
  --ink-2:      #1c150d;
  --paper:      #e8d9b0;
  --paper-dim:  #c9b283;
  --gold:       #d9ad55;
  --gold-bright:#ffe7a8;
  --vermilion:  #b23a2e;
  --line:       rgba(218, 172, 84, 0.22);
  --panel:      rgba(20, 14, 8, 0.62);
  --serif:      "Noto Serif SC", "Songti SC", "STSong", "SimSun", "KaiTi", "STKaiti", serif;
  --kai:        "KaiTi", "STKaiti", "Noto Serif SC", serif;
  /* 主题色 */
  --t-liao:    #6f9bc4;
  --t-court:   #c79bd8;
  --t-revolt:  #d96a4a;
  --t-disaster:#d2a24a;
  --t-jiashen: #c0392b;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--paper);
  font-family: var(--serif);
  line-height: 1.7;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(120, 84, 30, 0.18), transparent 60%),
    radial-gradient(900px 500px at 90% 110%, rgba(120, 40, 30, 0.1), transparent 55%),
    linear-gradient(180deg, #16100a 0%, #100b06 100%);
  background-attachment: fixed;
}

.bg-grain {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

body > *:not(.bg-grain) { position: relative; z-index: 1; }

/* ── 页头 ── */
.site-head {
  max-width: 880px;
  margin: 0 auto;
  padding: 64px 24px 26px;
  text-align: center;
}
.seal {
  display: inline-grid;
  place-items: center;
  position: relative;
  width: 76px;
  height: 76px;
  margin-bottom: 18px;
  border: 2.5px solid var(--vermilion);
  border-radius: 8px;
  color: var(--vermilion);
  font: 900 30px/1 var(--kai);
  letter-spacing: 0;
  box-shadow: 0 0 0 4px rgba(178, 58, 46, 0.12), inset 0 0 18px rgba(178, 58, 46, 0.18);
}
.seal span { position: absolute; right: 6px; bottom: 6px; font-size: 13px; opacity: 0.85; }
.site-head h1 {
  margin: 0;
  font: 900 clamp(38px, 7vw, 66px)/1.1 var(--kai);
  letter-spacing: 0.22em;
  color: var(--gold-bright);
  text-shadow: 0 6px 26px rgba(0, 0, 0, 0.6);
}
.subtitle {
  margin: 14px 0 0;
  color: var(--gold);
  letter-spacing: 0.32em;
  font-size: 14px;
}
.intro {
  max-width: 640px;
  margin: 20px auto 0;
  color: rgba(232, 217, 176, 0.74);
  font-size: 15px;
  line-height: 1.9;
}

/* ── 工具栏 ── */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 14px;
  max-width: 980px;
  margin: 26px auto 0;
  padding: 14px 24px;
  background: linear-gradient(180deg, rgba(16, 11, 6, 0.92), rgba(16, 11, 6, 0.66));
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 280px;
  max-width: 420px;
}
.search-wrap .icon { position: absolute; left: 12px; width: 17px; height: 17px; color: var(--gold); opacity: 0.7; }
#search {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(6, 5, 3, 0.5);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 14px;
}
#search:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(217, 173, 85, 0.15); }
#search::placeholder { color: rgba(201, 178, 131, 0.5); }

.filters { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; }
.chip {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(6, 5, 3, 0.4);
  color: var(--paper-dim, #c9b283);
  font-family: var(--kai);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.chip:hover { border-color: var(--gold); color: var(--gold-bright); }
.chip.is-active {
  background: linear-gradient(180deg, rgba(217, 173, 85, 0.28), rgba(217, 173, 85, 0.12));
  border-color: var(--gold);
  color: var(--gold-bright);
  box-shadow: 0 0 14px rgba(217, 173, 85, 0.2);
}
.chip .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

.sort-btn {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(6, 5, 3, 0.4);
  color: var(--gold);
  font-family: var(--kai);
  font-size: 13px;
  cursor: pointer;
}
.sort-btn:hover { border-color: var(--gold); color: var(--gold-bright); }

.result-line {
  max-width: 820px;
  margin: 18px auto 0;
  padding: 0 24px;
  color: rgba(201, 178, 131, 0.6);
  font-size: 13px;
  letter-spacing: 0.1em;
}

/* ── 时间轴 ── */
.timeline {
  max-width: 820px;
  margin: 8px auto 0;
  padding: 12px 24px 40px;
}
.evt {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 18px;
  position: relative;
  padding: 18px 0;
  cursor: pointer;
}
.evt::before {
  content: "";
  position: absolute;
  left: 75px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, var(--line) 14%, var(--line) 86%, transparent);
}
.evt:first-child::before { top: 30px; }
.evt:last-child::before { bottom: auto; height: 30px; }

.evt-rail { position: relative; text-align: right; padding-right: 4px; }
.evt-year {
  display: block;
  color: var(--gold);
  font: 700 17px/1.2 var(--kai);
  letter-spacing: 0.02em;
}
.evt-dot {
  position: absolute;
  right: -7px;
  top: 6px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(217, 173, 85, 0.18);
  z-index: 1;
}

.evt-body {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px 18px;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.evt:hover .evt-body {
  transform: translateY(-2px);
  border-color: rgba(218, 172, 84, 0.5);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}
.evt-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  color: rgba(201, 178, 131, 0.7);
  font-size: 12px;
}
.evt-meta .loc::before { content: "· "; opacity: 0.5; }
.evt-title {
  margin: 6px 0 6px;
  color: var(--gold-bright);
  font: 700 19px/1.4 var(--kai);
  letter-spacing: 0.03em;
}
.evt-summary {
  margin: 0;
  color: rgba(232, 217, 176, 0.82);
  font-size: 14px;
}
.evt-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag {
  padding: 2px 9px;
  border-radius: 4px;
  font-size: 11.5px;
  font-family: var(--kai);
  border: 1px solid transparent;
}
.tag.theme { color: #fff; }
.tag.cat { background: rgba(218, 172, 84, 0.14); color: var(--gold); border-color: var(--line); }
.tag.fig { background: rgba(178, 58, 46, 0.12); color: #e09a8c; border: 1px solid rgba(178, 58, 46, 0.3); }

.empty {
  text-align: center;
  padding: 60px 20px;
  color: rgba(201, 178, 131, 0.6);
  font-size: 15px;
}

/* ── 页脚 ── */
.site-foot {
  max-width: 820px;
  margin: 0 auto;
  padding: 30px 24px 56px;
  text-align: center;
  border-top: 1px solid var(--line);
  color: rgba(201, 178, 131, 0.6);
  font-size: 13px;
}
.site-foot b { color: var(--gold); }
.disclaimer { margin-top: 8px; font-size: 12px; opacity: 0.7; }
.beian { margin-top: 12px; font-size: 12px; }
.beian a { color: rgba(201, 178, 131, 0.55); text-decoration: none; letter-spacing: 0.05em; }
.beian a:hover { color: var(--gold); }

/* ── 详情弹窗 ── */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4, 3, 2, 0.7); backdrop-filter: blur(4px); }
.modal-card {
  position: relative;
  width: min(680px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid rgba(218, 172, 84, 0.4);
  border-radius: 10px;
  padding: 30px 34px 34px;
  background:
    radial-gradient(600px 300px at 50% -10%, rgba(120, 84, 30, 0.16), transparent 60%),
    linear-gradient(180deg, #1d160d, #14100a);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
  animation: modalUp 0.22s ease;
}
@keyframes modalUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(6, 5, 3, 0.5);
  color: var(--gold);
  font-size: 15px;
  cursor: pointer;
}
.modal-close:hover { border-color: var(--gold); color: var(--gold-bright); }
.m-eyebrow { display: flex; flex-wrap: wrap; gap: 6px 12px; color: rgba(201, 178, 131, 0.7); font-size: 13px; }
.m-eyebrow span + span::before { content: "· "; opacity: 0.5; }
.modal-card h2 {
  margin: 8px 0 12px;
  color: var(--gold-bright);
  font: 900 clamp(24px, 4vw, 32px)/1.3 var(--kai);
  letter-spacing: 0.04em;
}
.m-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 4px; }
.m-summary {
  margin: 16px 0 4px;
  padding: 12px 16px;
  border-left: 3px solid var(--gold);
  background: rgba(217, 173, 85, 0.07);
  color: var(--paper);
  font-size: 15.5px;
}
.m-section { margin-top: 22px; }
.m-section h4 {
  margin: 0 0 8px;
  color: var(--gold);
  font: 700 15px/1 var(--kai);
  letter-spacing: 0.18em;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.m-section p { margin: 0; color: rgba(232, 217, 176, 0.9); font-size: 15px; line-height: 1.95; text-align: justify; }
.m-signif p { color: rgba(231, 201, 130, 0.92); }
.m-figures { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.m-figures .tag.fig { font-size: 13px; padding: 4px 12px; }

@media (max-width: 560px) {
  .site-head { padding-top: 44px; }
  .evt { grid-template-columns: 56px 1fr; gap: 12px; }
  .evt::before { left: 55px; }
  .evt-year { font-size: 14px; }
  .toolbar { position: static; }
  .modal-card { padding: 26px 20px 28px; }
}
