/* Styles the Pješačke barijere report: header, map with its panel and layers, tables and charts.
   Mobile-first; the map panel becomes a bottom sheet on phones and a side panel from 861 px up. */
:root {
    --bg: #f5f4ef;
    --panel: #ffffff;
    --ink: #202124;
    --muted: #62615c;
    --line: #d7d3c8;
    --accent: #0f766e;
    --accent-soft: #eaf7f5;
    --accent-line: #99d5ce;
    --accent-2: #b45309;
    --shadow: 0 8px 24px rgba(31, 31, 28, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 300px;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

button,
select,
input {
    font: inherit;
}

a {
    color: var(--accent);
}

/* ---------------------------------------------------------------- header */

.topbar {
    padding: 14px 14px 16px;
    border-bottom: 1px solid var(--line);
    background: #fbfaf6;
}

.crumbs {
    display: flex;
    gap: 6px;
    align-items: center;
    color: var(--muted);
    font-size: 12px;
}

.crumbs a {
    color: var(--muted);
    text-decoration: none;
}

.crumbs a:hover {
    color: var(--accent);
}

.topbar h1 {
    margin: 8px 0 0;
    font-size: 22px;
    line-height: 1.15;
}

.subtitle {
    margin: 4px 0 0;
    font-size: 15px;
    color: var(--ink);
}

.data-date {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.load-state {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.load-state[hidden] {
    display: none;
}

/* The spinner appears only once loading has run past half a second, so a fast load never flickers. */
.spinner {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    opacity: 0;
    animation: spin 900ms linear infinite;
}

.load-state.slow .spinner {
    opacity: 1;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.load-error {
    margin: 14px 0 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff8e7;
    color: #6b4b12;
}

.load-error[hidden] {
    display: none;
}

.summary-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin-top: 14px;
}

.metric-tile {
    min-height: 92px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.metric-label {
    color: var(--muted);
    font-size: 12px;
}

.metric-value {
    margin-top: 4px;
    font-size: 22px;
    line-height: 1.1;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
}

.metric-note {
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
}

/* ---------------------------------------------------------------- sections */

.report {
    max-width: 1320px;
    margin: 0 auto;
    padding: 14px;
}

.report-section {
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    scroll-margin-top: 10px;
}

.disclosure-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    cursor: pointer;
    list-style: none;
}

.disclosure-summary::-webkit-details-marker {
    display: none;
}

.disclosure-summary::marker {
    content: '';
}

.disclosure-summary:focus-visible {
    outline: 2px solid rgba(15, 118, 110, 0.5);
    outline-offset: -2px;
}

.disclosure-summary h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
}

.disclosure-summary h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
}

.disclosure-chevron {
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg) translateY(-2px);
    transition: transform 140ms ease;
}

details[open] > .disclosure-summary .disclosure-chevron {
    transform: rotate(225deg) translate(-2px, -2px);
}

.section-body {
    padding: 0 14px 16px;
}

.section-intro {
    margin: 0 0 12px;
    max-width: 78ch;
    color: var(--muted);
}

.section-body h3 {
    margin: 18px 0 8px;
    font-size: 14px;
}

/* ---------------------------------------------------------------- map */

.map-shell {
    position: relative;
    display: grid;
    gap: 0;
}

/* clamp(), not a bare vh: a very tall viewport should not turn the map into the whole page, and it
   keeps a full-page screenshot (which expands the viewport) from growing the map without bound. */
.map-pane {
    position: relative;
    height: clamp(340px, 62vh, 620px);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #dfe9e1;
}

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

.map-legend {
    position: absolute;
    left: 10px;
    bottom: 10px;
    z-index: 500;
    padding: 8px 10px;
    border: 1px solid rgba(32, 33, 36, 0.16);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.93);
    box-shadow: var(--shadow);
    font-size: 11px;
    pointer-events: none;
}

.map-legend-title {
    margin-bottom: 5px;
    font-weight: 700;
}

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

