/* RouteHelper — jeden arkusz, bez frameworka. Ciemna paleta dobrana pod
   zdjęcie w tle (zachód słońca nad drogą): bursztyn jako akcent, chłodny
   grafit jako tło paneli. */

:root {
    --ink: #0d1117;
    --ink-2: #161b25;
    --ink-3: #1e2532;
    --line: rgba(255, 255, 255, 0.10);
    --line-strong: rgba(255, 255, 255, 0.20);

    --text: #f2f4f8;
    --text-dim: #a8b2c4;
    --text-faint: #78839a;

    --amber: #f0a500;
    --amber-soft: rgba(240, 165, 0, 0.14);
    --sky: #4cc4e0;
    --green: #5ac47d;
    --red: #ef6461;

    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background: var(--ink);
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

a { color: var(--amber); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 650; letter-spacing: -0.02em; }

.wrap { width: min(1120px, calc(100% - 3rem)); margin-inline: auto; }

.muted { color: var(--text-faint); }

/* -------------------------------------------------------------- banner --- */

/* Wąski pasek nad zdjęciem. Bursztyn tylko w obwódce i w odnośniku — pełne
   tło akcentem konkurowałoby z przyciskiem „Dodaj punkty”, a to pasek
   informacyjny, nie wezwanie do działania. */
.v2-banner {
    flex: 0 0 auto;
    border-bottom: 1px solid var(--line);
    background: var(--amber-soft);
    font-size: 0.875rem;
}

.v2-banner .wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: center;
    gap: 0.3rem 0.9rem;
    padding-block: 0.6rem;
}

.v2-banner p { margin: 0; color: var(--text-dim); }

.v2-banner strong { color: var(--text); font-weight: 650; }

.v2-banner a { white-space: nowrap; font-weight: 600; }

@media (max-width: 36rem) {
    /* Na wąskim ekranie do lewej, nie na środek: wyśrodkowany tekst łamiący
       się na trzy linijki czyta się gorzej niż zwykły akapit. */
    .v2-banner .wrap { justify-content: flex-start; }
}

/* ---------------------------------------------------------------- hero --- */

.hero {
    position: relative;
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    padding-block: 1.6rem 3rem;
    isolation: isolate;
}

/* Zdjęcie zajmuje pas u góry i wytapia się w tło strony. Rozciągnięte na całą
   (bardzo wysoką) sekcję było praktycznie niewidoczne — formularz przykrywał
   wszystko poza niebem. */
.hero::before,
.hero::after {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    /* Pas zdjęcia idzie w dół razem z nagłówkiem — po skróceniu tekstu formularz
       zaczyna się wyżej, więc wyższy pas kończyłby się już pod panelem. */
    height: min(620px, 74vh);
}

.hero::before {
    z-index: -2;
    background-image: url("../img/hero.jpg");
    background-size: cover;
    background-position: center 58%;
}

/* Góra przyciemniona pod nagłówek, środek prawie czysty (tam widać drogę
   i rowerzystę), dół schodzi do koloru tła strony. */
.hero::after {
    z-index: -1;
    background: linear-gradient(
        180deg,
        rgba(13, 17, 23, 0.62) 0%,
        rgba(13, 17, 23, 0.30) 22%,
        rgba(13, 17, 23, 0.22) 42%,
        rgba(13, 17, 23, 0.68) 72%,
        var(--ink) 100%);
}

.hero-head { text-align: center; margin-bottom: 1.4rem; }

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 0.74rem;
    color: var(--amber);
    margin-bottom: 0.7rem;
}

.brand::before {
    content: "";
    width: 26px;
    height: 2px;
    background: var(--amber);
}

.hero h1 {
    font-size: clamp(1.65rem, 3.6vw, 2.5rem);
    text-shadow: 0 2px 24px rgba(0, 0, 0, 0.55);
    max-width: 24ch;
    margin-inline: auto;
}

.hero .lead {
    margin: 0.5rem auto 0;
    max-width: 48ch;
    font-size: 1rem;
    color: #dfe5ef;
    text-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
}

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

.panel {
    background: rgba(22, 27, 37, 0.82);
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(1.4rem, 3vw, 2.2rem);
}

