/* =========================================================
   漫画阅读器
   一次一页、键盘/滑动翻页、进度记忆、白纸/米纸/夜间
   ========================================================= */

.reader{
  --r-bg:#FFFFFF;
  --r-ink:#111114;
  --r-muted:#6E6E76;
  --r-hair:#E8E7E3;
  --r-soft:#F7F6F3;
  --r-bar:rgba(255,255,255,.86);
  min-height:100vh;
  display:flex;
  flex-direction:column;
  background:var(--r-bg);
  color:var(--r-ink);
  transition:background .3s var(--ease),color .3s var(--ease);
}
.reader[data-theme="paper"]{
  --r-bg:#F7F6F3;
  --r-soft:#EFEDE8;
  --r-bar:rgba(247,246,243,.9);
}
.reader[data-theme="night"]{
  --r-bg:#141416;
  --r-ink:#EDEDEF;
  --r-muted:#9C9CA4;
  --r-hair:#2C2C31;
  --r-soft:#1B1B1F;
  --r-bar:rgba(20,20,22,.9);
}

.reader a{color:inherit}

.reader-progress{
  position:fixed;
  top:0;left:0;right:0;
  height:2px;
  z-index:30;
  pointer-events:none;
}
.reader-progress i{
  display:block;
  height:100%;
  width:0;
  background:linear-gradient(90deg,var(--gold-3),var(--gold-2),var(--gold));
  transition:width .25s var(--ease);
}

