@import url('https://fonts.googleapis.com/css2?family=Andika:wght@400;700&family=Lilita+One&display=swap');

:root {
  --wood: #b5763e;
  --wood-dark: #8a5326;
  --wood-light: #cf914f;
  --night: #16244a;
  --green: #4caf50;
  --text: #a8705a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font-family: 'Andika', system-ui, sans-serif; }
button { font: inherit; cursor: pointer; }

/* ------------------------- Estante ------------------------- */
body.estante {
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.05) 0 2px, transparent 2px 140px),
    linear-gradient(180deg, var(--wood-light), var(--wood));
  min-height: 100%;
}
.topo {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px; padding: 14px 16px 18px;
  background: radial-gradient(circle at 20% 30%, #23366b, var(--night));
  border-bottom: 10px solid var(--wood-dark);
  box-shadow: 0 6px 12px rgba(0,0,0,.25);
}
.topo h1 { flex: 1; margin: 0; color: #fff; font: 26px 'Lilita One', sans-serif; letter-spacing: .5px; text-shadow: 0 2px 0 rgba(0,0,0,.35); }
.topo h1 span { color: #ffd54a; }
.pill { background: rgba(0,0,0,.35); color: #fff; border: 0; border-radius: 999px; padding: 10px 16px; font: 15px 'Lilita One'; text-decoration: none; }
.estrelas { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.estrelas i { position: absolute; color: #ffd54a; font-style: normal; font-size: 14px; opacity: .8; }

.prateleira { position: relative; padding: 26px 0 0; }
.prateleira .livros {
  display: flex; gap: 22px; overflow-x: auto; padding: 0 22px 0; scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.prateleira .livros::-webkit-scrollbar { display: none; }
.prateleira .tabua {
  height: 26px; margin-top: -6px;
  background: linear-gradient(180deg, var(--cor) 0 60%, color-mix(in srgb, var(--cor) 70%, #000) 60% 100%);
  box-shadow: 0 8px 14px rgba(0,0,0,.25);
}
.prateleira .rotulo {
  position: relative; display: block; width: max-content; min-width: 55%; margin: -18px auto 0; padding: 6px 30px;
  background: var(--cor); color: #fff; border-radius: 0 0 30px 30px; text-align: center;
  font: 22px 'Lilita One', sans-serif; letter-spacing: 1.5px; text-transform: uppercase;
  text-shadow: 0 2px 0 rgba(0,0,0,.2);
}
.prateleira.tema-natal { background: linear-gradient(180deg, #2b4fa3, #4b3a8f); }

.livro {
  position: relative; flex: 0 0 auto; width: clamp(110px, 30vw, 190px); aspect-ratio: 3 / 4.1;
  scroll-snap-align: start; border: 0; padding: 0; background: none; text-align: center;
  transition: transform .15s;
}
.livro:active { transform: scale(.96); }
.livro .capa {
  position: absolute; inset: 0 8px 0 0; border-radius: 4px 10px 10px 4px; overflow: hidden;
  background: linear-gradient(160deg, #3fa26a, #1e6a5a) center/cover;
  box-shadow: inset 6px 0 6px -3px rgba(0,0,0,.35), 4px 6px 10px rgba(0,0,0,.35);
}
.livro .capa::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.25), transparent 40%); }
.livro::after { /* folhas do livro */
  content: ''; position: absolute; top: 6px; bottom: 3px; right: 0; width: 10px; border-radius: 0 6px 6px 0;
  background: repeating-linear-gradient(90deg, #fff 0 2px, #ddd 2px 3px);
  box-shadow: 2px 3px 6px rgba(0,0,0,.3);
}
.livro .titulo {
  position: absolute; z-index: 1; top: 8%; left: 6%; right: 12%;
  color: #fff; font: clamp(16px, 5vw, 28px)/1 'Lilita One', sans-serif; text-transform: uppercase;
  -webkit-text-stroke: 1px rgba(0,0,0,.35);
  text-shadow: 0 3px 0 rgba(0,0,0,.45), 0 0 10px rgba(0,0,0,.4);
}
.livro .cadeado {
  position: absolute; z-index: 2; right: 2px; top: 52%; width: 40px; height: 40px; border-radius: 10px 0 0 10px;
  background: linear-gradient(180deg, #ffd54a, #f0a500); display: grid; place-items: center; font-size: 20px;
  box-shadow: -2px 3px 6px rgba(0,0,0,.35);
}
.livro .rascunho { position: absolute; z-index: 2; left: 4px; bottom: 6px; background: #000a; color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 6px; }
.livro .progresso { position: absolute; z-index: 2; left: 8px; right: 16px; bottom: 8px; height: 6px; background: #0005; border-radius: 3px; overflow: hidden; }
.livro .progresso b { display: block; height: 100%; background: #ffd54a; }
.vazio { color: #fff; text-align: center; padding: 60px 20px; font-size: 20px; text-shadow: 0 1px 2px #0006; }
.vazio a { color: #ffd54a; }

/* ------------------------- Leitor ------------------------- */
body.leitor { background: #fffdfb; color: var(--text); overflow: hidden; }
body.leitor.noite { background: #1b1d2b; --text: #e8d6c2; }
.leitor .app { display: flex; flex-direction: column; height: 100dvh; max-width: 900px; margin: 0 auto; }
.ferramentas { display: flex; align-items: center; gap: 22px; padding: 18px 22px 0; }
.ferramentas button { background: none; border: 0; padding: 4px; color: #7fcf98; font-size: 26px; line-height: 1; opacity: .9; }
.ferramentas button.on { color: var(--green); opacity: 1; }
.ferramentas .menu { margin-left: auto; }
.ferramentas svg { width: 32px; height: 32px; fill: currentColor; display: block; }

.texto {
  flex: 1 1 auto; display: grid; place-items: center; padding: 10px 28px; text-align: center; min-height: 0;
  font-size: var(--fs, 34px); line-height: 1.75; overflow: auto;
}
.texto.oculto p { visibility: hidden; }
.texto p { margin: 0; word-spacing: .15em; }
.texto .w { border-radius: 8px; padding: 0 2px; transition: background .12s, color .12s; }
.texto .w.atual { background: #ffe9a8; color: #8a4b2a; }
.noite .texto .w.atual { background: #6b5a2a; color: #fff; }
.texto h2 { margin: 0; font: clamp(32px, 9vw, 56px)/1.1 'Lilita One', sans-serif; color: var(--green); }

.ilustracao { position: relative; flex: 0 0 auto; aspect-ratio: 4 / 3; max-height: 52dvh; background: #eee center/cover; overflow: hidden; }
.ilustracao img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: surge .5s ease; }
@keyframes surge { from { opacity: 0; transform: scale(1.03); } to { opacity: 1; transform: none; } }
.barra-prog { height: 8px; background: #fff; }
.barra-prog b { display: block; height: 100%; background: #2e9a46; transition: width .3s; }

.controles {
  display: flex; align-items: center; justify-content: space-around; padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #5cbf5f, #3e9e47); color: #fff;
}
.controles button { background: none; border: 0; color: #fff; padding: 6px 10px; filter: drop-shadow(0 3px 0 rgba(0,0,0,.25)); }
.controles button:disabled { opacity: .35; }
.controles svg { width: 40px; height: 40px; fill: #fff; display: block; }
.controles .contador { font: 22px 'Lilita One', sans-serif; min-width: 70px; text-align: center; }

.fim { display: flex; flex-direction: column; gap: 16px; align-items: center; }
.fim button { background: var(--green); color: #fff; border: 0; border-radius: 999px; padding: 14px 28px; font: 22px 'Lilita One'; box-shadow: 0 4px 0 #2e7d32; }

@media (min-width: 700px) and (orientation: landscape) {
  .leitor .app { max-width: none; display: grid; grid-template-columns: 1fr 1.2fr; grid-template-rows: auto 1fr auto auto; }
  .ferramentas { grid-column: 1 / -1; }
  .texto { grid-column: 1; grid-row: 2; }
  .ilustracao { grid-column: 2; grid-row: 2; max-height: none; aspect-ratio: auto; margin: 0 20px 20px 0; border-radius: 16px; }
  .barra-prog, .controles { grid-column: 1 / -1; }
}
