/* Pedway PDF Viewer styles.
   Customize by overriding these variables on .ppv (or on one viewer):
     .ppv { --ppv-btn-bg: #000; --ppv-btn-radius: 4px; }
   Individual buttons can be targeted with [data-control="zoomIn"] etc. */

.ppv {
    --ppv-height: min(85vh, 1111px);
    --ppv-bg: #302665;
    --ppv-page-shadow: 0 2px 14px rgba(0, 0, 0, 0.55);
    --ppv-bar-bg: #302665;
    --ppv-bar-border: #FFE385;
    --ppv-btn-bg: #302665;
    --ppv-btn-fg: #ffffff;
    --ppv-btn-hover-bg: #FFE385;
    --ppv-btn-hover-fg: #302665;
    --ppv-btn-border: rgba(255, 227, 133, 0.55);
    --ppv-btn-size: 44px;
    --ppv-btn-radius: 999px;
    --ppv-icon-size: 22px;
    --ppv-accent: #FFE385;
    --ppv-menu-bg: #252528;
    --ppv-menu-fg: #f4f4f6;
    --ppv-font: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;

    position: relative;
    display: flex;
    flex-direction: column;
    height: var(--ppv-height);
    width: 100%;
    box-sizing: border-box;
    background: var(--ppv-bg);
    color: var(--ppv-btn-fg);
    font-family: var(--ppv-font);
    font-size: 14px;
    text-align: left;
    overflow: hidden;
    isolation: isolate;
}

.ppv *,
.ppv *::before,
.ppv *::after {
    box-sizing: border-box;
}

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

.ppv-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: none;
    z-index: 3;
}

.ppv--toolbar .ppv-bar {
    justify-content: center;
    flex-wrap: wrap;
    padding: 6px 8px;
    background: var(--ppv-bar-bg);
    border-bottom: 4px solid var(--ppv-bar-border);
}

.ppv--toolbar .ppv-more {
    margin-left: auto;
}

