/* ============================================================================
 * GeoRoute v2 — app.css
 * ========================================================================== */
:root {
    --green:   #16a34a;
    --green-d: #15803d;
    --ink:     #1f2937;
    --muted:   #6b7280;
    --line:    #e5e7eb;
    --bg:      #f8fafc;
    --card:    #ffffff;
    --radius:  10px;
    --topbar:  52px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* wint van .ad-login/.ad-app display:flex */
html, body { margin: 0; height: 100%; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); }

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.gr-topbar {
    height: var(--topbar);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 12px; background: var(--green); color: #fff;
    position: sticky; top: 0; z-index: 1100;
}
.gr-logo { font-size: 18px; margin: 0; letter-spacing: .5px; }
.gr-icon-btn {
    background: rgba(255,255,255,.15); border: 0; color: #fff;
    width: 38px; height: 38px; border-radius: 8px; font-size: 18px; cursor: pointer;
}
.gr-icon-btn:active { transform: scale(.94); }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.gr-layout { display: flex; height: calc(100% - var(--topbar)); }
.gr-sidebar {
    width: 320px; flex-shrink: 0; background: var(--bg);
    border-right: 1px solid var(--line); overflow-y: auto; padding: 12px;
}
.gr-main { flex: 1; position: relative; }
#grMap { position: absolute; inset: 0; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* ── Kaarten/cards ───────────────────────────────────────────────────────── */
.gr-card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.gr-card h2 { font-size: 15px; margin: 0 0 10px; }

.gr-field { display: block; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.gr-field > span { display: block; margin-bottom: 4px; }
.gr-field input[type=text], .gr-field select, .gr-field input[type=range] {
    width: 100%; padding: 8px; border: 1px solid var(--line);
    border-radius: 8px; font-size: 14px; color: var(--ink); background: #fff;
}
.gr-input-row { display: flex; gap: 6px; }
.gr-input-row input { flex: 1; }

/* ── Knoppen ─────────────────────────────────────────────────────────────── */
.gr-btn {
    border: 1px solid var(--line); background: #fff; color: var(--ink);
    padding: 9px 14px; border-radius: 8px; font-size: 14px; cursor: pointer;
}
.gr-btn--primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.gr-btn:active { transform: scale(.97); }
.gr-btn-row { display: flex; gap: 8px; margin-top: 8px; }
.gr-btn-row .gr-btn--primary { flex: 1; }

.gr-mini-btn {
    border: 1px solid var(--line); background: #fff; color: var(--ink);
    padding: 5px 10px; border-radius: 7px; font-size: 12px; cursor: pointer;
}
.gr-mini-btn:active { transform: scale(.95); }
.gr-link-btn {
    background: none; border: 0; color: var(--green-d); padding: 0 0 8px;
    font-size: 13px; cursor: pointer; text-decoration: underline;
}
.gr-file { display: inline-block; }

/* ── Waypoints ───────────────────────────────────────────────────────────── */
.gr-waypoints { margin: 8px 0; }
.gr-wp-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; }
.gr-wp-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.gr-wp-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gr-wp-del { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 14px; }

/* ── Lagen ───────────────────────────────────────────────────────────────── */
.gr-layer { border-top: 1px solid var(--line); padding: 10px 0; }
.gr-layer:first-of-type { border-top: 0; }
.gr-layer-head { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.gr-layer-actions { display: flex; gap: 6px; margin-top: 6px; padding-left: 24px; }
.gr-poi-types { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; padding: 6px 0 6px 24px; font-size: 12px; color: var(--muted); }
.gr-poi-types label { display: flex; align-items: center; gap: 4px; }

/* ── Infobar + status ────────────────────────────────────────────────────── */
.gr-infobar {
    position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%) translateY(120%);
    background: #fff; border: 1px solid var(--line); border-radius: 999px;
    padding: 8px 18px; display: flex; gap: 16px; font-size: 13px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12); z-index: 800; transition: transform .25s;
}
.gr-infobar.is-visible { transform: translateX(-50%) translateY(0); }
.gr-engine { color: var(--muted); }

