/* ==========================================================
   Livros da Vó — estilos
   Letras grandes, botões grandes, cores calmas e alto contraste.
   ========================================================== */

:root {
  color-scheme: light;

  --fundo: #F5EFE4;
  --superficie: #FFFDF8;
  --texto: #2A211A;
  --texto-suave: #66574A;
  --borda: #E2D6C3;
  --acento: #8E3B26;
  --acento-escuro: #6F2C1B;
  --acento-texto: #FFFFFF;
  --palco: #E7DECF;
  --trilho: #E6DBCA;

  --fonte: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fonte-titulo: "Literata", Georgia, "Times New Roman", serif;

  --raio: 14px;
  --sombra-capa: 0 1px 2px rgba(42, 33, 26, .18), 0 6px 16px rgba(42, 33, 26, .16);
  --botao-altura: 64px;
}

* { box-sizing: border-box; }

html {
  font-size: 20px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--fundo);
  color: var(--texto);
  font-family: var(--fonte);
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

[hidden] { display: none !important; }

button {
  font: inherit;
  color: inherit;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

:focus-visible { outline: 3px solid var(--acento); outline-offset: 3px; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--botao-altura);
  padding: 0 18px;
  border-radius: var(--raio);
  border: 2px solid var(--borda);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .08s ease, background-color .15s ease;
}
.btn svg {
  width: 26px; height: 26px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2.6;
  stroke-linecap: round; stroke-linejoin: round;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .35; cursor: default; transform: none; }

.btn-claro { background: var(--superficie); }
.btn-claro:active { background: var(--trilho); }

.btn-forte {
  background: var(--acento);
  border-color: var(--acento);
  color: var(--acento-texto);
}
.btn-forte:active { background: var(--acento-escuro); }

/* ==========================================================
   ESTANTE
   ========================================================== */
.estante {
  max-width: 960px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 28px) 20px calc(env(safe-area-inset-bottom) + 40px);
}

.saudacao {
  margin: 0;
  font-size: 1.1rem;
  color: var(--texto-suave);
}

h1 {
  margin: 2px 0 24px;
  font-family: var(--fonte-titulo);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.01em;
}

.secao-titulo {
  margin: 36px 0 16px;
  font-family: var(--fonte-titulo);
  font-size: 1.3rem;
  font-weight: 700;
}

/* ---------- Capa (imagem real ou capa provisória colorida) ---------- */
.capa {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 4px 8px 8px 4px;
  overflow: hidden;
  background: var(--cor, #5B4636);
  box-shadow: var(--sombra-capa);
}
.capa img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  background: #fff;
}
/* lombada sutil */
.capa::after {
  content: "";
  position: absolute; inset: 0 auto 0 0;
  width: 7px;
  background: linear-gradient(90deg, rgba(0,0,0,.18), rgba(255,255,255,.08) 60%, transparent);
  pointer-events: none;
}
.capa-texto {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: center;
  gap: 8px;
  padding: 14% 12%;
  color: #FFF8EC;
  font-family: var(--fonte-titulo);
  font-weight: 700;
  font-size: .95rem;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}
.capa-texto small {
  font-family: var(--fonte);
  font-weight: 400;
  font-size: .7rem;
  opacity: .85;
}

/* ---------- Continuar lendo ---------- */
.continuar-cartao {
  display: flex;
  align-items: stretch;
  gap: 18px;
  width: 100%;
  padding: 16px;
  border: 2px solid var(--borda);
  border-radius: 18px;
  background: var(--superficie);
  text-align: left;
  cursor: pointer;
  transition: transform .08s ease;
}
.continuar-cartao:active { transform: scale(.98); }
.continuar-cartao .capa { width: 104px; flex: none; }
.continuar-info {
  display: flex; flex-direction: column; justify-content: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}
.rotulo {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--acento);
}
.continuar-titulo {
  font-family: var(--fonte-titulo);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.continuar-pagina { font-size: .9rem; color: var(--texto-suave); }
.continuar-acao {
  align-self: flex-start;
  margin-top: 6px;
  min-height: 52px;
  padding: 0 20px;
  pointer-events: none;
}

/* ---------- Barra de progresso ---------- */
.progresso {
  display: block;
  height: 8px;
  border-radius: 99px;
  background: var(--trilho);
  overflow: hidden;
}
.progresso > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--acento);
}

/* ---------- Grade de livros ---------- */
.grade {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 28px 20px;
}
.livro {
  display: flex; flex-direction: column;
  gap: 8px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  transition: transform .08s ease;
}
.livro:active { transform: scale(.97); }
.livro-titulo {
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.livro-autor { font-size: .85rem; color: var(--texto-suave); line-height: 1.25; }
.livro .progresso { height: 6px; margin-top: 2px; }

.selo-novo {
  position: absolute; top: 10px; right: 0;
  z-index: 1;
  padding: 4px 10px 4px 12px;
  border-radius: 99px 0 0 99px;
  background: #F2C14E;
  color: #2A211A;
  font-family: var(--fonte);
  font-size: .75rem;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}

/* ---------- Aviso (sem internet, lista vazia) ---------- */
.aviso {
  margin-top: 24px;
  padding: 22px;
  border-radius: 18px;
  background: var(--superficie);
  border: 2px dashed var(--borda);
  font-size: 1.05rem;
  text-align: center;
}
.aviso strong { display: block; font-size: 1.2rem; margin-bottom: 6px; }

/* ==========================================================
   LEITOR
   ========================================================== */
.leitor {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--palco);
}