.legend-swatch {
    width: 12px;
    height: 12px;
    flex: 0 0 auto;
    border: 1px solid rgba(32, 33, 36, 0.3);
    border-radius: 3px;
    background: var(--swatch, #ccc);
}

.legend-swatch-passage {
    background: var(--accent);
    border-radius: 50%;
}

.legend-swatch-worst {
    background: var(--accent-2);
    border-radius: 50%;
}

.legend-ramp {
    width: 44px;
    height: 12px;
    flex: 0 0 auto;
    border: 1px solid rgba(32, 33, 36, 0.3);
    border-radius: 3px;
    background: linear-gradient(90deg, #08313a, #0f5f63, #2f8f83, #7dbfa9, #d9ecdb);
}

/* Panel barijere: a bottom sheet over the map on phones, never taller than half of it. */
.barrier-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 600;
    max-height: 50%;
    overflow-y: auto;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--line);
    border-radius: 10px 10px 8px 8px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 -6px 18px rgba(31, 31, 28, 0.14);
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.panel-heading h3 {
    margin: 0;
    font-size: 14px;
    overflow-wrap: anywhere;
}

/* Reserved height so the panel does not jump between the empty state and a loaded barrier. */
.panel-body {
    min-height: 116px;
    margin-top: 6px;
}

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

.panel-ends,
.panel-kind {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 12px;
}

.panel-facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin: 8px 0 0;
}

.panel-facts div {
    padding: 6px 8px;
    border: 1px solid #ebe7dc;
    border-radius: 6px;
    background: #fbfaf6;
}

.panel-facts dt {
    color: var(--muted);
    font-size: 11px;
}

.panel-facts dd {
    margin: 2px 0 0;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    font-size: 12px;
}

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

.muted {
    color: var(--muted);
    font-weight: 400;
}

.ghost-button {
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font-size: 12px;
    cursor: pointer;
}

.ghost-button:hover:not(:disabled) {
    border-color: var(--accent-line);
    color: var(--accent);
}

.ghost-button:disabled {
    color: #9a9891;
    cursor: not-allowed;
}

.popup-action {
    margin-top: 6px;
    padding: 4px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
}

.layer-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-top: 10px;
}

.layer-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
}

.layer-toggle input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--accent);
}

.layer-toggle em {
    color: var(--muted);
    font-size: 11px;
    font-style: normal;
}

.reach-controls {
    display: grid;
    gap: 8px;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfaf6;
}

.reach-controls[hidden] {
    display: none;
}

.reach-radii {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    margin: 0;
    padding: 0;
    border: 0;
}

.reach-radii legend {
    padding: 0;
    color: var(--muted);
    font-size: 12px;
}

.reach-radii label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    cursor: pointer;
}

.reach-radii input {
    accent-color: var(--accent);
}

.reach-opacity {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
}

.reach-opacity input {
    flex: 1 1 160px;
    max-width: 260px;
    accent-color: var(--accent);
}