.panel--flat {
    background: var(--ink-2);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.step {
    display: flex;
    align-items: baseline;
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.step-no {
    flex: none;
    width: 1.55rem;
    height: 1.55rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--amber-soft);
    border: 1px solid rgba(240, 165, 0, 0.4);
    color: var(--amber);
    font-size: 0.8rem;
    font-weight: 700;
    align-self: center;
}

.step h2 { font-size: 1.06rem; }

.step p { margin: 0; font-size: 0.88rem; color: var(--text-faint); }

.field + .field { margin-top: 1.5rem; }

/* ---------------------------------------------------------- file input --- */

.drop {
    position: relative;
    display: block;
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    padding: 1.6rem 1.2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.drop:hover, .drop.is-hot {
    border-color: var(--amber);
    background: var(--amber-soft);
}

.drop input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.drop-title { display: block; font-weight: 600; }

.drop-hint { display: block; font-size: 0.85rem; color: var(--text-faint); margin-top: 0.2rem; }

.drop.has-file { border-style: solid; border-color: var(--green); background: rgba(90, 196, 125, 0.10); }

/* ------------------------------------------------------------- choices --- */

.group + .group { margin-top: 1.5rem; }

.group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.7rem;
}

.group-head h3 {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
}

.link-button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 0.8rem;
    color: var(--amber);
    cursor: pointer;
}

.link-button:hover { text-decoration: underline; }

.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.chip { position: relative; }

.chip input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.chip span {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    padding: 0.42rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    user-select: none;
}

.chip span:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.09); }

.chip input:checked + span {
    background: var(--amber);
    border-color: var(--amber);
    color: #22190a;
    font-weight: 600;
}

/* Klawiatura musi widzieć fokus — input jest wizualnie ukryty. */
.chip input:focus-visible + span {
    outline: 2px solid var(--sky);
    outline-offset: 2px;
}

.chip .count { font-size: 0.75rem; opacity: 0.65; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- range --- */

.range-row { display: flex; align-items: center; gap: 1rem; }

.range-row input[type="range"] { flex: 1; accent-color: var(--amber); }

.range-value {
    flex: none;
    min-width: 5.5rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--amber);
}

/* ------------------------------------------------------------- switch --- */

/* position:relative jest konieczne — bez niego ukryty input pozycjonuje się
   względem .hero, czyli fizycznie ląduje na górze strony, a kliknięcie
   przełącznika przewija widok do nagłówka. Tak samo jak w .chip. */
.switch { position: relative; display: flex; align-items: flex-start; gap: 0.85rem; cursor: pointer; }

.switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-box {
    flex: none;
    width: 42px;
    height: 24px;
    margin-top: 0.1rem;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.08);
    position: relative;
    transition: background 0.15s, border-color 0.15s;
}

.switch-box::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-dim);
    transition: transform 0.15s, background 0.15s;
}