.leitor-topo,
.leitor-base {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--fundo);
  border-color: var(--borda);
  border-style: solid;
  border-width: 0;
}
.leitor-topo {
  padding-top: calc(env(safe-area-inset-top) + 10px);
  border-bottom-width: 1px;
}
.leitor-base {
  padding-bottom: calc(env(safe-area-inset-bottom) + 12px);
  border-top-width: 1px;
}

.btn-fechar { padding: 0 16px 0 10px; flex: none; }
.btn-modo {
  flex: none;
  margin-left: auto;
  padding: 0 14px;
  font-size: .95rem;
  gap: 8px;
}
.icone-aa {
  font-family: var(--fonte-titulo);
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1;
}
.btn-modo .icone-pagina { width: 22px; height: 22px; stroke-width: 2.2; display: none; }
.modo-texto .btn-modo .icone-aa { display: none; }
.modo-texto .btn-modo .icone-pagina { display: block; }
.leitor-titulo {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-family: var(--fonte-titulo);
  font-weight: 700;
  font-size: .95rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.zoom { display: flex; gap: 8px; flex: none; }
.btn-zoom { width: 58px; min-height: 52px; padding: 0; gap: 1px; font-size: 1.05rem; }
.a-pequeno { font-size: .85rem; }
.a-grande { font-size: 1.3rem; }

/* meio da tela: página ou texto */
.leitor-meio {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}

/* área onde a página aparece */
.palco {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  overflow: hidden;
  padding: 10px;
  touch-action: none;          /* gestos tratados pelo app */
  -webkit-user-select: none;
  user-select: none;
}
.palco.ampliado {
  overflow: auto;
  touch-action: pan-x pan-y;   /* arrastar para ver a página ampliada */
  -webkit-overflow-scrolling: touch;
}
.folha {
  margin: auto;                /* centraliza sem cortar quando amplia */
  flex: none;
  line-height: 0;
}
.folha canvas {
  display: block;
  background: #fff;
  box-shadow: 0 1px 3px rgba(42, 33, 26, .2), 0 8px 24px rgba(42, 33, 26, .14);
  transform-origin: center center;
}
/* modo letra grande */
.texto {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: #FBF7EF;
  touch-action: pan-y;          /* rolar com o dedo; deslizar para o lado vira a página */
  -webkit-user-select: none;
  user-select: none;
}
.texto-conteudo {
  max-width: 34em;
  margin: 0 auto;
  padding: 22px 22px 36px;
  font-family: var(--fonte-titulo);
  font-weight: 450;
  font-size: 28px;
  line-height: 1.6;
  color: #221A13;
  overflow-wrap: break-word;
  -webkit-hyphens: auto;
  hyphens: auto;
}
.texto-conteudo p { margin: 0 0 .8em; }
.texto-conteudo p.verso span {
  display: block;
  padding-left: 1.2em;
  text-indent: -1.2em;
}
.texto-conteudo h2 {
  margin: .6em 0 .7em;
  font-size: 1.2em;
  font-weight: 700;
  line-height: 1.25;
}
.texto-imagem canvas {
  display: block;
  box-shadow: 0 1px 3px rgba(42, 33, 26, .2), 0 6px 18px rgba(42, 33, 26, .12);
}

.recado {
  position: absolute;
  left: 12px; right: 12px; bottom: 12px;
  z-index: 2;
  margin: 0;
  padding: 16px 18px;
  border-radius: var(--raio);
  background: #2A211A;
  color: #FFF8EC;
  font-size: 1rem;
  line-height: 1.35;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}

.carregando {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 16px 24px;
  border-radius: var(--raio);
  background: var(--superficie);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  max-width: calc(100% - 40px);
}

.leitor-base {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding-top: 8px;
}
.leitor-progresso {
  display: flex;
  align-items: center;
  gap: 12px;
}
.leitor-progresso .progresso { flex: 1; height: 6px; }
.contador {
  margin: 0;
  font-size: .85rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--texto-suave);
}
.leitor-botoes { display: flex; gap: 10px; }
.btn-pagina { flex: 1 1 0; min-width: 0; padding: 0 10px; font-size: 1.1rem; }

/* celulares estreitos: título do livro some do topo para sobrar espaço */
@media (max-width: 560px) {
  .leitor-titulo { visibility: hidden; }
}
@media (max-width: 360px) {
  html { font-size: 18px; }
  .btn-zoom { width: 52px; }
  .btn-modo { padding: 0 10px; }
}
