@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Playfair+Display:wght@500;600;700&display=swap');

/* ===== CORES DO SITE (variáveis usadas com var(--nome)) ===== */
:root {
  --ink: #f8f2e9;    /* texto claro */
  --muted: #c9c0b4;  /* texto apagado */
  --gold: #d4aa6a;   /* dourado */
  --cream: #f2eadf;  /* fundo das janelas */
}

/* ===== REGRAS GERAIS (valem para a página toda) ===== */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: #111514;
  font-family: "DM Sans", sans-serif;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #e7c28d;
  outline-offset: 3px;
}

/* Esconde um texto na tela, mas leitores de tela (para cegos) ainda leem */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== BARRA DO TOPO: logo, busca, link ===== */
.topbar {
  min-height: 68px;
  padding: 12px clamp(18px, 4vw, 58px);
  display: flex;
  align-items: center;
  gap: 28px;
  background: #171d1c;
  border-bottom: 1px solid #ffffff12;
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  text-decoration: none;
  font-family: "Playfair Display", serif;
  font-weight: 700;
  white-space: nowrap;
}

.brand-icon {
  font-size: 29px;
  color: var(--gold);
}

.search {
  display: flex;
  align-items: center;
  margin-left: auto;
  width: min(460px, 48vw);
  border: 1px solid #ffffff18;
  border-radius: 999px;
  background: #ffffff0b;
  overflow: hidden;
}

.search input {
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  padding: 12px 16px;
  min-width: 0;
  flex: 1;
}

.search input::placeholder {
  color: #b9b8b1;
}

.search button {
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 8px 15px;
  font-size: 25px;
  cursor: pointer;
}

.top-link {
  text-decoration: none;
  font-size: .9rem;
  white-space: nowrap;
}

.top-link:hover {
  color: var(--gold);
}

/* ===== BANNER DE BOAS-VINDAS (hero) ===== */
.hero {
  min-height: 360px;
  position: relative;
  display: flex;
  align-items: center;
  padding: 54px clamp(22px, 7vw, 100px);
  overflow: hidden;
  /* uma camada escura por cima da foto (para o texto continuar legível) + a foto */
  background: linear-gradient(90deg, #160e09ee 0%, #160e0999 50%, #160e0933 100%),
    url("img/banner.jpeg") center / cover;
  border-bottom: 1px solid #ffffff12;
}

.hero-content {
  max-width: 540px;
  position: relative;
  z-index: 1;
}

.eyebrow {
  color: var(--gold);
  letter-spacing: .18em;
  font-size: .69rem;
  font-weight: 700;
  margin: 0 0 12px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  font-family: "Playfair Display", Georgia, serif;
}

h1 {
  font-size: clamp(2.25rem, 4.6vw, 3.7rem);
  line-height: 1.08;
  margin-bottom: 16px;
}

.hero-content>p:not(.eyebrow) {
  color: #ded4c8;
  line-height: 1.7;
  max-width: 460px;
}

/* A estrela brilhante no canto do banner */
.hero-lamp {
  position: absolute;
  z-index: 1;
  right: 15%;
  top: 28px;
  font-size: 70px;
  color: #ffdda0;
  text-shadow: 0 0 35px #ffbd5a, 0 0 85px #ffb347;
}

/* ===== BOTÕES (dourado = primary, contorno = secondary) ===== */
.primary-button,
.secondary-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 18px;
  border-radius: 8px;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .2s, background .2s;
}

.primary-button {
  background: #d3aa6c;
  color: #20160d;
  font-weight: 700;
}

.primary-button:hover {
  background: #e4bf86;
  transform: translateY(-1px);
}

.hero .primary-button {
  margin-top: 8px;
}

.secondary-button {
  border-color: #d1c4b4;
  background: transparent;
  color: #29241e;
}

.secondary-button:hover {
  background: #e8ded1;
}

/* Botão de excluir (vermelho) */
.danger-button {
  border-color: #d3a59f;
  color: #8f2a20;
}

.danger-button:hover {
  background: #f3dad6;
}

/* ===== SEÇÕES E TÍTULOS ===== */
.section-wrap {
  padding: 42px clamp(18px, 4vw, 58px);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 22px;
}

.section-heading h2 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin-bottom: 5px;
}