.switch input:checked + .switch-box { background: var(--amber); border-color: var(--amber); }
.switch input:checked + .switch-box::after { transform: translateX(18px); background: #22190a; }
.switch input:focus-visible + .switch-box { outline: 2px solid var(--sky); outline-offset: 2px; }

.switch-title { display: block; font-weight: 600; font-size: 0.94rem; }

.switch-hint {
    display: block;
    font-size: 0.84rem;
    color: var(--text-faint);
    margin-top: 0.15rem;
}

.switch-hint code {
    background: rgba(255, 255, 255, 0.07);
    padding: 0.08rem 0.34rem;
    border-radius: 4px;
    font-size: 0.92em;
}

/* Przykład dopasowany do stanu przełącznika — bez JS-a, samym selektorem. */
.switch input:checked ~ .switch-text .when-off,
.switch input:not(:checked) ~ .switch-text .when-on { display: none; }

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

.actions { margin-top: 2rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.72rem 1.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.12s, background 0.12s, border-color 0.12s;
    text-decoration: none;
}

.btn:hover { text-decoration: none; }

.btn-primary { background: var(--amber); color: #22190a; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }

.btn-ghost { background: rgba(255, 255, 255, 0.06); border-color: var(--line-strong); color: var(--text); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }

.btn-file { flex-direction: column; gap: 0.1rem; align-items: flex-start; padding: 0.7rem 1.1rem; }
.btn-file .ext { font-size: 0.95rem; font-weight: 700; letter-spacing: 0.02em; }
.btn-file .note { font-size: 0.73rem; font-weight: 400; color: var(--text-faint); }
.btn-file.is-recommended { border-color: var(--amber); background: var(--amber-soft); }
.btn-file.is-recommended .note { color: var(--amber); }

/* -------------------------------------------------------------- alerts --- */

.alert {
    border-radius: var(--radius-sm);
    padding: 0.85rem 1.1rem;
    font-size: 0.92rem;
    margin-bottom: 1.4rem;
    border: 1px solid;
}

.alert-error { background: rgba(239, 100, 97, 0.12); border-color: rgba(239, 100, 97, 0.45); color: #ffd9d8; }
.alert-warn { background: rgba(240, 165, 0, 0.10); border-color: rgba(240, 165, 0, 0.40); color: #ffe6b8; }

.alert ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }

/* -------------------------------------------------------------- result --- */

.result-page { flex: 1 0 auto; padding-block: 2.2rem 3rem; }

.result-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.6rem;
}

.result-head h1 { font-size: clamp(1.5rem, 3vw, 2.1rem); }

.result-head .sub { color: var(--text-faint); font-size: 0.9rem; margin-top: 0.35rem; }

/* align-items:stretch zamiast dobierania paddingów na oko — oba przyciski
   dostają wysokość wyższego z nich, więc krawędzie się zgadzają niezależnie
   od tego, jak duża jest grafika z buycoffee. */
.head-actions {
    display: flex;
    align-items: stretch;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.coffee {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.06);
    transition: background 0.12s, border-color 0.12s;
}

.coffee:hover { background: rgba(255, 255, 255, 0.12); }

/* Wysokość, nie szerokość: to ona decyduje o wyrównaniu z sąsiednim
   przyciskiem. Szerokość dolicza się z proporcji 406×92. */
.coffee img {
    display: block;
    height: 30px;
    width: auto;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.6rem;
}

.stat { background: var(--ink-2); padding: 1rem 1.2rem; }

.stat .k {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
}

.stat .v {
    font-size: 1.45rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    margin-top: 0.15rem;
}

.stat .v small { font-size: 0.8rem; font-weight: 400; color: var(--text-faint); margin-left: 0.15rem; }

/* Pasek pobierania nad mapą, na całą szerokość. */
.download-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.2rem 1.6rem;
    flex-wrap: wrap;
    background: var(--ink-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.9rem 1.1rem;
    margin-bottom: 1.4rem;
}

.downloads { display: flex; flex-direction: row; flex-wrap: wrap; gap: 0.55rem; }

.download-hint {
    margin: 0;
    flex: 1 1 22ch;
    min-width: 0;
    font-size: 0.83rem;
    color: var(--text-faint);
    text-align: right;
}

.download-hint code {
    background: rgba(255, 255, 255, 0.07);
    padding: 0.08rem 0.34rem;
    border-radius: 4px;
}

@media (max-width: 720px) {
    .download-hint { text-align: left; }
}

/* Wysokość mapy jest jednocześnie wysokością listy punktów — obie kolumny
   kończą się w tej samej linii. */
.result-grid {
    --map-height: 620px;
    display: grid;
    grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr);
    gap: 1.4rem;
    align-items: start;
}

#map {
    height: var(--map-height);
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--ink-2);
    z-index: 0;
}

@media (max-width: 900px) {
    /* Jedna kolumna: mapa nad listą, obie niższe, żeby dało się je objąć
       wzrokiem bez przewijania przez pół ekranu. */
    .result-grid { --map-height: 380px; grid-template-columns: minmax(0, 1fr); }
}

.side h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin-bottom: 0.6rem;
}

.side h2 .count {
    font-size: 0.75rem;
    letter-spacing: 0;
    color: var(--amber);
    background: var(--amber-soft);
    border-radius: 999px;
    padding: 0.05rem 0.5rem;
    font-variant-numeric: tabular-nums;
}

/* Własny kontener przewijania: 100 punktów przewija się tu, a nie na stronie,
   więc mapa obok nie drgnie. */
.poi-list {
    max-height: var(--map-height);
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}

/* Wiersz to dwa przyciski obok siebie: treść punktu i kosz. Obramowanie i tło
   pod kursorem siedzą na wspólnym kontenerze, żeby wyglądały jak jeden pasek. */
.poi-item {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--line);
}

.poi-item:last-child { border-bottom: none; }
.poi-item:hover { background: rgba(255, 255, 255, 0.05); }

.poi-row {
    display: grid;
    grid-template-columns: 3.9rem minmax(0, 1fr);
    gap: 0.7rem;
    padding: 0.6rem 0.8rem;
    font-size: 0.88rem;
    flex: 1;
    min-width: 0;
    text-align: left;
    background: none;
    border: none;
    color: inherit;
    font-family: inherit;
    cursor: pointer;
}

/* Kosz jest wyblakły, dopóki kursor nie wejdzie na wiersz — lista ma się czytać
   jako punkty trasy, a nie jako rząd przycisków do kasowania. */
.poi-delete {
    flex: none;
    display: flex;
    align-items: center;
    padding: 0 0.7rem;
    border: none;
    background: none;
    color: var(--text-faint);
    cursor: pointer;
    opacity: 0.35;
}

.poi-item:hover .poi-delete,
.poi-delete:focus-visible { opacity: 1; }