.reach-readout {
    margin: 0;
    min-height: 18px;
    font-size: 12px;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.reach-overlay {
    image-rendering: auto;
}

.legend-detail {
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfaf6;
}

.legend-detail > .disclosure-summary {
    padding: 8px 10px;
}

.legend-list {
    margin: 0;
    padding: 0 10px 10px;
}

.legend-row {
    display: grid;
    grid-template-columns: minmax(96px, auto) minmax(0, 1fr);
    gap: 4px 10px;
    padding: 5px 0;
    border-top: 1px solid #ece9e0;
}

.legend-row:first-child {
    border-top: 0;
}

.legend-row dt {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 12px;
}

.legend-row dd {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

/* ---------------------------------------------------------------- tabs, tables */

.kind-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.kind-tab {
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--ink);
    font-size: 12px;
    cursor: pointer;
}

.kind-tab:hover {
    border-color: var(--accent-line);
}

.kind-tab.active {
    border-color: var(--accent-line);
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
}

.tab-count {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.kind-tab.active .tab-count {
    color: var(--accent);
}

.table-controls {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 8px;
}

.table-controls label {
    display: grid;
    gap: 3px;
    color: var(--muted);
    font-size: 11px;
}

.table-controls select {
    min-width: 200px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
}

.table-count {
    padding-bottom: 8px;
    color: var(--muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.table-wrap {
    max-height: 420px;
    overflow: auto;
    border: 1px solid #ebe7dc;
    border-radius: 6px;
}

.table-wrap-tall {
    max-height: 540px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.data-table th,
.data-table td {
    padding: 8px;
    border-bottom: 1px solid #ebe7dc;
    text-align: right;
    white-space: nowrap;
}

.data-table th:first-child,
.data-table td:first-child {
    text-align: left;
    white-space: normal;
}

.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #fbfaf6;
    color: var(--muted);
    font-weight: 700;
    cursor: pointer;
    user-select: none;
}

.data-table.static-table thead th {
    cursor: default;
}

.data-table th[data-sort]::after {
    content: attr(data-indicator);
    margin-left: 5px;
    color: var(--accent);
    font-size: 10px;
}

.data-table tbody tr {
    cursor: pointer;
}

.data-table.static-table tbody tr {
    cursor: default;
}

.data-table tbody tr:hover,
.data-table tbody tr.selected {
    background: var(--accent-soft);
}

.row-main {
    display: block;
    font-weight: 600;
}

.row-sub {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 400;
}

.kind-chip {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-right: 6px;
    border-radius: 2px;
    background: var(--swatch, #ccc);
}

.table-footer {
    display: flex;
    justify-content: center;
    margin-top: 10px;
}

.table-footer .ghost-button[hidden] {
    display: none;
}

/* ---------------------------------------------------------------- charts */

.chart-caption {
    margin: 0 0 8px;
    font-size: 13px;
    min-height: 20px;
}

.chart-frame {
    position: relative;
    margin-bottom: 12px;
    padding: 8px;
    border: 1px solid #ebe7dc;
    border-radius: 8px;
    background: #fbfaf6;
}

.chart-frame-avenue {
    height: 220px;
}

.chart-frame-reach {
    height: 420px;
}

/* ---------------------------------------------------------------- metodologija */

.definitions {
    margin: 0;
}

.definitions dt {
    margin-top: 10px;
    font-weight: 700;
}

.definitions dd {
    margin: 2px 0 0;
    color: var(--muted);
    max-width: 78ch;
}

.params {
    margin: 0;
}

.param-row {
    display: grid;
    grid-template-columns: minmax(150px, 260px) minmax(0, 1fr);
    gap: 4px 12px;
    padding: 6px 0;
    border-top: 1px solid #ece9e0;
}

.param-row:first-child {
    border-top: 0;
}

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

.param-row dd {
    margin: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.caveats {
    margin: 0;
    padding-left: 20px;
    max-width: 78ch;
    color: var(--muted);
}

.caveats li {
    margin-bottom: 6px;
}

.sources {
    margin-top: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfaf6;
}

.sources > .disclosure-summary {
    padding: 8px 10px;
}

.source-list {
    margin: 0;
    padding: 0 10px 10px 30px;
    color: var(--muted);
    font-size: 13px;
}

.source-list li {
    margin-bottom: 5px;
}

/* ---------------------------------------------------------------- footer */

.site-footer {
    padding: 18px 14px 28px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.site-footer p {
    margin: 0;
}

/* ---------------------------------------------------------------- leaflet tweaks */

.leaflet-container {
    font: inherit;
}

.leaflet-popup-content {
    margin: 10px 12px;
    font-size: 13px;
    line-height: 1.45;
}

/* ---------------------------------------------------------------- wider screens */

@media (min-width: 861px) {
    .topbar {
        padding: 18px 24px 20px;
    }

    .report {
        padding: 18px 24px 8px;
    }

    .map-shell {
        grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
        gap: 12px;
    }

    .map-pane {
        height: clamp(460px, 66vh, 720px);
    }

    /* From here the panel is a real side panel, not a sheet over the map. */
    .barrier-panel {
        position: static;
        max-height: clamp(460px, 66vh, 720px);
        border: 1px solid var(--line);
        border-radius: 8px;
        box-shadow: none;
        background: #fdfcf8;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 13px;
    }

    .topbar h1 {
        font-size: 19px;
    }

    .summary-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric-value {
        font-size: 18px;
    }

    .report {
        padding: 10px;
    }

    .section-body {
        padding: 0 10px 12px;
    }

    .disclosure-summary {
        padding: 10px;
    }

    .map-pane {
        height: clamp(300px, 58vh, 520px);
    }

    /* The bottom sheet covers the map's bottom-left corner, so the on-map legend would be hidden
       behind it; the full legend with its sentences sits right under the map anyway. */
    .map-legend {
        display: none;
    }

    .panel-facts {
        grid-template-columns: 1fr;
    }

    .table-controls select {
        min-width: 0;
        width: 100%;
    }

    .table-controls label {
        flex: 1 1 100%;
    }

    .data-table th,
    .data-table td {
        padding: 7px 6px;
    }

    .param-row,
    .legend-row {
        grid-template-columns: 1fr;
    }

    .chart-frame-reach {
        height: 360px;
    }
}

/* Motion is emphasis only: with it reduced the spinner stops and nothing else changes. */
@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation: none;
    }

    .disclosure-chevron {
        transition: none;
    }
}
