/* ============================================================
   FOOTNOTES & BIBLIOGRAPHY STYLES
   Used by bibliography pages + inline footnote markers
   Extends styles.css / fulltext.css design tokens
   ============================================================ */

/* ============================================================
   BIBLIOGRAPHY PAGE — editorial layout with axis-char watermark
   (Axis char + Roman numeral injected via data-book attribute;
    no markup changes required in the builder.)
   ============================================================ */
.bib-page {
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
}

.bib-main {
  max-width: 860px;
  margin: 0 auto;
  padding: 96px 24px 120px;
}

/* ---- Hero header with axis-char watermark ---- */
.bib-header {
  position: relative;
  padding: 24px 0 40px;
  margin-bottom: 56px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  isolation: isolate;
  text-align: center;
}

.bib-header::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--serif-kr);
  font-size: 360px;
  font-weight: 700;
  line-height: 1;
  color: rgba(212, 178, 85, 0.04);
  pointer-events: none;
  z-index: 0;
  white-space: nowrap;
}

.bib-header > * {
  position: relative;
  z-index: 1;
}

.bib-page[data-book="1"] .bib-header::before { content: '時'; }
.bib-page[data-book="2"] .bib-header::before { content: '空'; }
.bib-page[data-book="3"] .bib-header::before { content: '資'; }
.bib-page[data-book="4"] .bib-header::before { content: '制'; }
.bib-page[data-book="5"] .bib-header::before { content: '國'; }
.bib-page[data-book="6"] .bib-header::before { content: '個'; }

.bib-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-family: var(--sans-en);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin-bottom: 22px;
}

.bib-eyebrow::before,
.bib-eyebrow::after {
  content: '';
  display: inline-block;
  width: 24px;
  height: 1px;
  background: var(--accent-gold-dim);
}

/* Roman numeral accent above title, injected by data-book */
.bib-page .bib-header h1.bib-title::before {
  display: block;
  font-family: var(--serif-en);
  font-style: italic;
  font-weight: 400;
  font-size: 52px;
  line-height: 1;
  letter-spacing: 2px;
  color: var(--accent-gold);
  opacity: 0.9;
  margin-bottom: 18px;
}

.bib-page[data-book="1"] .bib-header h1.bib-title::before { content: 'I'; }
.bib-page[data-book="2"] .bib-header h1.bib-title::before { content: 'II'; }
.bib-page[data-book="3"] .bib-header h1.bib-title::before { content: 'III'; }
.bib-page[data-book="4"] .bib-header h1.bib-title::before { content: 'IV'; }
.bib-page[data-book="5"] .bib-header h1.bib-title::before { content: 'V'; }
.bib-page[data-book="6"] .bib-header h1.bib-title::before { content: 'VI'; }

.bib-title {
  font-family: var(--serif-kr);
  font-size: clamp(30px, 4.6vw, 46px);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.22;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}

.bib-subtitle {
  font-family: var(--serif-kr);
  font-size: 15px;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.8;
  max-width: 560px;
  margin: 0 auto;
}

.bib-intro {
  max-width: 680px;
  margin: 0 auto 56px;
  padding: 0 16px;
  font-family: var(--serif-kr);
  font-size: 15px;
  line-height: 1.9;
  color: var(--text-secondary);
  text-align: center;
}

.bib-intro p {
  margin: 0;
}

/* ---- Chapter jump navigation (pill grid) ---- */
.bib-jump-nav {
  position: relative;
  padding: 24px 28px 22px;
  margin-bottom: 64px;
  background: linear-gradient(180deg, rgba(22, 22, 34, 0.6), var(--bg-card));
  border: 1px solid var(--border);
  border-radius: 3px;
  border-left: 2px solid var(--accent-gold-dim);
}

.bib-jump-label {
  font-family: var(--sans-en);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.bib-jump-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--accent-gold-dim), transparent);
}

.bib-jump-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-family: var(--sans-en);
  font-size: 12px;
  letter-spacing: 0.5px;
}

.bib-jump-list a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 2px;
  transition: all 0.25s ease;
  background: rgba(255, 255, 255, 0.015);
  font-family: var(--sans-kr);
  font-size: 12px;
}

.bib-jump-list a:hover {
  color: var(--accent-gold);
  background: rgba(212, 178, 85, 0.08);
  border-color: var(--accent-gold-dim);
  transform: translateY(-1px);
}

/* ---- Chapter section ---- */
.bib-chapter {
  margin-bottom: 72px;
  scroll-margin-top: 80px;
}

