/* ============================================================
   PerunPath — Route Library redesign
   /maps/ — route_list.html
   ============================================================ */

/* ── Design tokens ───────────────────────────────────────── */
:root {
    --rl-green-900: #0f2a1e;
    --rl-green-800: #1b4332;
    --rl-green-700: #2d6a4f;
    --rl-green-500: #40916c;
    --rl-green-100: #d8f3dc;

    --rl-easy:   #16a34a;
    --rl-mod:    #d97706;
    --rl-hard:   #dc2626;

    --rl-bg:     #f8fafc;
    --rl-card:   #ffffff;
    --rl-border: #e2e8f0;
    --rl-text:   #0f172a;
    --rl-muted:  #64748b;
    --rl-chip-bg:#f1f5f9;

    --rl-filter-h: 52px;
    --rl-radius:   10px;
    --rl-shadow:   0 1px 4px rgba(15, 26, 20, .07), 0 4px 16px rgba(15, 26, 20, .06);
    --rl-shadow-hover: 0 4px 16px rgba(15, 26, 20, .12), 0 8px 32px rgba(15, 26, 20, .08);
}

/* ── Page shell ──────────────────────────────────────────── */
.rl-page {
    background: var(--rl-bg);
    min-height: 100vh;
}

/* ============================================================
   HERO
   ============================================================ */
.rl-hero {
    background: linear-gradient(140deg, var(--rl-green-900) 0%, #1a3c2e 55%, #2a5242 100%);
    color: #f0f9f4;
    padding: clamp(36px, 7vw, 80px) clamp(16px, 4vw, 48px) clamp(40px, 8vw, 88px);
    position: relative;
    /* overflow: visible — pozwala dropdownowi wyjść poza hero */
}

/* Decorative mountain silhouette */
.rl-hero-bg-pattern {
    position: absolute;
    inset: 0;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 200'%3E%3Cpath d='M0 200 L0 140 L150 60 L280 120 L400 40 L520 110 L650 20 L780 90 L900 50 L1020 100 L1150 30 L1200 80 L1200 200 Z' fill='rgba(255,255,255,0.03)'/%3E%3Cpath d='M0 200 L0 160 L100 90 L220 150 L340 70 L460 130 L580 50 L700 110 L820 60 L940 120 L1060 45 L1200 100 L1200 200 Z' fill='rgba(255,255,255,0.04)'/%3E%3C/svg%3E");
    background-size: cover;
    background-position: bottom;
    pointer-events: none;
}

.rl-hero-inner {
    position: relative;
    max-width: 860px;
}

.rl-hero h1 {
    font-size: clamp(28px, 5vw, 52px);
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: -.025em;
    margin: 0 0 14px;
    color: #fff;
}

.rl-hero-sub {
    font-size: clamp(14px, 1.6vw, 17px);
    color: rgba(240, 249, 244, .78);
    margin: 0 0 28px;
    max-width: 640px;
    line-height: 1.6;
}
.rl-hero-sub strong { color: #fff; }

/* Search + autocomplete */
.rl-search-outer {
    position: relative;   /* kontener dla dropdownu */
    max-width: 580px;
    margin-bottom: 32px;
    z-index: 300;
}

.rl-search-wrap {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, .97);
    border-radius: 10px;
    width: 100%;
    box-shadow: 0 4px 20px rgba(0,0,0,.22);
}

.rl-search-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 13px 42px 13px 16px;
    font-size: 15px;
    background: transparent;
    color: var(--rl-text);
    min-width: 0;
    border-radius: 10px;
}
.rl-search-input::placeholder { color: #94a3b8; }

.rl-search-clear {
    position: absolute;
    right: 12px;
    color: #94a3b8;
    font-size: 16px;
    text-decoration: none;
    line-height: 1;
    padding: 4px;
}
.rl-search-clear:hover { color: var(--rl-text); }

/* Autocomplete dropdown — dziecko .rl-search-outer */
.rl-search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,.22), 0 2px 8px rgba(0,0,0,.1);
    border: 1px solid #e2e8f0;
    z-index: 600;
    overflow: hidden;
    color: #0f172a; /* jawny ciemny kolor — nie dziedziczy białego z hero */
}

