/* =========================================================
   丙洲陳氏族譜網 · 古典風格主題 (bjClassic)
   宣紙底、墨色字、朱砂紅、金漆、深木色
   ========================================================= */
:root {
  --paper: #f5ecd7;
  --paper-2: #efe2c4;
  --paper-edge: #dcc9a0;
  --ink: #2b1d14;
  --ink-soft: #5a4636;
  --cinnabar: #9e2a1e;
  --cinnabar-2: #b8382a;
  --gold: #c39a4e;
  --gold-soft: #e3c98f;
  --wood: #3b2416;
  --wood-2: #5a3620;
  --jade: #2f5d4e;
  --shadow: 0 6px 18px rgba(43, 29, 20, .18);
  --font-kai: "LXGW WenKai TC", "BiauKai", "DFKai-SB", "標楷體", "Noto Serif TC", serif;
  --font-serif: "Noto Serif TC", "PMingLiU", "新細明體", serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  color: var(--ink);
  font-family: var(--font-serif);
  background-color: var(--paper);
  /* 宣紙纖維紋 */
  background-image:
    radial-gradient(rgba(120, 90, 50, .06) 1px, transparent 1px),
    radial-gradient(rgba(120, 90, 50, .04) 1px, transparent 1px),
    linear-gradient(180deg, #f8f1df 0%, var(--paper) 40%, var(--paper-2) 100%);
  background-size: 7px 7px, 13px 13px, 100% 100%;
  background-position: 0 0, 3px 5px, 0 0;
  background-attachment: fixed;
}

a { color: var(--cinnabar); text-decoration: none; }
a:hover { color: var(--cinnabar-2); text-decoration: underline; }

/* ---------- 回紋飾帶 ---------- */
.fret {
  height: 12px;
  background-color: var(--wood);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='12' viewBox='0 0 24 12'%3E%3Cpath d='M1 11V1h10v8H5V5h3' fill='none' stroke='%23c39a4e' stroke-width='1.4'/%3E%3Cpath d='M13 1v10h10V3h-6v4h3' fill='none' stroke='%23c39a4e' stroke-width='1.4'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-position: center;
}

/* ---------- 頁首 / 匾額 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(180deg, var(--wood-2) 0%, var(--wood) 100%);
  color: var(--gold-soft);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .35);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 8px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--gold-soft);
  text-decoration: none;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; color: #fff3cf; }

.seal {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  background: var(--cinnabar);
  color: #fbe9d0;
  font-family: var(--font-kai);
  font-size: 30px;
  line-height: 1;
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px rgba(251, 233, 208, .55), inset 0 0 0 4px var(--cinnabar), 0 1px 3px rgba(0,0,0,.4);
  transform: rotate(-3deg);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title {
  font-family: var(--font-kai);
  font-size: 26px;
  letter-spacing: .12em;
  color: #f3d58e;
  text-shadow: 0 1px 0 #000, 0 0 8px rgba(195, 154, 78, .35);
}
.brand-sub {
  font-size: 12px;
  letter-spacing: .3em;
  color: #cdb07a;
}

/* ---------- 主選單 ---------- */
.main-nav { flex: 1; min-width: 0; }
.menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.menu > li { position: relative; }

.menu-btn,
.menu > li > a.menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: var(--gold-soft);
  font-family: var(--font-kai);
  font-size: 19px;
  letter-spacing: .08em;
  cursor: pointer;
  border-radius: 4px;
  text-decoration: none;
}
.menu-btn:hover,
.menu > li.open > .menu-btn,
.menu-btn.active {
  background: rgba(195, 154, 78, .16);
  color: #fff3cf;
  text-decoration: none;
}
.menu-btn .caret {
  font-size: 10px;
  opacity: .7;
  transition: transform .2s;
}
.menu > li.open > .menu-btn .caret { transform: rotate(180deg); }

/* 下拉卷軸 */
.panel {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 250px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  padding: 10px 0;
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-top: 3px solid var(--cinnabar);
  border-radius: 0 0 6px 6px;
  box-shadow: var(--shadow);
  z-index: 60;
}
.header-inner { position: relative; }
.menu > li.mega { position: static; }
.panel.wide {
  left: 16px;
  right: 16px;
  top: calc(100% - 4px);
  min-width: 0;
  padding: 12px 6px;
}
.menu > li.open > .panel { display: block; }
.menu > li.open > .panel.wide {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  align-items: start;
}
.panel.wide .grp { padding: 0 4px 6px; }
.menu > li:last-child .panel,
.menu > li.align-right .panel { left: auto; right: 0; }

