/* CDLL 1.14.x — mobile map shell. Desktop keeps frontend.css unchanged. */
.cdll-mobile-toolbar,
.cdll-mobile-drawer-head,
.cdll-mobile-drawer-done,
.cdll-mobile-map-actions,
.cdll-mobile-result-count,
.cdll-mobile-search-status,
.cdll-mobile-map-message,
.cdll-mobile-backdrop,
.cdll-bottom-sheet {
    display: none;
}

@media (max-width: 760px) {
    html, body {
        width: 100%;
        min-width: 0;
        height: 100%;
        overflow: hidden;
        overscroll-behavior: none;
    }

    body {
        min-height: 100svh;
    }

    .cdll-wrap {
        width: 100%;
        max-width: none;
        height: 100svh;
        min-height: 100svh;
        margin: 0;
        padding: 0;
        overflow: hidden;
    }

    .cdll-header,
    .cdll-count,
    .cdll-list,
    .cdll-empty,
    .cdll-footer-bar {
        display: none !important;
    }

    /* Top toolbar — map remains the primary surface. */
    .cdll-mobile-toolbar {
        position: fixed;
        z-index: 1300;
        top: 0;
        left: 0;
        right: 0;
        min-height: calc(54px + env(safe-area-inset-top, 0px));
        padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px 14px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        pointer-events: none;
        background: linear-gradient(to bottom, rgba(14,18,33,.88), rgba(14,18,33,.38), transparent);
    }

    .cdll-mobile-toolbar-title {
        min-width: 0;
        max-width: calc(100vw - 82px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-family: var(--font-mono);
        font-size: .9rem;
        color: #fff;
        text-shadow: 0 1px 3px rgba(0,0,0,.75);
    }

    .cdll-mobile-menu-button,
    .cdll-mobile-drawer-close,
    .cdll-bottom-sheet-close,
    .cdll-mobile-map-action {
        width: 48px;
        height: 48px;
        min-width: 48px;
        border-radius: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .cdll-mobile-menu-button {
        pointer-events: auto;
        border: 1px solid rgba(255,255,255,.35);
        background: rgba(14,18,33,.86);
        color: #fff;
        font-size: 1.35rem;
        line-height: 1;
        box-shadow: 0 3px 14px rgba(0,0,0,.28);
    }

    /* Full viewport map. */
    .cdll-karta-wrap {
        position: fixed;
        z-index: 1000;
        inset: 0;
        width: 100vw;
        height: 100svh;
        max-width: none;
        margin: 0;
    }

    .cdll-karta-toggle {
        display: none !important;
    }

    .cdll-karta-container,
    .cdll-karta-container.cdll-karta-open {
        display: block;
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        min-width: 0;
        max-width: none;
        margin: 0;
        border: 0;
        border-radius: 0;
        overflow: hidden;
    }

    .cdll-karta {
        width: 100%;
        height: 100%;
        min-width: 0;
        max-width: none;
        padding-bottom: 0;
        position: relative;
    }

    .cdll-karta.leaflet-container,
    .cdll-karta > .leaflet-container {
        width: 100% !important;
        height: 100% !important;
        position: absolute;
        inset: 0;
    }

    /* Keep Leaflet's own controls clear of our toolbar. */
    .cdll-karta .leaflet-top {
        top: calc(54px + env(safe-area-inset-top, 0px));
    }

    .cdll-karta .leaflet-left {
        left: 6px;
    }

    .cdll-karta .leaflet-right {
        right: 6px;
    }

    /* Explicit viewport controls. Neither filter nor cluster clicks move map. */
    .cdll-mobile-map-actions {
        position: absolute;
        z-index: 1150;
        right: max(12px, env(safe-area-inset-right, 0px));
        bottom: calc(14px + env(safe-area-inset-bottom, 0px));
        display: flex;
        flex-direction: column;
        gap: 10px;
        pointer-events: none;
    }

    .cdll-mobile-map-action {
        pointer-events: auto;
        border: 1px solid rgba(42,51,88,.75);
        background: rgba(14,18,33,.92);
        color: #fff;
        font-family: var(--font-ui);
        font-size: 1.45rem;
        line-height: 1;
        box-shadow: 0 3px 14px rgba(0,0,0,.34);
    }

    .cdll-mobile-map-action:active,
    .cdll-mobile-menu-button:active {
        transform: scale(.96);
    }

    .cdll-mobile-map-action--location {
        color: var(--cyan);
    }

    .cdll-mobile-result-count {
        position: absolute;
        z-index: 1140;
        left: max(12px, env(safe-area-inset-left, 0px));
        bottom: calc(17px + env(safe-area-inset-bottom, 0px));
        display: block;
        max-width: calc(100vw - 150px);
        border: 1px solid rgba(42,51,88,.8);
        border-radius: 999px;
        padding: 10px 15px;
        background: rgba(14,18,33,.92);
        color: #fff;
        font-family: var(--font-ui);
        font-size: .86rem;
        font-weight: 650;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        box-shadow: 0 3px 14px rgba(0,0,0,.34);
        cursor: pointer;
    }

    .cdll-mobile-search-status {
        position: absolute;
        z-index: 1140;
        top: calc(62px + env(safe-area-inset-top, 0px));
        left: 50%;
        transform: translateX(-50%);
        display: block;
        max-width: min(calc(100vw - 120px), 420px);
        min-width: 0;
        padding: 7px 11px;
        border: 1px solid rgba(255,255,255,.24);
        border-radius: 999px;
        background: rgba(14,18,33,.82);
        color: #fff;
        font-family: var(--font-ui);
        font-size: .74rem;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        box-shadow: 0 2px 10px rgba(0,0,0,.24);
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        backdrop-filter: blur(5px);
    }

    .cdll-mobile-search-status:active {
        transform: translateX(-50%) scale(.98);
    }

    .cdll-mobile-map-message {
        position: absolute;
        z-index: 1160;
        left: 50%;
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
        transform: translateX(-50%);
        display: block;
        max-width: calc(100vw - 32px);
        padding: 9px 12px;
        border-radius: 7px;
        background: rgba(14,18,33,.94);
        color: #fff;
        font-size: .8rem;
        line-height: 1.35;
        text-align: center;
        box-shadow: 0 3px 14px rgba(0,0,0,.34);
    }
    .cdll-mobile-map-message[hidden] { display: none !important; }

    /* Filter drawer uses the same actual controls as desktop. */
    .cdll-filters {
        position: fixed;
        z-index: 1500;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(90vw, 390px);
        max-width: 390px;
        min-width: 0;
        margin: 0;
        padding: calc(12px + env(safe-area-inset-top, 0px)) 18px calc(20px + env(safe-area-inset-bottom, 0px));
        border: 0;
        border-left: 1px solid var(--border);
        border-radius: 0;
        background: rgba(14,18,33,.985);
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 18px;
        overflow-y: auto;
        overscroll-behavior: contain;
        transform: translateX(105%);
        transition: transform .2s ease;
        box-shadow: -12px 0 30px rgba(0,0,0,.32);
    }

    .cdll-filters.cdll-mobile-drawer-open {
        transform: translateX(0);
    }

    .cdll-mobile-drawer-head {
        position: sticky;
        z-index: 2;
        top: calc(-12px - env(safe-area-inset-top, 0px));
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin: calc(-12px - env(safe-area-inset-top, 0px)) -18px 2px;
        padding: calc(10px + env(safe-area-inset-top, 0px)) 10px 10px 18px;
        background: rgba(14,18,33,.99);
        border-bottom: 1px solid var(--border);
        color: #fff;
        font-family: var(--font-mono);
        font-size: .92rem;
    }

    .cdll-mobile-drawer-close,
    .cdll-bottom-sheet-close {
        border: 0;
        background: transparent;
        color: #fff;
        font-size: 1.8rem;
    }

    .cdll-filter-group {
        width: 100%;
        max-width: 100%;
    }

    .cdll-checkboxes {
        gap: 9px 13px;
    }

    .cdll-checkboxes label,
    .cdll-adjacent-label,
    .cdll-stangd-label {
        color: var(--text);
        min-height: 36px;
    }

    #cdll-ort-filter,
    #cdll-kommun-filter,
    #cdll-datum-filter,
    #cdll-datum-till-filter {
        width: 100%;
        min-height: 44px;
        background: var(--bg3);
        border-color: var(--border);
        color: var(--text);
    }

    .cdll-mobile-drawer-done {
        display: block;
        width: 100%;
        min-height: 48px;
        margin-top: 2px;
        border: 1px solid var(--cyan-dim);
        border-radius: 7px;
        background: #0d3b4f;
        color: #fff;
        font-weight: 700;
        cursor: pointer;
    }

    .cdll-mobile-backdrop {
        position: fixed;
        z-index: 1450;
        inset: 0;
        width: 100%;
        height: 100%;
        border: 0;
        background: rgba(0,0,0,.48);
        display: block;
        opacity: 1;
    }
    .cdll-mobile-backdrop[hidden] { display: none !important; }

    /* Bottom sheet for event info and result groups. */
    .cdll-bottom-sheet {
        position: fixed;
        z-index: 1600;
        left: 0;
        right: 0;
        bottom: 0;
        display: block;
        max-height: min(72svh, 620px);
        padding: 9px 16px calc(18px + env(safe-area-inset-bottom, 0px));
        border: 1px solid var(--border);
        border-bottom: 0;
        border-radius: 18px 18px 0 0;
        background: rgba(14,18,33,.985);
        color: var(--text);
        transform: translateY(calc(100% + 12px));
        transition: transform .22s ease;
        box-shadow: 0 -14px 34px rgba(0,0,0,.38);
        pointer-events: none;
    }

    .cdll-bottom-sheet.cdll-bottom-sheet--open {
        transform: translateY(0);
        pointer-events: auto;
    }

    .cdll-bottom-sheet-handle {
        width: 42px;
        height: 4px;
        margin: 1px auto 8px;
        border-radius: 999px;
        background: #526183;
    }

    .cdll-bottom-sheet-close {
        position: absolute;
        top: 7px;
        right: 7px;
        z-index: 2;
    }

    .cdll-bottom-sheet-content {
        max-height: calc(min(72svh, 620px) - 34px - env(safe-area-inset-bottom, 0px));
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 7px 42px 4px 0;
    }

    .cdll-sheet-title {
        margin: 0 0 7px;
        color: #fff;
        font-family: var(--font-ui);
        font-size: 1.08rem;
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    .cdll-sheet-meta,
    .cdll-sheet-address,
    .cdll-sheet-description,
    .cdll-sheet-note {
        margin-top: 7px;
        color: var(--text-dim);
        line-height: 1.45;
        overflow-wrap: anywhere;
    }

    .cdll-sheet-meta {
        color: var(--cyan);
        font-family: var(--font-mono);
        font-size: .82rem;
    }


    .cdll-sheet-distance {
        margin-top: 8px;
        color: #d8f4ff;
        font-family: var(--font-mono);
        font-size: .82rem;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }

    .cdll-sheet-distance--fallback {
        color: var(--text-dim);
    }


    .cdll-sheet-routing-attribution {
        display: block;
        margin-top: 3px;
        color: var(--text-dim);
        font-family: var(--font-ui);
        font-size: .64rem;
        line-height: 1.3;
    }

    .cdll-sheet-rating {
        display: flex;
        align-items: baseline;
        flex-wrap: wrap;
        gap: 7px;
        margin: 5px 0 2px;
        color: #f0c24b;
        font-family: var(--font-mono);
        font-size: .9rem;
        line-height: 1.25;
    }

    .cdll-sheet-rating--high {
        color: #ffd95a;
    }

    .cdll-sheet-rating--none {
        color: var(--text-dim);
        font-size: .76rem;
    }

    .cdll-sheet-rating-label {
        color: var(--text-dim);
        font-family: var(--font-ui);
        font-size: .76rem;
    }

    .cdll-sheet-description {
        padding-top: 10px;
        border-top: 1px solid var(--border);
        color: var(--text);
        font-size: .88rem;
    }

    .cdll-sheet-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 9px;
        margin-top: 14px;
    }

    .cdll-sheet-action {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
        max-width: 100%;
        padding: 8px 12px;
        border: 1px solid var(--cyan-dim);
        border-radius: 7px;
        background: #0d3b4f;
        color: #fff;
        text-decoration: none;
        font-size: .84rem;
        overflow-wrap: anywhere;
    }

    .cdll-sheet-results {
        display: flex;
        flex-direction: column;
        gap: 6px;
        margin-top: 10px;
    }

    .cdll-sheet-result {
        width: 100%;
        min-height: 48px;
        padding: 9px 10px;
        border: 1px solid var(--border);
        border-radius: 7px;
        background: var(--bg2);
        color: var(--text);
        text-align: left;
        cursor: pointer;
    }

    .cdll-sheet-result strong {
        display: block;
        color: #fff;
        font-size: .9rem;
        overflow-wrap: anywhere;
    }

    .cdll-sheet-result small {
        display: block;
        margin-top: 2px;
        color: var(--text-dim);
        font-size: .76rem;
    }

    @media (orientation: landscape) and (max-height: 520px) {
        .cdll-bottom-sheet {
            left: auto;
            top: 0;
            width: min(46vw, 420px);
            max-height: 100svh;
            border-radius: 16px 0 0 16px;
            transform: translateX(calc(100% + 12px));
        }
        .cdll-bottom-sheet.cdll-bottom-sheet--open {
            transform: translateX(0);
        }
        .cdll-bottom-sheet-content {
            max-height: calc(100svh - 34px - env(safe-area-inset-bottom, 0px));
        }
    }
}

/* 1.15: mobilens sparade sökpreferenser. */
@media (max-width: 760px) {
    .cdll-filter-group--when,
    .cdll-filter-group--map-behaviour {
        min-width: 0;
        width: 100%;
        max-width: 100%;
    }
    .cdll-date-presets {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }
    .cdll-date-preset {
        min-height: 42px;
        padding: 7px 9px;
        border-radius: 7px;
        text-align: center;
        touch-action: manipulation;
    }
    .cdll-custom-date-range {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }
    .cdll-custom-date-range label { min-width: 0; }
    .cdll-date-summary { font-size: .76rem; }
    .cdll-map-behaviour-option {
        min-height: 42px;
        align-items: center;
    }
    .cdll-reset-preferences {
        width: 100%;
        min-height: 44px;
        align-self: stretch;
    }
}

/* 1.16–1.17: app-identitet, sökstatus, utvecklarkontakt och extern kartapp. */
.cdll-mobile-version,
.cdll-mobile-developer-contact,
.cdll-filter-group--navigation {
    display: none;
}

@media (max-width: 760px) {
    .cdll-filter-group--navigation {
        display: block;
        min-width: 0;
        width: 100%;
        max-width: 100%;
    }

    .cdll-navigation-provider {
        width: 100%;
        min-width: 0;
        min-height: 44px;
        max-width: 100%;
        padding: 7px 10px;
        border: 1px solid var(--border);
        border-radius: 7px;
        background: var(--bg3);
        color: var(--text);
    }

    .cdll-mobile-version {
        position: absolute;
        z-index: 1125;
        left: max(7px, env(safe-area-inset-left, 0px));
        bottom: calc(4px + env(safe-area-inset-bottom, 0px));
        display: block;
        color: rgba(255,255,255,.96);
        opacity: var(--cdll-version-opacity,.34);
        font-family: var(--font-mono);
        font-size: .62rem;
        line-height: 1;
        letter-spacing: .02em;
        text-shadow: 0 1px 2px rgba(0,0,0,.5);
        pointer-events: none;
        user-select: none;
    }

    .cdll-mobile-result-count {
        bottom: calc(29px + env(safe-area-inset-bottom, 0px));
    }

    .cdll-mobile-developer-contact {
        display: block;
        width: 100%;
        max-width: 100%;
        padding-top: 14px;
        border-top: 1px solid var(--border);
    }

    .cdll-mobile-developer-info {
        margin: 7px 0 10px;
        color: var(--text-dim);
        font-size: .8rem;
        line-height: 1.45;
        overflow-wrap: anywhere;
    }

    .cdll-mobile-developer-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        min-height: 44px;
        max-width: 100%;
        padding: 8px 12px;
        border: 1px solid var(--border);
        border-radius: 7px;
        background: var(--bg2);
        color: var(--cyan);
        text-decoration: none;
        font-weight: 650;
        overflow-wrap: anywhere;
    }
}