.section-note,
.collection-subtitle {
  color: var(--muted);
  margin: 0;
  font-size: .92rem;
}

/* ===== CARTÕES DE CATEGORIA ===== */
.category-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.category-card {
  position: relative;      /* a imagem de fundo se posiciona dentro do cartão */
  overflow: hidden;        /* a imagem não passa da borda */
  min-height: 100px;       /* altura mínima do cartão */
  padding: 12px;           /* espaço interno */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  color: var(--ink);
  background: linear-gradient(135deg, #26302c, #151b19);
  border: 1px solid #ffffff12;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .2s, border-color .2s, background .2s;
}

.category-card:nth-child(2) {
  background: linear-gradient(135deg, #422b1d, #1a1d19);
}

.category-card:nth-child(3) {
  background: linear-gradient(135deg, #253d3a, #171b1a);
}

.category-card:nth-child(4) {
  background: linear-gradient(135deg, #443326, #1a1c19);
}

.category-card:nth-child(5) {
  background: linear-gradient(135deg, #243b4b, #171b1c);
}

.category-card:nth-child(6) {
  background: linear-gradient(135deg, #39402b, #181d19);
}

.category-card:hover,
.category-card.selected {
  transform: translateY(-2px);
  border-color: var(--gold);
}

/* A imagem de fundo do cartão */
.category-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: .35;            /* escurece a imagem para o texto aparecer */
  z-index: 0;
}

/* O texto do cartão fica por cima da imagem */
.category-card>span {
  position: relative;
  z-index: 1;
}

.category-symbol {
  font-size: 22px;
  color: var(--gold);
  margin-bottom: 8px;
}

.category-name {
  font-weight: 700;
  margin-bottom: 5px;
}

.category-description {
  color: #d0c7bb;
  font-size: .83rem;
  line-height: 1.4;
}

/* ===== ACERVO: cabeçalho e menu "Ordenar por" ===== */
.collection {
  padding-top: 30px;
  background: #0e1211;
}

.collection-heading {
  align-items: center;
}

.sort-control {
  display: flex;
  gap: 9px;
  align-items: center;
  font-size: .85rem;
  color: var(--muted);
  white-space: nowrap;
}

.sort-control select {
  color: var(--ink);
  background: #202725;
  border: 1px solid #ffffff25;
  border-radius: 8px;
  padding: 10px;
}

/* Aviso "foi adicionado / foi excluído" */
#add-status:not(:empty) {
  margin-top: 6px;
  color: var(--gold);
}

/* ===== ESTANTE DE MADEIRA E OS LIVROS (capas, legendas, prateleiras) ===== */
.bookcase {
  padding: 22px 18px 0;
  background: linear-gradient(90deg, #29180f, #5b3820 4%, #3a2416 50%, #654027 96%, #21140d);
  border: 1px solid #805735;
  border-radius: 10px 10px 0 0;
  box-shadow: inset 0 0 28px #0009;
}

.bookshelf {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: end;
  gap: 20px 16px;
  padding: 10px 8px 0;
}

.book {
  position: relative;
  display: flex;
  align-items: stretch;
  flex-direction: column;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  perspective: 800px;
}

.book-cover {
  height: clamp(170px, 23vw, 285px);
  width: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 15px 10px;
  color: #f7e9ce;
  text-align: center;
  border: 1px solid #ffffff30;
  border-radius: 3px 5px 5px 3px;
  box-shadow: inset 5px 0 6px #0005, 4px 6px 8px #0007;
  transition: transform .28s, box-shadow .28s;
  background: linear-gradient(135deg, #34516a, #142938);
}

/* A linha clara perto da lombada */
.book-cover::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 7px;
  width: 2px;
  background: #ffffff2b;
}

/* Cores de capa diferentes conforme a posição na estante (para livros sem imagem) */
.book:nth-child(5n + 2) .book-cover {
  background: linear-gradient(135deg, #6e3928, #28150f);
}

.book:nth-child(5n + 3) .book-cover {
  background: linear-gradient(135deg, #52613c, #202a1b);
}

.book:nth-child(5n + 4) .book-cover {
  background: linear-gradient(135deg, #b28a4e, #57391c);
}

.book:nth-child(5n + 5) .book-cover {
  background: linear-gradient(135deg, #594b68, #251e30);
}

/* Ao passar o mouse: o livro sobe e gira um pouco */
.book:hover .book-cover,
.book:focus-visible .book-cover {
  transform: translateY(-10px) rotateY(-5deg);
  box-shadow: 8px 12px 16px #0009;
}

/* A imagem de capa do livro (preenche a capa inteira) */
.cover-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-ornament {
  font-size: 1.7rem;
  opacity: .9;
  margin-bottom: 12px;
}

.cover-title {
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 700;
  font-size: clamp(.95rem, 1.5vw, 1.25rem);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.cover-author {
  font-size: .68rem;
  margin-top: 12px;
  opacity: .85;
}

/* A legenda embaixo da capa: título e autor numa linha só, com "..." se não couber */
.book-caption {
  color: #e5d6c4;
  text-align: left;
  font-size: .82rem;
  line-height: 1.4;
  padding: 10px 2px 14px;
}

.book-caption strong {
  display: block;
  color: #fff7ed;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-caption span {
  display: block;
  color: #c2b3a3;
  font-size: .75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A tábua de prateleira (a cada 5 livros) */
.shelf-board {
  grid-column: 1 / -1;
  height: 16px;
  margin: 0 -18px;
  background: linear-gradient(#a8794a, #5e391f 40%, #2c1a10);
  border-top: 2px solid #c18a51;
  box-shadow: 0 8px 12px #0008;
}

/* ===== MENSAGENS EMBAIXO DA ESTANTE ===== */
.empty-state {
  padding: 36px 0;
  color: var(--muted);
  text-align: center;
}

.demo-note {
  color: #a79c90;
  font-size: .78rem;
  margin: 16px 0 0;
}

/* ===== RODAPÉ ===== */
.footer {
  padding: 28px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: left;
  background: #f1e9de;
  color: #29241e;
}

.footer-mark {
  font-size: 34px;
  color: #76502f;
}

.footer p {
  margin: 0;
  font-family: "Playfair Display", serif;
  line-height: 1.5;
}

.footer p strong {
  font-size: 1.1rem;
}

/* ===== JANELAS (detalhes do livro e formulário) ===== */
.book-dialog {
  width: min(760px, calc(100% - 28px));
  max-width: none;
  padding: 0;
  color: #25231f;
  background: var(--cream);
  border: 0;
  border-radius: 15px;
  box-shadow: 0 24px 90px #000a;
  overflow: visible;
}

.book-dialog::backdrop {
  background: #030605c9;
  backdrop-filter: blur(5px);
}

/* O botão "×" no canto */
.book-dialog>form {
  position: absolute;
  right: 12px;
  top: 10px;
  z-index: 2;
}

.close-dialog {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  color: #29231d;
  background: #e5dbce;
  font-size: 27px;
  cursor: pointer;
}

/* Janela de detalhes: capa à esquerda, informações à direita */
.dialog-layout {
  display: grid;
  grid-template-columns: minmax(170px, 240px) 1fr;
  gap: clamp(22px, 4vw, 42px);
  padding: clamp(22px, 5vw, 42px);
}

.dialog-cover-wrap {
  align-self: start;
  padding-top: 8px;
}

.dialog-cover {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 5px;
  box-shadow: 0 10px 24px #0003;
}

/* Livro sem capa: o script.js coloca "hidden" e a capa some */
.dialog-cover[hidden] {
  display: none;
}

.dialog-info {
  padding-top: 4px;
}

.dialog-info .eyebrow {
  color: #8b6536;
}

.dialog-info h2 {
  font-size: clamp(1.6rem, 3.5vw, 2.3rem);
  margin: 0 36px 8px 0;
  line-height: 1.12;
}

.dialog-author {
  color: #655a4e;
  margin-bottom: 15px;
}

.meta-row {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
  font-size: .83rem;
  margin-bottom: 20px;
}

.tag {
  padding: 5px 9px;
  border-radius: 999px;
  background: #e3d8c9;
}

.synopsis {
  line-height: 1.75;
  color: #49433c;
  white-space: pre-line;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.dialog-actions .primary-button {
  background: #18201e;
  color: #fff8ef;
}

.dialog-help {
  color: #766b5f;
  font-size: .78rem;
  margin: 13px 0 0;
}

/* ===== FORMULÁRIO DE NOVO LIVRO ===== */
#add-dialog {
  max-height: calc(100vh - 28px);
  overflow-y: auto;
}

.add-form-wrap {
  padding: clamp(22px, 5vw, 42px);
}

.add-form {
  display: grid;
  gap: 14px;
}

.add-form .eyebrow {
  color: #8b6536;
  margin: 0;
}

.add-form h2 {
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  margin: 0 36px 4px 0;
}

.add-form label {
  display: grid;
  gap: 6px;
  font-size: .85rem;
  color: #49433c;
}

.add-form input,
.add-form select,
.add-form textarea {
  padding: 11px 12px;
  border: 1px solid #cdbfae;
  border-radius: 8px;
  background: #fffaf3;
  color: #25231f;
  font: inherit;
}

.add-form :focus-visible {
  outline: 3px solid #8b6536;
  outline-offset: 2px;
}

/* Mensagem de erro do formulário (vermelha) */
.form-message {
  margin: 0;
  min-height: 1.3em;
  color: #a1362b;
  font-size: .85rem;
  font-weight: 600;
}

/* ===== CELULAR E TABLET (telas até 760px) ===== */
@media (max-width: 760px) {
  .topbar {
    gap: 12px;
    flex-wrap: wrap;
  }

  .brand {
    flex: 1;
  }

  .top-link {
    display: none;
  }

  .search {
    order: 2;
    width: 100%;
  }

  .hero {
    min-height: 330px;
    padding-top: 44px;
    padding-bottom: 44px;
  }

  .hero-lamp {
    right: 8%;
    top: 16px;
    font-size: 48px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bookshelf {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px 12px;
  }

  .book-cover {
    height: clamp(160px, 54vw, 245px);
  }

  .collection-heading {
    gap: 14px;
  }

  .dialog-layout {
    grid-template-columns: 105px 1fr;
    gap: 18px;
    padding: 22px 16px;
  }

  .dialog-info h2 {
    font-size: 1.45rem;
  }

  .dialog-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .dialog-actions>* {
    width: 100%;
  }
}

/* ===== CELULAR PEQUENO (telas até 390px) ===== */
@media (max-width: 390px) {
  .category-grid {
    grid-template-columns: 1fr;
  }

  .bookshelf {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dialog-layout {
    grid-template-columns: 1fr;
  }

  .dialog-cover-wrap {
    width: 125px;
  }
}

/* ===== ACESSIBILIDADE: menos animação para quem pediu isso no sistema ===== */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}

/* ===== BOTÃO DE ALTERNAR TEMA ===== */

.botao-tema {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    padding: 9px 13px;

    color: var(--ink);
    background: transparent;

    border: 1px solid var(--gold);
    border-radius: 8px;

    font-size: 0.85rem;
    cursor: pointer;

    white-space: nowrap;

    transition: background .2s, color .2s;
}

.botao-tema:hover {
    background: #ffffff12;
}

.botao-tema span:first-child {
    font-size: 19px;
}


/* ============================================================
   MINHA BIBLIOTECA — MODO CLARO
   ============================================================ */

html[data-tema="claro"] {

    /* CORES PRINCIPAIS */
    --ink: #29241e;
    --muted: #71675c;
    --gold: #9a6b32;
    --cream: #fffaf3;
}

/* FUNDO GERAL */
html[data-tema="claro"] body {
    color: var(--ink);
    background: #f5f0e8;
}

/* CABEÇALHO */
html[data-tema="claro"] .topbar {
    background: #fffaf3;
    border-bottom: 1px solid #e5d8c6;
}

html[data-tema="claro"] .brand {
    color: #29241e;
}

html[data-tema="claro"] .brand-icon {
    color: #9a6b32;
}

/* PESQUISA */
html[data-tema="claro"] .topbar .search {
    background: #ffffff !important;
    border: 1px solid #d8c9b7 !important;
}

html[data-tema="claro"] .topbar .search input {
    background: #ffffff !important;
    color: #29241e !important;
}

html[data-tema="claro"] .topbar .search input::placeholder {
    color: #82776b;
    opacity: 1;
}

html[data-tema="claro"] .topbar .search button {
    background: #ffffff !important;
    color: #29241e !important;
}