.rl-ac-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    text-decoration: none;
    color: #0f172a;
    transition: background .1s;
    border-bottom: 1px solid #f1f5f9;
}
.rl-ac-item:last-child { border-bottom: none; }
.rl-ac-item:hover,
.rl-ac-item--active { background: #f0faf4; color: #0f172a; }

.rl-ac-type { font-size: 16px; flex-shrink: 0; width: 22px; text-align: center; }
.rl-ac-name { font-size: 13px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #0f172a; }
.rl-ac-sub  { font-size: 11px; color: #64748b; white-space: nowrap; }

.rl-ac-empty {
    padding: 14px 16px;
    font-size: 13px;
    color: #64748b;
    text-align: center;
}

/* Hero stats */
.rl-hero-stats {
    display: flex;
    align-items: center;
    gap: 0;
    flex-wrap: wrap;
    row-gap: 12px;
}

.rl-hero-stat {
    display: flex;
    flex-direction: column;
    padding: 0 24px 0 0;
}
.rl-hero-stat strong {
    font-size: clamp(20px, 2.5vw, 28px);
    font-weight: 800;
    color: #fff;
    line-height: 1;
}
.rl-hero-stat span {
    font-size: 11px;
    color: rgba(240, 249, 244, .65);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-top: 2px;
}

.rl-hero-stat-sep {
    width: 1px;
    height: 36px;
    background: rgba(255, 255, 255, .18);
    margin: 0 24px 0 0;
}

/* ============================================================
   STICKY FILTER BAR
   ============================================================ */
.rl-filter-bar {
    position: sticky;
    top: 0;
    z-index: 200;
    background: #fff;
    border-bottom: 1px solid var(--rl-border);
    box-shadow: 0 2px 8px rgba(15,26,20,.06);
}

.rl-filter-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    height: var(--rl-filter-h);
    max-width: 100%;
}

/* Scrollable chips container */
.rl-chips-scroll {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    flex: 1;
    min-width: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 8px 0;
    mask-image: linear-gradient(to right, black 90%, transparent 100%);
}
.rl-chips-scroll::-webkit-scrollbar { display: none; }

/* Individual chip */
.rl-chip {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    padding: 5px 12px;
    border-radius: 20px;
    border: 1.5px solid var(--rl-border);
    background: var(--rl-chip-bg);
    color: var(--rl-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    user-select: none;
    line-height: 1;
}
.rl-chip input { display: none; }
.rl-chip:hover {
    border-color: var(--rl-green-500);
    color: var(--rl-green-800);
    background: #f0faf4;
}
.rl-chip--on {
    background: var(--rl-green-800);
    border-color: var(--rl-green-800);
    color: #fff;
}
.rl-chip--on:hover {
    background: var(--rl-green-700);
    color: #fff;
}

/* Difficulty variant chips */
.rl-chip--easy.rl-chip--on  { background: var(--rl-easy); border-color: var(--rl-easy); }
.rl-chip--mod.rl-chip--on   { background: var(--rl-mod); border-color: var(--rl-mod); }
.rl-chip--hard.rl-chip--on  { background: var(--rl-hard); border-color: var(--rl-hard); }

.rl-chip-divider {
    flex-shrink: 0;
    width: 1px;
    height: 20px;
    background: var(--rl-border);
    margin: 0 4px;
}

/* Right controls */
.rl-filter-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.rl-sort-sel {
    border: 1.5px solid var(--rl-border);
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 13px;
    color: var(--rl-text);
    background: #fff;
    cursor: pointer;
    outline: none;
}
.rl-sort-sel:focus { border-color: var(--rl-green-500); }

.rl-clear-all {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--rl-muted);
    background: #f1f5f9;
    text-decoration: none;
    white-space: nowrap;
    transition: all .15s;
}
.rl-clear-all:hover { background: #fee2e2; color: #b91c1c; }

.rl-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    background: var(--rl-green-800);
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s;
}
.rl-add-btn:hover { background: var(--rl-green-700); }

/* ── Tags bar ────────────────────────────────────────────── */
.rl-tags-bar {
    background: #fff;
    border-bottom: 1px solid var(--rl-border);
    padding: 0 16px;
}

.rl-tags-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--rl-muted);
    background: none;
    border: none;
    cursor: pointer;
    transition: color .15s;
}
.rl-tags-toggle:hover, .rl-tags-toggle--open { color: var(--rl-green-800); }

