:root {
    --toolbar-h: 64px;
    --bg: #ecebed;
    --panel: #ffffff;
    --text: #222222;
    --muted: #6c6571;
    --accent: #692a7c;
    --focus: #0b57d0;
    --shadow: rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background: var(--bg);
    overflow: hidden;
}

.toolbar {
    height: var(--toolbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 14px;
    background: var(--panel);
    border-bottom: 1px solid #d6d1d8;
    position: relative;
    z-index: 50;
}
.toolbar__title { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.toolbar__title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.updated { font-size: 12px; color: var(--muted); }
.toolbar__controls { display: flex; align-items: center; gap: 7px; flex-wrap: nowrap; }

button, .button-link, input {
    font: inherit;
}
button, .button-link {
    border: 1px solid #bdb7c1;
    border-radius: 6px;
    background: #fff;
    color: #222;
    min-height: 36px;
    padding: 7px 10px;
    cursor: pointer;
    text-decoration: none;
}
button:hover, .button-link:hover { border-color: var(--accent); }
button:focus-visible, .button-link:focus-visible, input:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent);
    outline-offset: 1px;
}
button:disabled { opacity: .45; cursor: default; }

.page-jump { display: flex; align-items: center; gap: 5px; font-size: 14px; white-space: nowrap; }
.page-jump input {
    width: 64px;
    min-height: 36px;
    padding: 6px 7px;
    border: 1px solid #bdb7c1;
    border-radius: 6px;
    background: #fff;
    color: #222;
}

.viewer-shell {
    height: calc(100vh - var(--toolbar-h));
    height: calc(100dvh - var(--toolbar-h));
    width: 100vw;
    display: grid;
    place-items: center;
    position: relative;
    overflow: hidden;
    padding: 12px;
}
.book { width: 100%; height: 100%; }

.global-loading, .error {
    position: absolute;
    z-index: 20;
    max-width: min(90vw, 620px);
    padding: 14px 18px;
    border-radius: 8px;
    background: rgba(255,255,255,.95);
    box-shadow: 0 4px 18px var(--shadow);
}
.error { color: #8b0000; }

.page {
    background: #fff;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.05);
}
.pdf-stage {
    width: 100%;
    height: 100%;
    position: relative;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: #fff;
}
.pdf-stage canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.page-loader {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #777;
    font-size: 14px;
    background: #fff;
}
.page.rendered .page-loader { display: none; }

.annotation-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.annotation-link {
    position: absolute;
    display: block;
    pointer-events: auto;
    cursor: pointer;
    background: transparent;
    border-radius: 2px;
}
.annotation-link:focus-visible {
    outline: 2px solid var(--focus);
    background: rgba(11, 87, 208, .12);
}

/* Voor testen kan deze klasse in de inspector worden toegevoegd. */
.show-link-areas .annotation-link { background: rgba(0, 90, 255, .13); outline: 1px solid rgba(0, 90, 255, .35); }

@media (max-width: 860px) {
    :root { --toolbar-h: 104px; }
    .toolbar { align-items: flex-start; flex-direction: column; padding: 8px 10px; }
    .toolbar__title { width: 100%; }
    .toolbar__controls { width: 100%; overflow-x: auto; padding-bottom: 2px; }
    .toolbar__controls > * { flex: 0 0 auto; }
    .toolbar__controls button, .button-link { min-height: 34px; padding: 6px 8px; }
    .viewer-shell { padding: 6px; }
}

@media (prefers-color-scheme: dark) {
    :root { --bg: #222126; --panel: #302d33; --text: #f3eff4; --muted: #c1b9c4; }
    button, .button-link, .page-jump input { background: #3a363d; color: #fff; border-color: #706875; }
}


/* Navigatie midden onder.
   Alleen de positie/opmaak van de bestaande navigatie is gewijzigd.
   De flipbook-logica in app.js is ongewijzigd. */
.viewer-shell {
    padding-bottom: 76px;
}

.bottom-navigation {
    position: fixed;
    left: 50%;
    bottom: max(14px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
}

.bottom-navigation .bottom-page-jump {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    margin: 0;
}

.bottom-navigation #pageNumber {
    width: 58px;
    text-align: center;
}

.bottom-navigation .nav-button {
    min-width: 44px;
    min-height: 40px;
    font-size: 22px;
    line-height: 1;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (prefers-color-scheme: dark) {
    .bottom-navigation {
        background: rgba(35, 35, 35, 0.96);
    }
}


/* Kleine correctie: pijlen exact verticaal uitlijnen met paginanavigatie */
.bottom-navigation > * {
    align-self: center;
}

.bottom-navigation .nav-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding-top: 0;
    padding-bottom: 0;
    vertical-align: middle;
}

.bottom-navigation .bottom-page-jump,
.bottom-navigation .bottom-page-jump input,
.bottom-navigation .bottom-page-jump span {
    align-self: center;
}


/* Horizontale paginaschuif onder de navigatie */
.bottom-navigation {
    flex-direction: column;
    gap: 7px;
    min-width: min(430px, calc(100vw - 28px));
}

.bottom-navigation__row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
}

.page-slider-wrap {
    display: block;
    width: 100%;
    margin: 0;
}

.page-slider {
    display: block;
    width: 100%;
    margin: 0;
    cursor: pointer;
}

.viewer-shell {
    padding-bottom: 116px;
}


/* ---------------------------------------------------------------
   KLIKBARE ZOOM VAN DE HELE ZICHTBARE SPREAD
   De zoomweergave staat volledig los van StPageFlip.
   --------------------------------------------------------------- */
.zoom-open-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    margin: 0;
}

.zoom-overlay[hidden] {
    display: none !important;
}

.zoom-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    flex-direction: column;
    background: rgba(18, 18, 18, 0.96);
}

