/* =========================================================
   BOOKS ARCHIVE
   ========================================================= */

.books-page {
    padding: 3rem 0 7rem;
    overflow: hidden;
}

/* =========================================================
   HEADER
   ========================================================= */

.books-header {
    margin-bottom: 5.5rem;
    animation: booksFadeUp 0.8s var(--ease-smooth) both;
}

.books-header-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;

    font-family: "Work Sans", sans-serif;
    font-size: 0.68rem;
    font-weight: 600;

    letter-spacing: 0.14em;
    text-transform: uppercase;

    color: var(--on-surface-muted);
}

.books-header-rule {
    width: 100%;
    height: 1px;

    margin-top: 1rem;

    background: var(--outline);
    opacity: 0.65;
}

.books-header-content {
    max-width: 850px;
    margin-top: 3.5rem;
}

.books-header-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;

    margin-bottom: 1.25rem;

    font-family: "Work Sans", sans-serif;
    font-size: 0.68rem;
    font-weight: 600;

    letter-spacing: 0.12em;
    text-transform: uppercase;

    color: var(--on-surface-muted);
}

.header-number {
    color: var(--secondary);
}

.books-header h1 {
    margin: 0;

    font-family: "Noto Serif", serif;
    font-size: clamp(3.5rem, 8vw, 7rem);
    font-weight: 400;
    line-height: 0.95;
    letter-spacing: -0.055em;

    color: var(--on-surface);
}

.books-header h1 em {
    display: block;

    font-weight: 400;
    font-style: italic;

    color: var(--secondary);
}

.books-header p {
    max-width: 580px;

    margin: 2rem 0 0;

    font-family: "Work Sans", sans-serif;
    font-size: 1rem;
    line-height: 1.8;

    color: var(--on-surface-variant);
}

/* =========================================================
   BOOK GRID
   ========================================================= */

.books-grid {
    display: grid;

    grid-template-columns: repeat(3, minmax(0, 1fr));

    gap: 4rem 2rem;
}

/* =========================================================
   BOOK CARD
   ========================================================= */

