/* Map page. Shared tokens and controls live in base.css. */

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

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

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

.panel {
    position: fixed;
    top: 12px;
    left: 12px;
    bottom: 12px;
    width: var(--panel-width);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
    z-index: 2;
}

.sheet-handle { display: none; }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 10px;
}


.head-actions { display: flex; align-items: center; gap: 10px; }

.mobile-only { display: none; }

.foot-link {
    align-items: center;
    gap: 6px;
    color: var(--accent);
    font-weight: 550;
    text-decoration: none;
}

.link-quiet {
    color: var(--text-2);
    text-decoration: none;
    font-size: 14px;
}
.link-quiet:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- buttons ---------- */

/* ---------- search ---------- */

.search {
    position: relative;
    margin: 0 16px;
}

.search input {
    width: 100%;
    height: 44px;
    padding: 0 48px 0 40px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    font-size: 15px;
}
.search input::placeholder { color: var(--text-3); }
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--surface); }
.search input::-webkit-search-cancel-button { display: none; }

.search-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    translate: 0 -50%;
    font-size: 18px;
    color: var(--text-3);
    pointer-events: none;
}

.locate-btn {
    position: absolute;
    right: 4px;
    top: 4px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--accent);
    font-size: 20px;
    cursor: pointer;
}
.locate-btn:hover { background: var(--accent-soft); }
.locate-btn.is-busy .ph { animation: pulse 1s ease-in-out infinite; }

.search-results {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-height: min(60vh, 420px);
    overflow-y: auto;
    z-index: 5;
}

.search-option {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
}
.search-option .ph { font-size: 18px; color: var(--text-3); margin-top: 1px; }
.search-option.is-active, .search-option:hover { background: var(--surface-2); }
.search-option.is-disabled { cursor: default; background: none; }
.option-text { display: flex; flex-direction: column; min-width: 0; }

.search-heading {
    padding: 10px 10px 4px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3);
}
.option-title { font-weight: 550; }
.option-sub { font-size: 13px; color: var(--text-2); }

/* ---------- fuel type ---------- */

.fuel-field {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px 2px;
}

.fuel-field label {
    font-size: 14px;
    font-weight: 550;
    color: var(--text-2);
}

/* ---------- body: summary, list ---------- */

.panel-body {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.panel[data-view="detail"] .list-view { display: none; }

.summary {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 12px;
    padding: 12px 16px 8px;
    min-height: 82px;
}

.stat-main .stat-value { font-size: 28px; color: var(--price-1); }

.summary-empty {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-2);
}
.summary-empty p { margin: 0; }

.legend {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px 10px;
    font-size: 12px;
    color: var(--text-3);
}
.legend-scale { display: inline-flex; gap: 2px; }
.legend-scale i { width: 14px; height: 6px; border-radius: 3px; }
.legend-note { margin-left: auto; }

.list-tools {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 8px 16px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.station-list {
    margin: 0;
    padding: 6px 8px 12px;
    list-style: none;
}

.station-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 8px;
    border: 0;
    border-radius: 10px;
    background: none;
    text-align: left;
    cursor: pointer;
}
.station-row:hover { background: var(--surface-2); }
.station-row.is-selected { background: var(--accent-soft); }

.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-name, .row-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-name { font-weight: 550; }
.row-meta { font-size: 13px; color: var(--text-2); }

.row-side { display: flex; flex-direction: column; align-items: flex-end; font-size: 13px; }
.row-distance { color: var(--text-2); font-variant-numeric: tabular-nums; }
.row-stale { color: var(--text-3); }

.list-note {
    padding: 12px 8px 4px;
    font-size: 13px;
    color: var(--text-3);
    text-align: center;
}

/* Loading placeholders shaped like the real content */

.skeleton-summary { grid-column: 1 / -1; height: 62px; }
.skeleton-row { height: 46px; margin: 6px 0; }

/* ---------- detail ---------- */

.detail { padding: 8px 16px 20px; }
.detail[hidden] { display: none; }

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 8px -8px;
    padding: 6px 8px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--text-2);
    font-size: 14px;
    cursor: pointer;
}
.back-btn:hover { background: var(--surface-2); color: var(--text); }

.detail-head h2 {
    font-size: 20px;
    font-weight: 650;
    letter-spacing: -0.01em;
    line-height: 1.25;
}
.detail-head h2:focus { outline: none; }
.detail-sub { margin: 4px 0 0; color: var(--text-2); font-size: 14px; }
.detail-address { margin: 2px 0 0; color: var(--text-2); font-size: 14px; }

