/* ============================================================
   WhereDoWeGo — floating dark-glass dashboard
   ============================================================ */

:root {
    --bg:           #0e1013;
    --panel:        rgba(20, 23, 28, 0.78);
    --panel-edge:   rgba(255, 255, 255, 0.08);
    --panel-edge-2: rgba(255, 255, 255, 0.04);
    --text:         #e9ecef;
    --text-muted:   #9aa0a6;
    --text-faint:   #6b7177;
    --accent:       #11ABB0;
    --accent-hov:   #1bc8cd;
    --accent-dim:   rgba(17, 171, 176, 0.18);
    --danger:       #d96b6b;
    --danger-bg:    rgba(217, 107, 107, 0.12);
    --radius:       12px;
    --radius-sm:    8px;
    --shadow:       0 8px 30px rgba(0, 0, 0, 0.35);
    --font:         "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
                    Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Map (full screen behind) ---------- */

#map {
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* tone down Leaflet's default attribution */
.leaflet-control-attribution {
    background: rgba(20, 23, 28, 0.7) !important;
    color: var(--text-muted) !important;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 4px 0 0 0;
}
.leaflet-control-attribution a { color: var(--text) !important; }

/* zoom buttons fit the theme */
.leaflet-bar a, .leaflet-bar a:hover {
    background: var(--panel) !important;
    color: var(--text) !important;
    border-bottom-color: var(--panel-edge) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.leaflet-bar { box-shadow: var(--shadow) !important; border: 1px solid var(--panel-edge) !important; }

/* ---------- Burger toggle for controls panel ---------- */

.panel-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1100;
    width: 42px;
    height: 42px;
    padding: 0;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--panel-edge);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: background .15s, transform .1s;
}
.panel-toggle:hover { background: rgba(255, 255, 255, 0.08); }
.panel-toggle:active { transform: scale(0.96); }

.panel-toggle__bar {
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    transform-origin: center;
    transition: transform .2s ease, opacity .15s;
}

/* aria-expanded="true" (panel visible) → bars morph into an X */
.panel-toggle[aria-expanded="true"] .panel-toggle__bar:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}
.panel-toggle[aria-expanded="true"] .panel-toggle__bar:nth-child(2) {
    opacity: 0;
}
.panel-toggle[aria-expanded="true"] .panel-toggle__bar:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* Generic panel shell ---------- */

.panel {
    position: absolute;
    z-index: 1000;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--panel-edge);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.panel--controls {
    top: 20px;
    left: 20px;
    width: 320px;
    max-height: calc(100vh - 40px);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    transition: transform .25s ease-out, opacity .2s;
}

/* Make room for the burger button at top-left of the panel header */
.panel--controls .panel__head {
    padding-left: 52px;
    min-height: 38px;
}

/* Hidden state — slides off-screen, mouse/touch events stop hitting it */
.panel--controls.panel--hidden {
    transform: translateX(-115%);
    opacity: 0;
    pointer-events: none;
}

.panel__head { display: flex; flex-direction: column; gap: 4px; }
.panel__title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.panel__hint {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.83rem;
    line-height: 1.4;
}

.panel__foot {
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid var(--panel-edge-2);
    font-size: 0.82rem;
    text-align: center;
}
.panel__foot a {
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 1px dotted var(--panel-edge);
    padding-bottom: 1px;
    transition: color .15s;
}
.panel__foot a:hover { color: var(--accent); }

.panel__close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: 0;
    color: var(--text-muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background .15s, color .15s;
}
.panel__close:hover { background: rgba(255,255,255,0.06); color: var(--text); }

/* ---------- Search row ---------- */

.search {
    position: relative;
    display: flex;
    gap: 6px;
    align-items: stretch;
}
.search__input {
    flex: 1;
    min-width: 0;
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--panel-edge);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.93rem;
    transition: border-color .15s, background .15s;
}
.search__input::placeholder { color: var(--text-faint); }
.search__input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.06);
}
.search__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    background: var(--accent);
    color: #0e1013;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .15s, transform .05s;
}
.search__btn:hover { background: var(--accent-hov); border-color: var(--accent-hov); }
.search__btn:active { transform: scale(0.97); }
.search__btn:disabled { opacity: 0.5; cursor: progress; }

