/*!
 * CPPLightbox — toolbar styling kept visually consistent with the
 * Wizard of Doku modal (indigo #2e52f2 brand accent, white text on the
 * dark glass toolbar). The toolbar sits over fullscreen content that
 * may be either dark (images) or light (PDF), so the bar itself keeps
 * a dark glassmorphism backdrop for readability while the primary
 * action button borrows the wizard's indigo brand colour.
 */

/* ---- Toolbar shell ---------------------------------------------------- */

.cpplb-bar {
    position: absolute;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    z-index: 2147483000;            /* above GLightbox slide content */
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.7rem;
    background: rgba(20, 25, 45, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    box-shadow:
        0 8px 28px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(46, 82, 242, 0.15);  /* faint indigo halo */
}

/* ---- Buttons (shared base) ------------------------------------------- */

.cpplb-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.95rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1;
    text-decoration: none !important;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.12s ease,
                border-color   0.12s ease,
                color          0.12s ease,
                box-shadow     0.12s ease,
                transform      0.08s ease;
}
.cpplb-btn:active { transform: translateY(1px); }
.cpplb-btn:focus-visible {
    outline: 2px solid #6580f5;
    outline-offset: 2px;
}
.cpplb-btn svg {
    flex: 0 0 auto;
    opacity: 0.95;
}

/* ---- Secondary: View Attachment Page (ghost on dark glass) ----------- */

.cpplb-btn-view {
    background: rgba(255, 255, 255, 0.08);
    color: #fff !important;
    border-color: rgba(255, 255, 255, 0.22);
}
.cpplb-btn-view:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.38);
}
.cpplb-btn-view:active {
    background: rgba(255, 255, 255, 0.22);
}

/* ---- Primary: Download (wizard indigo) ------------------------------- */

.cpplb-btn-download {
    background: #2e52f2;
    color: #fff !important;
    border-color: #2e52f2;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
.cpplb-btn-download:hover {
    background: #5570f5;
    border-color: #5570f5;
    color: #fff !important;
}
.cpplb-btn-download:active {
    background: #2244d6;
    border-color: #2244d6;
}

/* ---- Share PDF Link (ghost — same family as View) ------------------- */
/* Buttons styled like .cpplb-btn-view so View + Share form a pair of
 * secondary actions next to the primary Download button. */
.cpplb-btn-share {
    background: rgba(255, 255, 255, 0.08);
    color: #fff !important;
    border-color: rgba(255, 255, 255, 0.22);
}
.cpplb-btn-share:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.38);
}
.cpplb-btn-share:active {
    background: rgba(255, 255, 255, 0.22);
}

/* Brief success flash after the link is copied. Bulma-ish green so it
 * visually matches the copy feedback used elsewhere in the wiki UI. */
.cpplb-btn.cpplb-btn-copied,
.cpplb-btn.cpplb-btn-copied:hover {
    background: #48c774;
    border-color: #48c774;
    color: #fff !important;
}

/* ---- Standalone (non-linked) images become clickable ----------------- */

img.cpplb-img { cursor: zoom-in; }


/* ======================================================================
 * PDF.js viewer modal
 * Custom modal (not GLightbox) so we can host a canvas + nav controls.
 * The shell occupies most of the viewport; pages are rendered into a
 * canvas that the user can scroll if zoomed past viewport size.
 * ====================================================================== */

.cpplb-pdf-modal {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Prevent any accidental flash if hidden attribute isn't honoured. */
}
.cpplb-pdf-modal[hidden] { display: none; }

.cpplb-pdf-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.cpplb-pdf-shell {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 96vw;
    height: 96vh;
    max-width: 1400px;
    background: #1a1d28;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.6),
                0 0 0 1px rgba(46, 82, 242, 0.18);
}

.cpplb-pdf-close {
    position: absolute;
    top: 10px;
    /* Pushed left of the typical desktop scrollbar (~16-18 px) so the
     * button is always clickable even when the canvas overflows. */
    right: 22px;
    width: 36px;
    height: 36px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
}
.cpplb-pdf-close svg { display: block; }
.cpplb-pdf-close:hover { background: rgba(255, 255, 255, 0.22); }
.cpplb-pdf-close:focus-visible {
    outline: 2px solid #6580f5;
    outline-offset: 2px;
}

/* Scroll-container that hosts the canvas. Padding gives breathing room
 * and is matched by fitToWidth()'s "avail = clientWidth - 40" logic. */
.cpplb-pdf-viewport {
    position: relative;
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    background: #2a2d38;
}

.cpplb-pdf-canvas {
    background: #fff;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    display: block;
    max-width: 100%;
    /* Allow the canvas to grow taller than the viewport so the user can
     * scroll vertically when zoomed in. */
    height: auto;
}
.cpplb-pdf-canvas:focus {
    outline: 2px solid #2e52f2;
    outline-offset: 4px;
}

/* Centred status overlay (loading / errors). Sits above the canvas. */
.cpplb-pdf-status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 0.95rem;
    text-align: center;
    padding: 14px 22px;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 6px;
    pointer-events: none;
}

/* Controls row: page nav + zoom. Stays at the foot of the shell, above
 * the toolbar. */
.cpplb-pdf-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.9rem;
    background: rgba(15, 18, 28, 0.95);
    color: #fff;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 0.875rem;
}
.cpplb-pdf-controls button {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.cpplb-pdf-controls button:hover  { background: rgba(255, 255, 255, 0.18); }
.cpplb-pdf-controls button:active { background: rgba(255, 255, 255, 0.26); }
.cpplb-pdf-controls button:focus-visible {
    outline: 2px solid #6580f5;
    outline-offset: 2px;
}
/* Both fit buttons share the same compact text-label treatment. */
.cpplb-pdf-fit-btn {
    font-size: 0.82rem !important;
    padding: 0 10px;
    white-space: nowrap;
}

.cpplb-pdf-page-num {
    width: 56px;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    padding: 5px 6px;
    font: inherit;
    /* Strip the native number-input spinners — they look gnarly on dark. */
    -moz-appearance: textfield;
    appearance: textfield;
}
.cpplb-pdf-page-num::-webkit-outer-spin-button,
.cpplb-pdf-page-num::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.cpplb-pdf-page-wrap   { white-space: nowrap; }
.cpplb-pdf-spacer      { flex: 1; }
.cpplb-pdf-zoom-level  { min-width: 56px; text-align: center; }

/* The bundled toolbar (.cpplb-bar) is normally absolute-positioned over
 * a GLightbox slide; inside our PDF modal we anchor it in normal flow at
 * the bottom of the shell. */
.cpplb-pdf-toolbar.cpplb-bar {
    position: static;
    transform: none;
    left: auto;
    bottom: auto;
    border-radius: 0;
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    justify-content: center;
    background: rgba(15, 18, 28, 0.95);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: none;
    padding: 0.6rem 0.9rem;
}

/* Lock page scroll behind the modal so wheel events stay inside the
 * canvas viewport. */
body.cpplb-pdf-open { overflow: hidden; }

/* ---- Phones ----------------------------------------------------------- */

@media (max-width: 540px) {
    .cpplb-bar {
        bottom: 14px;
        gap: 0.45rem;
        padding: 0.4rem 0.55rem;
    }
    .cpplb-btn {
        padding: 0.45rem 0.75rem;
        font-size: 0.82rem;
    }
    .cpplb-pdf-shell {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
    .cpplb-pdf-controls {
        flex-wrap: wrap;
        gap: 0.35rem;
        padding: 0.45rem 0.6rem;
    }
    /* Keep both Fit buttons on phones — they wrap onto the next row
     * with the other controls thanks to flex-wrap above. */
}
