/*
 * The map page. Colors, fonts, and the band come from /assets/site.css; these aliases keep the names the
 * map's rules were written with.
 */

:root {
    --bg: var(--paper);
    --text: var(--ink);
    --text-muted: var(--ink-muted);
    --border: var(--rule);
    --accent: #2f6b3a;
    --accent-soft: #e4efe5;
    --highlight: #fff1b8;
    --shadow: 0 1px 3px rgb(0 0 0 / 0.15);

    --sidebar-width: 360px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --accent: #7fc48b;
        --accent-soft: #263a2a;
        --highlight: #5a4d12;
        --shadow: 0 1px 3px rgb(0 0 0 / 0.5);
    }
}

:root[data-theme="dark"] {
    --accent: #7fc48b;
    --accent-soft: #263a2a;
    --highlight: #5a4d12;
    --shadow: 0 1px 3px rgb(0 0 0 / 0.5);
}

/* The band sits on top; the map and sidebar fill the rest of the viewport. */
html,
body.page-map {
    height: 100%;
}

body.page-map {
    display: flex;
    flex-direction: column;
    font-size: 14px;
    line-height: 1.4;
}

.page-map h1 {
    font-size: 1.3rem;
}

.page-map h2 {
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0;
    color: var(--text-muted);
}

button,
input {
    font: inherit;
    color: inherit;
}

.app {
    display: flex;
    flex: 1;
    min-height: 0;
}


/*
 * Sidebar
 */

.sidebar {
    flex: 0 0 var(--sidebar-width);
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    overflow-y: auto;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-footer {
    margin-top: auto;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.sidebar-footer p {
    margin: 0;
}

.icon-button,
.link-button {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.icon-button {
    font-size: 1.6rem;
    line-height: 1;
}

.link-button {
    color: var(--accent);
    text-decoration: underline;
}

.close-sidebar,
.open-sidebar {
    display: none;
}


/*
 * Search
 */

.search {
    position: relative;
}

.search input,
.facet-filter {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.search input {
    padding: 10px 12px;
    font-size: 1rem;
}

.search input:focus,
.facet-filter:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
}

.suggestions {
    position: absolute;
    z-index: 1000;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 6px 18px rgb(0 0 0 / 0.18);
}

.suggestions li {
    padding: 6px 12px;
    cursor: pointer;
}

.suggestions li[aria-selected="true"] {
    background: var(--accent-soft);
}

.suggestions mark {
    background: var(--highlight);
    color: inherit;
    border-radius: 2px;
}

.suggestions .empty {
    color: var(--text-muted);
    cursor: default;
}

.suggestion-name {
    display: block;
    font-weight: 600;
}

.meta {
    display: block;
    font-size: 0.85em;
    color: var(--text-muted);
}

.tag {
    display: inline-block;
    margin-left: 4px;
    padding: 0 5px;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    white-space: nowrap;
}


/*
 * Selected park and map popups share parkDetails() markup.
 */

.selected {
    padding: 12px;
    background: var(--accent-soft);
    border-radius: 8px;
    position: relative;
}

.selected .icon-button {
    position: absolute;
    top: 6px;
    right: 10px;
}

.park-details h3 {
    margin: 0 24px 4px 0;
    font-size: 1rem;
}

.park-details p {
    margin: 2px 0;
}

.park-details a {
    color: var(--accent);
}


/*
 * Facets
 */

.filters-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.facet {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 10px;
}

.facet summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    font-weight: 600;
    cursor: pointer;
}

.facet-badge {
    padding: 0 7px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--surface);
    background: var(--accent);
    border-radius: 10px;
}

.facet-filter {
    margin-bottom: 6px;
}

.facet-options {
    margin: 0 0 10px;
    padding: 0;
    list-style: none;
}

.facet-options--scroll {
    max-height: 260px;
    overflow-y: auto;
}

.facet-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    cursor: pointer;
}

.facet-options .count {
    margin-left: auto;
    font-size: 0.85em;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.facet-options .is-empty {
    opacity: 0.45;
}

.swatch {
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--swatch);
}


/*
 * Results
 */

.results h2 {
    margin-bottom: 6px;
}

.results-count {
    text-transform: none;
    letter-spacing: 0;
    font-weight: normal;
}

.results-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.results-list button {
    display: block;
    width: 100%;
    padding: 6px 8px;
    text-align: left;
    background: none;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}

.results-list button:hover,
.results-list button:focus-visible {
    background: var(--bg);
}

.results-list button[aria-current="true"] {
    background: var(--accent-soft);
}


/*
 * Map
 */

#map {
    flex: 1;
    min-width: 0;
}

.leaflet-container {
    font-family: var(--font-body);
}

.park-marker span {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--swatch);
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.5);
}

.park-marker--selected span {
    outline: 3px solid var(--swatch);
    outline-offset: 2px;
}

.legend {
    padding: 8px 10px;
    background: var(--surface);
    color: var(--text);
    border-radius: 6px;
    box-shadow: var(--shadow);
    line-height: 1.7;
}

.legend div {
    display: flex;
    align-items: center;
    gap: 6px;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background: var(--surface);
    color: var(--text);
}

.leaflet-container a.leaflet-popup-close-button {
    color: var(--text-muted);
}


/*
 * Phones: the map fills the screen and the sidebar becomes a drawer.
 */

@media (max-width: 760px) {
    .sidebar {
        position: fixed;
        z-index: 2000;
        inset: var(--band-height) auto 0 0;
        width: min(100%, 420px);
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow);
    }

    .sidebar.is-open {
        transform: none;
    }

    .close-sidebar {
        display: block;
    }

    /* The designation filter's swatches double as the legend. */
    .legend {
        display: none;
    }

    .open-sidebar {
        display: block;
        position: fixed;
        z-index: 1000;
        top: calc(var(--band-height) + 12px);
        left: 0;
        right: 0;
        width: max-content;
        margin: 0 auto;
        padding: 10px 18px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 20px;
        box-shadow: var(--shadow);
        font-weight: 600;
        cursor: pointer;
    }
}
