:root {
  --primary: #00334d;
  --primary-light: #01547d;
  --accent: #00a859;
  --bg: #f4f7f8;
  --card: #ffffff;
  --text: #0f2a3d;
  --muted: #6b7c85;
  --border: #e6ecf0;
  --radius: 14px;
  /* espaço horizontal reservado pros botões de "página anterior/próxima"
     ao redor do livro — encolhe em telas menores pra sobrar mais largura
     pro livro em si (ver breakpoints mais abaixo). */
  --livro-chrome-x: 180px;
}

* { box-sizing: border-box; }

/* garante que [hidden] sempre esconda o elemento, mesmo quando a classe
   dele define display:flex/grid em outro lugar da folha de estilos */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- topo ---------- */
.topo {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  background: var(--primary);
  color: #fff;
  padding: 14px 28px;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
}

.topo-marca {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  margin-right: auto;
}
.marca-nome { font-weight: 800; font-size: 22px; letter-spacing: 3px; }
.marca-tag { font-size: 11px; opacity: .75; letter-spacing: .5px; }

.topo-busca {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1 1 380px;
  max-width: 720px;
}
.topo-busca input,
.topo-busca select {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.topo-busca input { flex: 2 1 160px; min-width: 140px; }
.topo-busca select { flex: 1 1 130px; min-width: 120px; max-width: 190px; color: var(--text); }

.topo-acoes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.botao-baixar {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  padding: 11px 20px;
  border-radius: 999px;
  white-space: nowrap;
  transition: filter .15s ease, transform .15s ease;
}
.botao-baixar:hover { filter: brightness(1.08); transform: translateY(-1px); }

.botao-secundario {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,.55);
  color: #fff;
}
.botao-secundario:hover { background: rgba(255,255,255,.1); filter: none; }

/* ---------- status ---------- */
.status {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 15px;
}
.status-erro { color: #b3261e; }

/* ---------- livro (flipbook) ---------- */
main {
  min-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 10px 6px;
}

.livro-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  justify-content: center;
  padding: 10px;
  border-radius: 28px;
  background: radial-gradient(ellipse at center, rgba(0,51,77,.07) 0%, rgba(0,51,77,0) 72%);
}

/* --livro-h é calculada e atualizada via JavaScript (main.js), medindo
   a altura real do cabeçalho, do rodapé e do contador de página nesse
   exato instante — por isso o livro sempre sabe, com precisão, quanto
   espaço realmente sobra na tela, mesmo se o cabeçalho quebrar em duas
   linhas num celular ou numa janela estreita. As três medidas dentro
   do min() competem entre si: a menor sempre vence, então a caixa
   encolhe pela largura OU pela altura, o que for mais apertado — nunca
   corta produto nenhum, nunca "vaza" pra fora da tela. */
.livro-stage {
  position: relative;
  width: min(1300px, calc(100vw - var(--livro-chrome-x)), calc(var(--livro-h, 82vh) * 1300 / 1500));
  aspect-ratio: 1300 / 1500;
  max-height: var(--livro-h, 82vh);
  perspective: 2200px;
}

.livro {
  position: relative;
  width: 100%;
  height: 100%;
  box-shadow: 0 20px 50px rgba(0,51,77,.28);
  border-radius: 4px 10px 10px 4px;
  overflow: visible;
}

/* lombada do livro, só decorativa */
.livro::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 4px;
  bottom: 4px;
  width: 10px;
  background: linear-gradient(90deg, rgba(0,51,77,.35), rgba(0,51,77,0));
  border-radius: 6px;
  z-index: 0;
}