.bib-chapter-heading {
  position: relative;
  font-family: var(--serif-kr);
  font-size: clamp(20px, 2.5vw, 26px);
  font-weight: 700;
  color: var(--text-primary);
  padding: 0 0 18px;
  margin-bottom: 32px;
  display: flex;
  align-items: baseline;
  gap: 16px;
  line-height: 1.35;
  letter-spacing: -0.005em;
  border-bottom: 1px solid var(--border);
}

.bib-chapter-heading::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 72px;
  height: 2px;
  background: var(--accent-gold);
}

.bib-chapter-heading .bib-chapter-num {
  font-family: var(--serif-en);
  font-size: 14px;
  font-style: italic;
  font-weight: 400;
  color: var(--accent-gold);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  flex-shrink: 0;
  padding: 3px 10px;
  border: 1px solid var(--accent-gold-dim);
  border-radius: 2px;
  background: rgba(212, 178, 85, 0.04);
  align-self: center;
  line-height: 1.4;
}

.bib-chapter-note {
  font-family: var(--serif-kr);
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.85;
  margin-bottom: 28px;
  padding: 10px 16px;
  border-left: 2px solid var(--accent-gold-dim);
  background: rgba(212, 178, 85, 0.03);
  border-radius: 0 2px 2px 0;
}

/* ---- Category subheader ---- */
.bib-category {
  margin-bottom: 36px;
}

.bib-category-heading {
  font-family: var(--sans-en);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin-bottom: 14px;
  padding-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.bib-category-heading::before {
  content: '◆';
  font-size: 8px;
  color: var(--accent-gold-dim);
  letter-spacing: 0;
}

.bib-category-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--accent-gold-dim), transparent 80%);
}

/* ---- Bibliography entries ---- */
.bib-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: bib-entry;
}

.bib-list li {
  position: relative;
  counter-increment: bib-entry;
  padding: 12px 0 12px 28px;
  font-family: var(--serif-kr);
  font-size: 14.5px;
  line-height: 1.8;
  color: var(--text-secondary);
  border-bottom: 1px dotted rgba(255, 255, 255, 0.055);
  transition: background 0.25s ease, padding 0.25s ease;
}

.bib-list li:last-child {
  border-bottom: none;
}

.bib-list li::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 22px;
  width: 12px;
  height: 1px;
  background: var(--accent-gold-dim);
  transition: width 0.25s ease, background 0.25s ease;
}

.bib-list li:hover {
  background: linear-gradient(90deg, rgba(212, 178, 85, 0.04), transparent 70%);
  padding-left: 34px;
}

.bib-list li:hover::before {
  width: 18px;
  background: var(--accent-gold);
}

.bib-list li em,
.bib-list li i {
  font-family: var(--serif-kr);
  font-style: italic;
  color: var(--text-primary);
  font-weight: 500;
}

.bib-list a {
  color: var(--accent-gold);
  text-decoration: none;
  border-bottom: 1px solid rgba(212, 178, 85, 0.3);
  transition: border-color 0.2s, color 0.2s;
  word-break: break-word;
}

.bib-list a:hover {
  color: var(--text-primary);
  border-bottom-color: var(--accent-gold);
}

.bib-list a::after {
  content: ' \2197';
  font-size: 10px;
  opacity: 0.65;
  letter-spacing: 1px;
}

/* ---- Back to top button ---- */
.bib-back-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 800;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--accent-gold-dim);
  color: var(--accent-gold);
  cursor: pointer;
  font-size: 16px;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(212, 178, 85, 0.08);
}

.bib-back-top:hover {
  color: var(--bg-deep);
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(212, 178, 85, 0.3);
}

.bib-back-top.visible {
  display: flex;
}

/* ---- Bibliography footer ---- */
.bib-footer {
  position: relative;
  margin-top: 96px;
  padding-top: 36px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.bib-footer::before {
  content: '◆';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--accent-gold-dim);
  background: var(--bg-deep);
  padding: 0 12px;
}

.bib-footer-meta {
  font-family: var(--sans-en);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.bib-footer-link {
  font-family: var(--sans-kr);
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 12px 22px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.015);
  transition: all 0.25s ease;
  letter-spacing: 0.3px;
}

.bib-footer-link:hover {
  color: var(--accent-gold);
  border-color: var(--accent-gold-dim);
  background: rgba(212, 178, 85, 0.05);
  transform: translateY(-1px);
}

