/* ============================================================
   PDF 杂志阅读器 · 样式
   命名空间：pf-   （不污染宿主站点样式）
   ============================================================ */

.pf-app {
  --pf-primary: #123C63;
  --pf-primary-2: #1d5c92;
  --pf-teal: #0E8A7D;
  --pf-gold: #F2A93B;
  --pf-ink: #0a1724;
  --pf-stage-1: #17324c;
  --pf-stage-2: #0a1724;
  --pf-chrome: rgba(11, 27, 42, .94);
  --pf-line: rgba(255, 255, 255, .10);
  --pf-text: #e9eff6;
  --pf-muted: #93a8bc;
  --pf-serif: Georgia, "Songti SC", "SimSun", "Noto Serif SC", serif;
  --pf-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", Roboto, Arial, sans-serif;
  --pf-bar-h: 58px;
  --pf-foot-h: 62px;
  --pf-radius: 12px;

  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--pf-stage-2);
  color: var(--pf-text);
  font-family: var(--pf-sans);
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}

.pf-app *,
.pf-app *::before,
.pf-app *::after { box-sizing: border-box; }

/* ---------------- 顶栏 ---------------- */
.pf-bar {
  flex: 0 0 var(--pf-bar-h);
  height: var(--pf-bar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  background: var(--pf-chrome);
  border-bottom: 1px solid var(--pf-line);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  z-index: 5;
}
.pf-brand {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 30px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--pf-primary-2), var(--pf-primary));
  color: #fff;
  font: 700 13px/1 var(--pf-sans);
  letter-spacing: .06em;
}
.pf-meta { flex: 1 1 auto; min-width: 0; }
.pf-title {
  margin: 0;
  font: 600 16px/1.25 var(--pf-serif);
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pf-sub {
  margin: 3px 0 0;
  font-size: 12px;
  line-height: 1.2;
  color: var(--pf-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pf-tools { flex: 0 0 auto; display: flex; gap: 8px; }

/* ---------------- 按钮 ---------------- */
.pf-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .06);
  color: var(--pf-text);
  font: 500 13px/1 var(--pf-sans);
  padding: 0 12px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .18s, border-color .18s, color .18s, transform .12s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.pf-btn:hover { background: rgba(255, 255, 255, .13); border-color: rgba(255, 255, 255, .3); }
.pf-btn:active { transform: translateY(1px); }
.pf-btn:focus-visible { outline: 2px solid var(--pf-gold); outline-offset: 2px; }
.pf-btn[disabled] { opacity: .35; cursor: default; }
.pf-btn--primary {
  background: linear-gradient(135deg, var(--pf-primary-2), var(--pf-primary));
  border-color: transparent;
  color: #fff;
  height: 38px;
  padding: 0 20px;
}
.pf-btn--primary:hover { background: linear-gradient(135deg, #24699f, #16496f); }
.pf-btn--nav {
  width: 38px;
  padding: 0;
  font-size: 19px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---------------- 舞台 ---------------- */
.pf-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(130% 110% at 50% -10%, var(--pf-stage-1) 0%, var(--pf-stage-2) 62%, #050c14 100%);
  touch-action: none;
  overflow: hidden;
}
.pf-stage::after {
  /* 台面渐晕 */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(80% 70% at 50% 45%, transparent 55%, rgba(0, 0, 0, .45) 100%);
}

.pf-clip {
  position: relative;
  perspective: 2400px;
  perspective-origin: 50% 50%;
  transform-style: flat;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  max-width: 100%;
  max-height: 100%;
}

.pf-book {
  position: relative;
  width: 600px;
  height: 850px;
  transform: translateZ(0);
  filter: drop-shadow(0 26px 46px rgba(0, 0, 0, .55));
}
.pf-book::before {
  /* 书页底座（撑起右下角的厚度感） */
  content: "";
  position: absolute;
  inset: 4px -5px -6px 4px;
  border-radius: 2px;
  background: #d9e2ea;
  opacity: .5;
}

.pf-half {
  position: absolute;
  top: 0;
  height: 100%;
  background: #fff;
  overflow: hidden;
}
.pf-half--left { left: 0; }
.pf-half--right { left: 50%; }
.pf-half.is-void { background: transparent; }
.pf-half.is-void::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 2px, transparent 2px 5px);
}

.pf-cv {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  user-select: none;
  -webkit-user-drag: none;
}
.pf-half.is-void .pf-cv { background: transparent; opacity: 0; }

.pf-gutter {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 26px;
  transform: translateX(-50%);
  pointer-events: none;
  display: none;
  background: linear-gradient(90deg,
    rgba(0, 0, 0, 0) 0%,
    rgba(12, 30, 48, .16) 34%,
    rgba(12, 30, 48, .34) 50%,
    rgba(12, 30, 48, .16) 66%,
    rgba(0, 0, 0, 0) 100%);
}
.pf-book.is-spread .pf-gutter { display: block; }

/* ---------------- 翻页纸张 ---------------- */
.pf-sheet {
  position: absolute;
  top: 0;
  left: 50%;
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  will-change: transform;
  backface-visibility: visible;
}
.pf-sheet.is-idle { visibility: hidden; }

.pf-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #fff;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.pf-face--back { transform: rotateY(180deg); }

.pf-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}
.pf-face--front .pf-shade {
  background: linear-gradient(90deg, rgba(0, 0, 0, .05) 0%, rgba(0, 0, 0, .34) 78%, rgba(0, 0, 0, .5) 100%);
}
.pf-face--back .pf-shade {
  background: linear-gradient(90deg, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, .34) 22%, rgba(0, 0, 0, .05) 100%);
}

/* ---------------- 载入遮罩 ---------------- */
.pf-veil {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 15, 24, .82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity .3s ease;
}
.pf-veil.is-hidden { opacity: 0; pointer-events: none; }
.pf-card {
  width: min(90vw, 380px);
  padding: 28px 26px 24px;
  border-radius: 16px;
  border: 1px solid var(--pf-line);
  background: linear-gradient(180deg, rgba(28, 50, 72, .96), rgba(13, 28, 43, .96));
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  text-align: center;
}
.pf-card__spinner {
  display: block;
  width: 34px;
  height: 34px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .16);
  border-top-color: var(--pf-gold);
  animation: pf-spin .9s linear infinite;
}
.pf-veil.is-error .pf-card__spinner { display: none; }
@keyframes pf-spin { to { transform: rotate(360deg); } }