.detail-compare {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 12px 0 0;
    font-size: 14px;
    font-weight: 550;
}
.detail-compare.is-cheaper { color: var(--price-1); }
.detail-compare.is-pricier { color: var(--price-4); }

.detail-prices {
    margin: 16px 0;
    padding: 0;
    list-style: none;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.detail-prices li {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0 12px;
    padding: 10px 14px;
}
.detail-prices li + li { border-top: 1px solid var(--border); }
.detail-prices li.is-current { background: var(--accent-soft); }
.fuel-name { font-weight: 550; }
.fuel-price { font-size: 17px; font-weight: 650; text-align: right; }
.fuel-age, .fuel-fill { font-size: 13px; color: var(--text-2); }
.fuel-age.is-stale { color: var(--danger); }
.fuel-fill { text-align: right; grid-column: 2; grid-row: 2; }

.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.detail-actions .btn:not(.btn-icon) { flex: 1; }

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

.panel-foot {
    padding: 10px 16px 12px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-3);
}

/* ---------- dialog + toast ---------- */

.dialog {
    width: min(360px, calc(100vw - 32px));
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgb(10 12 14 / 0.45); }
.dialog h2 { font-size: 18px; font-weight: 650; }
.dialog-text { margin: 4px 0 16px; color: var(--text-2); font-size: 14px; }
.dialog label { display: block; margin-bottom: 6px; font-weight: 550; font-size: 14px; }
.dialog input {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
}
.field-help { margin: 6px 0 0; font-size: 13px; color: var(--text-2); }
.field-error { margin: 6px 0 0; font-size: 13px; color: var(--danger); }
.dialog-actions { display: flex; gap: 8px; margin-top: 20px; }
.dialog-actions .btn:first-child { margin-right: auto; }

.toast {
    position: fixed;
    left: calc(var(--panel-width) + 24px + (100vw - var(--panel-width) - 24px) / 2);
    bottom: 24px;
    translate: -50% 0;
    max-width: min(440px, calc(100vw - 32px));
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--text);
    color: var(--surface);
    font-size: 14px;
    box-shadow: var(--shadow);
    z-index: 10;
}
.toast[hidden] { display: none; }

/* ---------- MapLibre controls ---------- */

.maplibregl-ctrl-group {
    background: var(--surface) !important;
    border: 1px solid var(--border);
    border-radius: 10px !important;
    box-shadow: var(--shadow) !important;
    overflow: hidden;
}
.maplibregl-ctrl-group button + button { border-top-color: var(--border) !important; }
@media (prefers-color-scheme: dark) {
    .maplibregl-ctrl-group .maplibregl-ctrl-icon { filter: invert(1); }
    .maplibregl-ctrl-attrib { background: rgb(23 25 28 / 0.8) !important; color: var(--text-2); }
    .maplibregl-ctrl-attrib a { color: var(--text-2) !important; }
}

/* ---------- mobile: bottom sheet ---------- */

@media (max-width: 767px) {
    .panel {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: auto;
        height: calc(var(--sheet-peek) + env(safe-area-inset-bottom));
        border-radius: 16px 16px 0 0;
        border-bottom: 0;
        padding-bottom: env(safe-area-inset-bottom);
        transition: height 0.28s var(--ease);
    }
    .panel[data-sheet="half"] { height: 55dvh; }
    .panel[data-sheet="full"] { height: calc(100dvh - 56px); }
    .panel.is-dragging { transition: none; }

    .sheet-handle {
        display: grid;
        place-items: center;
        flex: none;
        height: 22px;
        border: 0;
        background: none;
        cursor: grab;
        touch-action: none;
    }
    .sheet-handle span {
        width: 40px;
        height: 5px;
        border-radius: 999px;
        background: var(--surface-3);
    }

    .panel-head { padding: 0 16px 8px; }
    .brand { font-size: 15px; }
    .summary { min-height: 0; padding-top: 10px; }
    .stat-main .stat-value { font-size: 24px; }
    .desktop-only { display: none; }
    .mobile-only { display: inline-flex; }

    /* The header row doubles as a drag area for the sheet */
    .panel-head { touch-action: none; cursor: grab; }

    /* Footer (with the Leaderboard link) only once the sheet is pulled up, away from the drag zone */
    .panel-foot {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        font-size: 13px;
    }
    .panel[data-sheet="peek"] .panel-foot { display: none; }

    .maplibregl-ctrl-bottom-right { display: none; }

    /* At the top on phones, clear of the sheet whatever height it's at */
    .toast {
        left: 50%;
        top: calc(12px + env(safe-area-inset-top));
        bottom: auto;
    }
}