/* ---- Chapter footer: bibliography link ---- */
.chapter-bib-link {
  max-width: 720px;
  margin: 48px auto 0;
  padding: 20px 24px;
  text-align: center;
  font-family: var(--sans-kr);
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px dashed var(--border);
  border-bottom: 1px dashed var(--border);
}

.chapter-bib-link a {
  color: var(--accent-gold);
  text-decoration: none;
  font-weight: 500;
  letter-spacing: 0.3px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
  margin-left: 6px;
}

.chapter-bib-link a:hover {
  border-bottom-color: var(--accent-gold);
}

/* ---- Chapter footer: research notes link (Books 3 & 6) ---- */
.chapter-research-link {
  max-width: 720px;
  margin: 16px auto 0;
  padding: 18px 24px;
  text-align: center;
  font-family: var(--sans-kr);
  font-size: 13px;
  color: var(--text-muted);
  background: rgba(201, 162, 77, 0.035);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.chapter-research-link a {
  color: var(--accent-gold);
  text-decoration: none;
  font-weight: 500;
  letter-spacing: 0.3px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
  margin-left: 6px;
}

.chapter-research-link a:hover {
  border-bottom-color: var(--accent-gold);
}

/* ---- Inline footnote marker (future use) ---- */
.fn-ref {
  display: inline-block;
  vertical-align: super;
  font-size: 10px;
  font-weight: 600;
  color: var(--accent-gold);
  background: rgba(212, 178, 85, 0.1);
  border: 1px solid var(--accent-gold-dim);
  border-radius: 3px;
  padding: 0 4px;
  margin: 0 2px;
  line-height: 1.3;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  user-select: none;
}

.fn-ref:hover,
.fn-ref:focus {
  background: var(--accent-gold);
  color: var(--bg-deep);
  outline: none;
}

.fn-ref.active {
  background: var(--accent-gold);
  color: var(--bg-deep);
}

/* Popover tooltip (desktop hover) */
.fn-popover {
  position: absolute;
  z-index: 1500;
  max-width: 340px;
  min-width: 220px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--accent-gold-dim);
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  font-family: var(--sans-kr);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s, transform 0.2s;
}

.fn-popover.visible {
  opacity: 1;
  transform: translateY(0);
}

.fn-popover::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 20px;
  width: 10px;
  height: 10px;
  background: var(--bg-card);
  border-top: 1px solid var(--accent-gold-dim);
  border-left: 1px solid var(--accent-gold-dim);
  transform: rotate(45deg);
}

.fn-popover a {
  color: var(--accent-gold);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.fn-popover a:hover {
  border-bottom-color: var(--accent-gold);
}

/* Mobile slide-up panel */
@media (max-width: 640px) {
  .fn-popover {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    top: auto;
    max-width: none;
    transform: translateY(100%);
    transition: transform 0.25s ease;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.6);
  }

  .fn-popover.visible {
    transform: translateY(0);
  }

  .fn-popover::before {
    display: none;
  }

  .fn-popover-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
  }
}

/* Chapter footnotes section (bottom of chapter) */
.footnotes {
  max-width: 720px;
  margin: 48px auto 0;
  padding: 32px 24px;
  border-top: 1px solid var(--border);
  font-family: var(--sans-kr);
  font-size: 13px;
}

.footnotes-heading {
  font-family: var(--sans-en);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin-bottom: 20px;
}

.footnotes ol {
  list-style: decimal;
  padding-left: 24px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.footnotes li {
  padding: 6px 0;
  scroll-margin-top: 80px;
}

.footnotes li:target {
  background: rgba(212, 178, 85, 0.06);
  border-radius: 3px;
  padding: 6px 8px;
  margin-left: -8px;
}

.footnotes a.fn-back {
  color: var(--accent-gold);
  text-decoration: none;
  margin-left: 6px;
  font-size: 11px;
  opacity: 0.7;
}

.footnotes a.fn-back:hover {
  opacity: 1;
}

/* ---- Mobile adjustments ---- */
@media (max-width: 720px) {
  .bib-main {
    padding: 80px 18px 100px;
  }

  .bib-title {
    font-size: 26px;
  }

  .bib-chapter-heading {
    font-size: 18px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .bib-chapter-heading .bib-chapter-num {
    font-size: 13px;
  }

  .bib-list li {
    font-size: 13px;
    padding-left: 16px;
  }

  .bib-jump-nav {
    padding: 16px 18px;
  }

  .bib-jump-list {
    font-size: 12px;
    gap: 4px 10px;
  }
}

@media (max-width: 480px) {
  .bib-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .bib-footer-link {
    width: 100%;
    text-align: center;
  }
}