.zoom-overlay__bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    background: #fff;
    color: #222;
}

.zoom-overlay__bar button {
    min-width: 42px;
}

.zoom-viewport {
    flex: 1 1 auto;
    overflow: auto;
    padding: 24px;
}

.zoom-spread {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    width: max-content;
    min-width: 100%;
    margin: 0 auto;
}

.zoom-page {
    position: relative;
    flex: 0 0 auto;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 18px rgba(0,0,0,.4);
}

.zoom-page canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.zoom-page .annotation-layer {
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: none;
}

.zoom-page .annotation-link {
    position: absolute;
    display: block;
    pointer-events: auto;
    cursor: pointer;
}

@media (max-width: 760px) {
    .zoom-spread {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }
}

@media (prefers-color-scheme: dark) {
    .zoom-overlay__bar {
        background: #222;
        color: #fff;
    }
}


/* ---------------------------------------------------------------
   INTUÏTIEVE ZOOM-OVERLAY
   --------------------------------------------------------------- */
body.zoom-open {
    overflow: hidden;
}

.zoom-overlay[hidden] {
    display: none !important;
}

.zoom-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(3px);
}

.zoom-modal {
    width: min(96vw, 1800px);
    height: min(94vh, 1100px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f4f4f4;
    border-radius: 14px;
    box-shadow: 0 18px 60px rgba(0,0,0,.38);
}

.zoom-modal__header {
    flex: 0 0 auto;
    min-height: 58px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    padding: 10px 14px 10px 18px;
    background: #fff;
    border-bottom: 1px solid rgba(0,0,0,.14);
}

.zoom-modal__title-group {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}

.zoom-modal__hint {
    font-size: .85rem;
    color: #666;
    white-space: nowrap;
}

.zoom-modal__controls {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.zoom-modal__controls button {
    min-width: 42px;
    height: 38px;
    margin: 0;
}

#zoomReset {
    min-width: 72px;
}

.zoom-modal__close {
    justify-self: end;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border-radius: 50%;
    font-size: 28px;
    line-height: 1;
}

.zoom-viewport {
    flex: 1 1 auto;
    overflow: auto;
    padding: 28px;
    background:
        linear-gradient(45deg, #ececec 25%, transparent 25%),
        linear-gradient(-45deg, #ececec 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ececec 75%),
        linear-gradient(-45deg, transparent 75%, #ececec 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.zoom-spread {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    width: max-content;
    min-width: 100%;
    margin: 0 auto;
}

.zoom-page {
    position: relative;
    flex: 0 0 auto;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 16px rgba(0,0,0,.28);
}

.zoom-page canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.zoom-page .annotation-layer {
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: none;
}

.zoom-page .annotation-link {
    position: absolute;
    display: block;
    pointer-events: auto;
    cursor: pointer;
}

@media (max-width: 900px) {
    .zoom-overlay {
        padding: 8px;
    }

    .zoom-modal {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .zoom-modal__header {
        grid-template-columns: 1fr auto;
    }

    .zoom-modal__controls {
        order: 3;
        grid-column: 1 / -1;
        padding-top: 6px;
    }

    .zoom-modal__hint {
        display: none;
    }

    .zoom-spread {
        flex-direction: column;
        align-items: center;
        gap: 14px;
    }
}

@media (prefers-color-scheme: dark) {
    .zoom-modal {
        background: #202020;
    }

    .zoom-modal__header {
        background: #262626;
        color: #fff;
        border-bottom-color: rgba(255,255,255,.14);
    }

    .zoom-modal__hint {
        color: #bbb;
    }

    .zoom-viewport {
        background: #1a1a1a;
    }
}


/* ---------------------------------------------------------------
   GEMEENTEZOEKER
   --------------------------------------------------------------- */
.municipality-search {
    position: relative;
    width: min(320px, 38vw);
    min-width: 210px;
}

.municipality-search__field {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    padding: 0 10px;
    border: 1px solid rgba(0,0,0,.22);
    border-radius: 8px;
    background: #fff;
}

.municipality-search__field:focus-within {
    border-color: #6f2c91;
    box-shadow: 0 0 0 2px rgba(111,44,145,.16);
}

.municipality-search__icon {
    flex: 0 0 auto;
    font-size: 20px;
    line-height: 1;
    color: #6f2c91;
}

#municipalitySearch {
    width: 100%;
    min-width: 0;
    padding: 7px 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: inherit;
    font: inherit;
}

.municipality-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 4500;
    width: min(440px, calc(100vw - 24px));
    max-height: min(430px, 60vh);
    overflow-y: auto;
    padding: 5px;
    border: 1px solid rgba(0,0,0,.18);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(0,0,0,.22);
}

.municipality-results[hidden] {
    display: none !important;
}

.municipality-result {
    width: 100%;
    display: grid;
    grid-template-columns: 78px 1fr;
    gap: 10px;
    align-items: start;
    margin: 0;
    padding: 9px 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #222;
    text-align: left;
    cursor: pointer;
}

.municipality-result:hover,
.municipality-result.is-active {
    background: rgba(111,44,145,.10);
}

.municipality-result__page {
    color: #6f2c91;
    white-space: nowrap;
}

.municipality-result__snippet {
    min-width: 0;
    font-size: .88rem;
    line-height: 1.35;
    color: #444;
}

.municipality-results__status {
    padding: 11px;
    color: #555;
}

/* De zoomknop gebruikt bewust geen vergrootglas meer:
   ⤢ staat voor vergroten / uitvouwen. */
.zoom-open-button > span {
    display: inline-block;
    font-size: 24px;
    line-height: 1;
}

@media (max-width: 760px) {
    .toolbar__controls {
        width: 100%;
    }

    .municipality-search {
        width: 100%;
        min-width: 0;
        flex: 1 1 100%;
    }

    .municipality-results {
        width: 100%;
    }
}

@media (prefers-color-scheme: dark) {
    .municipality-search__field,
    .municipality-results {
        background: #262626;
        border-color: rgba(255,255,255,.22);
    }

    .municipality-result {
        color: #fff;
    }

    .municipality-result__snippet,
    .municipality-results__status {
        color: #ccc;
    }

    .municipality-result:hover,
    .municipality-result.is-active {
        background: rgba(190,130,220,.17);
    }
}


/* Zoekresultaat: toon alleen woorden/URL's die de zoekterm bevatten */
.municipality-result__snippet {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 8px;
    align-items: center;
}

.municipality-result__match {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 5px;
    background: rgba(111,44,145,.08);
    color: inherit;
    font-size: .9rem;
    line-height: 1.25;
}

@media (prefers-color-scheme: dark) {
    .municipality-result__match {
        background: rgba(190,130,220,.14);
    }
}


/* ---------------------------------------------------------------
   GELE MARKERING VAN GEVONDEN ZOEKTEKST
   --------------------------------------------------------------- */
.pdf-stage {
    position: relative;
}

.search-highlight-layer {
    position: absolute;
    inset: 0;
    z-index: 6;
    pointer-events: none;
    overflow: hidden;
}

.search-highlight {
    position: absolute;
    display: block;
    background: rgba(255, 235, 59, 0.62);
    border-radius: 2px;
    box-shadow: inset 0 0 0 1px rgba(190, 160, 0, 0.18);
    mix-blend-mode: multiply;
    pointer-events: none;
}


/* Correctie zoekmarkering: duidelijk geel en boven het canvas,
   maar onder/zonder blokkering van klikbare PDF-links. */
.search-highlight-layer {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    overflow: hidden;
}

.search-highlight {
    position: absolute;
    display: block;
    background: rgba(255, 235, 0, 0.68);
    border: 1px solid rgba(210, 170, 0, 0.30);
    border-radius: 2px;
    box-sizing: border-box;
    pointer-events: none;
}

.annotation-layer {
    z-index: 10;
}


/* ---------------------------------------------------------------
   AANPASSINGEN
   - Zoompictogram: plus in vierkant (⊞)
   - Zoekmarkering: transparant oranje
   --------------------------------------------------------------- */

.zoom-open-button > span {
    display: inline-block;
    font-size: 26px;
    line-height: 1;
}

.search-highlight {
    background: rgba(255, 152, 0, 0.42);
    border: 1px solid rgba(230, 115, 0, 0.28);
    box-shadow: none;
}

/* Oranje zoekmarkering in de vergrote weergave */
.zoom-search-highlight-layer {
    position: absolute;
    inset: 0;
    z-index: 6;
    pointer-events: none;
    overflow: hidden;
}
.zoom-search-highlight {
    position: absolute;
    display: block;
    box-sizing: border-box;
    background: rgba(255, 152, 0, 0.42);
    border: 1px solid rgba(230, 115, 0, 0.28);
    border-radius: 2px;
    pointer-events: none;
}
.zoom-page .annotation-layer { z-index: 10; }


/* ---------------------------------------------------------------
   ZOOM-SCHUIFREGELAAR IN VERGROTE WEERGAVE
   --------------------------------------------------------------- */
.zoom-modal__controls {
    min-width: min(360px, 42vw);
}

.zoom-slider-label {
    display: flex;
    align-items: center;
    width: min(280px, 32vw);
    margin: 0;
}

.zoom-slider {
    width: 100%;
    margin: 0;
    cursor: pointer;
    accent-color: #6f2c91;
}

.zoom-percent {
    min-width: 52px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Chrome / Edge / Safari */
.zoom-slider::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 999px;
    background: #d9c2e5;
}

.zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    margin-top: -6px;
    border: 0;
    border-radius: 50%;
    background: #6f2c91;
}

/* Firefox */
.zoom-slider::-moz-range-track {
    height: 6px;
    border-radius: 999px;
    background: #d9c2e5;
}

.zoom-slider::-moz-range-progress {
    height: 6px;
    border-radius: 999px;
    background: #6f2c91;
}

.zoom-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border: 0;
    border-radius: 50%;
    background: #6f2c91;
}

@media (max-width: 900px) {
    .zoom-modal__controls {
        width: 100%;
        min-width: 0;
    }

    .zoom-slider-label {
        width: 100%;
        max-width: none;
    }
}