/* ---------- Suggestions dropdown ---------- */

.suggestions {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 1500;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    max-height: 240px;
    overflow-y: auto;
}
.suggestions[hidden] { display: none; }
.suggestions li {
    padding: 8px 12px;
    color: var(--text);
    font-size: 0.88rem;
    line-height: 1.35;
    cursor: pointer;
    transition: background .1s, color .1s;
}
.suggestions li:hover,
.suggestions li.active {
    background: rgba(255, 255, 255, 0.07);
}
.suggestions li.active { color: var(--accent-hov); }
.suggestions li mark {
    background: transparent;
    color: var(--accent);
    font-weight: 600;
}
.suggestions::-webkit-scrollbar { width: 6px; }
.suggestions::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

/* ---------- Field (label + select) ---------- */

.field { display: flex; flex-direction: column; gap: 5px; }
.field__label {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
}
.field__select {
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--panel-edge);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.92rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%239aa0a6'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 32px;
}
.field__select:focus { outline: none; border-color: var(--accent); }
.field__select option { background: #1a1d21; color: var(--text); }

/* ---------- Filters (collapsible) ---------- */

.filters {
    border: 1px solid var(--panel-edge-2);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.025);
    padding: 0 10px;
}
.filters > summary {
    list-style: none;
    cursor: pointer;
    padding: 8px 2px;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.filters > summary::-webkit-details-marker { display: none; }
.filters > summary::before {
    content: '▸';
    color: var(--text-faint);
    transition: transform .15s;
    display: inline-block;
    width: 10px;
}
.filters[open] > summary::before { transform: rotate(90deg); }

.field--inline {
    padding: 6px 0 10px;
    gap: 4px;
}
.field--inline .field__label strong {
    color: var(--accent);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.field__hint {
    font-size: 0.74rem;
    color: var(--text-faint);
    line-height: 1.4;
    margin-top: 2px;
}
.field__hint code {
    background: rgba(255, 255, 255, 0.05);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.85em;
}

.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    outline: none;
    margin: 6px 0 2px;
}
.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: grab;
    border: 2px solid #0e1013;
    box-shadow: 0 0 0 1px var(--accent);
    transition: transform .1s;
}
.slider::-webkit-slider-thumb:active { transform: scale(1.15); cursor: grabbing; }
.slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: grab;
    border: 2px solid #0e1013;
    box-shadow: 0 0 0 1px var(--accent);
}

/* ---------- Points list ---------- */

.points { display: flex; flex-direction: column; gap: 6px; }
.points__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}
.points__label {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
}
.points__count {
    font-variant-numeric: tabular-nums;
    font-size: 0.78rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.05);
    padding: 1px 8px;
    border-radius: 999px;
}
.points__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 30vh;
    overflow-y: auto;
}
.points__list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 10px;
    background: rgba(255,255,255,0.035);
    border: 1px solid var(--panel-edge-2);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    line-height: 1.3;
}
.points__list .point__swatch {
    flex-shrink: 0;
    width: 10px;
    height: 18px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.35);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18) inset;
}
.points__list .point__label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}
.points__list .point__remove {
    flex-shrink: 0;
    background: none;
    border: 0;
    color: var(--text-faint);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 1rem;
    line-height: 1;
    transition: background .15s, color .15s;
}
.points__list .point__remove:hover {
    background: var(--danger-bg);
    color: var(--danger);
}
.points__empty {
    color: var(--text-faint) !important;
    font-style: italic;
    background: transparent !important;
    border: 1px dashed var(--panel-edge) !important;
    text-align: center;
}

/* scrollbar (subtle) */
.points__list::-webkit-scrollbar,
.panel--controls::-webkit-scrollbar { width: 6px; }
.points__list::-webkit-scrollbar-thumb,
.panel--controls::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
}
.points__list::-webkit-scrollbar-thumb:hover,
.panel--controls::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.15);
}

/* ---------- Actions ---------- */

.actions { display: flex; flex-direction: column; gap: 8px; }
.actions__row { display: flex; gap: 6px; }

.btn {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--panel-edge);
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.04);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.15);
}
.btn:active { transform: translateY(1px); }

