/* MAXLEITURA - a pele da estante. Veste o kit da casa (kit/maxworks-ui.css) e
   so acrescenta o que e da estante: o topo com os trilhos, a grade de capas e
   a ficha. Escura por padrao (261004-a4-46), capas como destaque e o resto
   quieto: o topo rola junto com a estante, nada fica pregado por cima delas.
   Medidas da escala selada da casa (PADRAO-HARMONIA: 4, 8, 12, 16, 20, 24);
   no iPhone todo alvo de toque tem 44 px. */

:root {
  --vao: 12px;   /* a mesma calha em linha e coluna, nas pilulas e nas capas */
  --toque: 44px;
  /* margem lateral que respeita a ilha e o entalhe com o iPhone deitado */
  --esq: max(16px, env(safe-area-inset-left, 0px));
  --dir: max(16px, env(safe-area-inset-right, 0px));
}

body {
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
html.ficha-aberta, html.ficha-aberta body { overflow: hidden; }

/* ------------------------------------------------------------ o topo */
.topo { position: relative; padding-top: env(safe-area-inset-top, 0px); }
.topo-in {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px calc(var(--dir) + var(--toque) + 12px) 16px var(--esq);
  display: flex;
  align-items: center;
}
/* O botao de tema do kit, no tamanho de toque e rolando junto com o topo. */
.mx-tema {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: var(--dir);
  width: var(--toque);
  height: var(--toque);
}

/* Os trilhos: 12 trilhas na mesma calha da estante. A primeira linha tem 4
   pilulas (3 trilhas cada) e a segunda 3 (4 trilhas cada): a segunda linha cai
   exatamente sobre as 3 colunas de capas e nenhuma casa fica vazia. */
.filtros {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 var(--dir) 16px var(--esq);
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--vao);
  border-bottom: 1px solid var(--line);
}
.filtros .mx-chip {
  grid-column: span 3;
  min-height: var(--toque);
  padding: 8px 4px;
  font-size: 10px;
  letter-spacing: .06em;
  text-align: center;
}
.filtros .mx-chip:nth-child(n+5) { grid-column: span 4; }

/* --------------------------------------------------- a grade de capas */
.estante {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px var(--dir) 8px var(--esq);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: var(--vao);
}
.livro {
  display: block;
  align-self: start;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 8px;
}
.livro:active { transform: scale(.98); }
.capa {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 8px 16px rgba(0, 0, 0, .35);
}
[data-theme="light"] .capa { box-shadow: 0 4px 12px rgba(0, 0, 0, .14); }

/* Capa que nao carregou: o titulo inteiro no ladrilho, nunca cortado. */
.capa-texto {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .06em;
  line-height: 1.4;
  color: var(--ink2);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------ o rodape */
.rodape { max-width: 860px; margin: 0 auto; padding: 8px var(--dir) 0 var(--esq); }
.versao {
  text-align: center;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .2em;
  color: var(--ink3);
  margin-top: 24px;
}
.rodape .mx-assinatura.mx-filete { margin-top: 12px; }

/* ------------------------------------------------------------- a ficha */
.ficha-fundo {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, .62);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overscroll-behavior: contain;
}
.ficha {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 92dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  padding: 24px var(--dir) calc(24px + env(safe-area-inset-bottom, 0px)) var(--esq);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.ficha-fechar {
  position: absolute;
  top: 12px;
  right: 12px;
  width: var(--toque);
  height: var(--toque);
  flex: none;
}
.ficha-capa {
  width: 150px;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg);
  box-shadow: 0 12px 24px rgba(0, 0, 0, .4);
  margin: 8px 0 16px;
}
.ficha-titulo { font-size: 15px; font-weight: 800; letter-spacing: .08em; line-height: 1.4; padding: 0 var(--toque); }
.ficha-autor { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--ink2); margin-top: 8px; }
.ficha-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.ficha-porque {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink2);
  margin-top: 16px;
  max-width: 40ch;
}
.ficha-porque:empty { display: none; }

@media (min-width: 700px) {
  .ficha-fundo { align-items: center; }
  .ficha { border-radius: 16px; border-bottom: 1px solid var(--line); }
}
@media (prefers-reduced-motion: no-preference) {
  .livro { transition: transform .12s ease; }
}
