/* Preview of a 7/12 that is too large to show as a single image.
 *
 * Such a record is rendered as page-sized slices that load while the citizen scrolls. The intent is
 * that it does not LOOK split: the slices sit flush against one another so the document reads as one
 * continuous page, exactly like a normal preview.
 *
 * Classes only, no inline styles - the portal is moving to a nonce-based CSP (CLAUDE.md). */

.lr712-preview-body {
    /* The modal is where a long record is actually read, so it scrolls. */
    max-height: 80vh;
    overflow-y: auto;
}

.lr712-slices {
    display: block;
    width: 100%;
}

/* Reserves each slice's height BEFORE its image arrives.
 *
 * padding-bottom in percent resolves against the element's WIDTH, which is why it is used here
 * instead of measuring: the container is built while the preview modal is still hidden, so its
 * clientWidth is 0 at that moment. Measuring there gave every placeholder zero height, which stacked
 * all of them inside the viewport at once and made the observer request every slice simultaneously.
 * This needs no measurement and is correct whether the modal is open or not. */
.lr712-slice-wrap {
    display: block;
    position: relative;
    width: 100%;
    /* Flush: no gap, no border between slices, so the joins do not show. */
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
}

.lr712-slice {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    image-rendering: crisp-edges;
}

/* A page whose picture is carried by the batch image above it: it keeps its place in the document
 * order but reserves no height of its own, because the host slot already reserves the whole run. */
.lr712-slice-merged {
    padding-bottom: 0 !important;
    height: 0;
}

.lr712-slice-pending {
    background-color: #f4f4f4;
    background-image: linear-gradient(90deg, #f4f4f4 0%, #ececec 50%, #f4f4f4 100%);
}

/* ONE loader for the whole preview, centred in the pop-up.
 *
 * It exists because a pale placeholder is ambiguous in the worst way on a long record: scrolling into
 * empty space looks exactly like reaching the end of the document. One steady marker in the middle of
 * the box answers that without putting a spinner on every page.
 *
 * Positioned against .modal-content (which Bootstrap already makes position:relative), NOT against the
 * scrolling body - so it stays in the centre of the box while the document scrolls behind it. */
.lr712-preview-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    max-width: 90%;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #d6d6d6;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
    color: var(--nav-bg, #095a6f);
    font-weight: 600;
    text-align: center;
    /* The citizen reads and scrolls the document underneath; this never intercepts that. */
    pointer-events: none;
}

.lr712-preview-loader.hidden {
    display: none;
}

.lr712-spinner {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    border: 3px solid #d6d6d6;
    border-top-color: var(--nav-bg, #095a6f);
    border-radius: 50%;
}

@media (prefers-reduced-motion: no-preference) {
    .lr712-spinner {
        animation: lr712-spin 0.9s linear infinite;
    }

    @keyframes lr712-spin {
        to { transform: rotate(360deg); }
    }
}

/* There is deliberately no per-page error style here. Inside the preview a page that fails is simply
 * re-requested when it is scrolled to again; a column of error messages and buttons is worse company
 * for a citizen reading their record than a short wait. The Try again button lives on the View step,
 * where the document genuinely could not be fetched. */

@media (prefers-reduced-motion: no-preference) {
    /* A page whose picture is carried by the batch image above it: it keeps its place in the document
 * order but reserves no height of its own, because the host slot already reserves the whole run. */
.lr712-slice-merged {
    padding-bottom: 0 !important;
    height: 0;
}

.lr712-slice-pending {
        background-size: 200% 100%;
        animation: lr712-slice-shimmer 1.2s linear infinite;
    }

    @keyframes lr712-slice-shimmer {
        0% { background-position: 200% 0; }
        100% { background-position: -200% 0; }
    }
}