.btn--primary {
    background: var(--accent);
    color: #0e1013;
    border-color: var(--accent);
    font-weight: 600;
}
.btn--primary:hover {
    background: var(--accent-hov);
    border-color: var(--accent-hov);
    color: #0e1013;
}

.btn--ghost {
    background: transparent;
    font-size: 0.82rem;
    padding: 8px 10px;
}

.btn--danger:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }

.btn.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent-hov);
}

/* ---------- Result card ---------- */

.panel--result {
    bottom: 20px;
    right: 20px;
    width: 280px;
    padding: 16px 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.result__kicker {
    margin: 0;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    font-weight: 600;
}
.result__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
}
.result__meta {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.result__link {
    margin-top: 8px;
    display: inline-block;
    color: var(--accent);
    font-size: 0.88rem;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color .15s;
    align-self: flex-start;
}
.result__link:hover { border-bottom-color: var(--accent); }

/* ---------- Toast ---------- */

.toast {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    padding: 10px 18px;
    background: rgba(20, 23, 28, 0.92);
    border: 1px solid var(--panel-edge);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.88rem;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: toast-in .2s ease-out;
}
@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Responsive ---------- */

/* Tablet: floating panel keeps its shape but trims width */
@media (min-width: 601px) and (max-width: 900px) {
    .panel--controls { width: 280px; }
    .panel--result   { width: 240px; }
}

/* Phone (≤600 px): controls become a bottom sheet, result floats at top */
@media (max-width: 600px) {
    .panel--controls {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: auto;
        max-height: 62vh;
        border-radius: var(--radius) var(--radius) 0 0;
        /* honour notched-device safe areas at the bottom */
        padding: 22px 16px calc(18px + env(safe-area-inset-bottom));
    }
    /* on mobile, the burger floats at top-left of the viewport, NOT inside the
       bottom sheet, so the panel header doesn't need extra left padding. */
    .panel--controls .panel__head { padding-left: 0; min-height: 0; }
    /* slide DOWN instead of LEFT when hidden */
    .panel--controls.panel--hidden { transform: translateY(115%); }
    /* drag-handle hint at the top of the bottom sheet */
    .panel--controls::before {
        content: '';
        position: absolute;
        top: 7px;
        left: 50%;
        transform: translateX(-50%);
        width: 38px;
        height: 4px;
        border-radius: 2px;
        background: rgba(255, 255, 255, 0.22);
    }
    .panel--result {
        bottom: auto;
        top: calc(env(safe-area-inset-top, 0px) + 12px);
        left: 12px;
        right: 12px;
        width: auto;
    }
    .points__list { max-height: 18vh; }
    .panel__title { font-size: 1.05rem; }
    .panel__hint  { font-size: 0.78rem; }
    .suggestions  { max-height: 180px; }
}

/* Touch devices: bigger hit-targets regardless of viewport width */
@media (hover: none) and (pointer: coarse) {
    .slider {
        height: 6px;
    }
    .slider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
    .slider::-moz-range-thumb {
        width: 22px;
        height: 22px;
    }
    .point__remove {
        padding: 4px 10px;
        font-size: 1.15rem;
        min-width: 28px;
        min-height: 28px;
    }
    .panel__close {
        font-size: 1.6rem;
        padding: 6px 12px;
    }
    .btn { padding: 12px 14px; }
    .btn--ghost { padding: 10px 10px; }
    .socials a { width: 42px; height: 42px; }
}

/* Tiny phones: clamp the panel further to keep the map visible */
@media (max-width: 380px) {
    .panel--controls {
        max-height: 70vh;
        padding-left: 12px;
        padding-right: 12px;
    }
    .points__list { max-height: 14vh; }
}

/* Landscape on small screens: side panel instead of bottom sheet */
@media (max-width: 900px) and (max-height: 480px) and (orientation: landscape) {
    .panel--controls {
        top: 12px;
        bottom: 12px;
        left: 12px;
        right: auto;
        width: 280px;
        max-height: none;
        border-radius: var(--radius);
        padding: 14px;
    }
    .panel--controls::before { display: none; }
    .panel--result {
        top: auto;
        bottom: 12px;
        left: auto;
        right: 12px;
        width: 260px;
    }
}
