/* ── Flipbook widget (compact, embeddable) ─────────── */
.flipbook-widget {
    margin: 2rem 0;
    border-radius: 12px;
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    overflow: hidden;
}

.flipbook-viewport {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px 12px 8px;
    min-height: 320px;
}

/* PageFlip pages */
.page {
    background-color: #fff;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.04);
    border: solid 1px #e5e7eb;
    overflow: hidden;
}
.page.--left {
    border-right: 0;
    box-shadow: inset -8px 0 16px rgba(0, 0, 0, 0.07);
}
.page.--right {
    border-left: 0;
    box-shadow: inset 8px 0 16px rgba(0, 0, 0, 0.07);
}
.page-content {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}
.page canvas {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}
.page.cover {
    background-color: var(--main-bg);
    color: white;
    border: 2px solid #2d3345;
}

/* ── Inline controls bar ───────────────────────────── */
.flipbook-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--main-bg);
    border-radius: 0 0 12px 12px;
    position: relative;
}
.flipbook-controls button {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: double 2px transparent;
    background-image: linear-gradient(
            var(--main-bg),
            var(--main-bg)
        ),
        linear-gradient(to right in lch, #ff4040, #4cbfff);
    background-origin: border-box;
    background-clip: padding-box, border-box;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: rgba(255, 255, 255, 0.8);
    padding: 0;
}
.flipbook-controls button:hover:not(:disabled) {
    background-image: linear-gradient(
            var(--secondary-red),
            var(--secondary-red)
        ),
        linear-gradient(to right in lch, #ff4040, #4cbfff);
    color: white;
    transform: translateY(-1px);
}
.flipbook-controls button:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}
.flipbook-controls button svg {
    width: 14px;
    height: 14px;
}
.flipbook-controls .page-indicator {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.5);
    font-variant-numeric: tabular-nums;
    min-width: 80px;
    text-align: center;
}
.flipbook-controls .page-indicator strong {
    color: white;
    font-family: "Lato-bold", sans-serif;
    font-size: 1.1rem;
}
/* ── Loader (scoped inside widget) ─────────────────── */
.flipbook-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
    gap: 10px;
}
.flipbook-loader.hidden {
    display: none;
}
.flipbook-loader .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--secondary-red);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
.flipbook-loader .progress-track {
    width: 180px;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
}
.flipbook-loader .progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 2px;
    background: linear-gradient(to right in lch, #ff4040, #4cbfff);
    transition: width 0.25s ease;
}
.flipbook-loader p {
    font-size: 0.75rem !important;
    color: #6b7280 !important;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 640px) {
    .flipbook-viewport {
        min-height: 240px;
    }
}
