/* =========================================================
   CATÁLOGO COMPLETO DE LIBROS
   ========================================================= */

.all-books-page {
    min-height: 70vh;
    padding: 70px 0 80px;
    background: #f5f0e6;
    color: #17243a;
}

.all-books-heading {
    width: 100%;
    max-width: 900px;
    margin: 0 auto 48px;
    text-align: center;
}

.all-books-heading .section-eyebrow {
    margin: 0 0 12px;
    color: #a78136;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.16em;
}

.all-books-heading h1 {
    margin: 0;
    color: #17243a;
    font-size: clamp(2.2rem, 4vw, 3.5rem);
    line-height: 1.15;
}

.all-books-intro {
    max-width: 680px;
    margin: 20px auto 0;
    color: #5c6067;
    font-size: 1.05rem;
    line-height: 1.7;
}

/* Barra de filtros y búsqueda */

.books-catalog {
    max-width: 1440px;
    margin: 0 auto;
}

.books-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 28px;
    margin-bottom: 26px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(23, 36, 58, 0.15);
}

.books-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.book-filter {
    appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--navy);
  padding: 9px 15px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  text-transform: uppercase;
}

.book-filter:hover {
    border-color: #17243a;
}

.book-filter.active {
    border-color: #17243a;
    background: #17243a;
    color: #fff;
}

.book-filter:focus-visible,
.clear-search:focus-visible,
.reset-books-button:focus-visible {
    outline: 2px solid #a78136;
    outline-offset: 3px;
}

/* Buscador */

.books-search {
    width: min(100%, 390px);
    flex: 0 1 390px;
}

.books-search label {
    display: block;
    margin-bottom: 8px;
    color: #17243a;
    font-size: 0.85rem;
    font-weight: 600;
}

.books-search-field {
    position: relative;
    display: flex;
    align-items: center;
}

.books-search-field input {
    width: 100%;
    min-height: 44px;
    padding: 11px 42px 11px 14px;
    border: 1px solid rgba(23, 36, 58, 0.25);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.6);
    color: #17243a;
    font: inherit;
    font-size: 0.92rem;
    box-sizing: border-box;
    transition:
        border-color 0.2s ease,
        background-color 0.2s ease;
}

.books-search-field input:focus {
    border-color: #a78136;
    outline: none;
    background: #fff;
}

.books-search-field input::placeholder {
    color: #858585;
}

.clear-search {
    position: absolute;
    right: 8px;
    top: 50%;
    display: grid;
    width: 30px;
    height: 30px;
    padding: 0;
    place-items: center;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: #17243a;
    font-size: 1.5rem;
    cursor: pointer;
}

.clear-search[hidden] {
    display: none;
}

/* Contador de resultados */

.books-results-info {
    margin-bottom: 22px;
}

.books-results-info p {
    margin: 0;
    color: #696969;
    font-size: 0.9rem;
}

/* Cuadrícula */

.all-books-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 42px 28px;
    align-items: start;
}

.all-books-grid:empty {
    display: none;
}


.all-book-link {
    display: block;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.all-book-cover-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 340px;
    margin-bottom: 22px;
    overflow: visible;
}

.all-book-cover {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 245px;
    object-fit: contain;
    transform: rotate(-3deg) scale(0.94);
    filter: drop-shadow(0 8px 9px rgba(0, 0, 0, 0.10));
    transition:
        transform 0.3s ease,
        filter 0.3s ease;
}

.all-book-link:hover .all-book-cover,
.all-book-link:focus-visible .all-book-cover {
    transform: rotate(0deg) scale(1);
    filter: drop-shadow(0 15px 15px rgba(0, 0, 0, 0.18));
}

.all-book-link:focus-visible {
    outline: 2px solid #a78136;
    outline-offset: 5px;
}

.all-book-category {
    display: block;
    margin-bottom: 8px;
    color: #a78136;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.all-book-title {
    margin: 0;
    color: #17243a;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.45;
    transition: color 0.2s ease;
}

.all-book-link:hover .all-book-title {
    color: #96712e;
}

.all-book-date {
    margin: 9px 0 0;
    color: #777;
    font-size: 0.84rem;
}

/* Estados vacíos y error */

.books-empty-state,
.books-load-error {
    padding: 48px 20px;
    text-align: center;
}

.books-empty-state h2 {
    margin: 0 0 12px;
    color: #17243a;
    font-size: 1.5rem;
}

.books-empty-state p,
.books-load-error p {
    margin: 0 0 22px;
    color: #696969;
    line-height: 1.6;
}

.books-empty-state[hidden],
.books-load-error[hidden] {
    display: none;
}

.reset-books-button {
    padding: 12px 20px;
    border: 1px solid #17243a;
    border-radius: 3px;
    background: #17243a;
    color: #fff;
    font: inherit;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.reset-books-button:hover {
    background: #293d5c;
}

/* Adaptación a pantallas medianas */

@media (max-width: 1100px) {
    .all-books-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 38px 22px;
    }

    .all-book-cover-wrap {
        height: 310px;
    }
}

@media (max-width: 800px) {
    .all-books-page {
        padding: 50px 0 60px;
    }

    .books-toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: 22px;
    }

    .books-search {
        width: 100%;
        max-width: none;
        flex-basis: auto;
    }

    .all-books-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 34px 20px;
    }

    .all-book-cover-wrap {
        height: 300px;
    }
}

/* Móviles */

@media (max-width: 700px) {
    .all-books-page {
        padding: 50px 0 60px;
    }
}

@media (max-width: 480px) {
    .all-books-page {
        padding: 38px 0 56px;
    }

    .all-books-heading {
        margin-bottom: 34px;
    }

    .all-books-intro {
        font-size: 0.96rem;
    }

    .books-filters {
        gap: 8px;
    }

    .book-filter {
        padding: 9px 12px;
        font-size: 0.82rem;
    }

    .all-books-grid {
        gap: 30px 12px;
    }

    .all-book-cover-wrap {
        height: 220px;
        margin-bottom: 16px;
    }

    .all-book-title {
        font-size: 0.94rem;
    }

    .all-book-category {
        font-size: 0.65rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .book-filter,
    .books-search-field input,
    .all-book-cover,
    .all-book-title,
    .reset-books-button {
        transition: none;
    }
}