/* 国家地理分级阅读 · 课文 PDF / 打印样式 */
:root {
  --ng-gold: #f5c400;
  --ng-gold-dim: #c9a008;
  --ink: #1a1a1a;
  --ink-soft: #5a5a5a;
  --paper: #f7f5f0;
  --paper-edge: #e8e4db;
  --frame: #d4cfc3;
  --accent: #0277bd;
  --wild: #2c4a3e;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body.ng-story-print-body {
  font-family: "Noto Sans SC", "Segoe UI", sans-serif;
  background: #eceff1;
  color: var(--ink);
  padding: 1rem;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.no-print {
}

.ng-story-toolbar {
  max-width: 52rem;
  margin: 0 auto 1rem;
  background: #fff;
  border-radius: 14px;
  padding: 1.1rem 1.25rem;
  border-left: 5px solid var(--ng-gold);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.ng-story-toolbar h1 {
  font-family: "Source Serif 4", "Noto Serif SC", Georgia, serif;
  font-size: 1.35rem;
  color: var(--accent);
  margin-bottom: 0.4rem;
  line-height: 1.35;
}

.ng-story-toolbar p {
  font-size: 0.88rem;
  color: #546e7a;
  line-height: 1.55;
  margin-bottom: 0.65rem;
}

.ng-story-toolbar .row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  margin: 0.5rem 0;
}

.ng-story-toolbar label {
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.ng-story-btn {
  font-family: "Noto Sans SC", sans-serif;
  font-weight: 700;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  touch-action: manipulation;
}

.ng-story-btn.primary {
  background: var(--ng-gold);
  border-color: var(--ng-gold-dim);
}

.ng-story-btn.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.ng-story-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

#storyPrintArea {
  max-width: 52rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── A4 页面（所有预览、导出与打印统一为 210mm × 297mm）── */
.story-print-sheet {
  width: 210mm;
  height: 297mm;
  min-height: 297mm;
  margin: 0 auto;
  background: var(--paper);
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.1);
  page-break-after: always;
  break-after: page;
}

.story-print-sheet:last-child {
  page-break-after: auto;
  break-after: auto;
}

.story-print-sheet::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: var(--ng-gold);
  z-index: 2;
}

.story-print-inner {
  padding: 14mm 16mm 16mm 18mm;
  height: 297mm;
  min-height: 297mm;
  display: flex;
  flex-direction: column;
}

/* 封面 */
.story-print-cover .story-print-inner {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.story-print-cover .ng-mark {
  display: inline-block;
  width: 48px;
  height: 8px;
  background: var(--ng-gold);
  margin-bottom: 1.2rem;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.story-print-cover .cover-tag {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 0.8rem;
}

.story-print-cover h2 {
  font-family: "Source Serif 4", "Noto Serif SC", Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
  margin-bottom: 0.5rem;
}

.story-print-cover .cover-sub {
  font-size: 1rem;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.story-print-cover .cover-desc {
  font-size: 0.92rem;
  color: var(--ink-soft);
  line-height: 1.65;
  max-width: 28rem;
  margin: 0 auto 1.5rem;
}

.story-print-cover .cover-meta {
  display: inline-flex;
  gap: 1.5rem;
  font-size: 0.85rem;
  color: #78909c;
  border-top: 2px solid var(--ng-gold);
  padding-top: 1rem;
}

.story-print-cover .cover-frame {
  position: absolute;
  inset: 10mm 12mm;
  border: 1px solid var(--frame);
  pointer-events: none;
  border-radius: 2px;
}

/* 内容页顶栏 */
.story-page-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--ng-gold);
  padding-bottom: 6px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.story-page-hdr .book-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.story-page-hdr .page-num {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

/* 插图区 */
.story-art-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6mm 0;
  min-height: 0;
}

.story-polaroid {
  background: #fff;
  border: 1px solid var(--frame);
  border-radius: 4px;
  padding: 8px 8px 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  max-width: 100%;
  position: relative;
}

.story-polaroid::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  height: 3px;
  background: var(--ng-gold);
  opacity: 0.5;
}

.story-polaroid img {
  display: block;
  width: 100%;
  max-width: 155mm;
  max-height: 155mm;
  object-fit: contain;
  border-radius: 2px;
}

.story-polaroid .art-fallback {
  display: none;
  font-size: 4rem;
  text-align: center;
  padding: 2rem;
  min-width: 120mm;
  min-height: 90mm;
  line-height: 90mm;
}

.story-polaroid img.is-hide + .art-fallback {
  display: block;
}

/* 文字区 */
.story-text-block {
  flex-shrink: 0;
  padding-top: 4mm;
}

.story-num-badge {
  display: inline-block;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  padding: 2px 10px;
  margin-bottom: 8px;
}

.story-en {
  font-family: "Source Serif 4", "Noto Serif SC", Georgia, serif;
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--ink);
  margin-bottom: 10px;
}