.rl-tags-count {
    background: var(--rl-chip-bg);
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
    color: var(--rl-muted);
}

.rl-tags-chevron {
    transition: transform .2s;
}
.rl-tags-toggle--open .rl-tags-chevron { transform: rotate(180deg); }

.rl-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0 12px;
}

.rl-tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 14px;
    border: 1.5px solid var(--rl-border);
    font-size: 12px;
    color: var(--rl-muted);
    text-decoration: none;
    transition: all .15s;
}
.rl-tag:hover { border-color: var(--rl-green-500); color: var(--rl-green-800); background: #f0faf4; }
.rl-tag--on { background: var(--rl-green-800); border-color: var(--rl-green-800); color: #fff; }

/* ============================================================
   BODY: split-pane
   ============================================================ */
.rl-body {
    display: flex;
    align-items: flex-start;
    min-height: calc(100vh - var(--rl-filter-h));
}

/* ── List pane ───────────────────────────────────────────── */
.rl-list-pane {
    flex: 0 0 43%;
    width: 43%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--rl-border);
}

/* Mobile tabs (hidden on desktop) */
.rl-tab-bar {
    display: none;
    background: #fff;
    border-bottom: 1px solid var(--rl-border);
}

/* Results bar */
.rl-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #fff;
    border-bottom: 1px solid var(--rl-border);
    font-size: 13px;
}
.rl-results-count strong { color: var(--rl-text); font-weight: 700; }
.rl-results-count { color: var(--rl-muted); }
.rl-page-info { color: var(--rl-muted); font-size: 12px; }

/* Cards list */
.rl-cards {
    display: flex;
    flex-direction: column;
}

/* ─── Single trail card ─────────────────────────────────── */
.rl-card {
    display: flex;
    align-items: stretch;
    background: var(--rl-card);
    border-bottom: 1px solid var(--rl-border);
    transition: background .12s;
    position: relative;
    /* Colored left border by difficulty */
    border-left: 4px solid #e2e8f0;
}
.rl-card:hover { background: #f8fffe; }

.rl-diff-border--easy     { border-left-color: var(--rl-easy); }
.rl-diff-border--moderate { border-left-color: var(--rl-mod); }
.rl-diff-border--hard     { border-left-color: var(--rl-hard); }

/* Thumbnail */
.rl-card-thumb {
    flex-shrink: 0;
    width: 88px;
    height: 88px;
    display: block;
    overflow: hidden;
    background: #e2e8f0;
    align-self: stretch;
}
.rl-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s;
}
.rl-card:hover .rl-card-thumb img { transform: scale(1.05); }

.rl-card-thumb-empty {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
    color: var(--rl-muted);
}

