/* 绘本网页版样式（所有绘本共用）。页头、页脚、表单、按钮沿用 account.css。
 * 改了之后，把各绘本 index.html 里 book.css?v= 的版本号加 1（EO 会把 css 在节点上缓存 30 天）。 */

.screen { display: flex; flex-direction: column; min-height: 100vh; min-height: 100svh; }
.header-links { display: flex; align-items: center; gap: 18px; }
.back-link { font-size: 14px; color: var(--muted); }
.back-link:hover { color: var(--blue); }

.pb-main { flex: 1; padding-bottom: 110px; }

/* 布局：窄屏从上到下是 介绍 → 绘本 → 表单（先看到绘本长什么样）；
   宽屏左边介绍和表单，右边绘本，绘本跟着页面停在视线里，边填名字边看 */
.pb-layout { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "intro" "result" "form"; }
.pb-intro { grid-area: intro; }
.pb-result { grid-area: result; min-width: 0; margin-bottom: 36px; }
.pb-form { grid-area: form; }
@media (min-width: 1024px) {
  .pb-layout { grid-template-columns: minmax(340px, 5fr) minmax(0, 7fr); grid-template-rows: auto 1fr; grid-template-areas: "intro result" "form result"; column-gap: 56px; align-items: start; }
  .pb-result { position: sticky; top: 16px; margin: 24px 0 0; }
}

