/* ZCBS Beeldbank — overzicht en detailpagina */
* {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    background: #f5f6f8;
    color: #243040;
}

header {
    background: #193955;
    color: white;
    padding: 28px 32px;
}

header h1 {
    margin: 0;
}

header p {
    margin: 8px 0 0;
    color: #dbe6ef;
}

main {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
}

input {
    width: 100%;
    max-width: 500px;
    padding: 12px;
    border: 1px solid #bbb;
    border-radius: 6px;
    font-size: 16px;
}

#aantal {
    margin: 18px 0;
    color: #667;
}

/* Bestaande fotogalerij */
#resultaten {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 18px;
}

.object {
    background: white;
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 2px 8px #00000012;
    overflow: hidden;
}

.object-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.object-link:hover h3 {
    text-decoration: underline;
}

.object h3 {
    margin: 0 0 10px;
    color: #193955;
}

.object p {
    margin: 5px 0;
}

.nummer {
    color: #777;
    font-size: 13px;
}

.object-foto {
    display: block;
    width: 100%;
    height: 180px;
    object-fit: contain;
    background: #eef1f4;
    border-radius: 6px;
    margin-bottom: 12px;
}

.geen-foto {
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eef1f4;
    color: #777;
    border-radius: 6px;
    margin-bottom: 12px;
    text-align: center;
    padding: 12px;
}

#navigatie {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
    margin: 32px 0;
}

#navigatie button {
    padding: 10px 18px;
    border: 0;
    border-radius: 7px;
    background: #193955;
    color: white;
    cursor: pointer;
    font-size: 15px;
}

#navigatie button:hover:not(:disabled) {
    background: #28587d;
}

#navigatie button:disabled {
    opacity: .4;
    cursor: default;
}

/* Detailindeling gebaseerd op officiële ZCBS-beeldbank */
.detail-pagina {
    max-width: 1500px;
}

.detail-navigatie {
    margin-bottom: 22px;
}

.terug {
    display: inline-flex;
    padding: 10px 16px;
    background: white;
    border: 1px solid #dce2e8;
    border-radius: 8px;
    color: #193955;
    font-weight: bold;
    text-decoration: none;
}

.terug:hover {
    background: #eaf0f5;
}

.detail {
    background: white;
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 3px 18px #00000012;
}

.detail-kop {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 22px;
}

.detail-label {
    margin: 0 0 8px;
    color: #6e8192;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 1.2px;
}

.detail-kop h2 {
    margin: 0;
    color: #193955;
    font-size: clamp(24px, 3vw, 34px);
    line-height: 1.25;
}

.detail-recordnummer {
    flex-shrink: 0;
    padding: 9px 13px;
    background: #eef3f7;
    color: #496176;
    font-size: 13px;
    border-radius: 8px;
}

.detail-hoofdindeling {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 30px;
    align-items: start;
}

.detail-linkerkolom,
.detail-rechterkolom {
    min-width: 0;
}

.detail-afbeelding {
    background: #f1f3f5;
    border: 1px solid #e4e9ed;
    border-radius: 12px;
    padding: 15px;
}

#foto-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 250px;
    text-align: center;
}

.detail-foto {
    display: block;
    max-width: 100%;
    max-height: 72vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 5px;
    box-shadow: 0 3px 12px #00000018;
    cursor: zoom-in;
}

.detail-foto:focus-visible {
    outline: 3px solid #3578aa;
    outline-offset: 5px;
}

.detail-sectie {
    margin-top: 26px;
    padding-top: 22px;
    border-top: 1px solid #e5eaf0;
}

