/* ---------- base ---------- */

:root {
    --ink: #1f2328;
    --muted: #5b6470;
    --line: #d8dde3;
    --surface: #ffffff;
    --hover: #f2f4f7;
    --accent: #1d4ed8; /* same blue as the highlights on the map */
    --accent-dark: #1e40af;
    --accent-soft: #e8eefc;
    --radius: 10px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
    --gap: 12px;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: #e9ecef;
}

#map {
    position: absolute;
    inset: 0;
}

/* The hidden attribute must win over display rules below. */
[hidden] {
    display: none !important;
}

.card {
    position: absolute;
    z-index: 1;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ---------- header with search ---------- */

.header {
    top: var(--gap);
    left: var(--gap);
    width: 340px;
    padding: 14px 16px 12px;
}

.header h1 {
    margin: 0;
    font-size: 17px;
}

.stats {
    margin: 2px 0 10px;
    font-size: 12px;
    color: var(--muted);
}

/* The suggestions are positioned against the field, so they open right below it. */
.search__field {
    position: relative;
}

.search input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    font: inherit;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* The selected cadastral unit, shown as a removable chip. */
.unit-filter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    padding: 4px 4px 4px 12px;
    font-size: 13px;
    color: var(--accent-dark);
    background: var(--accent-soft);
    border-radius: 999px;
}

.unit-filter button {
    flex: none;
    width: 26px;
    height: 26px;
    font-size: 18px;
    line-height: 1;
    color: var(--accent-dark);
    background: none;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.unit-filter button:hover {
    background: rgba(29, 78, 216, 0.12);
}

/* Suggestions open below the field, over the map. */
.results {
    position: absolute;
    top: 44px;
    left: 0;
    right: 0;
    z-index: 2;
    max-height: min(420px, 60vh);
    overflow-y: auto;
    margin: 0;
    padding: 6px 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.results button {
    display: block;
    width: 100%;
    padding: 8px 12px;
    font: inherit;
    text-align: left;
    color: var(--ink);
    background: none;
    border: 0;
    cursor: pointer;
}

.results button:hover,
.results button.is-active {
    background: var(--hover);
}

.results__group {
    padding: 8px 12px 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.results__note {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--muted);
}

.tip {
    margin: 10px 0 0;
    font-size: 12px;
    color: var(--muted);
}

/* Settings: collapsed at the bottom of the header card. */
.settings {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
}

.settings summary {
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}

.settings summary:hover {
    color: var(--ink);
}

.switch {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0 0;
    font-size: 13px;
    cursor: pointer;
}

/* ---------- legend ---------- */

.legend {
    bottom: 32px;
    left: var(--gap);
    width: 240px;
    padding: 0;
}

.legend summary {
    padding: 10px 14px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

#legend {
    padding: 0 14px 12px;
}

#legend h3 {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

#legend label,
.legend__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    font-size: 13px;
}

#legend label {
    cursor: pointer;
}

#legend input {
    margin: 0;
    accent-color: var(--accent);
}

#legend hr {
    margin: 8px 0;
    border: 0;
    border-top: 1px solid var(--line);
}

.swatch {
    flex: none;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.swatch--line {
    height: 0;
    border: 0;
    border-top: 2px solid #2b1d14;
    border-radius: 0;
}

.swatch--thick {
    border-top-width: 4px;
}

/* A checkbox drawn as a switch (settings). */
.switch input {
    position: relative;
    flex: none;
    width: 30px;
    height: 18px;
    appearance: none;
    background: var(--line);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s;
}

.switch input::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s;
}

.switch input:checked {
    background: var(--accent);
}

.switch input:checked::after {
    transform: translateX(12px);
}

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

/* ---------- parcel panel ---------- */

.panel {
    top: var(--gap);
    right: var(--gap);
    width: 320px;
    max-height: calc(100% - 2 * var(--gap));
    overflow-y: auto;
    padding: 16px 18px;
}

.panel__close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    font-size: 22px;
    line-height: 1;
    color: var(--muted);
    background: none;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.panel__close:hover {
    color: var(--ink);
    background: var(--hover);
}

.panel h2 {
    margin: 0 36px 2px 0;
    font-size: 19px;
}

.panel .subtitle {
    margin: 0 0 14px;
    color: var(--muted);
}

.panel dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 16px;
    margin: 0 0 16px;
}

.panel dt {
    color: var(--muted);
}

.panel dd {
    margin: 0;
    font-weight: 500;
}

.panel__actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.button {
    display: block;
    padding: 9px 14px;
    font: inherit;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    color: #ffffff;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 8px;
    cursor: pointer;
}

.button:hover {
    background: var(--accent-dark);
}

.button--secondary {
    color: var(--accent);
    background: var(--surface);
}

.button--secondary:hover {
    background: var(--accent-soft);
}

.panel .note {
    margin: 12px 0 0;
    font-size: 12px;
    color: var(--muted);
}

/* ---------- label next to the cursor (MapLibre popup) ---------- */

.maplibregl-popup-content {
    padding: 5px 9px;
    font-size: 12px;
    border-radius: 6px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
}

/* ---------- phones ---------- */

/* Back button next to + and − (an own MapLibre control). */
.back-control button {
    font-size: 17px;
    line-height: 1;
    color: #333333;
}

.back-control button:disabled {
    color: #c0c4c9;
    cursor: default;
}

@media (max-width: 600px) {
    :root {
        --gap: 8px;
    }

    .header {
        right: var(--gap);
        width: auto;
        padding: 10px 12px;
    }

    .stats,
    .tip {
        display: none;
    }

    .header h1 {
        margin-bottom: 8px;
        font-size: 15px;
    }

    .legend {
        bottom: 36px;
        width: auto;
        max-width: calc(100% - 2 * var(--gap));
    }

    /* The parcel panel becomes a sheet at the bottom of the screen. */
    .panel {
        top: auto;
        bottom: var(--gap);
        left: var(--gap);
        right: var(--gap);
        width: auto;
        max-height: 55%;
        z-index: 3;
    }
}