.poi-delete:hover:not(:disabled) { color: #ef6461; }

/* Wyłączone na czas trwającego usuwania — jeden indeks naraz. Selektor musi
   być tak samo szczegółowy jak reguła hovera wyżej, żeby ją przebić. */
.poi-item .poi-delete:disabled { cursor: default; opacity: 0.2; }

.poi-delete svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Wiersz w trakcie usuwania. Treść chowamy przez visibility, a nie display —
   wiersz zachowuje wtedy swoją wysokość i lista nie skacze pod kursorem. */
.poi-item.is-busy {
    position: relative;
    background: none;
}

.poi-item.is-busy > * { visibility: hidden; }

.poi-item.is-busy::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 16px;
    height: 16px;
    border: 2px solid var(--line);
    border-top-color: var(--amber);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.poi-km { color: var(--amber); font-variant-numeric: tabular-nums; font-weight: 600; }

/* Bez min-width:0 element gridu nie kurczy się poniżej swojej treści i długie
   nazwy sklepów wylewają się poza panel zamiast dostać wielokropek. */
.poi-body { min-width: 0; }

.poi-name,
.poi-meta {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.poi-meta { font-size: 0.78rem; color: var(--text-faint); }

/* Pasek luki — celowo łamie rytm listy: to jedyny element, który nie jest
   punktem, tylko jego brakiem. */
.gap-band {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.8rem;
    border: none;
    border-block: 1px dashed rgba(239, 100, 97, 0.5);
    background: rgba(239, 100, 97, 0.09);
    color: var(--text-dim);
    font: inherit;
    font-size: 0.82rem;
    text-align: left;
    cursor: pointer;
}

.gap-band:hover { background: rgba(239, 100, 97, 0.17); }

.gap-band:focus-visible { outline: 2px solid var(--sky); outline-offset: -2px; }

.gap-len {
    font-weight: 700;
    color: var(--red);
    font-variant-numeric: tabular-nums;
}

.stat--warn .v { color: var(--red); }

.stat-note {
    margin-top: 0.1rem;
    font-size: 0.74rem;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
}

.bar {
    display: inline-block;
    width: 14px;
    height: 4px;
    border-radius: 2px;
    margin-right: 0.4rem;
    vertical-align: 3px;
}

.bar-gap { background: var(--red); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.4rem; vertical-align: 1px; }
.dot-fuel { background: var(--amber); }
.dot-shop { background: var(--sky); }
.dot-food { background: var(--red); }

.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.82rem; color: var(--text-dim); margin-top: 0.8rem; }

.note-box {
    margin-top: 1.5rem;
    font-size: 0.83rem;
    color: var(--text-faint);
    border-left: 2px solid var(--amber);
    padding-left: 0.9rem;
}

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

.site-footer {
    flex: none;
    border-top: 1px solid var(--line);
    padding-block: 1.5rem;
    font-size: 0.82rem;
    color: var(--text-faint);
    background: var(--ink);
}

.site-footer p { margin: 0; }
.site-footer p + p { margin-top: 0.3rem; }

/* Marker POI rysowany przez Leaflet — divIcon, więc stylujemy tutaj. */
.poi-marker {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    border: 2px solid #0d1117;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.leaflet-popup-content-wrapper { background: var(--ink-2); color: var(--text); border-radius: var(--radius-sm); }
.leaflet-popup-tip { background: var(--ink-2); }
.leaflet-popup-content { margin: 0.7rem 0.9rem; font-size: 0.87rem; }
.leaflet-popup-content b { color: var(--amber); }
.leaflet-container a.leaflet-popup-close-button { color: var(--text-faint); }

/* --------------------------------------------------------------- modal --- */

.modal {
    border: none;
    padding: 0;
    background: transparent;
    color: var(--text);
    max-width: min(34rem, calc(100vw - 2rem));
}

.modal::backdrop { background: rgba(0, 0, 0, 0.6); }

.modal-card {
    border: 1px solid rgba(239, 100, 97, 0.45);
    background: var(--ink-2);
    border-radius: var(--radius);
    padding: 1.3rem 1.4rem;
    font-size: 0.92rem;
}

.modal-card h2 { font-size: 1.05rem; color: #ffd9d8; margin-bottom: 0.7rem; }
.modal-card ul { margin: 0; padding-left: 1.1rem; }
.modal-card li + li { margin-top: 0.5rem; }
.modal-card p { margin-top: 0.9rem; color: var(--text-faint); }
.modal-card .btn { margin-top: 1.1rem; }

/* Przycisk, który ma wyglądać jak odnośnik — otwiera okno znanych problemów. */
.link-button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--amber);
    text-decoration: underline;
    cursor: pointer;
}