.pf-card__title {
  margin: 0 0 16px;
  font: 600 16px/1.4 var(--pf-serif);
  color: #fff;
}
.pf-card__hint {
  margin: 12px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--pf-muted);
  word-break: break-word;
}
.pf-veil.is-error .pf-progress { display: none; }

.pf-progress {
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .12);
  overflow: hidden;
}
.pf-progress > i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--pf-teal), var(--pf-gold));
  transition: width .25s ease;
}

/* 舞台小转圈（跳页/渲染中） */
.pf-spinner {
  position: absolute;
  left: 50%;
  bottom: 14px;
  width: 20px;
  height: 20px;
  margin-left: -10px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .18);
  border-top-color: var(--pf-gold);
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
  animation: pf-spin .8s linear infinite;
}
.pf-stage.is-busy .pf-spinner { opacity: 1; }

/* 拖拽提示 */
.pf-drop {
  position: absolute;
  inset: 12px;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--pf-gold);
  border-radius: 14px;
  background: rgba(8, 20, 32, .8);
  font: 600 15px/1 var(--pf-serif);
  color: var(--pf-gold);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s;
}
.pf-app.is-dragover .pf-drop { opacity: 1; }

/* ---------------- 底栏 ---------------- */
.pf-foot {
  position: relative;
  flex: 0 0 var(--pf-foot-h);
  height: var(--pf-foot-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--pf-chrome);
  border-top: 1px solid var(--pf-line);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  z-index: 5;
}
.pf-nav { flex: 0 0 auto; display: flex; gap: 8px; }

