/* ============================================
   TOPOGRAFIE - kaart (gedeeld) + editor
   De oefenpagina (/topografie) gebruikt alleen het kaartdeel.
   ============================================ */

/* ---------- Kaart ---------- */
.topo-kaart {
    position: relative;
    background: #BFE0F2;
    border-radius: 14px;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.topo-svg { display: block; width: 100%; height: 100%; cursor: default; }
.topo-kaart.is-slepen .topo-svg { cursor: grabbing; }

.topo-zee { fill: #BFE0F2; }
.topo-buurland { fill: #ECEAE3; stroke: #CFCBBE; stroke-width: 1; vector-effect: non-scaling-stroke; }
.topo-land path { fill: #F7F3E8; stroke: #D8CFB8; vector-effect: non-scaling-stroke; }
.topo-rivieren-basis path { fill: none; stroke: #8EC3E6; stroke-linecap: round; stroke-linejoin: round; }

/* Items */
.topo-item { cursor: pointer; }
.topo-vlak { fill: #FFE7A3; stroke: #C9A646; stroke-width: 1.4; transition: fill .15s; }
.topo-vlak > * { vector-effect: non-scaling-stroke; }
.topo-vlak-stip { fill-opacity: .85; stroke-width: 2; }
.topo-meer { fill: #BFE0F2; stroke: #9CC6E4; stroke-width: .6; vector-effect: non-scaling-stroke; pointer-events: none; }
.topo-vlak:hover { fill: #FFD966; }
.topo-lijn .topo-hit { fill: none; stroke: transparent; stroke-linecap: round; }
.topo-lijn-vis { fill: none; stroke: #2F86C9; stroke-linecap: round; stroke-linejoin: round; transition: stroke .15s; }
.topo-lijn:hover .topo-lijn-vis { stroke: #1A5F99; }
.topo-punt .topo-hit { fill: transparent; }
/* Zones: gebergten bruinig, woestijnen en andere gebieden zandkleurig */
.topo-zone .topo-hit { fill: transparent; stroke: none; }
.topo-zone-vis { fill: #8B5A2B; fill-opacity: .32; transition: fill-opacity .15s, fill .15s; }
.topo-zone:not(.soort-gebergte) .topo-zone-vis { fill: #C9A227; fill-opacity: .38; }
.topo-zone:hover .topo-zone-vis { fill-opacity: .5; }
.topo-zone.is-doel .topo-zone-vis { fill: #FF8C1A; fill-opacity: .6; animation: topo-puls 1.1s ease-in-out infinite; }
.topo-zone.is-goed .topo-zone-vis { fill: #2E8B57; fill-opacity: .55; }
.topo-zone.is-fout .topo-zone-vis { fill: #C0392B; fill-opacity: .5; }
.topo-zone.is-gekozen .topo-zone-vis { fill: #6C63FF; fill-opacity: .45; }
.topo-label.label-zone { fill: #5C3A17; font-style: italic; }
.topo-punt-vis { fill: #2D3436; stroke: #fff; stroke-width: 2; vector-effect: non-scaling-stroke; transition: fill .15s; }
.topo-punt.soort-water .topo-punt-vis { fill: #1F78C1; }
.topo-punt.soort-gebergte .topo-punt-vis { fill: #8B5A2B; }
.topo-punt.soort-werelddeel .topo-punt-vis { fill: #C2410C; }
.topo-breedte { fill: none; stroke: #7FA8C4; stroke-width: 1; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; pointer-events: none; }
.topo-punt.soort-eiland .topo-punt-vis,
.topo-punt.soort-gebied .topo-punt-vis { fill: #2E8B57; }
.topo-punt.soort-eigen .topo-punt-vis { fill: #6C63FF; }
.topo-punt:hover .topo-punt-vis { fill: #6C63FF; }

/* Statussen tijdens het oefenen */
.topo-vlak.is-doel { fill: #FFB55C; stroke: #E07B00; animation: topo-puls 1.1s ease-in-out infinite; }
.topo-vlak.is-goed { fill: #8FD694; stroke: #2E8B57; }
.topo-vlak.is-fout { fill: #F4A3A3; stroke: #C0392B; }
.topo-vlak.is-gekozen { fill: #C9C4FF; stroke: #6C63FF; }
.topo-lijn.is-doel .topo-lijn-vis { stroke: #FF8C1A; animation: topo-puls 1.1s ease-in-out infinite; }
.topo-lijn.is-goed .topo-lijn-vis { stroke: #2E8B57; }
.topo-lijn.is-fout .topo-lijn-vis { stroke: #C0392B; }
.topo-punt.is-doel .topo-punt-vis { fill: #FF8C1A; stroke: rgba(255, 140, 26, .45); stroke-width: 14; animation: topo-puls 1.1s ease-in-out infinite; }
.topo-punt.is-goed .topo-punt-vis { fill: #2E8B57; }
.topo-punt.is-fout .topo-punt-vis { fill: #C0392B; }
.topo-punt.is-gekozen .topo-punt-vis { fill: #6C63FF; }
@keyframes topo-puls { 50% { opacity: .45; } }

/* Tijdens een vraag over een vlak mogen stippen en lijnen de klik niet afvangen */
.topo-kaart[data-modus="vlak"] .topo-laag-zone,
.topo-kaart[data-modus="vlak"] .topo-laag-punt,
.topo-kaart[data-modus="vlak"] .topo-laag-lijn { pointer-events: none; }
.topo-kaart[data-modus="stil"] .topo-item { pointer-events: none; }

/* Namen */
.topo-label {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    font-weight: 700;
    fill: #2D3436;
    stroke: rgba(255, 255, 255, .92);
    paint-order: stroke;
    stroke-linejoin: round;
    pointer-events: none;
    display: none;
}
.topo-label.label-lijn { fill: #1A5F99; font-style: italic; }
.topo-label.label-vlak { fill: #6B5410; }
.topo-kaart.labels-aan .topo-label,
.topo-label.is-zichtbaar { display: inline; }

/* Zoomknoppen */
.topo-zoom {
    position: absolute; top: 10px; right: 10px;
    display: flex; flex-direction: column; gap: 6px;
}
.topo-zoom button {
    width: 38px; height: 38px; border-radius: 10px; border: none;
    background: #fff; color: #2D3436; font-size: 20px; font-weight: 700; line-height: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .15); cursor: pointer; font-family: inherit;
}
.topo-zoom button:hover { background: #F0EEFF; color: #6C63FF; }
.topo-bron {
    position: absolute; left: 8px; bottom: 6px;
    font-size: 10px; color: #4A6A80; background: rgba(255, 255, 255, .7);
    padding: 1px 6px; border-radius: 6px; pointer-events: none;
}

/* ============================================
   Editor (lesmateriaal/topografie)
   ============================================ */
.topo-scherm[hidden],
.topo-paneel [hidden] { display: none !important; }

.topo-lijst-kop { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.topo-lijst-kop h2 { font-size: 20px; color: var(--text-dark); }
.topo-lijst-kop p { color: var(--text-medium); font-size: 14px; margin-top: 4px; }

.topo-knop {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 18px; border-radius: 10px; border: 2px solid transparent;
    font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
    background: var(--primary); color: #fff; transition: var(--transition); text-decoration: none;
}
.topo-knop:hover { background: var(--primary-dark); }
.topo-knop.licht { background: #EEF0FF; color: var(--primary); }
.topo-knop.licht:hover { background: #E0E3FF; }
.topo-knop.rand { background: #fff; color: var(--text-dark); border-color: #E3E1F2; }
.topo-knop.rand:hover { border-color: var(--primary); color: var(--primary); }
.topo-knop.gevaar { background: #fff; color: #C0392B; border-color: #F3D1CD; }
.topo-knop.gevaar:hover { background: #FDECEA; }
.topo-knop.klein { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.topo-knop:disabled { opacity: .5; cursor: not-allowed; }

.topo-kaarten { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 640px) { .topo-kaarten { grid-template-columns: 1fr; } }
.topo-kaartje {
    border: 2px solid #ECEAF7; border-radius: 16px; padding: 18px;
    display: flex; flex-direction: column; gap: 10px; background: #fff;
}
.topo-kaartje h3 { font-size: 17px; color: var(--text-dark); word-break: break-word; }
.topo-kaartje .meta { font-size: 13px; color: var(--text-medium); }
.topo-kaartje .acties { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.topo-leeg { text-align: center; padding: 50px 20px; color: var(--text-medium); }
.topo-leeg .icoon { font-size: 48px; display: block; margin-bottom: 10px; }

/* Bewerken */
.topo-bewerk-kop { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.topo-titel-invoer {
    flex: 1; min-width: 200px; font: inherit; font-size: 18px; font-weight: 700;
    border: 2px solid #E3E1F2; border-radius: 10px; padding: 9px 12px; color: var(--text-dark); outline: none;
}
.topo-titel-invoer:focus { border-color: var(--primary); }
.topo-opgeslagen { font-size: 13px; color: var(--text-medium); min-width: 90px; }

.topo-bewerk { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.topo-bewerk .topo-kaart { width: 100%; max-height: min(78vh, 760px); }
.topo-paneel { display: flex; flex-direction: column; gap: 12px; max-height: min(78vh, 760px); overflow-y: auto; padding-right: 4px; }

.topo-blok { border: 2px solid #ECEAF7; border-radius: 14px; padding: 12px 14px; background: #fff; }
.topo-blok > summary {
    cursor: pointer; font-weight: 800; font-size: 15px; color: var(--text-dark);
    list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.topo-blok > summary::-webkit-details-marker { display: none; }
.topo-blok > summary::after { content: '\25BE'; color: var(--text-light); transition: transform .15s; }
.topo-blok[open] > summary::after { transform: rotate(180deg); }
.topo-blok .teller { font-size: 12px; font-weight: 700; color: var(--primary); background: #EEF0FF; border-radius: 20px; padding: 2px 9px; margin-left: auto; }
.topo-blok-inhoud { margin-top: 10px; }
.topo-blok-acties { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.topo-hint { font-size: 12.5px; color: var(--text-medium); line-height: 1.45; margin-bottom: 8px; }

.topo-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.topo-chip {
    border: 2px solid #E6E3F5; background: #fff; color: #4A4468;
    border-radius: 20px; padding: 4px 11px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.topo-chip:hover { border-color: var(--primary); }
.topo-chip.aan { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Gekozen plaatsen en eigen punten: klik op een chip om hem weg te halen */
.topo-weglijst { margin-top: 10px; }
.topo-weglijst:empty { display: none; }
.topo-weglijst .topo-chips { margin-top: 6px; }
.topo-wegchip {
    display: inline-flex; align-items: center; gap: 6px;
    border: 2px solid var(--primary); background: var(--primary); color: #fff;
    border-radius: 20px; padding: 4px 8px 4px 11px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.topo-wegchip .kruis { font-size: 15px; line-height: 1; opacity: .8; }
.topo-wegchip:hover { background: #fff; color: #C0392B; border-color: #F3D1CD; }
.topo-wegchip:hover .kruis { opacity: 1; }
.topo-weglijst-kop { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 700; color: var(--text-medium); }
.topo-weglijst-kop button { border: none; background: none; color: #C0392B; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; padding: 0; }
.topo-weglijst-kop button:hover { text-decoration: underline; }
.topo-chip-groep { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--text-light); margin: 10px 0 6px; }
.topo-chip-groep:first-child { margin-top: 0; }

.topo-zoek { position: relative; }
.topo-zoek input {
    width: 100%; font: inherit; font-size: 14px; border: 2px solid #E3E1F2; border-radius: 10px;
    padding: 9px 12px; outline: none; box-sizing: border-box;
}
.topo-zoek input:focus { border-color: var(--primary); }
.topo-suggesties { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.topo-suggestie {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; border: none; background: none;
    font-family: inherit; text-align: left; color: var(--text-dark);
}
.topo-suggestie:hover, .topo-suggestie.actief { background: #F0EEFF; }
.topo-suggestie small { color: var(--text-light); font-size: 12px; }
.topo-suggestie.al { color: var(--text-light); cursor: default; }

.topo-eigen-form { display: flex; gap: 6px; margin-top: 8px; }
.topo-eigen-form input { flex: 1; font: inherit; font-size: 14px; border: 2px solid #E3E1F2; border-radius: 10px; padding: 8px 10px; outline: none; min-width: 0; }
.topo-eigen-form input:focus { border-color: var(--primary); }
.topo-kaart.plaats-modus .topo-svg { cursor: crosshair; }
.topo-plaats-tip {
    position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
    background: #2D3436; color: #fff; font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 20px;
    pointer-events: none; white-space: nowrap;
}

.topo-gekozen { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; }
.topo-gekozen-item {
    display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; font-size: 14px;
}
.topo-gekozen-item:hover { background: #F7F6FD; }
.topo-gekozen-item .soort { font-size: 11px; color: var(--text-light); font-weight: 700; text-transform: uppercase; margin-left: auto; }
.topo-gekozen-item button {
    border: none; background: none; color: var(--text-light); cursor: pointer; font-size: 18px; line-height: 1; padding: 0 2px;
}
.topo-gekozen-item button:hover { color: #C0392B; }

/* Nieuwe kaart: basiskaart kiezen */
.topo-basis-keuze { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.topo-basis {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    border: 2px solid #E6E3F5; background: #fff; border-radius: 16px; padding: 16px 8px;
    font: inherit; font-size: 16px; font-weight: 800; color: var(--text-dark); cursor: pointer;
}
.topo-basis:hover:not(:disabled) { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.topo-basis:disabled { opacity: .45; cursor: not-allowed; }
.topo-basis .em { font-size: 34px; line-height: 1; }
.topo-basis small { font-size: 12px; font-weight: 600; color: var(--text-medium); line-height: 1.35; }
@media (max-width: 520px) { .topo-basis-keuze { grid-template-columns: 1fr; } }

/* Deel-venster */
.topo-modal { position: fixed; inset: 0; background: rgba(30, 27, 60, .55); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.topo-modal[hidden] { display: none; }
.topo-modal-kaart { background: #fff; border-radius: 20px; padding: 26px; width: 100%; max-width: 460px; text-align: center; position: relative; }
.topo-modal-kaart h3 { font-size: 20px; margin-bottom: 6px; color: var(--text-dark); }
.topo-modal-kaart p { color: var(--text-medium); font-size: 14px; line-height: 1.5; }
.topo-modal-sluit { position: absolute; top: 10px; right: 14px; border: none; background: none; font-size: 26px; color: var(--text-light); cursor: pointer; }
.topo-qr { margin: 16px auto 12px; display: flex; justify-content: center; }
.topo-qr img { width: 220px; height: 220px; image-rendering: pixelated; }
.topo-link { display: flex; gap: 6px; margin-bottom: 12px; }
.topo-link input { flex: 1; min-width: 0; font: inherit; font-size: 14px; border: 2px solid #E3E1F2; border-radius: 10px; padding: 9px 10px; color: var(--text-dark); background: #F8F9FE; }
.topo-modal-acties { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.topo-modal.is-groot .topo-modal-kaart { max-width: 760px; }
.topo-modal.is-groot .topo-qr img { width: min(60vh, 480px); height: min(60vh, 480px); }
.topo-modal.is-groot .topo-link input { font-size: 20px; font-weight: 700; text-align: center; }

@media (max-width: 900px) {
    .topo-bewerk { grid-template-columns: 1fr; }
    .topo-bewerk .topo-kaart { max-height: 62vh; }
    .topo-paneel { max-height: none; overflow: visible; }
}

/* ============================================
   Afdrukken (js/topografie-print.js)
   ============================================ */
.topo-afdruk-opties { display: flex; flex-direction: column; gap: 12px; text-align: left; margin-top: 14px; }
.topo-afdruk-optie { border: 2px solid #ECEAF7; border-radius: 14px; padding: 14px 16px; }
.topo-afdruk-optie h4 { font-size: 16px; color: var(--text-dark); margin-bottom: 4px; }
.topo-afdruk-optie p { font-size: 13.5px; margin-bottom: 10px; }
.topo-afdruk-optie label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-dark); margin-bottom: 6px; cursor: pointer; }
.topo-afdruk-optie .topo-knop { margin-top: 6px; }
/* Toets: welke onderdelen erop komen */
.topo-toets-keuze { border: 2px solid #ECEAF7; border-radius: 12px; padding: 8px 12px; margin: 4px 0 8px; }
.topo-toets-keuze > summary { cursor: pointer; font-size: 14px; font-weight: 700; color: var(--text-dark); list-style: none; display: flex; justify-content: space-between; gap: 8px; }
.topo-toets-keuze > summary::-webkit-details-marker { display: none; }
.topo-toets-keuze .wijzig { color: var(--primary); font-size: 13px; }
.topo-toets-keuze[open] .wijzig { display: none; }
.topo-toets-acties { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 8px; }
.topo-toets-acties .topo-knop { margin-top: 0; }
.topo-willekeurig { display: inline-flex; align-items: center; gap: 4px; }
.topo-willekeurig input { width: 58px; font: inherit; font-size: 14px; border: 2px solid #E3E1F2; border-radius: 8px; padding: 4px 6px; }
.topo-toets-lijst { max-height: 240px; overflow-y: auto; overflow-x: hidden; }
.topo-toets-lijst .groep { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; margin-bottom: 8px; }
.topo-toets-lijst .groep-titel { grid-column: 1 / -1; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--text-light); margin-bottom: 3px; }
.topo-afdruk-optie .topo-toets-lijst label { font-size: 13px; margin-bottom: 2px; gap: 6px; }
@media (max-width: 520px) { .topo-toets-lijst .groep { grid-template-columns: 1fr; } }

.topo-afspraak { font-size: 13px; background: #F8F7FF; border-radius: 12px; padding: 10px 12px; color: var(--text-medium); line-height: 1.6; text-align: left; margin-top: 12px; }
.topo-afspraak b { color: var(--text-dark); }
.topo-modal-kaart.breed { max-width: 560px; max-height: calc(100vh - 32px); overflow-y: auto; }

.topo-print { display: none; }

@media print {
    @page { size: A4 portrait; margin: 12mm; }
    body.topo-printen { background: #fff !important; padding: 0 !important; margin: 0 !important; }
    body.topo-printen > *:not(.topo-print) { display: none !important; }
    body.topo-printen .topo-print { display: block; }

    .topo-print { font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: #111; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .tp-blad { break-after: page; page-break-after: always; }
    .tp-blad:last-child { break-after: auto; page-break-after: auto; }

    .tp-kop { display: flex; justify-content: space-between; align-items: flex-end; gap: 8mm; border-bottom: 0.4mm solid #111; padding-bottom: 2.5mm; margin-bottom: 3mm; }
    .tp-titel { font-size: 15pt; font-weight: 800; }
    .tp-sub { font-size: 9.5pt; color: #555; margin-top: 0.5mm; }
    .tp-velden { display: flex; gap: 6mm; font-size: 11pt; font-weight: 600; white-space: nowrap; }
    .tp-veld span { display: inline-block; width: 55mm; border-bottom: 0.3mm solid #111; margin-left: 1.5mm; }
    .tp-veld.kort span { width: 12mm; }
    .tp-legenda { font-size: 9pt; color: #333; margin-bottom: 3mm; }
    .tp-bron { font-size: 6.5pt; color: #888; text-align: right; margin-top: 0.8mm; }

    .tp-kaart { display: block; width: 100%; height: auto; }
    .tp-kaart-vol { width: 186mm; margin: 0 auto; }
    .tp-naast { display: grid; grid-template-columns: 112mm 1fr; gap: 6mm; align-items: start; }

    .tp-kolommen { columns: 2; column-gap: 10mm; }
    .tp-groep { break-inside: avoid-column; margin-bottom: 4mm; }
    .tp-groep-titel { font-size: 10pt; font-weight: 800; margin-bottom: 1mm; }
    .tp-lijn { display: flex; align-items: flex-end; gap: 2.5mm; height: 8.5mm; break-inside: avoid; }
    .tp-code { width: 8mm; font-size: 11pt; font-weight: 800; text-align: right; flex-shrink: 0; }
    .tp-streep { flex: 1; border-bottom: 0.25mm solid #777; font-size: 11pt; padding-bottom: 0.6mm; min-height: 5mm; }
    .tp-nakijk .tp-streep { border-bottom-color: #CCC; }
}