.gr-status {
    position: absolute; top: 12px; left: 50%; transform: translateX(-50%) translateY(-150%);
    background: var(--ink); color: #fff; padding: 8px 16px; border-radius: 8px;
    font-size: 13px; z-index: 900; transition: transform .25s; max-width: 90%;
}
.gr-status.is-visible { transform: translateX(-50%) translateY(0); }
.gr-status--error { background: #dc2626; }

/* ── Marker-iconen ───────────────────────────────────────────────────────── */
.gr-dot span { display: block; width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.gr-emoji span { font-size: 22px; line-height: 28px; text-align: center; display: block; }
/* GPS-marker: wrapper MOET relative zijn, anders "ontsnapt" de absolute pulse
   bij pannen/zoomen naar de eerste positioned ancestor in de pagina — en
   schuift zichtbaar los van de blauwe stip totdat hij van de kaart verdwijnt. */
.gr-gps { position: relative; width: 22px; height: 22px; }
.gr-gps-pulse {
    position: absolute; inset: 0; border-radius: 50%; background: #3b82f6;
    opacity: .35; animation: gr-pulse 1.8s ease-out infinite;
}
.gr-gps-core { position: absolute; inset: 5px; border-radius: 50%; background: #2563eb; border: 2px solid #fff; }
@keyframes gr-pulse { 0% { transform: scale(.6); opacity: .5; } 100% { transform: scale(1.8); opacity: 0; } }

/* ── Mobiel ──────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .gr-sidebar {
        position: absolute; top: var(--topbar); bottom: 0; left: 0; z-index: 1000;
        width: 88%; max-width: 340px; transform: translateX(-100%); transition: transform .25s;
        box-shadow: 2px 0 16px rgba(0,0,0,.2);
    }
    .gr-sidebar.is-open { transform: translateX(0); }
}

/* ── Quest-paneel ────────────────────────────────────────────────────────── */
.gr-mini-btn--primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.gr-quest {
    position: absolute; right: 12px; bottom: 12px; z-index: 950;
    width: 360px; max-width: calc(100% - 24px); max-height: 70%;
    background: #fff; border: 1px solid var(--line); border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0,0,0,.18); display: flex; flex-direction: column; overflow: hidden;
}
.gr-quest-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #9333ea; color: #fff; }
.gr-quest-title { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gr-quest-test { font-size: 12px; display: flex; align-items: center; gap: 4px; cursor: pointer; }
.gr-quest-head .gr-icon-btn { width: 30px; height: 30px; font-size: 15px; }
.gr-quest-progress { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.gr-qdot { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 12px; cursor: pointer; }
.gr-qdot.cur { border-color: #9333ea; background: #f3e8ff; font-weight: 700; }
.gr-qdot.done { background: #16a34a; color: #fff; border-color: #16a34a; }
.gr-qcount { margin-left: auto; font-size: 12px; color: var(--muted); }
.gr-quest-body { padding: 14px; overflow-y: auto; }
.gr-q-name { font-weight: 600; margin-bottom: 6px; }
.gr-q-desc { font-size: 14px; color: #374151; margin: 6px 0; }
.gr-q-story { font-size: 14px; font-style: italic; background: #faf5ff; border-left: 3px solid #9333ea; padding: 8px 10px; border-radius: 6px; margin: 8px 0; }
.gr-q-question { font-weight: 600; margin: 10px 0 6px; }
.gr-q-feedback { margin-top: 8px; font-size: 14px; min-height: 18px; }
.gr-q-feedback.ok { color: #16a34a; font-weight: 600; }
.gr-q-feedback.err { color: #dc2626; }
.gr-q-locked { background: #f9fafb; border: 1px dashed var(--line); border-radius: 8px; padding: 12px; font-size: 13px; color: var(--muted); }
.gr-quest-body audio { width: 100%; margin: 8px 0; }
.gr-quest-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.gr-quest-dist { font-size: 13px; color: var(--muted); }
.gr-q-finish { text-align: center; padding: 16px; }
.gr-q-finish-emoji { font-size: 44px; }
.gr-q-finish h3 { margin: 6px 0; }

@media (max-width: 768px) {
    .gr-quest { left: 12px; right: 12px; width: auto; max-height: 60%; }
}

/* ── Certificaat ─────────────────────────────────────────────────────────── */
.gr-cert {
    text-align: center; padding: 20px; border: 3px double #9333ea; border-radius: 12px;
    background: linear-gradient(180deg,#faf5ff,#fff);
}
.gr-cert-emoji { font-size: 40px; }
.gr-cert-head { font-size: 13px; letter-spacing: 1px; text-transform: uppercase; color: #9333ea; margin-top: 4px; }
.gr-cert-name { font-size: 22px; font-weight: 700; margin: 8px 0 2px; }
.gr-cert-route { font-size: 15px; color: #374151; }
.gr-cert-meta { font-size: 12px; color: var(--muted); margin-top: 10px; }

@media print {
    body * { visibility: hidden !important; }
    #grCert, #grCert * { visibility: visible !important; }
    #grCert { position: fixed; inset: 0; margin: auto; width: 80%; height: max-content; border: 4px double #9333ea; }
}

/* ── Teaser-melding "quest in de buurt" ──────────────────────────────────── */
.gr-teaser {
    position: absolute; top: 12px; left: 50%; transform: translateX(-50%) translateY(-160%);
    z-index: 960; display: flex; align-items: center; gap: 10px;
    background: #fff; border: 1px solid var(--line); border-left: 5px solid #9333ea;
    border-radius: 12px; padding: 8px 10px 8px 14px; box-shadow: 0 6px 24px rgba(0,0,0,.18);
    max-width: calc(100% - 24px); transition: transform .3s;
}
.gr-teaser.is-visible { transform: translateX(-50%) translateY(0); }
.gr-teaser-txt { font-size: 13px; }
.gr-teaser .gr-btn { padding: 6px 12px; }
.gr-teaser-x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; }

.gr-qdot.gr-qfin { border-color: #9333ea; background: #fff; }

/* ── Kaart contextmenu (long-press / rechtsklik) ─────────────────────────── */
.gr-ctx-menu {
    position: absolute; z-index: 1200; background: #fff; border: 1px solid var(--line);
    border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.22); overflow: hidden;
    display: flex; flex-direction: column; min-width: 190px;
}
.gr-ctx-menu button {
    border: 0; background: #fff; text-align: left; padding: 11px 14px; font-size: 14px;
    cursor: pointer; border-bottom: 1px solid var(--line);
}
.gr-ctx-menu button:last-child { border-bottom: 0; color: var(--muted); }
.gr-ctx-menu button:active { background: var(--bg); }

/* ── Marker-popup acties (start/tussenstop/eind) ─────────────────────────── */
.gr-pop-actions { display: flex; gap: 4px; margin-top: 6px; }
.gr-pop-actions .gr-mini-btn { flex: 1; padding: 5px 4px; font-size: 11px; }

/* ── GPS-knop: visuele status van volgmodus ──────────────────────────────── */
.gr-icon-btn.is-following { background: #fff; color: var(--green); }

/* AccessiRoute found-log dialoog */
.gr-found-dialog[hidden] { display: none; }
.gr-found-dialog { position: fixed; inset: 0; z-index: 5000; display: grid; place-items: center; padding: 18px; }
.gr-found-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .48); }
.gr-found-card { position: relative; width: min(460px, 100%); background: #fff; border-radius: 18px; padding: 18px; box-shadow: 0 20px 70px rgba(0,0,0,.25); border: 1px solid var(--line); }
.gr-found-card h3 { margin: 0 34px 4px 0; }
.gr-found-route { margin: 0 0 12px; color: var(--muted); }
.gr-found-card textarea { resize: vertical; }
.gr-found-x { position: absolute; top: 10px; right: 12px; border: 0; background: transparent; font-size: 24px; cursor: pointer; color: var(--muted); }
