/* ═══════════════════════════════════════════
   page-flip (biblioteca não publica CSS no pacote dist)
═══════════════════════════════════════════ */
.stf__parent {
  position: relative;
  display: block;
  box-sizing: border-box;
  transform: translateZ(0);
  /* zoom nativo do navegador não é confiável em apps instalados (PWA standalone),
     então o pinça-zoom é feito manualmente via JS (ver revista.html) — aqui só
     evitamos que o navegador tente fazer pan/zoom nativo por conta própria */
  -ms-touch-action: none;
  touch-action: none;
}
.stf__wrapper, .sft__wrapper {
  position: relative;
  width: 100%;
  box-sizing: border-box;
}
.stf__parent canvas {
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
}
.stf__block {
  position: absolute;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  perspective: 2000px;
}
.stf__item {
  display: none;
  position: absolute;
  transform-style: preserve-3d;
}
.stf__outerShadow, .stf__innerShadow, .stf__hardShadow, .stf__hardInnerShadow {
  position: absolute;
  left: 0;
  top: 0;
}

/* ═══════════════════════════════════════════
   TELA DA REVISTA — fundo escuro, per mockup
═══════════════════════════════════════════ */
.dark-shell {
  background: var(--blue-deep) !important;
  color: white;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
@media (min-width: 560px) {
  .dark-shell { height: calc(100vh - 40px); }
}

/* CAPAS-VIEW e LEITOR-VIEW ocupam o corpo do dark-shell por completo,
   alternando visibilidade — só um dos dois é mostrado por vez */
.dark-shell > #capas-view, .dark-shell > #leitor-view {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
}

/* ═══════════════════════════════════════════
   TELA DE CAPAS — lista de edições publicadas
═══════════════════════════════════════════ */
.capas-header { background: transparent; box-shadow: none; padding: max(10px, env(safe-area-inset-top)) 16px 8px; flex: none; }
.capas-header .title { color: white; }
.capas-header .subtitle { color: rgba(255,255,255,0.6); }
.capas-header .back-btn { background: rgba(255,255,255,0.12); color: white; }
.capas-grid {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 4px 16px calc(20px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px;
}
.capa-card-revista {
  background: rgba(255,255,255,0.06); border-radius: 14px; overflow: hidden;
  display: flex; flex-direction: column;
}
.capa-card-revista .capa-img-wrap {
  aspect-ratio: 0.75; background: rgba(255,255,255,0.08); overflow: hidden;
  border: none; padding: 0; display: block; width: 100%; cursor: pointer;
}
.capa-card-revista .capa-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.capa-card-info { padding: 10px 10px 4px; }
.capa-card-titulo { font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 0.85rem; color: white; line-height: 1.25; }
.capa-card-edicao { font-size: 0.68rem; color: rgba(255,255,255,0.55); margin-top: 2px; text-transform: capitalize; }
.capa-card-botoes { display: flex; gap: 6px; padding: 8px 10px 10px; }
.capa-card-botoes button, .capa-card-botoes a {
  flex: 1; text-align: center; padding: 7px 4px; border-radius: 8px; font-size: 0.72rem; font-weight: 700;
  font-family: 'Inter', sans-serif; text-decoration: none; cursor: pointer; border: none;
}
.capa-card-botoes .btn-ler { background: var(--gold); color: var(--blue-deep); }
.capa-card-botoes .btn-baixar { background: rgba(255,255,255,0.12); color: white; }

/* BARRA SUPERIOR MÍNIMA — o leitor ocupa quase toda a tela */
.leitor-topbar {
  display: flex; align-items: center; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 14px 8px;
  flex: none;
}
.leitor-btn {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: rgba(255,255,255,0.12); border: none; color: white;
  display: flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none;
}
.leitor-titulo { flex: 1; min-width: 0; }
.leitor-titulo .t1 { font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 0.95rem; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leitor-titulo .t2 { font-size: 0.68rem; color: rgba(255,255,255,0.55); margin-top: 1px; }

/* VISUALIZADOR — page-flip (efeito de folhear real) */
#leitor-viewport {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  padding: 4px 8px; position: relative; overflow: hidden;
  /* todo o gesto (zoom, pan, virar página) é controlado manualmente via JS */
  touch-action: none;
}
#flipbook-wrap { display: flex; align-items: center; justify-content: center; position: relative; margin: 0 auto; transform-origin: center center; }
#flipbook { box-shadow: 0 12px 30px rgba(0,0,0,0.4); }

.flip-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  color: var(--blue-deep);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
.flip-nav-btn.left  { left: 8px; }
.flip-nav-btn.right { right: 8px; }

/* BARRA DE FERRAMENTAS INFERIOR — navegação óbvia, sempre visível */
.leitor-toolbar {
  flex: none; display: flex; flex-direction: column; gap: 4px;
  padding: 6px 14px max(10px, env(safe-area-inset-bottom));
  background: rgba(0,0,0,0.28);
}

/* linha do scrubber — arrastar pra qualquer página, como um leitor de revista digital */
.leitor-scrubber-row { display: flex; align-items: center; gap: 6px; }
.scrub-btn {
  background: none; border: none; color: rgba(255,255,255,0.85); cursor: pointer; flex: none;
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 50%;
}
.scrub-btn:active { background: rgba(255,255,255,0.15); }
.scrub-slider-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
#page-indicator { font-size: 0.7rem; color: rgba(255,255,255,0.65); }
#page-slider {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,0.2); outline: none; margin: 0;
}
#page-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--gold); cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
#page-slider::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%; background: var(--gold); border: none; cursor: pointer;
}