.book-card {
    /*
       These values come from the admin CategoryTheme.
       The page itself is NOT affected.
    */

    --card-bg: var(--book-light-background, #D8B9C5);
    --card-surface: var(--book-light-card, #EAD8DE);
    --card-accent: var(--book-light-accent, #795260);

    --card-text: #30262b;
    --card-muted: rgba(48, 38, 43, 0.72);
    --card-border: rgba(48, 38, 43, 0.18);

    display: flex;
    flex-direction: column;

    min-width: 0;

    overflow: hidden;

    border-radius: 0.2rem;

    background: var(--card-bg);

    box-shadow:
        0 14px 35px rgba(0, 0, 0, 0.12);

    animation: booksFadeUp 0.7s var(--ease-smooth) both;

    transition:
        transform 0.45s var(--ease-smooth),
        box-shadow 0.45s var(--ease-smooth),
        background-color 0.4s ease,
        color 0.4s ease;
}

/* =========================================================
   DARK MODE CARD COLOURS
   ========================================================= */

html[data-theme="dark"] .book-card {
    --card-bg: var(--book-dark-background, #3A2931);
    --card-surface: var(--book-dark-card, #4B3740);
    --card-accent: var(--book-dark-accent, #D5AEBB);

    --card-text: #ffffff;
    --card-muted: rgba(255, 255, 255, 0.78);
    --card-border: rgba(255, 255, 255, 0.2);
}

/* =========================================================
   BOOK CARD HOVER
   ========================================================= */

.book-card:hover {
    transform: translateY(-8px);

    box-shadow:
        0 22px 45px rgba(0, 0, 0, 0.2);
}

/* =========================================================
   COVER
   ========================================================= */

.book-cover-link {
    display: block;

    color: inherit;
    text-decoration: none;
}

.book-cover {
    position: relative;

    aspect-ratio: 2 / 3;

    margin: 1.25rem 1.25rem 0;

    overflow: hidden;

    background: #151b18;

    box-shadow:
        0 12px 24px rgba(0, 0, 0, 0.28);

    transition:
        transform 0.5s var(--ease-smooth),
        box-shadow 0.5s var(--ease-smooth);
}

.book-card:hover .book-cover {
    transform: translateY(-5px);

    box-shadow:
        0 18px 32px rgba(0, 0, 0, 0.35);
}

.book-cover img {
    width: 100%;
    height: 100%;

    display: block;

    object-fit: cover;

    transition:
        transform 0.7s var(--ease-smooth),
        filter 0.4s ease;
}

.book-card:hover .book-cover img {
    transform: scale(1.035);
}

/* =========================================================
   BOOKMARK
   ========================================================= */

.book-cover::after {
    content: "";

    position: absolute;

    top: 0;
    right: 1.2rem;

    width: 16px;
    height: 48px;

    background: var(--card-accent);

    clip-path: polygon(
        0 0,
        100% 0,
        100% 100%,
        50% 78%,
        0 100%
    );

    z-index: 2;

    transition:
        height 0.35s var(--ease-smooth),
        background-color 0.4s ease;
}

.book-card:hover .book-cover::after {
    height: 58px;
}

/* =========================================================
   COVER INDEX
   ========================================================= */

.book-index {
    position: absolute;

    top: 0.8rem;
    left: 0.8rem;

    z-index: 3;

    padding: 0.4rem 0.55rem;

    background: rgba(15, 20, 17, 0.78);

    border: 1px solid rgba(255, 255, 255, 0.2);

    font-family: "Work Sans", sans-serif;
    font-size: 0.55rem;
    font-weight: 600;

    letter-spacing: 0.12em;
    text-transform: uppercase;

    color: #ffffff;
}

/* =========================================================
   COVER OVERLAY
   ========================================================= */

.book-cover-overlay {
    position: absolute;

    inset: 0;

    display: flex;
    align-items: flex-end;
    justify-content: space-between;

    padding: 1.2rem;

    background: linear-gradient(
        to top,
        rgba(10, 15, 12, 0.88),
        rgba(10, 15, 12, 0) 50%
    );

    color: #ffffff;

    font-family: "Work Sans", sans-serif;
    font-size: 0.65rem;
    font-weight: 600;

    letter-spacing: 0.1em;
    text-transform: uppercase;

    opacity: 0;

    transition: opacity 0.35s ease;
}

.book-card:hover .book-cover-overlay {
    opacity: 1;
}

.overlay-arrow {
    font-size: 1.05rem;

    transition:
        transform 0.3s var(--ease-smooth);
}

.book-card:hover .overlay-arrow {
    transform: translate(3px, -3px);
}

/* =========================================================
   CONTENT
   ========================================================= */

.book-content {
    display: flex;
    flex-direction: column;
    flex: 1;

    padding: 1.5rem 1.5rem 1.25rem;

    background: var(--card-surface);

    color: var(--card-text);

    transition:
        background-color 0.4s ease,
        color 0.4s ease;
}

.book-content-top {
    flex: 1;
}

.book-record {
    display: block;

    margin-bottom: 0.65rem;

    font-family: "Work Sans", sans-serif;
    font-size: 0.58rem;
    font-weight: 600;

    letter-spacing: 0.13em;
    text-transform: uppercase;

    color: var(--card-accent);

    transition: color 0.4s ease;
}

.book-title {
    margin: 0 0 0.85rem;

    font-family: "Noto Serif", serif;
    font-size: clamp(1.5rem, 2vw, 1.85rem);
    font-weight: 600;
    line-height: 1.2;

    color: var(--card-text);

    transition: color 0.4s ease;
}

.book-title a {
    color: inherit;
    text-decoration: none;

    transition: color 0.25s ease;
}

.book-title a:hover {
    color: var(--card-accent);
}

.book-summary {
    display: -webkit-box;

    margin: 0 0 1.25rem;

    overflow: hidden;

    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;

    font-family: "Noto Serif", serif;
    font-size: 0.9rem;
    line-height: 1.7;

    color: var(--card-muted);

    transition: color 0.4s ease;
}

/* =========================================================
   TAGS
   ========================================================= */

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;

    margin-bottom: 1.5rem;
}

.tag {
    padding: 0.35rem 0.6rem;

    border: 1px solid var(--card-border);

    background: rgba(255, 255, 255, 0.08);

    font-family: "Work Sans", sans-serif;
    font-size: 0.58rem;
    font-weight: 600;

    letter-spacing: 0.08em;
    text-transform: uppercase;

    color: var(--card-text);

    transition:
        background 0.25s ease,
        border-color 0.25s ease,
        color 0.25s ease;
}

.book-card:hover .tag {
    border-color: var(--card-accent);
    background: rgba(255, 255, 255, 0.12);
    color: var(--card-accent);
}

/* =========================================================
   ACTION
   ========================================================= */

.book-actions {
    margin-top: auto;

    padding-top: 0.8rem;

    border-top: 1px solid var(--card-border);

    transition: border-color 0.4s ease;
}

.book-link {
    display: flex;
    align-items: center;
    justify-content: space-between;

    width: 100%;

    padding: 0.75rem 0;

    font-family: "Work Sans", sans-serif;
    font-size: 0.65rem;
    font-weight: 600;

    letter-spacing: 0.12em;
    text-transform: uppercase;

    color: var(--card-text);

    text-decoration: none;

    transition:
        color 0.25s ease,
        padding 0.25s var(--ease-smooth);
}

.book-link-arrow {
    font-size: 1rem;

    color: var(--card-accent);

    transition:
        transform 0.3s var(--ease-smooth),
        color 0.4s ease;
}

.book-link:hover {
    color: var(--card-accent);
    padding-left: 0.25rem;
}

.book-link:hover .book-link-arrow {
    transform: translateX(5px);
}

/* =========================================================
   EMPTY STATE
   ========================================================= */

.empty-state {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1.5rem;

    align-items: start;

    padding: 2rem;

    border-top: 1px solid var(--outline);
    border-bottom: 1px solid var(--outline);

    background: var(--surface-container-low);

    animation: booksFadeUp 0.7s var(--ease-smooth) both;
}

.empty-number {
    font-family: "Work Sans", sans-serif;
    font-size: 0.7rem;
    font-weight: 600;

    letter-spacing: 0.1em;

    color: var(--secondary);
}

.empty-state h2 {
    margin: 0 0 0.5rem;

    font-family: "Noto Serif", serif;
    font-size: 1.5rem;
    font-weight: 400;

    color: var(--on-surface);
}

.empty-state p {
    margin: 0;

    font-family: "Work Sans", sans-serif;
    font-size: 0.9rem;

    color: var(--on-surface-muted);
}

/* =========================================================
   FOOTER
   ========================================================= */

.books-footer {
    margin-top: 7rem;

    animation: booksFadeUp 0.8s 0.35s var(--ease-smooth) both;
}

.books-footer-rule {
    width: 100%;
    height: 1px;

    background: var(--outline);
}

.books-footer-content {
    display: flex;
    justify-content: space-between;

    padding-top: 1rem;

    font-family: "Work Sans", sans-serif;
    font-size: 0.62rem;
    font-weight: 600;

    letter-spacing: 0.12em;
    text-transform: uppercase;

    color: var(--on-surface-muted);
}

/* =========================================================
   ANIMATION
   ========================================================= */

@keyframes booksFadeUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1100px) {

    .books-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 4rem 2.5rem;
    }

    .books-grid .book-card {
        animation-delay: 0s;
    }

    .books-grid .book-card:nth-child(2n + 1) {
        animation-delay: 0.05s;
    }

    .books-grid .book-card:nth-child(2n + 2) {
        animation-delay: 0.13s;
    }
}

@media (max-width: 700px) {

    .books-page {
        padding: 2rem 0 5rem;
    }

    .books-header {
        margin-bottom: 3.5rem;
    }

    .books-header-content {
        margin-top: 2.5rem;
    }

    .books-header h1 {
        font-size: clamp(3.2rem, 16vw, 5rem);
    }

    .books-header p {
        margin-top: 1.5rem;
        font-size: 0.9rem;
    }

    .books-grid {
        grid-template-columns: 1fr;
        gap: 4.5rem;
    }

    .book-cover {
        max-width: 440px;
    }

    .book-content {
        max-width: 440px;
    }

    .book-title {
        font-size: 1.8rem;
    }

    .book-summary {
        font-size: 0.95rem;
    }

    .books-footer-content {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    .books-header,
    .book-card,
    .empty-state,
    .books-footer {
        animation: none;
    }

    .book-cover,
    .book-cover img,
    .book-cover-overlay,
    .book-cover::after,
    .overlay-arrow,
    .tag,
    .book-link,
    .book-link-arrow,
    .book-title a {
        transition: none;
    }
}