.pb-intro { padding-block: 40px 28px; max-width: 760px; }
.pb-intro .eyebrow { margin: 0 0 18px; color: #667080; font-size: 14px; letter-spacing: .1em; }
.pb-intro h1 { margin: 0; font-size: clamp(34px, 5vw, 52px); line-height: 1.3; font-weight: 650; letter-spacing: -.04em; }
.pb-intro h1 .hl { color: #E07A2E; }
.pb-intro .lead { margin: 18px 0 0; color: var(--muted); font-size: 16px; line-height: 1.85; }
.pb-points { display: grid; gap: 8px; margin: 18px 0 0; padding: 0; list-style: none; font-size: 15px; line-height: 1.6; color: #3b4556; }
.pb-points li { position: relative; padding-left: 28px; }
.pb-points li::before { content: ""; position: absolute; left: 0; top: .2em; width: 18px; height: 18px; border-radius: 50%;
  background: var(--blue-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M5 9.4l2.6 2.6L13 6.6' fill='none' stroke='%232b59ec' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 18px no-repeat; }
.pb-price-tag { color: #C8561B; font-weight: 600; }
.pb-intro .pb-more { margin: 16px 0 0; font-size: 14px; color: var(--muted); }
.pb-intro .pb-more a { color: var(--blue); }

/* 表单 */
.pb-form { max-width: 560px; padding: 32px; margin-bottom: 48px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; scroll-margin-top: 16px; }
.pb-form fieldset { margin: 0 0 18px; padding: 0; border: 0; }
.pb-form legend { margin-bottom: 8px; padding: 0; font-size: 14px; font-weight: 500; color: #2b3445; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: inline-block; padding: 10px 16px; border: 1px solid var(--input-line); border-radius: 999px; background: #fff; font-size: 14px; cursor: pointer; transition: border-color .15s ease, background-color .15s ease; }
.choice input:checked + span { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); font-weight: 500; }
.choice input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }
.pb-form .privacy { margin: 14px 0 0; font-size: 13px; color: #8a92a0; }

/* 结果区 */
.pb-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; padding: 0 0 14px; }
.pb-toolbar > div { flex: 1 1 240px; min-width: 0; }
.pb-toolbar h2 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.pb-note { margin: 4px 0 0; font-size: 13px; color: #8a6a3a; }
.pb-note a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.pb-price { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.pb-price.is-owned { color: var(--success); }
.pb-actions { display: flex; flex: 0 0 auto; gap: 10px; }
.pb-result > .form-msg:empty { display: none; }

/* 阅读器：横向 scroll-snap，一次一页；宽屏上按屏幕高度限制页宽，整页（插画 + 文字 + 翻页条）一屏看完 */
.reader { padding: 20px 20px 14px; background: #141B3F; border-radius: 20px; color: #F4ECDD; }
.reader .loading { display: grid; place-items: center; aspect-ratio: 4 / 3; margin: 0; color: #B9B3D6; }
.reader-track { display: flex; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scrollbar-width: none; border-radius: 14px; }
.reader-track::-webkit-scrollbar { display: none; }
.reader-track:focus-visible { outline: 3px solid #FFD95A; outline-offset: 4px; }
.rpage { --page-w: min(100%, max(320px, calc((100svh - 440px) * 4 / 3))); display: flex; flex: 0 0 100%; flex-direction: column; align-items: center; margin: 0; scroll-snap-align: center; scroll-snap-stop: always; font-family: WenKai, "PingFang SC", serif; }
.rpage.is-plain { justify-content: center; } /* 封面、献词、证书没有文字说明：插画上下居中，翻页条位置不动 */
.rart { position: relative; width: var(--page-w); container-type: inline-size; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 14px; background: #1D2552; color: #3B2A20; }
.rart:empty { background: linear-gradient(100deg, #1D2552 40%, #26306a 50%, #1D2552 60%) 0 0 / 300% 100%; animation: pb-shimmer 1.4s linear infinite; }
@keyframes pb-shimmer { to { background-position: -150% 0; } }
.rart svg { width: 100%; height: 100%; display: block; }
.rpage figcaption { width: var(--page-w); padding: 14px 2px 0; font-size: 16px; line-height: 1.8; text-align: justify; }
.rpage figcaption b { margin-right: 10px; color: #FFD95A; font-weight: 500; }
.rpage figcaption .nm { color: #FFB06B; font-weight: 500; }

.reader-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.reader-nav { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 16px; border: 1px solid rgba(255, 255, 255, .2); border-radius: 999px; background: rgba(255, 255, 255, .06); color: #F4ECDD; font: inherit; font-size: 14px; cursor: pointer; transition: background-color .15s ease, opacity .15s ease; }
.reader-nav span { font-size: 22px; line-height: 1; }
.reader-nav em { font-style: normal; }
.reader-nav:hover:not(:disabled) { background: rgba(255, 255, 255, .14); }
.reader-nav:disabled { opacity: .3; cursor: default; }
.reader-nav:focus-visible { outline: 3px solid #FFD95A; outline-offset: 2px; }
.reader-pos { display: grid; justify-items: center; gap: 4px; min-width: 0; }
.reader-count { font-size: 13px; color: #CFC9EA; font-variant-numeric: tabular-nums; }
.reader-dots { display: flex; flex-wrap: wrap; justify-content: center; }
.reader-dot { position: relative; width: 18px; height: 18px; padding: 0; border: 0; background: none; cursor: pointer; }
.reader-dot::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: rgba(255, 255, 255, .28); transition: background-color .2s ease, transform .2s ease; }
.reader-dot:hover::before { background: rgba(255, 255, 255, .55); }
.reader-dot.is-on::before { background: #FFD95A; transform: scale(1.4); }
@media (prefers-reduced-motion: reduce) {
  .rart:empty { animation: none; }
  .reader-dot::before, .reader-nav { transition: none; }
}

/* 打印装订说明 */
.pb-guide { margin-top: 32px; padding: 6px 24px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; font-size: 15px; line-height: 1.85; color: #3b4556; }
.pb-guide summary { padding: 14px 0; font-size: 16px; font-weight: 600; color: #18202f; cursor: pointer; }
.pb-guide h3 { margin: 18px 0 4px; font-size: 15px; color: #C8561B; }
.pb-guide ul { margin: 0 0 8px; padding-left: 20px; }

/* 插画上叠加的文字：屏幕和打印共用（屏幕的尺寸由 app.js 换算成 cqw） */
.center { position: absolute; left: 8%; width: 84%; text-align: center; }
.cover-title { top: 5%; background: rgba(255, 251, 242, .94); }
.cover-title h1 { margin: 0; font-weight: 500; letter-spacing: .06em; }
.cover-title p { color: #7A5A44; }
.box { position: absolute; background: rgba(255, 251, 242, .94); line-height: 1.75; text-align: justify; }
.nm { color: #C8561B; font-weight: 500; }
.rart, .print-root { font-family: WenKai, serif; }

/* 打印版：照搬 book.py 的 BOOK_CSS */
.print-root { display: none; color: #3B2A20; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.print-root .page { position: relative; width: 297mm; height: 210mm; overflow: hidden; break-after: page; background: #fff; }
.print-root .page:last-child { break-after: auto; }
.print-root .art { position: absolute; left: 24mm; top: 10mm; width: 253.33mm; height: 190mm; overflow: hidden; border-radius: 4mm; }
.print-root .art svg { width: 100%; height: 100%; display: block; }
.print-root .no { position: absolute; bottom: 3.2mm; right: 20mm; font-size: 9pt; color: #A08C78; }
.print-root.coloring .box, .print-root.coloring .cover-title { background: #fff; border: .4mm solid #BBB; }
.print-root.coloring .nm { color: #3B2A20; }

@page { size: 297mm 210mm; margin: 0; }

/* 购买对话框 */
.pay-dialog { width: min(400px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 28px 28px 20px; border: 0; border-radius: 20px; color: #18202f; background: #fff; box-shadow: 0 24px 64px rgba(15, 23, 42, .28); }
.pay-dialog::backdrop { background: rgba(15, 20, 35, .55); }
.pay-dialog h2 { margin: 0 32px 8px 0; font-size: 20px; font-weight: 650; letter-spacing: -.02em; line-height: 1.4; }
.pay-close { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: none; font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; }
.pay-close:hover { background: var(--card); color: #18202f; }
.pay-lead { margin: 0; font-size: 14px; line-height: 1.75; color: var(--muted); }
.pay-price { margin: 14px 0 18px; font-size: 30px; font-weight: 650; letter-spacing: -.02em; color: #C8561B; }
.pay-price:empty { display: none; }
.pay-text { margin: 0 0 16px; font-size: 14px; line-height: 1.75; color: #3b4556; }
.pay-buttons { display: flex; gap: 10px; }
.pay-buttons .btn { flex: 1; }
.pay-qr { margin: 0 0 12px; text-align: center; }
.pay-qr img { display: block; width: 220px; height: 220px; margin: 0 auto 10px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff; image-rendering: pixelated; }
.pay-qr figcaption { font-size: 13px; line-height: 1.7; color: var(--muted); }
.pay-note { margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--card); font-size: 12px; line-height: 1.7; color: var(--muted); }
.pay-test { margin: 0 0 10px; padding: 6px 10px; border-radius: 8px; background: #fff7e0; font-size: 12px; color: #8a6a3a; text-align: center; }
.pay-success { margin: 0 0 16px; padding: 12px 14px; border-radius: 10px; background: var(--success-soft); color: var(--success); font-size: 15px; font-weight: 500; }
.pay-dialog .form-msg { margin: 12px 0 0; }
.pay-foot { margin: 14px 0 0; font-size: 12px; color: #8a92a0; }
.pay-foot a { color: var(--blue); }
@media print {
  html, body { margin: 0; padding: 0; background: #fff; }
  body { display: block; min-height: 0; }
  body > :not(.print-root) { display: none !important; }
  .print-root { display: block; }
  /* 没买（或打印文件还没取回）时直接按 Ctrl/Cmd + P：打出一页说明，而不是一张白纸 */
  .print-root:empty::before { content: "购买这本绘本后才能打印：请回到网页，点“打印 / 保存 PDF”。"; display: block; padding: 60mm 30mm; font: 16pt/1.8 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; color: #3B2A20; text-align: center; }
}

@media (max-width: 760px) {
  .pb-intro { padding-block: 24px 24px; }
  .pb-form { padding: 24px; margin-bottom: 36px; }
  .reader { padding: 10px 10px 8px; border-radius: 16px; }
  .rart { border-radius: 10px; }
  .rpage figcaption { padding: 12px 6px 0; font-size: 16px; }
  .reader-bar { margin-top: 10px; }
  .reader-nav { height: 36px; padding: 0 12px; }
  .reader-nav em { display: none; }
  .reader-dot { width: 16px; }
}
@media (max-width: 430px) {
  .pb-actions { width: 100%; flex-wrap: wrap; }
  .pb-actions .btn { flex: 1; }
}