.nav {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--primary);
  font-size: 30px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  cursor: pointer;
  flex: 0 0 auto;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
  transition: background .15s ease;
}
.nav:hover { background: #eef3f5; }

.contador {
  flex: 0 0 auto;
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

/* páginas dentro do flipbook — cada uma ocupa o container inteiro,
   empilhadas, e a troca é animada com um giro 3D (efeito de virar página) */
.pagina-livro {
  position: absolute;
  inset: 0;
  background: #fff;
  padding: 42px 42px 28px;
  display: flex;
  flex-direction: column;
  border-radius: inherit;
  backface-visibility: hidden;
  transform-origin: left center;
  transform: rotateY(0deg);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transition: transform .5s cubic-bezier(.4,.1,.2,1), opacity .35s ease, box-shadow .5s ease;
}
.pagina-livro.st-instant { transition: none !important; }
.pagina-livro.st-ativa {
  opacity: 1;
  pointer-events: auto;
  z-index: 3;
  box-shadow: none;
}
.pagina-livro.st-saindo-esq {
  opacity: 1;
  transform: rotateY(-140deg);
  box-shadow: 12px 0 30px rgba(0,0,0,.25);
  z-index: 2;
}
.pagina-livro.st-entrando-dir {
  opacity: 1;
  transform: rotateY(140deg);
  z-index: 2;
}
.pagina-livro.st-saindo-dir {
  opacity: 1;
  transform: rotateY(140deg);
  box-shadow: -12px 0 30px rgba(0,0,0,.25);
  z-index: 2;
}
.pagina-livro.st-entrando-esq {
  opacity: 1;
  transform: rotateY(-140deg);
  z-index: 2;
}
.pagina-capa {
  background: linear-gradient(160deg, var(--primary), var(--primary-light));
  color: #fff;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.pagina-capa .capa-marca { letter-spacing: 8px; font-weight: 800; opacity: .85; margin-bottom: 22px; font-size: 17px; }
.pagina-capa h1 { font-size: 44px; margin: 0 0 14px; }
.pagina-capa p { font-size: 19px; opacity: .8; margin: 0; }

.pagina-cabecalho {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 12px;
  margin-bottom: 24px;
  font-weight: 800;
  color: var(--primary);
  font-size: 18px;
  letter-spacing: 2px;
}

/* 10 produtos por página, em grade 2x5 — as linhas usam "1fr" pra se
   esticarem e ocupar toda a altura disponível da página, sem sobrar
   espaço em branco embaixo (mesmo numa página com menos produtos). */
.pagina-grade {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(5, 1fr);
  gap: 12px;
  overflow: hidden;
}

.produto-card {
  display: flex;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  align-items: center;
  text-align: left;
  background: #fff;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,51,77,.05);
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
.produto-card:hover {
  box-shadow: 0 10px 24px rgba(0,51,77,.14);
  transform: translateY(-2px);
  border-color: rgba(0,168,89,.35);
}
.produto-card img {
  width: min(100px, 40%);
  height: 92%;
  object-fit: contain;
  border-radius: 8px;
  background: #f8fafb;
  border: 1px solid var(--border);
  flex: 0 0 auto;
}
.produto-card .produto-info { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.produto-card .produto-marca { color: var(--accent); font-weight: 800; font-size: 10px; letter-spacing: .5px; text-transform: uppercase; }
.produto-card .produto-nome { font-weight: 700; font-size: 12.5px; line-height: 1.2; margin: 3px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.produto-card .produto-cod { font-size: 10px; color: var(--muted); }
.produto-card .produto-preco {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 11px;
  border-radius: 999px;
  background: rgba(0,168,89,.12);
  color: #00753d;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .2px;
}

.pagina-banner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: linear-gradient(160deg, #eef7f2, #dff2e7);
  border-radius: 12px;
}
.pagina-banner h2 { color: var(--primary); font-size: 18px; margin: 0 0 6px; }
.pagina-banner p { color: #37525f; font-size: 12px; margin: 0; }

.pagina-rodape {
  text-align: center;
  font-size: 8px;
  color: #a8b6bc;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid #eef1f2;
}

/* ---------- grade mobile (fallback em telas pequenas) ---------- */
.grade-mobile {
  width: 100%;
  max-width: 720px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.grade-mobile .produto-card {
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}
.grade-mobile .produto-card img { width: 100%; height: 110px; }

.rodape-site {
  flex: 0 0 auto;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: #fff;
}

/* telas médias (tablets, janelas menores de PC): encolhe as margens e
   os botões de navegação do livro, pra sobrar mais espaço horizontal
   pra caixa em si — sem isso, num tablet o livro ficava espremido ou
   até cortado nas laterais. */
@media (max-width: 1024px) {
  :root { --livro-chrome-x: 140px; }
  .livro-wrap { gap: 6px; padding: 6px; }
  .nav { width: 38px; height: 38px; font-size: 22px; }
  .pagina-livro { padding: 22px 18px 14px; }
  .pagina-cabecalho { font-size: 13px; margin-bottom: 12px; padding-bottom: 8px; }
  .pagina-grade { gap: 8px; }
  .produto-card { padding: 7px; gap: 7px; border-radius: 10px; }
  .produto-card .produto-marca { font-size: 8.5px; }
  .produto-card .produto-nome { font-size: 10.5px; }
  .produto-card .produto-cod { font-size: 8.5px; }
  .produto-card .produto-preco { font-size: 10.5px; padding: 2px 8px; margin-top: 3px; }
  .pagina-capa h1 { font-size: 30px; }
  .pagina-capa p { font-size: 14px; }
  .pagina-capa .capa-marca { font-size: 13px; margin-bottom: 14px; }
}

@media (max-width: 900px) {
  .topo { gap: 12px; padding: 12px 16px; }
  .topo-busca { max-width: none; }
}

@media (max-width: 720px) {
  .topo { padding: 12px 16px; }
  .botao-baixar span { display: none; }
  .botao-baixar::after { content: '⬇ PDF'; }
  .botao-secundario::after { content: '📖 Revista'; }
}

/* celular: exatamente a mesma aparência do site inteiro (mesmo
   cabeçalho, mesmo livro com 2 colunas de produto por página) — só
   menor, pra caber na tela. Nada de reorganizar ou trocar o layout,
   só encolher tudo proporcionalmente. Abaixo desse tamanho o
   cabeçalho empilha em coluna (marca, busca, botões, cada um ocupando
   a largura toda) em vez de tentar quebrar linha sozinho de um jeito
   imprevisível. */
@media (max-width: 640px) {
  :root { --livro-chrome-x: 60px; }
  .topo { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 14px; }
  .topo-marca { margin-right: 0; flex-direction: row; align-items: baseline; gap: 8px; }
  /* sem isso, o "flex: 1 1 380px" (pensado pro cabeçalho em linha)
     faz a busca esticar pra ocupar o espaço vertical todo do
     cabeçalho empilhado, virando um balão gigante */
  .topo-busca { flex: 0 0 auto; max-width: none; }
  .topo-acoes { flex: 0 0 auto; width: 100%; }
  .topo-acoes .botao-baixar { flex: 1 1 0; text-align: center; }
  main { padding: 6px 4px 4px; }
  .livro-wrap { gap: 2px; padding: 2px; }
  .nav { width: 26px; height: 26px; font-size: 15px; }
  .pagina-livro { padding: 8px 8px 5px; }
  .pagina-cabecalho { font-size: 9px; margin-bottom: 5px; padding-bottom: 3px; }
  .pagina-grade { gap: 4px; }
  .produto-card { padding: 3px; gap: 4px; border-radius: 6px; }
  .produto-card img { width: 30%; }
  .produto-card .produto-marca { font-size: 6.5px; }
  .produto-card .produto-nome { font-size: 8px; line-height: 1.1; margin: 1px 0; }
  .produto-card .produto-cod { font-size: 6.5px; }
  .produto-card .produto-preco { font-size: 8px; padding: 1px 6px; margin-top: 1px; }
  .pagina-capa h1 { font-size: 20px; }
  .pagina-capa p { font-size: 11px; }
  .pagina-capa .capa-marca { font-size: 10px; margin-bottom: 8px; letter-spacing: 4px; }
  .pagina-banner h2 { font-size: 13px; }
  .pagina-banner p { font-size: 10px; padding: 0 6px; }
}