.reader-bar{
  position:fixed;
  top:0;left:0;right:0;
  z-index:25;
  display:flex;
  align-items:center;
  gap:clamp(12px,2vw,28px);
  height:56px;
  padding:0 clamp(12px,3vw,24px);
  background:var(--r-bar);
  -webkit-backdrop-filter:saturate(180%) blur(16px);
  backdrop-filter:saturate(180%) blur(16px);
  border-bottom:1px solid var(--r-hair);
}
.reader-back{
  flex:none;
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-size:12.5px;
  color:var(--r-muted);
  transition:color .25s var(--ease);
}
.reader-back:hover{color:var(--r-ink)}
.reader-name{
  display:flex;
  flex-direction:column;
  gap:2px;
  margin:0;
  min-width:0;
  line-height:1.3;
}
.reader-name b{font-size:13.5px;font-weight:600;letter-spacing:.01em}
.reader-name span{
  font-size:10.5px;
  letter-spacing:.1em;
  color:var(--r-muted);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.reader-tools{
  margin-left:auto;
  display:flex;
  align-items:center;
  gap:6px;
  flex:none;
}
.reader-tools button,
.reader-pager button{
  min-height:34px;
  padding:0 12px;
  border:1px solid var(--r-hair);
  border-radius:var(--pill);
  background:transparent;
  color:var(--r-ink);
  font-size:12px;
  cursor:pointer;
  transition:border-color .25s var(--ease),background .25s var(--ease);
}
.reader-tools button:hover,
.reader-pager button:hover{border-color:var(--r-muted);background:rgba(128,128,128,.06)}
.reader-tools button b{font-weight:500;font-size:11px;letter-spacing:.08em}
.reader-tools button:disabled,
.reader-pager button:disabled{opacity:.35;cursor:default}

.reader-stage{
  flex:1;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:calc(56px + 20px) 0 calc(64px + 20px);
  position:relative;
}
.reader-pages{
  position:relative;
  width:min(1280px,calc(100vw - clamp(16px,6vw,120px)));
  display:grid;
  place-items:center;
}
.reader-sheet{
  grid-area:1 / 1;
  width:100%;
  margin:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  opacity:0;
  visibility:hidden;
  transition:opacity .28s var(--ease),visibility .28s;
}
.reader-sheet.is-active{opacity:1;visibility:visible}
.reader-sheet img{
  max-width:100%;
  max-height:calc(100vh - 200px);
  width:auto;
  height:auto;
  border:1px solid var(--r-hair);
  border-radius:10px;
  background:var(--r-soft);
}
.reader-blank{
  width:100%;
  aspect-ratio:16 / 9;
  max-height:calc(100vh - 210px);
  border:1px solid var(--r-hair);
  border-radius:10px;
  background:linear-gradient(160deg,#FFFDF8 0%,var(--r-soft) 100%);
}
.reader[data-theme="night"] .reader-sheet img{filter:brightness(.88)}
.reader[data-theme="night"] .reader-blank{background:var(--r-soft)}
.reader[data-theme="night"] .media-note{color:var(--r-muted)}
.reader[data-theme="night"] .media-mark path,
.reader[data-theme="night"] .media-mark circle{stroke:var(--gold-2)}
.reader-sheet figcaption{
  display:flex;
  justify-content:space-between;
  gap:16px;
  width:100%;
  margin-top:10px;
  font-size:11px;
  letter-spacing:.08em;
  color:var(--r-muted);
}

.reader-zone{
  position:absolute;
  top:calc(56px + 20px);
  bottom:calc(64px + 20px);
  width:16%;
  border:0;
  background:transparent;
  color:var(--r-muted);
  font-size:18px;
  cursor:pointer;
  opacity:0;
  transition:opacity .25s var(--ease),color .25s var(--ease);
}
.reader-zone--prev{left:0}
.reader-zone--next{right:0}
.reader-stage:hover .reader-zone{opacity:.55}
.reader-zone:hover{color:var(--r-ink);opacity:1}
.reader-zone:focus-visible{opacity:1;outline-offset:-6px}

.reader-foot{
  position:fixed;
  bottom:0;left:0;right:0;
  z-index:25;
  display:grid;
  grid-template-columns:1fr auto 1fr;
  align-items:center;
  gap:16px;
  height:64px;
  padding:0 clamp(12px,3vw,24px);
  background:var(--r-bar);
  -webkit-backdrop-filter:saturate(180%) blur(16px);
  backdrop-filter:saturate(180%) blur(16px);
  border-top:1px solid var(--r-hair);
}
.reader-pager{
  grid-column:2;
  display:flex;
  align-items:center;
  gap:14px;
}
.reader-count{
  margin:0;
  font-family:var(--mono);
  font-size:12px;
  letter-spacing:.06em;
  color:var(--r-muted);
  min-width:64px;
  text-align:center;
}
.reader-count b{color:var(--r-ink);font-weight:600}
.reader-hint{
  grid-column:3;
  justify-self:end;
  margin:0;
  font-size:11px;
  letter-spacing:.04em;
  color:var(--r-muted);
}

.reader-drawer{
  position:fixed;
  top:0;right:0;bottom:0;
  z-index:40;
  width:min(380px,88vw);
  display:flex;
  flex-direction:column;
  background:var(--r-bg);
  border-left:1px solid var(--r-hair);
  transform:translateX(101%);
  transition:transform .4s var(--ease-out);
  box-shadow:-30px 0 70px -50px rgba(0,0,0,.5);
}
.reader-drawer[aria-hidden="false"]{transform:none}
.reader-drawer-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:18px 20px;
  border-bottom:1px solid var(--r-hair);
}
.reader-drawer-head p{margin:0;font-size:13px;font-weight:600}
.reader-drawer-head span{
  font-weight:400;
  font-size:10.5px;
  letter-spacing:.1em;
  color:var(--r-muted);
  margin-left:8px;
}
.reader-drawer-head button{
  width:32px;height:32px;
  border:1px solid var(--r-hair);
  border-radius:50%;
  background:transparent;
  color:var(--r-muted);
  font-size:15px;
  line-height:1;
  cursor:pointer;
  transition:border-color .25s var(--ease),color .25s var(--ease);
}
.reader-drawer-head button:hover{border-color:var(--r-muted);color:var(--r-ink)}
.reader-chapters{
  list-style:none;
  margin:0;
  padding:6px 0;
  flex:1;
  overflow-y:auto;
}
.reader-chapters a{
  display:grid;
  grid-template-columns:58px minmax(0,1fr) auto;
  align-items:center;
  gap:12px;
  padding:14px 20px;
  border-bottom:1px solid var(--r-hair);
  transition:background .25s var(--ease);
}
.reader-chapters a:hover{background:var(--r-soft)}
.reader-chapters span{
  font-family:var(--mono);
  font-size:10.5px;
  letter-spacing:.08em;
  color:var(--gold);
}
.reader-chapters b{font-size:13px;font-weight:600}
.reader-chapters i{
  font-style:normal;
  font-size:11px;
  color:var(--r-muted);
}
.reader-chapters .is-current a{background:var(--r-soft)}
.reader-drawer-foot{
  margin:0;
  padding:16px 20px;
  border-top:1px solid var(--r-hair);
  font-size:11.5px;
  color:var(--r-muted);
}
.reader-drawer-foot a:hover{color:var(--r-ink)}

@media (max-width:720px){
  .reader-name span{display:none}
  .reader-tools button{min-height:38px;padding:0 12px;font-size:11.5px}
  .reader-hint{display:none}
  .reader-zone{display:none}
  .reader-foot{grid-template-columns:1fr}
  .reader-pager{grid-column:1;justify-self:center}
  .reader-stage{align-items:flex-start;padding-top:calc(56px + 14px)}
  .reader-sheet img{max-height:calc(100vh - 180px)}
  .reader-blank{max-height:none}
}

@media (prefers-reduced-motion:reduce){
  .reader *,
  .reader-sheet,
  .reader-drawer{transition-duration:.001ms !important}
}