.panel a,
.panel .na {
  display: block;
  padding: 5px 18px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
}
.panel a:hover {
  background: linear-gradient(90deg, rgba(158, 42, 30, .12), transparent);
  color: var(--cinnabar);
}
.panel a.current { color: var(--cinnabar); font-weight: 700; }
.panel .na { color: #9b8a76; cursor: default; }

/* 層級 — 以族譜線代替 ├ └ 字元 */
.panel .l1 { font-weight: 600; }
.panel .l1::before {
  content: "◆";
  color: var(--cinnabar);
  font-size: 9px;
  margin-right: 8px;
  vertical-align: 2px;
}
.panel .l2 { padding-left: 38px; font-size: 14.5px; }
.panel .l3 { padding-left: 56px; font-size: 14px; color: var(--ink-soft); }
.panel .l4 { padding-left: 74px; font-size: 14px; color: var(--ink-soft); }
.panel .l2::before,
.panel .l3::before,
.panel .l4::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 50%;
  width: 10px;
  border-left: 1px solid var(--gold);
  border-bottom: 1px solid var(--gold);
}
.panel .l2::before { left: 23px; }
.panel .l3::before { left: 41px; }
.panel .l4::before { left: 59px; }
.panel a[target="_blank"]::after { content: " ↗"; font-size: 11px; color: var(--gold); }

.panel h6 {
  margin: 8px 14px 4px;
  padding: 4px 6px 3px;
  font-family: var(--font-kai);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: .2em;
  color: var(--cinnabar);
  border-bottom: 1px dashed var(--paper-edge);
}
.panel h6:first-child { margin-top: 0; }

/* 手機選單鈕 */
.nav-toggle {
  display: none;
  margin-left: auto;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(195, 154, 78, .5);
  border-radius: 6px;
  background: transparent;
  color: var(--gold-soft);
  font-size: 22px;
  cursor: pointer;
}

/* ---------- 主內容：卷軸 ---------- */
.stage {
  max-width: 1400px;
  margin: 14px auto 0;
  padding: 0 16px 16px;
}

.crumb {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 2px 6px 8px;
  font-family: var(--font-kai);
  font-size: 18px;
  color: var(--wood-2);
}
.crumb::before {
  content: "";
  width: 8px;
  height: 22px;
  background: var(--cinnabar);
  border-radius: 2px;
}
.crumb .sep { color: var(--gold); margin: 0 4px; }
.crumb .tools { margin-left: auto; display: flex; gap: 6px; }
.crumb .ai-credit {
  margin-left: 14px;
  font-family: var(--font-kai);
  font-size: 17px;
  letter-spacing: .08em;
  color: var(--cinnabar);
  white-space: nowrap;
}
.crumb .tools a {
  font-family: var(--font-serif);
  font-size: 13px;
  padding: 3px 10px;
  border: 1px solid var(--paper-edge);
  border-radius: 14px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, .45);
}
.crumb .tools a:hover { color: var(--cinnabar); border-color: var(--cinnabar); text-decoration: none; }

.scroll {
  position: relative;
  padding: 14px;
  background: #fbf6ea;
  border: 1px solid var(--paper-edge);
  border-radius: 4px;
  box-shadow: var(--shadow), inset 0 0 40px rgba(195, 154, 78, .12);
}
/* 上下卷軸木桿 */
.scroll::before,
.scroll::after {
  content: "";
  position: absolute;
  left: -10px;
  right: -10px;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(180deg, #7a4a2a, var(--wood) 60%, #24150c);
  box-shadow: 0 2px 4px rgba(0,0,0,.35);
}
.scroll::before { top: -6px; }
.scroll::after { bottom: -6px; }

.scroll iframe {
  display: block;
  width: 100%;
  height: calc(100vh - 170px);
  min-height: 480px;
  border: 0;
  background: #fff;
}

/* ---------- 頁尾 ---------- */
.site-footer {
  margin-top: 18px;
  padding: 14px 16px 18px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: .08em;
}
.site-footer .motto {
  font-family: var(--font-kai);
  font-size: 16px;
  color: var(--wood-2);
  letter-spacing: .4em;
  margin-bottom: 4px;
}

/* ---------- 響應式 ---------- */
@media (max-width: 1240px) {
  .menu-btn, .menu > li > a.menu-btn { padding: 10px 8px; font-size: 17px; letter-spacing: .02em; }
  .brand-title { font-size: 22px; }
  .brand-sub { letter-spacing: .1em; }
  .header-inner { gap: 10px; }
}

@media (max-width: 1080px) {
  .menu-btn, .menu > li > a.menu-btn { padding: 10px 6px; font-size: 16px; }
  .brand-sub { display: none; }
  .seal { width: 40px; height: 40px; font-size: 26px; }
}

@media (max-width: 900px) {
  .header-inner { flex-wrap: wrap; }
  .nav-toggle { display: inline-block; }
  .main-nav {
    display: none;
    flex-basis: 100%;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    padding-bottom: 8px;
  }
  .site-header.nav-open .main-nav { display: block; }
  .menu { flex-direction: column; align-items: stretch; }
  .menu-btn, .menu > li > a.menu-btn {
    width: 100%;
    justify-content: space-between;
    border-bottom: 1px solid rgba(195, 154, 78, .2);
    border-radius: 0;
  }
  .panel,
  .menu > li:last-child .panel {
    position: static;
    max-height: none;
    min-width: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .menu > li.open > .panel.wide { display: block; }
  .panel a, .panel .na { white-space: normal; }
  .brand-sub { display: none; }
  .scroll iframe { height: calc(100vh - 150px); }
  .crumb .tools { display: none; }
}