/* Card body */
.rl-card-content {
    flex: 1;
    min-width: 0;
    padding: 10px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.rl-card-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.rl-card-region {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: var(--rl-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}
.rl-card-region svg { flex-shrink: 0; }

.rl-card-acts {
    font-size: 13px;
    flex-shrink: 0;
}

.rl-card-title {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--rl-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.rl-card-title a {
    text-decoration: none;
    color: inherit;
}
.rl-card-title a:hover { color: var(--rl-green-800); }

/* Stats row */
.rl-card-stats-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.rl-stat {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    color: var(--rl-muted);
    font-weight: 500;
}
.rl-stat svg { flex-shrink: 0; color: var(--rl-green-500); }

/* Difficulty badge */
.rl-diff-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    background: #f1f5f9;
    color: var(--rl-muted);
}
.rl-diff--easy     { background: #dcfce7; color: #15803d; }
.rl-diff--moderate { background: #fef9c3; color: #a16207; }
.rl-diff--hard     { background: #fee2e2; color: #b91c1c; }

/* Bottom row: rating / gpx / favorite */
.rl-card-bottom-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.rl-card-rating {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    font-weight: 600;
    color: #92400e;
}
.rl-rating-count { font-weight: 400; color: var(--rl-muted); font-size: 11px; }

.rl-gpx-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    padding: 2px 6px;
    border-radius: 4px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.rl-fav-form { margin: 0; }
.rl-fav-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    transition: color .15s, transform .15s;
    margin-left: auto;
}
.rl-fav-btn:hover { transform: scale(1.2); }
.rl-fav-btn.is-fav { color: #e11d48; }

/* Empty state */
.rl-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 24px;
    gap: 12px;
    text-align: center;
    color: var(--rl-muted);
}
.rl-empty-ico { color: var(--rl-green-700); }
.rl-empty h3 { margin: 0; font-size: 18px; color: var(--rl-text); }
.rl-empty p  { margin: 0; font-size: 14px; }

.rl-btn-reset {
    display: inline-block;
    margin-top: 8px;
    padding: 10px 22px;
    background: var(--rl-green-800);
    color: #fff;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s;
}
.rl-btn-reset:hover { background: var(--rl-green-700); }

/* ── Pagination ──────────────────────────────────────────── */
.rl-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 20px 16px;
    border-top: 1px solid var(--rl-border);
    background: #fff;
}

.rl-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--rl-chip-bg);
    color: var(--rl-text);
    text-decoration: none;
    transition: all .15s;
    border: 1.5px solid var(--rl-border);
}
.rl-page-btn:hover { background: var(--rl-green-800); color: #fff; border-color: var(--rl-green-800); }
.rl-page-btn--dis { opacity: .4; cursor: not-allowed; }

.rl-page-nums {
    display: flex;
    align-items: center;
    gap: 3px;
}
.rl-page-n {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    color: var(--rl-text);
    transition: all .15s;
    border: 1.5px solid transparent;
    padding: 0 6px;
}
.rl-page-n:hover { background: var(--rl-chip-bg); border-color: var(--rl-border); }
.rl-page-n--cur {
    background: var(--rl-green-800);
    color: #fff;
    font-weight: 700;
    border-color: var(--rl-green-800);
}
.rl-page-dots {
    font-size: 13px;
    color: var(--rl-muted);
    padding: 0 4px;
}

/* ── Map pane ────────────────────────────────────────────── */
.rl-map-pane {
    flex: 1;
    position: sticky;
    top: var(--rl-filter-h);
    height: calc(100vh - var(--rl-filter-h));
    overflow: hidden;
}

#rl-map {
    width: 100%;
    height: 100%;
}

.rl-map-credit {
    display: none; /* OSM attribution is inside Leaflet control */
}

/* Leaflet popup overrides for this page */
.leaflet-popup-content-wrapper {
    border-radius: var(--rl-radius) !important;
    box-shadow: var(--rl-shadow-hover) !important;
}
.leaflet-popup-tip { background: #fff !important; }

/* ============================================================
   MOBILE (≤ 900px): stacked layout, tabs
   ============================================================ */
@media (max-width: 900px) {
    .rl-body {
        flex-direction: column;
    }

    .rl-list-pane {
        width: 100%;
        flex: none;
        border-right: none;
    }

    /* Tab bar visible */
    .rl-tab-bar {
        display: flex;
        gap: 0;
    }
    .rl-tab {
        flex: 1;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 10px;
        font-size: 13px;
        font-weight: 600;
        color: var(--rl-muted);
        background: none;
        border: none;
        border-bottom: 2px solid transparent;
        cursor: pointer;
        transition: all .15s;
    }
    .rl-tab--active {
        color: var(--rl-green-800);
        border-bottom-color: var(--rl-green-800);
    }

    /* Map pane hidden by default on mobile */
    .rl-map-pane {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 150;
        height: 100%;
        display: none;
    }
    .rl-map-pane--mobile-show {
        display: block;
    }

    /* Card thumbnail smaller */
    .rl-card-thumb {
        width: 72px;
        height: 72px;
    }
}

@media (max-width: 600px) {
    /* Hero */
    .rl-hero {
        padding: 28px 16px 36px;
    }
    .rl-hero-stats {
        gap: 0;
    }
    .rl-hero-stat {
        padding: 0 16px 0 0;
    }
    .rl-hero-stat-sep {
        margin: 0 16px 0 0;
    }

    /* Filter bar: allow chip scroll, hide sort label */
    .rl-filter-form {
        padding: 0 10px;
    }
    .rl-sort-sel {
        font-size: 12px;
        padding: 4px 8px;
    }

    /* Cards */
    .rl-card-thumb {
        width: 64px;
        height: 64px;
    }
    .rl-card-content {
        padding: 8px 10px 6px;
    }
    .rl-card-title {
        font-size: 13px;
    }
}

/* ============================================================
   LARGE SCREENS
   ============================================================ */
@media (min-width: 1400px) {
    .rl-list-pane { flex: 0 0 38%; width: 38%; }
}

@media (min-width: 1600px) {
    .rl-list-pane { flex: 0 0 34%; width: 34%; }
}

/* ============================================================
   DARK MODE (respects OS preference)
   ============================================================ */
/* ── Tags bar (remove from new design, keep for compat) ─── */
.rl-tags-bar { display: none; }

/* ── Infinite scroll ────────────────────────────────────── */
.rl-scroll-sentinel {
    height: 1px;
    visibility: hidden;
}
.rl-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    font-size: 13px;
    color: var(--rl-muted);
}
.rl-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--rl-border);
    border-top-color: var(--rl-green-500);
    border-radius: 50%;
    animation: rl-spin .7s linear infinite;
}
@keyframes rl-spin { to { transform: rotate(360deg); } }