/* linha de ícones — páginas / edições / tela cheia */
.leitor-toolbar-icons { display: flex; align-items: center; justify-content: center; gap: 18px; padding-top: 2px; }
.leitor-toolbar-icons button {
  background: none; border: none; color: rgba(255,255,255,0.7); cursor: pointer;
  display: flex; align-items: center; gap: 5px; font-size: 0.68rem; font-family: 'Inter', sans-serif;
  padding: 4px 2px;
}
.leitor-toolbar-icons button:active { color: white; }
#btn-curtir.curtido { color: var(--gold); }
#btn-curtir.curtido #icon-curtir { filter: drop-shadow(0 0 3px rgba(201,154,62,0.7)); }
#btn-curtir:active #icon-curtir { transform: scale(1.2); }
#btn-curtir #icon-curtir { display: flex; font-size: 1rem; line-height: 1; transition: transform 0.15s ease; }

/* PAINEL DE EDIÇÕES / PÁGINAS — bottom sheet, some só quando aberto */
.painel-fundo {
  position: fixed; inset: 0; z-index: 4000; background: rgba(0,0,0,0.5); animation: fadeIn 0.2s ease;
}
.painel-edicoes {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4001; max-width: 480px; margin: 0 auto;
  background: var(--card); border-radius: 20px 20px 0 0; max-height: 70vh; display: flex; flex-direction: column;
  box-shadow: 0 -10px 40px rgba(0,0,0,0.3); animation: slideUpSheet 0.25s ease;
}
@keyframes slideUpSheet { from { transform: translateY(100%); } to { transform: translateY(0); } }
.painel-edicoes-topo {
  display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 10px;
  font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 1.05rem; color: var(--blue-deep);
  border-bottom: 1px solid var(--border); flex: none;
}
.painel-edicoes-topo button { background: none; border: none; color: var(--text-soft); font-size: 1.1rem; cursor: pointer; }
.edicoes-lista { overflow-y: auto; padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); }
.edicao-item {
  display: flex; gap: 12px; align-items: center; width: 100%; padding: 10px 6px; border: none; background: none;
  cursor: pointer; text-align: left; font-family: 'Inter', sans-serif; border-radius: 10px;
}
.edicao-item.ativa { background: var(--bg); }
.edicao-item .capa { width: 42px; height: 56px; border-radius: 5px; flex: none; background-size: cover; background-position: center; }
.edicao-item .info .titulo { font-weight: 700; font-size: 0.82rem; color: var(--text); }
.edicao-item .info .edicao { font-size: 0.72rem; color: var(--text-soft); margin-top: 2px; }

/* GRADE DE PÁGINAS (miniaturas pra ir direto numa página) */
.paginas-grid {
  overflow-y: auto; padding: 12px calc(12px + env(safe-area-inset-bottom)) 12px 12px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.pagina-grid-item {
  position: relative; border: 2px solid transparent; border-radius: 6px; overflow: hidden; padding: 0;
  background: var(--bg); cursor: pointer; aspect-ratio: 0.75;
}
.pagina-grid-item.ativa { border-color: var(--gold); }
.pagina-grid-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pagina-grid-item span {
  position: absolute; bottom: 2px; right: 3px; font-size: 0.6rem; color: white;
  background: rgba(0,0,0,0.6); padding: 1px 5px; border-radius: 4px;
}