.detail-sectie-eerste {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.detail-sectie h3 {
    margin: 0 0 16px;
    color: #193955;
    font-size: 20px;
}

.detail-beschrijving {
    white-space: pre-wrap;
    line-height: 1.7;
    font-size: 15px;
    color: #334155;
    overflow-wrap: anywhere;
}

.detail-gegevens {
    display: grid;
    grid-template-columns: minmax(120px, 150px) minmax(0, 1fr);
    gap: 0;
    margin: 0;
}

.detail-gegevens dt,
.detail-gegevens dd {
    padding: 10px 9px;
    border-bottom: 1px solid #edf0f3;
}

.detail-gegevens dt {
    font-weight: bold;
    color: #526579;
}

.detail-gegevens dd {
    margin: 0;
    color: #243040;
    overflow-wrap: anywhere;
}

.detail-gegevens dt:nth-of-type(even),
.detail-gegevens dd:nth-of-type(even) {
    background: #f8fafc;
}

.detail-gegevens a,
.kaart-kop a {
    color: #175f91;
}

/* Bladeren door alle records */
.foto-navigatie {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px 0;
}

.foto-navigatie-link {
    display: inline-block;
    padding: 10px 14px;
    border-radius: 8px;
    background: #193955;
    color: white;
    text-decoration: none;
    font-weight: bold;
}

.foto-navigatie-link:hover {
    background: #28587d;
}

.foto-navigatie-teller {
    color: #667;
    font-size: 14px;
}

/* -x vergelijking */
.foto-vergelijking {
    width: 100%;
    max-width: 950px;
    margin: 0 auto;
}

.foto-vergelijking-kop {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    color: #193955;
    font-size: 14px;
    font-weight: bold;
}

.foto-vergelijking-beeld {
    position: relative;
    width: 100%;
    max-height: 72vh;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #202730;
    border-radius: 8px;
    box-shadow: 0 3px 12px #00000020;
    cursor: ew-resize;
    touch-action: none;
    user-select: none;
}

.foto-vergelijking-restauratie,
.foto-vergelijking-origineel {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    pointer-events: none;
}

.foto-vergelijking-origineel {
    z-index: 1;
}

.foto-vergelijking-lijn {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 3px;
    background: white;
    transform: translateX(-50%);
    box-shadow: 0 0 5px #00000088;
    z-index: 2;
    pointer-events: none;
}

.foto-vergelijking-lijn::after {
    content: '◀ ▶';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 40px;
    border-radius: 24px;
    background: white;
    color: #193955;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
    box-shadow: 0 2px 8px #00000055;
}

.foto-vergelijking-bediening {
    padding: 18px 0 4px;
    text-align: left;
}

.foto-vergelijking-bediening p {
    margin: 0 0 12px;
    color: #526579;
    font-size: 14px;
}

.foto-vergelijking-slider-rij {
    display: flex;
    align-items: center;
    gap: 16px;
}

.foto-vergelijking-slider {
    flex: 1;
    width: 100%;
    max-width: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    accent-color: #193955;
}

.foto-vergelijking-percentage {
    min-width: 105px;
    text-align: right;
    font-size: 13px;
    color: #526579;
    font-variant-numeric: tabular-nums;
}

.foto-vergelijking-zoom {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.foto-vergelijking-knop {
    padding: 11px 14px;
    border: 0;
    border-radius: 8px;
    background: #193955;
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}

.foto-vergelijking-knop:hover {
    background: #28587d;
}

/* Schermvullende vergroting */
.foto-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, .96);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.foto-zoom-werkvlak {
    position: absolute;
    inset: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    touch-action: none;
}

.foto-zoom-werkvlak.ingezoomd {
    cursor: grab;
}

.foto-zoom-werkvlak.ingezoomd:active {
    cursor: grabbing;
}

.foto-overlay-afbeelding {
    display: block;
    max-width: 95%;
    max-height: 90%;
    width: auto;
    height: auto;
    object-fit: contain;
    transform-origin: center center;
    user-select: none;
    pointer-events: none;
    will-change: transform;
}

.foto-zoom-bediening {
    position: absolute;
    left: 50%;
    bottom: 25px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(30, 30, 30, .92);
    color: white;
    z-index: 1001;
    box-shadow: 0 4px 20px #00000055;
}

.foto-zoom-bediening button {
    min-width: 45px;
    height: 42px;
    padding: 0 10px;
    border: 0;
    border-radius: 7px;
    background: #ffffff20;
    color: white;
    font-size: 20px;
    cursor: pointer;
}

.foto-zoom-bediening button:hover:not(:disabled) {
    background: #ffffff40;
}

.foto-zoom-bediening button:disabled {
    opacity: .35;
    cursor: default;
}

.foto-zoom-percentage {
    min-width: 55px;
    text-align: center;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.foto-overlay-sluiten {
    position: absolute;
    top: 15px;
    right: 20px;
    z-index: 1002;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 50%;
    background: white;
    color: #222;
    font-size: 30px;
    cursor: pointer;
}

.foto-overlay-sluiten:hover {
    background: #e0e0e0;
}

/* Leaflet-kaart */
.kaart-kop {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

#object-kaart {
    width: 100%;
    height: 370px;
    border-radius: 10px;
    border: 1px solid #dae2e8;
    z-index: 0;
}

.kaart-bron,
.kaart-melding {
    margin: 8px 0 0;
    font-size: 12px;
    color: #637387;
}

/* De hidden-attribuut mag niet door display-regels worden overschreven. */
[hidden] {
    display: none !important;
}

@media (max-width: 850px) {
    .detail-hoofdindeling {
        grid-template-columns: 1fr;
    }

    .detail-rechterkolom {
        padding-top: 2px;
    }
}

@media (max-width: 600px) {
    header {
        padding: 20px;
    }

    main {
        margin: 20px auto;
        padding: 0 12px;
    }

    #resultaten {
        grid-template-columns: 1fr;
    }

    .detail {
        padding: 18px;
        border-radius: 10px;
    }

    .detail-kop {
        flex-direction: column;
        gap: 12px;
    }

    .detail-recordnummer {
        align-self: flex-start;
    }

    .detail-afbeelding {
        padding: 10px;
    }

    #foto-container {
        min-height: 150px;
    }

    .detail-foto {
        max-height: 60vh;
    }

    .detail-gegevens {
        grid-template-columns: minmax(105px, 125px) minmax(0, 1fr);
        font-size: 14px;
    }

    .foto-vergelijking-kop {
        font-size: 12px;
    }

    .foto-vergelijking-slider-rij {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .foto-vergelijking-percentage {
        min-width: 0;
        width: 100%;
        text-align: center;
    }

    .foto-vergelijking-zoom {
        flex-direction: column;
    }

    .foto-vergelijking-knop {
        width: 100%;
    }

    .foto-navigatie {
        justify-content: center;
    }

    .foto-navigatie-teller {
        order: -1;
        width: 100%;
        text-align: center;
    }

    .foto-zoom-bediening {
        bottom: 15px;
        gap: 5px;
        padding: 8px;
    }

    .foto-zoom-bediening button {
        min-width: 40px;
        height: 40px;
        font-size: 17px;
    }

    .foto-overlay-sluiten {
        top: 10px;
        right: 10px;
    }

    #object-kaart {
        height: 300px;
    }
}

/* ==========================================
   OpenStreetMap - kleiner en links uitlijnen
========================================== */

#kaart {
    width: 100%;
    max-width: 500px;
    height: 350px;
    margin-left: 0;
    margin-right: auto;
}

/* ==========================================
   OpenStreetMap - links en kleiner
========================================== */

#kaart-sectie {
    width: 100%;
}

#object-kaart {
    width: 100%;
    max-width: 500px;
    height: 350px;
    margin-left: 0;
    margin-right: auto;
    border-radius: 10px;
}

@media (max-width: 600px) {
    #object-kaart {
        max-width: 100%;
        height: 300px;
    }
}