.rl-end-msg {
    text-align: center;
    padding: 16px;
    font-size: 12px;
    color: var(--rl-muted);
    border-top: 1px solid var(--rl-border);
}

.rl-hero-inner { position: relative; }

@media (prefers-color-scheme: dark) {
    :root {
        --rl-bg:     #0f172a;
        --rl-card:   #1e293b;
        --rl-border: #334155;
        --rl-text:   #f1f5f9;
        --rl-muted:  #94a3b8;
        --rl-chip-bg:#1e293b;
    }
    .rl-filter-bar,
    .rl-tags-bar,
    .rl-results-bar,
    .rl-pagination { background: #1e293b; border-color: #334155; }
    .rl-card { background: #1e293b; border-color: #334155; }
    .rl-card:hover { background: #253347; }
    .rl-chip { background: #1e293b; border-color: #334155; color: #94a3b8; }
    .rl-sort-sel { background: #1e293b; color: #f1f5f9; border-color: #334155; }
    .rl-clear-all { background: #1e293b; color: #94a3b8; }
    .rl-card-thumb-empty { background: linear-gradient(135deg, #1e293b, #263347); }
    .rl-page-btn, .rl-page-n { background: #1e293b; color: #f1f5f9; border-color: #334155; }
    .rl-results-bar { border-color: #334155; }
    .rl-tab { background: #1e293b; }
    .rl-tags-toggle { color: #94a3b8; }
    .rl-tags-count { background: #334155; }
    .rl-tag { background: #1e293b; border-color: #334155; color: #94a3b8; }
    .rl-tag--on { background: var(--rl-green-800); border-color: var(--rl-green-800); color: #fff; }
    .rl-diff-badge { background: #334155; color: #94a3b8; }
}