.pf-pager {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--pf-muted);
}
.pf-pager__input {
  width: 56px;
  height: 34px;
  padding: 0 8px;
  text-align: center;
  font: 600 14px/1 var(--pf-sans);
  color: #fff;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  outline: none;
  transition: border-color .18s, background .18s;
}
.pf-pager__input:focus { border-color: var(--pf-gold); background: rgba(255, 255, 255, .12); }
.pf-pager__total b { color: #fff; font-weight: 600; }
.pf-pager__range {
  padding-left: 10px;
  border-left: 1px solid var(--pf-line);
  color: #cfdcea;
  font-size: 12.5px;
  white-space: nowrap;
}

.pf-track {
  position: relative;
  flex: 1 1 auto;
  min-width: 56px;
  height: 22px;
  cursor: pointer;
  touch-action: none;
}
.pf-track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 9px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .1);
}
.pf-track::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 6px;
  height: 10px;
  border-radius: 99px;
}
.pf-track:hover::before { background: rgba(255, 255, 255, .18); }
.pf-track > i {
  position: absolute;
  left: 0;
  top: 9px;
  width: 0;
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--pf-teal), var(--pf-gold));
  transition: width .3s ease;
  pointer-events: none;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 767px) {
  .pf-app { --pf-bar-h: 52px; --pf-foot-h: 56px; }
  .pf-bar { padding: 0 10px; gap: 10px; }
  .pf-brand { width: 40px; height: 26px; font-size: 11px; }
  .pf-title { font-size: 14px; }
  .pf-sub { display: none; }
  .pf-btn { padding: 0 10px; height: 32px; font-size: 12.5px; }
  .pf-btn--hide-sm { display: none; }
  .pf-foot { padding: 0 10px; gap: 10px; }
  .pf-btn--nav { width: 34px; font-size: 17px; }
  .pf-pager__range { display: none; }
  .pf-pager__input { width: 48px; height: 32px; }
  .pf-clip { padding: 8px; }
  .pf-track { min-width: 44px; } /* 小屏保留快速定位条 */
}

@media (max-width: 479px) {
  .pf-nav .pf-btn--nav:first-child,
  .pf-nav .pf-btn--nav:last-child { display: none; }
  .pf-pager__label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .pf-card__spinner, .pf-spinner { animation-duration: 2.4s; }
}

/* ---------------- 内嵌 (iframe) 模式 ---------------- */
.pf-app.is-embed { --pf-bar-h: 46px; --pf-foot-h: 54px; }
.pf-app.is-embed .pf-bar { justify-content: center; }
.pf-app.is-embed .pf-meta { flex: 0 1 auto; text-align: center; }
.pf-app.is-embed .pf-tools { display: none; }
.pf-app.is-embed .pf-foot { justify-content: center; }
.pf-app.is-embed .pf-track { display: none; }

/* ---------------- 版权保护（仅在线浏览） ---------------- */
.pf-app.is-protected { -webkit-user-select: none; user-select: none; }
.pf-app.is-protected .pf-stage { -webkit-touch-callout: none; }
/* 仅在线浏览：本地文件入口一律不出现（含 JS 未执行完的首帧，避免闪现） */
.pf-app.is-protected #pfBtnOpen,
.pf-app.is-protected #pfBtnPick,
.pf-app.is-protected .pf-drop { display: none !important; }
.pf-cv { draggable: false; -webkit-user-drag: none; }