.story-divider {
  width: 48px;
  height: 3px;
  background: linear-gradient(90deg, var(--ng-gold), transparent);
  margin: 8px 0 10px;
  border-radius: 2px;
}

.story-zh {
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.55;
  color: var(--wild);
}

.story-zh.is-hidden {
  display: none;
}

/* 双句布局 */
.story-print-sheet--double .story-double-grid {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 8mm;
  flex: 1;
  min-height: 0;
}

.story-print-sheet--double .story-block {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.story-print-sheet--double .story-art-wrap {
  padding: 2mm 0;
}

.story-print-sheet--double .story-polaroid img {
  max-height: 95mm;
  max-width: 100%;
}

.story-print-sheet--double .story-en {
  font-size: 1.15rem;
}

.story-print-sheet--double .story-zh {
  font-size: 0.95rem;
}

.story-page-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px dashed var(--frame);
  font-size: 0.72rem;
  color: #90a4ae;
  text-align: center;
}

/* 屏幕预览缩放 */
@media screen {
  .story-print-sheet {
    transform-origin: top center;
  }
}

@media screen and (max-width: 800px) {
  body.ng-story-print-body {
    padding: 0.5rem;
  }

  .story-print-sheet {
    width: calc(100vw - 1rem);
    height: auto;
    min-height: auto;
  }

  .story-print-inner {
    height: auto;
    min-height: auto;
    padding: 10mm 12mm;
  }
}

/* html2pdf 必须始终按真实 A4 尺寸采集，不能继承窄屏预览缩放。 */
body.ng-story-print-body.is-exporting {
  padding: 0;
}

#storyPrintArea.is-exporting {
  width: 210mm;
  max-width: none;
  gap: 0;
}

#storyPrintArea.is-exporting .story-print-sheet {
  width: 210mm !important;
  /* 留出 1mm 栅格化余量，避免 html2pdf 将恰好 297mm 的页误判为跨页。 */
  height: 296mm !important;
  min-height: 296mm !important;
  margin: 0 !important;
  transform: none !important;
  box-shadow: none;
  page-break-after: auto !important;
  break-after: auto !important;
}

#storyPrintArea.is-exporting .story-print-inner {
  height: 296mm !important;
  min-height: 296mm !important;
}

@media print {
  body.ng-story-print-body {
    background: #fff;
    padding: 0;
  }

  .no-print {
    display: none !important;
  }

  #storyPrintArea {
    width: 210mm;
    max-width: none;
    gap: 0;
  }

  .story-print-sheet {
    box-shadow: none;
    margin: 0;
    width: 210mm !important;
    height: auto !important;
    min-height: 296mm !important;
    overflow: visible;
    transform: none !important;
  }

  .story-print-inner {
    height: auto !important;
    min-height: 296mm !important;
  }
}

@page {
  size: A4 portrait;
  margin: 0;
}
