/* Catalog flipbook - enqueued on the catalog page only, alongside catalog-flipbook.js */

.catalog-flipbook {
    padding: 60px 0 80px;
    background-color: #f4f4f4;
}

.catalog-flipbook__viewer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.catalog-flipbook__stage {
    position: relative;
    width: 100%;
    /* keep a 2-page spread (612 x 792 pages) within the screen height */
    max-width: calc((100vh - 220px) * 1.545);
    min-height: 300px;
}

.catalog-flipbook__book {
    width: 100%;
    margin: 0 auto;
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.6s ease;
}

/* center the closed book - see updateCentering() in catalog-flipbook.js */
.catalog-flipbook__book.is-front-cover {
    transform: translateX(calc(var(--catalog-flipbook-shift, 25%) * -1));
}

.catalog-flipbook__book.is-back-cover {
    transform: translateX(var(--catalog-flipbook-shift, 25%));
}

.catalog-flipbook__viewer.is-ready .catalog-flipbook__book {
    opacity: 1;
}

.catalog-flipbook__page {
    background-color: #ffffff;
    overflow: hidden;
}

.catalog-flipbook__page img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.3s ease;
    user-select: none;
    pointer-events: none;
}

.catalog-flipbook__page.is-loaded img {
    opacity: 1;
}

/* subtle placeholder while an individual page is still rendering */
.catalog-flipbook__page:not(.is-loaded) {
    background-image: linear-gradient(110deg, #ffffff 30%, #f0f0f0 50%, #ffffff 70%);
    background-size: 200% 100%;
    animation: catalog-flipbook-shimmer 1.4s linear infinite;
}

@keyframes catalog-flipbook-shimmer {
    to {
        background-position: -200% 0;
    }
}

/* loading & error messages */
.catalog-flipbook__status {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 20px;
    text-align: center;
    font-family: 'source-sans-3', sans-serif;
    font-size: 18px;
    color: #363636;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.catalog-flipbook__status.is-hidden {
    opacity: 0;
    visibility: hidden;
}

.catalog-flipbook__status.is-error .catalog-flipbook__spinner {
    display: none;
}

.catalog-flipbook__status a {
    color: #A21A2A;
    text-decoration: underline;
}

.catalog-flipbook__spinner {
    width: 44px;
    height: 44px;
    border: 4px solid #d3d3d3;
    border-top-color: #A21A2A;
    border-radius: 50%;
    animation: catalog-flipbook-spin 0.9s linear infinite;
}

@keyframes catalog-flipbook-spin {
    to {
        transform: rotate(360deg);
    }
}

/* toolbar */
.catalog-flipbook__toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background-color: #161616;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.catalog-flipbook__control {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 0;
    background-color: transparent;
    color: #ffffff;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.catalog-flipbook__control[hidden] {
    display: none;
}

.catalog-flipbook__control svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.catalog-flipbook__control:hover,
.catalog-flipbook__control:focus-visible {
    background-color: #A21A2A;
    color: #ffffff;
}

.catalog-flipbook__control:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: -4px;
}

.catalog-flipbook__control:disabled {
    opacity: 0.35;
    cursor: default;
    background-color: transparent;
}

.catalog-flipbook__counter {
    min-width: 150px;
    padding: 0 8px;
    text-align: center;
    font-family: 'montserrat', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
}

.catalog-flipbook__toolbar-divider {
    width: 1px;
    height: 24px;
    margin: 0 4px;
    background-color: rgba(255, 255, 255, 0.25);
}

.catalog-flipbook__noscript {
    text-align: center;
}

/* full screen */
.catalog-flipbook__viewer.is-fullscreen {
    justify-content: center;
    padding: 20px;
    background-color: #2a2a2a;
}

.catalog-flipbook__viewer.is-fullscreen .catalog-flipbook__stage {
    max-width: calc((100vh - 120px) * 1.545);
}

@media screen and (max-width: 768px) {
    .catalog-flipbook {
        padding: 30px 0 50px;
    }

    .catalog-flipbook__viewer {
        gap: 16px;
    }

    .catalog-flipbook__counter {
        min-width: 120px;
        font-size: 14px;
    }
}