/* Floating: a small pill of buttons over the bottom-right corner */
.ppv--floating .ppv-bar {
    position: absolute;
    right: 12px;
    bottom: 12px;
    flex-direction: column;
    padding: 6px;
    border-radius: calc(var(--ppv-btn-size) / 2 + 6px);
    background: rgba(28, 22, 64, 0.82);
    border: 2px solid var(--ppv-bar-border);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

/* Map-style order in the floating pill: + above −, full screen last */
.ppv--floating .ppv-bar > * { order: 4; }
.ppv--floating .ppv-bar > [data-control="zoomIn"] { order: 1; }
.ppv--floating .ppv-bar > [data-control="zoomLevel"] { order: 2; }
.ppv--floating .ppv-bar > [data-control="zoomOut"] { order: 3; }

.ppv--floating .ppv-menu {
    right: calc(100% + 10px);
    bottom: 0;
    top: auto;
}

.ppv-bar[hidden],
.ppv-bar [hidden],
.ppv-menu [hidden],
.ppv-single {
    display: none !important;
}

.ppv-btn {
    display: inline-grid;
    place-items: center;
    width: var(--ppv-btn-size);
    height: var(--ppv-btn-size);
    margin: 0;
    padding: 0;
    border: 2px solid var(--ppv-btn-border);
    border-radius: var(--ppv-btn-radius);
    background: var(--ppv-btn-bg);
    color: var(--ppv-btn-fg);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.ppv-btn--small {
    width: calc(var(--ppv-btn-size) - 8px);
    height: calc(var(--ppv-btn-size) - 8px);
}

.ppv-btn:hover:not(:disabled) {
    background: var(--ppv-btn-hover-bg);
    color: var(--ppv-btn-hover-fg);
    border-color: var(--ppv-btn-hover-bg);
}

.ppv-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.ppv-icon {
    width: var(--ppv-icon-size);
    height: var(--ppv-icon-size);
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

[data-control="more"] .ppv-icon circle {
    fill: currentColor;
    stroke: none;
}

.ppv :focus-visible {
    outline: 3px solid var(--ppv-accent);
    outline-offset: 2px;
}

.ppv-select,
.ppv-page-input {
    height: calc(var(--ppv-btn-size) - 8px);
    margin: 0;
    padding: 0 8px;
    border: 2px solid var(--ppv-btn-border);
    border-radius: 6px;
    background: var(--ppv-btn-bg);
    color: var(--ppv-btn-fg);
    font: inherit;
    font-weight: 700;
}

.ppv-select {
    min-width: 96px;
    cursor: pointer;
}

.ppv-select option {
    background: #fff;
    color: #000;
}

.ppv-page {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ppv-page-input {
    width: 3.2em;
    text-align: center;
}

.ppv-page-count {
    padding-right: 2px;
    white-space: nowrap;
    font-weight: 700;
}

/* ---------- "More" menu ---------- */

.ppv-more {
    position: relative;
}

.ppv-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    min-width: 220px;
    padding: 6px;
    border-radius: 8px;
    border-top: 4px solid var(--ppv-accent);
    background: var(--ppv-menu-bg);
    color: var(--ppv-menu-fg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.ppv-menu[hidden] {
    display: none;
}

.ppv-menu-item,
.ppv-menu-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    width: 100%;
    margin: 0;
    padding: 6px 12px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: inherit;
    font: inherit;
    font-size: 15px;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.ppv-menu-row {
    cursor: default;
    justify-content: space-between;
}

.ppv-menu-item:hover,
.ppv-menu-item:focus-visible {
    background: rgba(255, 227, 133, 0.14);
}

.ppv-menu .ppv-icon {
    color: var(--ppv-accent);
}

/* ---------- Document area ---------- */

.ppv-stage {
    position: relative;
    flex: 1;
    min-height: 0;
}

/* PDF.js requires an absolutely positioned scroll container. */
.ppv-container {
    position: absolute;
    inset: 0;
    overflow: auto;
    background: var(--ppv-bg);
    /* We handle pinch-zoom ourselves; let the browser only scroll. */
    touch-action: pan-x pan-y;
    /* Let scrolling continue to the page at the map's edges, so the text
       below an embedded viewer stays reachable (like Chrome's viewer). */
    overscroll-behavior: auto;
    -webkit-overflow-scrolling: touch;
    outline: none;
}

.ppv--drag .ppv-container {
    cursor: grab;
}

.ppv--dragging .ppv-container,
.ppv--dragging .ppv-container * {
    cursor: grabbing !important;
    -webkit-user-select: none;
    user-select: none;
}

/* Page borders/margins come from PDF.js (removePageBorders); only add a shadow,
   which doesn't change layout. */
.ppv .pdfViewer .page {
    box-shadow: var(--ppv-page-shadow);
}

/* Keep the site's global img rules away from PDF.js output */
.ppv .pdfViewer img {
    max-width: none;
    margin: 0;
    padding: 0;
    float: none;
}

/* ---------- Loading / errors ---------- */

.ppv-progress {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    z-index: 2;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.ppv--loading .ppv-progress {
    opacity: 1;
}

.ppv-progress span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--ppv-accent);
    transition: width 0.2s;
}

.ppv-status {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 2;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100% - 32px);
    padding: 14px 18px;
    border-radius: 8px;
    background: rgba(28, 22, 64, 0.92);
    border-left: 5px solid var(--ppv-accent);
    color: #fff;
    font-size: 15px;
    line-height: 1.4;
}

.ppv-status[hidden],
.ppv-status:empty {
    display: none;
}

.ppv-status a {
    color: var(--ppv-accent);
}

.ppv-spinner {
    width: 18px;
    height: 18px;
    flex: none;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-top-color: var(--ppv-accent);
    animation: ppv-spin 0.8s linear infinite;
}

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

/* ---------- Full screen ---------- */

.ppv:fullscreen {
    height: 100%;
    width: 100%;
}

.ppv:-webkit-full-screen {
    height: 100%;
    width: 100%;
}

/* Fallback for browsers without element fullscreen (iPhone Safari) */
.ppv.ppv--fill {
    position: fixed;
    inset: 0;
    z-index: 10000;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
}

html.ppv-noscroll,
html.ppv-noscroll body {
    overflow: hidden;
}

.ppv-print-frame {
    position: fixed;
    right: 0;
    bottom: 0;
    width: 0;
    height: 0;
    border: 0;
}

@media (prefers-reduced-motion: reduce) {
    .ppv-spinner {
        animation-duration: 2s;
    }

    .ppv-btn,
    .ppv-progress span {
        transition: none;
    }
}
