/* 现代纸本注解弹窗 */

body.nj-amodal-open {
  overflow: hidden;
}

.nj-amodal {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  box-sizing: border-box;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.nj-amodal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.nj-amodal[hidden] {
  display: none !important;
}

.nj-amodal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 12, 4, 0.52);
  backdrop-filter: blur(2px);
}

.nj-amodal-panel {
  position: relative;
  z-index: 1;
  width: min(520px, 94vw);
  max-height: min(78vh, 720px);
  height: auto;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  background:
    linear-gradient(165deg, #fffdf8 0%, #f7edd4 58%, #f2e4c4 100%);
  border: 1px solid rgba(154, 122, 58, 0.55);
  box-shadow:
    0 24px 64px rgba(20, 10, 0, 0.38),
    0 0 0 1px rgba(255, 248, 230, 0.35) inset;
  transform: translateY(10px) scale(0.98);
  transition: transform 0.2s ease;
}

.nj-amodal.is-open .nj-amodal-panel {
  transform: translateY(0) scale(1);
}

.nj-amodal-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  /* 标题贴左缘，对应截图左侧红框 */
  padding: 14px 14px 14px 16px;
  background: linear-gradient(180deg, #5a3f1c 0%, #3d2a10 100%);
  border-bottom: 1px solid rgba(201, 162, 39, 0.55);
  position: relative;
  z-index: 2;
}

.nj-amodal-title {
  flex: 1 1 auto;
  margin: 0;
  margin-right: auto;
  min-width: 0;
  padding: 0;
  font-family: "LXGW WenKai", "KaiTi", "STKaiti", serif;
  text-align: left !important;
  font-size: clamp(20px, 2.4vw, 26px);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fff4c8;
  line-height: 1.35;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

/* 覆盖 jing-img/style.css 的 button{height:20px}，避免「关闭」被裁切 */
button.nj-amodal-close {
  flex: 0 0 auto;
  appearance: none;
  -webkit-appearance: none;
  width: auto !important;
  height: auto !important;
  min-width: 4.5em;
  min-height: 36px !important;
  margin: 0 !important;
  border: 1px solid rgba(240, 208, 120, 0.45) !important;
  background: rgba(255, 255, 255, 0.08) !important;
  color: #f0d078 !important;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif !important;
  font-size: 14px !important;
  font-weight: 600;
  letter-spacing: 0.16em;
  line-height: 1.25 !important;
  padding: 9px 16px 9px 18px !important;
  border-radius: 999px;
  cursor: pointer;
  box-sizing: border-box;
  overflow: visible;
  white-space: nowrap;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

button.nj-amodal-close:hover,
button.nj-amodal-close:focus-visible {
  background: rgba(255, 255, 255, 0.14) !important;
  color: #fff !important;
  outline: none;
}

.nj-amodal-body {
  position: relative;
  z-index: 1;
  flex: 0 1 auto;
  min-height: 0;
  /* 短内容随正文收缩；长内容才在此高度内滚动 */
  max-height: calc(min(78vh, 720px) - 64px);
  padding: 28px 32px 36px;
  overflow-x: hidden;
  overflow-y: hidden; /* JS 在需要时改为 auto */
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(122, 98, 54, 0.45) transparent;
}

.nj-amodal-body.is-scrollable {
  padding-right: 28px;
}

.nj-amodal-body::-webkit-scrollbar {
  width: 8px;
}

.nj-amodal-body::-webkit-scrollbar-thumb {
  background: rgba(122, 98, 54, 0.4);
  border-radius: 8px;
}

.nj-amodal-body::-webkit-scrollbar-track {
  background: transparent;
}

.nj-amodal-loading,
.nj-amodal-empty {
  margin: 0;
  color: #6b5528;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-align: center;
  padding: 28px 8px;
}

.nj-amodal-zhuyin,
.nj-amodal-body #zhuyin {
  position: relative;
  z-index: 1;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  width: auto !important;
  max-width: 100%;
  background: transparent !important;
  box-sizing: border-box;
}

.nj-amodal-zhuyin ul,
.nj-amodal-body #zhuyin ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.nj-amodal-zhuyin li,
.nj-amodal-body #zhuyin li {
  margin: 0 0 1.15em;
  padding: 0;
  color: #3a2412;
  font-size: 15px;
  line-height: 2.05;
  letter-spacing: 0.03em;
  font-family: "LXGW WenKai", "KaiTi", "Microsoft YaHei", sans-serif;
}

.nj-amodal-zhuyin li:last-child,
.nj-amodal-body #zhuyin li:last-child {
  margin-bottom: 0;
}

.nj-amodal-zhuyin h1,
.nj-amodal-body #zhuyin h1,
.nj-amodal-py {
  margin: 0 0 1.05em !important;
  padding: 0 0 0.7em !important;
  border-bottom: 1px solid rgba(154, 122, 58, 0.18);
  font-size: 15px !important;
  line-height: 1.7 !important;
  letter-spacing: 0.08em;
  color: #5a3208 !important;
  font-family: "LXGW WenKai", "KaiTi", "STKaiti", serif !important;
  font-weight: 700 !important;
  background: none !important;
}

.nj-amodal-zhuyin h1:last-of-type,
.nj-amodal-body #zhuyin h1:last-of-type {
  margin-bottom: 1.35em !important;
}

.nj-amodal-zhuyin img,
.nj-amodal-body #zhuyin img {
  display: block;
  float: left;
  max-width: min(168px, 40%);
  height: auto;
  margin: 0.2em 1.1em 1em 0;
  border: 1px solid rgba(154, 122, 58, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
}

.nj-amodal-zhuyin::after,
.nj-amodal-body #zhuyin::after {
  content: "";
  display: table;
  clear: both;
}

/* 装饰：不抢正文 */
.nj-amodal-lotus,
.nj-amodal-ting,
.nj-amodal-seal {
  position: absolute;
  pointer-events: none;
  z-index: 0;
}

.nj-amodal-lotus {
  right: -4%;
  bottom: -2%;
  width: min(300px, 70%);
  height: min(190px, 46%);
  background-color: #8a6a38;
  -webkit-mask: url("../jing-img/decor/lotus-ornament.svg") no-repeat right bottom / contain;
  mask: url("../jing-img/decor/lotus-ornament.svg") no-repeat right bottom / contain;
  opacity: 0.11;
}

.nj-amodal-ting {
  /* 避开标题栏左侧，避免看起来像「标题右侧空着」 */
  left: 18px;
  top: 88px;
  width: 48px;
  height: 48px;
  background-color: #6b5528;
  -webkit-mask: url("../jing-img/decor/tingchan-ornament.svg") no-repeat center / contain;
  mask: url("../jing-img/decor/tingchan-ornament.svg") no-repeat center / contain;
  opacity: 0.07;
}

.nj-amodal-seal {
  right: 18px;
  bottom: 14px;
  width: 40px;
  height: 40px;
  background-color: #8b3a2a;
  -webkit-mask: url("../jing-img/decor/buddha-hand.svg") no-repeat center / contain;
  mask: url("../jing-img/decor/buddha-hand.svg") no-repeat center / contain;
  opacity: 0.12;
}
