/* Shared foundation for every page: fonts, colour tokens (light + dark), and common controls.
   Shape rule: panels 16px, popovers 12px, controls 10px, chips and price badges are full pills. */

@font-face {
    font-family: "Geist";
    src: url("../fonts/Geist-Variable.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

@font-face {
    font-family: "Geist Mono";
    src: url("../fonts/GeistMono-Variable.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

:root {
    color-scheme: light;
    --font: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

    --map-bg: #eef0ec;
    --surface: #fbfbfa;
    --surface-2: #f1f2ef;
    --surface-3: #e7e9e4;
    --border: #e1e3de;
    --text: #15181b;
    --text-2: #50565c;
    --text-3: #6b7178;
    --accent: #2453d6;
    --accent-ink: #ffffff;
    --accent-soft: #e6ecfb;
    --danger: #b3261e;
    --shadow: 0 1px 2px rgb(27 35 28 / 0.06), 0 8px 28px rgb(27 35 28 / 0.12);

    /* Price buckets, cheapest to priciest. Also read by layers.js for the map pins. */
    --price-1: #0e7a4b;
    --price-1-ink: #ffffff;
    --price-2: #7fb648;
    --price-2-ink: #14260a;
    --price-3: #f2b53a;
    --price-3-ink: #2b1d00;
    --price-4: #c63f35;
    --price-4-ink: #ffffff;
    --pin-outline: #ffffff;

    --panel-width: 376px;
    --sheet-peek: 248px;
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --map-bg: #121417;
        --surface: #17191c;
        --surface-2: #202327;
        --surface-3: #2a2e33;
        --border: #2b2f34;
        --text: #eceef0;
        --text-2: #b0b6bd;
        --text-3: #959ba2;
        --accent: #7b9cff;
        --accent-ink: #0b1430;
        --accent-soft: #1d2640;
        --danger: #ff8a80;
        --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 12px 32px rgb(0 0 0 / 0.45);

        --price-1: #34b27b;
        --price-1-ink: #04170e;
        --price-2: #a3cf62;
        --price-2-ink: #172907;
        --price-3: #f5c451;
        --price-3-ink: #2b1d00;
        --price-4: #f06b5f;
        --price-4-ink: #2a0604;
        --pin-outline: #121417;
    }
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.45;
    color: var(--text);
    background: var(--map-bg);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

*, *::before, *::after { box-sizing: border-box; }

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

a { color: inherit; }

h2 { margin: 0; }

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

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.price { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    font-weight: 550;
    font-size: 14px;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s, transform 0.1s;
}

.btn:hover { background: var(--surface-2); }

.btn:active { transform: translateY(1px); }

.btn .ph { font-size: 18px; }

.btn-small { min-height: 32px; padding: 0 10px; font-size: 13px; }

.btn-small .ph { font-size: 15px; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }

.btn-icon { padding: 0; width: 40px; }

@keyframes pulse { 50% { opacity: 0.35; } }

.select-wrap {
    position: relative;
    flex: 1;
}

.select-wrap select {
    width: 100%;
    height: 40px;
    padding: 0 36px 0 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    font-size: 15px;
    font-weight: 550;
    appearance: none;
    cursor: pointer;
}

.select-wrap select:hover { background: var(--surface-2); }

.select-wrap select:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }

.select-wrap .ph {
    position: absolute;
    right: 12px;
    top: 50%;
    translate: 0 -50%;
    color: var(--text-2);
    pointer-events: none;
}

.bucket-0 { background: var(--price-1); color: var(--price-1-ink); }

.bucket-1 { background: var(--price-2); color: var(--price-2-ink); }

.bucket-2 { background: var(--price-3); color: var(--price-3-ink); }

.bucket-3 { background: var(--price-4); color: var(--price-4-ink); }

.segmented {
    display: inline-flex;
    margin: 0;
    padding: 2px;
    border: 0;
    border-radius: 10px;
    background: var(--surface-2);
}

.segmented input { position: absolute; opacity: 0; pointer-events: none; }

.segmented label {
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 550;
    color: var(--text-2);
    cursor: pointer;
}

.segmented input:checked + label { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.1); }

.segmented input:disabled + label { opacity: 0.5; cursor: not-allowed; }

.segmented input:focus-visible + label { outline: 2px solid var(--accent); }

.check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
}

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

.price-badge {
    min-width: 58px;
    padding: 4px 10px;
    border-radius: 999px;
    text-align: center;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 14px;
    font-weight: 650;
}

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 32px 16px;
    text-align: center;
    color: var(--text-2);
}

.empty .ph { font-size: 28px; color: var(--text-3); }

.empty p { margin: 0; max-width: 32ch; }

.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    border-radius: 10px;
    animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- page shell (every page except the full-screen map) ---------- */

body.app {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.site-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: 880px;
    margin: 0 auto;
    padding: 12px 16px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 650;
    font-size: 16px;
    letter-spacing: -0.01em;
    text-decoration: none;
}
.brand .ph { font-size: 20px; color: var(--accent); }

.site-nav { display: flex; gap: 4px; }
.site-nav a {
    padding: 6px 12px;
    border-radius: 10px;
    color: var(--text-2);
    font-size: 14px;
    font-weight: 550;
    text-decoration: none;
}
.site-nav a:hover { background: var(--surface-2); color: var(--text); }
.site-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

.page {
    flex: 1;
    width: 100%;
    max-width: 880px;
    margin: 0 auto;
    padding: 28px 16px 40px;
}

.page-head h1 {
    margin: 0;
    font-size: 30px;
    font-weight: 650;
    letter-spacing: -0.02em;
    line-height: 1.15;
}
.page-sub { margin: 6px 0 0; color: var(--text-2); max-width: 60ch; }

.site-foot {
    padding: 20px 16px 28px;
    text-align: center;
    font-size: 13px;
    color: var(--text-3);
}

/* ---------- form fields ---------- */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: 14px; font-weight: 550; color: var(--text-2); }
.field-help { margin: 0; font-size: 13px; color: var(--text-2); }
.field-error { margin: 0; font-size: 13px; color: var(--danger); }

.text-input, .field input[type="text"] {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    font-size: 15px;
}
.field input[type="text"]::placeholder { color: var(--text-3); }
.field input[type="text"]:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.icon-btn {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--accent);
    font-size: 18px;
    cursor: pointer;
}
.icon-btn:hover { background: var(--accent-soft); }
.icon-btn.is-busy .ph { animation: pulse 1s ease-in-out infinite; }

/* ---------- stats ---------- */

.stat { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.stat-label { font-size: 13px; color: var(--text-2); }
.stat-value { font-size: 22px; font-weight: 600; line-height: 1.2; }
.stat-sub { font-size: 13px; color: var(--text-2); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