/* 表层水印（双图层 · 同级并列）：锚在显示区域之上，pointer-events:none 不影响翻页与阅读
   【只有一套网格】关键约束：
   1) 两层必须是 .pf-stage 的「同级兄弟」，各自独立 mix-blend-mode；
      若把浅色层嵌进带 mix-blend-mode/opacity 的父级，会被父级隔离并整体 multiply 到画面上，
      深色版面上就彻底看不见了（实测教训）。
   2) 锚点、background-size（tile）、background-position 必须完全一致 ——
      只有同源同相位才合成「一套」图案；任一项不同即变成两套错位网格。
   3) 屏幕渲染路径绝不可再往页面画布烧入平铺水印：画布位图会被
      .pf-cv 的 object-fit:contain 二次缩放（位图 320px 显示为 279px 等），
      烧入网格的可见周期变为 tile/缩放率 = 233.7 CSS px，与这里的 268 CSS px 错开，
      左右页各自锚在自身页面盒、相位也不一致 —— 翻页即成多套水印叠印（本次线上故障根因）。
      另存图片的加印改走 guardCanvasExport()，只在导出副本上加印。
   - 深色水印（multiply）负责浅底显影；浅色水印（screen）负责深底显影；二者叠加即为一套
   强度由 JS 写入的 --pf-mark-dark-a / --pf-mark-light-a 控制（以 tiles 合成 alpha 为准）。 */
.pf-mark {
  position: absolute;
  inset: 0;
  z-index: 4;              /* 书页之上，遮罩(6) / 加载指示(7) 之下 */
  pointer-events: none;
  user-select: none;
  background-repeat: repeat;
  background-position: 0 0;
  background-size: var(--pf-mark-size, 268px 268px);
}
.pf-mark--dark {
  background-image: var(--pf-mark-dark, none);
  mix-blend-mode: multiply;
  opacity: var(--pf-mark-dark-a, .10);
}
.pf-mark--light {
  background-image: var(--pf-mark-light, none);
  mix-blend-mode: screen;
  opacity: var(--pf-mark-light-a, .34);
}
.pf-mark[hidden] { display: none; }

/* 顶栏「仅在线浏览」徽章 */
.pf-lock {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid rgba(242, 169, 59, .45);
  background: rgba(242, 169, 59, .12);
  color: #f5c477;
  font-size: 12px;
  letter-spacing: .02em;
  white-space: nowrap;
}
.pf-lock[hidden] { display: none; }
.pf-lock > i {
  position: relative;
  width: 7px;
  height: 9px;
  border-radius: 2px;
  background: currentColor;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .3);
}
.pf-lock > i::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: 7px;
  height: 5px;
  margin-left: -3.5px;
  border: 1.5px solid currentColor;
  border-bottom: 0;
  border-radius: 3px 3px 0 0;
}

/* 载入卡内的版权声明 */
.pf-card__legal {
  margin: 12px 0 16px;
  font-size: 12px;
  line-height: 1.6;
  color: rgba(214, 226, 238, .62);
}

/* 操作提示 */
.pf-toast {
  position: fixed;
  left: 50%;
  bottom: 86px;
  transform: translate(-50%, 8px);
  z-index: 60;
  max-width: min(86vw, 430px);
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(15, 38, 60, .94);
  border: 1px solid rgba(120, 160, 200, .28);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .38);
  color: #eaf2fa;
  font-size: 13.5px;
  line-height: 1.55;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}
.pf-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* 打印：整块隐藏，只留声明 —— 封堵「打印为 PDF」这条常规下载路径 */
@media print {
  .pf-bar, .pf-stage, .pf-foot, .pf-toast { display: none !important; }
  html, body { background: #fff !important; }
  body::after {
    content: "本文档仅供在线浏览，不提供打印或下载。Document available for online viewing only.";
    display: block;
    padding: 96px 32px;
    color: #123c63;
    font: 500 17px/1.9 var(--pf-serif);
    text-align: center;
  }
}
.pf-app.is-printing .pf-stage { visibility: hidden; }

@media (max-width: 767px) {
  .pf-lock { height: 24px; padding: 0 8px; font-size: 11px; gap: 5px; }
  .pf-toast { bottom: 74px; font-size: 13px; padding: 9px 14px; }
}
@media (max-width: 479px) {
  .pf-lock { display: none; }   /* 小屏空间紧张：改由载入卡声明 + 操作提示承担 */
}
