/* =====================================================
   🗺️ KARTAN (/karta/, map/map.html + javascript/map.js)
   Laddas bara på kartsidan. Leaflets egna stilar: vendor/leaflet/.
   ===================================================== */

.map-filters[hidden],
.map-empty[hidden] {
    display: none;
}

/* ---------- 📍 Matguider på kartan (map_guides.js) ---------- */
/* Öppnas med fliken "Matguider" i Närmast dig-panelen (.map-panel-tab, längre ner) */

.map-guides-btn[hidden],
.map-guides[hidden],
.map-guides-icon-btn[hidden] {
    display: none;
}

.map-guides-btn:focus-visible,
.map-guides-icon-btn:focus-visible,
.map-guide-card:focus-visible,
.map-guide-row:focus-visible,
.map-guides-handle:focus-visible {
    outline: 3px solid var(--hype-orange);
    outline-offset: 2px;
}

/* Dator: en panel till vänster över kartan */
.map-guides {
    position: absolute;
    top: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 1002;

    display: flex;
    flex-direction: column;
    width: min(360px, calc(100% - 24px));
    border-radius: 18px;
    border: 1px solid rgb(var(--ink-rgb) / .08);
    background: var(--pure-white);
    box-shadow: 0 10px 32px rgb(0 0 0 / .2);
    overflow: hidden;
}

.map-guides-handle {
    display: none;
}

.map-guides-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 12px 10px 16px;
    border-bottom: 1px solid rgb(var(--shade-rgb) / .08);
}

.map-guides-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 1.02rem;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.map-guides-icon-btn {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: rgb(var(--shade-rgb) / .06);
    color: var(--dark-text);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.map-guides-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px;
}

.map-guides-note {
    margin: 0 4px 10px;
    color: var(--text-muted);
    font-size: 13px;
}

.map-guide-cards,
.map-guide-rows {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.map-guide-card,
.map-guide-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 8px;
    border: 1px solid rgb(var(--shade-rgb) / .08);
    border-radius: 14px;
    background: var(--pure-white);
    color: var(--dark-text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.map-guide-card:hover,
.map-guide-row:hover,
.map-guide-row.is-active {
    border-color: rgba(255, 111, 0, .5);
    background: rgba(255, 111, 0, .06);
}

.map-guide-card-cover {
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface-warm);
}

.map-guide-card-cover img,
.map-guide-row img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.map-guide-card-noimg {
    display: grid;
    place-items: center;
    height: 100%;
    font-size: 26px;
}

.map-guide-card-text,
.map-guide-row-text {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.map-guide-card-text strong,
.map-guide-row-text strong {
    overflow-wrap: anywhere;
}

.map-guide-card-text small,
.map-guide-row-text small {
    color: var(--text-muted);
    font-size: 13px;
}

.map-guide-card-kicker {
    color: var(--orange-text) !important;
    font-weight: 800;
}

.map-guide-intro {
    margin: 0 4px 12px;
}

.map-guide-intro p {
    margin: 4px 0 10px;
    color: var(--text-muted);
    font-size: 14px;
}

.map-guide-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* En rad: nummer (som markören), bild, namn och ägarens kommentar */
.map-guide-num {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    min-width: 30px;
    height: 30px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--hype-orange);
    color: #fff;
    font-size: 14px;
    font-weight: 800;
}

.map-guide-row.is-tried .map-guide-num {
    background: #1f9d63;
}

.map-guide-row img {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 10px;
}

/* Dator: panelen ligger där Närmast dig ligger, under toppkortet */
@media (min-width: 900px) {
    .map-guides {
        top: calc(var(--map-top-h, 120px) + 28px);
        left: 16px;
        bottom: 16px;
        border-radius: 22px;
    }
}

/* Mobil: ett ark nerifrån — titt / halv / hel (map_guides.js sätter transform) */
@media (max-width: 899px) {
    .map-guides {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: auto;
        height: 85%;
        border-radius: 20px 20px 0 0;
        border-bottom: none;
        transition: transform .25s ease;
        touch-action: none;
    }

    .map-guides.is-dragging {
        transition: none;
    }

    .map-guides-body {
        touch-action: pan-y;
    }

    .map-guides-handle {
        display: grid;
        place-items: center;
        height: 22px;
        cursor: grab;
    }

    .map-guides-handle span {
        width: 44px;
        height: 5px;
        border-radius: 999px;
        background: rgb(var(--shade-rgb) / .2);
    }

    .map-guides-head {
        padding-top: 2px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .map-guides {
        transition: none;
    }
}


/* ---------- Ramen ---------- */

.map-frame {
    position: relative;
    /* Leaflets z-index (upp till 1000) stannar här — headerns menyer hamnar ovanpå */
    isolation: isolate;

    overflow: hidden;
    border-radius: 20px;
    border: 1px solid rgb(var(--ink-rgb) / .08);
    box-shadow: 0 6px 20px rgba(30, 42, 68, .05);
    background: var(--surface-warm);
}

.hype-map {
    /* Kartan fyller fönstret under headern — allt annat flyter ovanpå */
    height: clamp(520px, calc(100dvh - 120px), 1100px);
    font: inherit;
    background: var(--surface-warm);
}

/* 🌙 Mörkt tema: OpenStreetMaps ljusa kartbilder inverteras (bara bilderna, inte markörerna) */
[data-theme="dark"] .hype-map .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.85) saturate(.6);
}

.map-note {
    margin: 12px 4px 0;
    color: var(--text-muted);
    font-size: 14px;
}

.map-note a {
    color: var(--orange-text);
    font-weight: 700;
}


/* ---------- 🔥 Markörerna ---------- */

/* Leaflet placerar ankaret på punkten; bubblan står ovanpå med spetsen där */
.hype-pin-anchor {
    width: 0 !important;
    height: 0 !important;
}

.hype-pin {
    position: absolute;
    left: 0;
    bottom: 7px;
    transform: translateX(-50%);

    display: inline-flex;
    align-items: center;
    gap: 3px;

    padding: 4px 9px;
    border-radius: 999px;

    background: var(--pure-white);
    color: var(--dark-text);
    border: 2px solid var(--pure-white);
    box-shadow: 0 2px 8px rgb(0 0 0 / .25);

    font-size: 13px;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition: transform .15s ease;
}

/* Spetsen */
.hype-pin::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -7px;
    width: 10px;
    height: 10px;
    transform: translateX(-50%) rotate(45deg);
    background: inherit;
    border-right: inherit;
    border-bottom: inherit;
    border-bottom-right-radius: 2px;
    z-index: -1;
}

.leaflet-marker-icon:hover .hype-pin,
.leaflet-marker-icon:focus-visible .hype-pin {
    transform: translateX(-50%) scale(1.1);
}

.leaflet-marker-icon:focus-visible {
    outline: none;
}

.leaflet-marker-icon:focus-visible .hype-pin {
    outline: 3px solid var(--social-blue);
    outline-offset: 2px;
}

/* Ingen hajp än: bara kategorins emoji */
.hype-pin.heat-0 {
    padding: 4px 6px;
    font-size: 14px;
}

.hype-pin.heat-1 {
    background: var(--orange-soft-2);
    color: var(--orange-text);
}

/* 📍 Matguide: radens nummer (lists/_guide_map.html) */
.hype-pin.is-numbered {
    min-width: 26px;
    justify-content: center;
    background: var(--hype-orange);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}

/* ✓ den som tittar har testat stället (bara hen ser det) */
.hype-pin.is-numbered.is-tried {
    background: #1f9d63;
}

/* 🖥️ Raden man hovrar i guiden (guide_view.js) — markören lyfts */
.hype-pin.is-numbered.is-active {
    transform: translateX(-50%) scale(1.25);
    background: var(--orange-text, #c2410c);
    box-shadow: 0 0 0 4px rgba(255, 111, 0, .3), 0 3px 12px rgb(0 0 0 / .3);
    z-index: 2;
}

.hype-pin.heat-2 {
    padding: 5px 11px;
    background: var(--hype-orange);
    color: #fff;
    font-size: 14px;
}

.hype-pin.heat-3 {
    padding: 6px 13px;
    background: linear-gradient(135deg, #ff8a00, #ff3d00);
    color: #fff;
    font-size: 16px;
    box-shadow: 0 0 0 4px rgba(255, 111, 0, .25), 0 3px 12px rgb(0 0 0 / .3);
}

/* Spetsen kan inte ärva en gradient */
.hype-pin.heat-3::after {
    background: #ff3d00;
}

/* 📈 Trendar — en liten bricka i markörens hörn */
.hype-pin-trend {
    position: absolute;
    top: -9px;
    right: -9px;

    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;
    background: var(--pure-white);
    box-shadow: 0 1px 4px rgb(0 0 0 / .3);
    font-size: 11px;
    line-height: 1;
}

/* ✓ Har varit här / ♥ Sparad (den inloggades egna, map.js) — i vänstra hörnet */
.hype-pin-mine {
    position: absolute;
    top: -9px;
    left: -9px;

    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;
    border: 2px solid var(--pure-white);
    box-shadow: 0 1px 4px rgb(0 0 0 / .3);
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
}

.hype-pin-mine.is-tried {
    background: var(--green-engaging);
}

.hype-pin-mine.is-saved {
    background: var(--heart-red);
    font-size: 10px;
}

/* Popupen: "✓ Du har varit här" / "❤️ Sparad" under namnet */
.map-popup-body .map-popup-mine {   /* .map-popup-body p nollar annars marginalen */
    margin: 2px 0 4px;
    font-size: 13px;
    font-weight: 800;
}

.map-popup-mine.is-tried {
    color: var(--green-text);
}

.map-popup-mine.is-saved {
    color: var(--red-text);
}

.map-popup-mine small {
    font-weight: 600;
    color: var(--text-muted);
}


/* ---------- Kluster ---------- */

.hype-cluster-anchor {
    background: none;
}

.hype-cluster {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    width: 52px;
    height: 52px;
    border-radius: 50%;

    background: var(--pure-white);
    color: var(--dark-text);
    border: 3px solid var(--pure-white);
    box-shadow: 0 0 0 5px rgb(var(--ink-rgb) / .12), 0 3px 10px rgb(0 0 0 / .25);

    line-height: 1.05;
    cursor: pointer;
}

.hype-cluster strong {
    font-size: 16px;
    font-weight: 900;
}

.hype-cluster small {
    font-size: 10px;
    font-weight: 800;
}

.hype-cluster.heat-1 {
    background: var(--orange-soft-2);
    color: var(--orange-text);
    box-shadow: 0 0 0 5px rgba(255, 111, 0, .15), 0 3px 10px rgb(0 0 0 / .25);
}

.hype-cluster.heat-2,
.hype-cluster.heat-3 {
    background: var(--hype-orange);
    color: #fff;
    box-shadow: 0 0 0 5px rgba(255, 111, 0, .3), 0 3px 10px rgb(0 0 0 / .25);
}

.hype-cluster.heat-3 {
    background: linear-gradient(135deg, #ff8a00, #ff3d00);
}

/* Markörerna glider när ett kluster öppnas (MarkerCluster.Default.css är inte med) */
.leaflet-cluster-anim .leaflet-marker-icon,
.leaflet-cluster-anim .leaflet-marker-shadow {
    transition: transform .3s ease-out, opacity .3s ease-in;
}


/* ---------- Rutan när man trycker på en restaurang ---------- */

.hype-map .leaflet-popup-content-wrapper {
    padding: 0;
    overflow: hidden;
    border-radius: 16px;
    background: var(--pure-white);
    color: var(--dark-text);
    box-shadow: 0 8px 28px rgb(0 0 0 / .25);
}

.hype-map .leaflet-popup-content {
    margin: 0;
    font: inherit;
    line-height: 1.4;
}

.hype-map .leaflet-popup-tip {
    background: var(--pure-white);
}

.hype-map a.leaflet-popup-close-button {
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgb(0 0 0 / .45);
    color: #fff;
    font: 700 18px/28px system-ui, sans-serif;
}

.hype-map a.leaflet-popup-close-button:hover {
    background: rgb(0 0 0 / .65);
    color: #fff;
}

.map-popup-image {
    display: block;
    width: 100%;
    height: 110px;
    object-fit: cover;
    background: var(--surface-warm);
}

.map-popup-body {
    padding: 12px 14px 14px;
}

.map-popup-body p {
    margin: 0;
}

.map-popup-name {
    display: block;
    padding-right: 26px;   /* plats för stängknappen när bild saknas */
    color: var(--dark-text) !important;
    font-size: 16px;
    font-weight: 900;
    text-decoration: none;
}

.map-popup-name:hover {
    text-decoration: underline;
}

.map-popup-meta,
.map-popup-address {
    margin-top: 2px !important;
    color: var(--text-muted);
    font-size: 13px;
}

.map-popup-hype-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 8px;
    margin-top: 8px !important;
}

.map-popup-hype {
    color: var(--orange-text);
    font-weight: 900;
}

.map-popup-hype.is-empty {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13px;
}

.map-popup-chain {
    color: var(--text-muted);
    font-size: 13px;
}

.map-popup-open {
    margin-top: 4px !important;
    color: var(--text-muted);
    font-size: 13px;
}

.map-popup-open.is-open {
    color: var(--green-text);
    font-weight: 700;
}

.map-popup-links {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 12px;
    margin-top: 10px !important;
}

.map-popup-directions {
    color: var(--text-muted) !important;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.map-popup-directions:hover {
    color: var(--dark-text) !important;
    text-decoration: underline;
}

.map-popup-link {
    display: inline-block;
    color: var(--orange-text) !important;
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
}

.map-popup-link:hover {
    text-decoration: underline;
}


/* ---------- Knappar och rutor ovanpå kartan ---------- */

/* 📍 Hitta mig: till höger, under toppkortet */
.map-locate {
    position: absolute;
    top: calc(var(--map-top-h, 120px) + 28px);
    right: 16px;
    z-index: 1001;

    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 16px 0 12px;
    border: none;
    border-radius: 14px;

    background: var(--hype-orange);
    color: #fff;
    box-shadow: 0 10px 24px rgba(255, 111, 0, .32);

    font: inherit;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
}

.map-locate .nav-icon {
    width: 20px;
    height: 20px;
    color: #fff;
}

.map-locate:hover {
    background: #e65f00;
}

.map-locate:focus-visible {
    outline: 3px solid var(--dark-text);
    outline-offset: 2px;
}

.map-locate.is-busy .nav-icon {
    animation: map-locate-pulse 1s ease-in-out infinite;
}

@keyframes map-locate-pulse {
    50% { opacity: .3; }
}

.map-status {
    position: absolute;
    left: 50%;
    bottom: 28px;
    z-index: 1001;
    transform: translateX(-50%);

    max-width: calc(100% - 32px);
    margin: 0;
    padding: 8px 14px;
    border-radius: 999px;

    background: var(--dark-text);
    color: var(--page-bg);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
}

.map-empty {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 1001;
    transform: translate(-50%, -50%);

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;

    width: min(320px, calc(100% - 32px));
    padding: 18px 20px;
    border-radius: 16px;

    background: var(--pure-white);
    color: var(--dark-text);
    box-shadow: 0 8px 28px rgb(0 0 0 / .2);
    text-align: center;
}

.map-empty span {
    color: var(--text-muted);
    font-size: 14px;
}

.map-empty a {
    margin-top: 6px;
    color: var(--orange-text);
    font-weight: 800;
}

/* Området saknar restauranger: en remsa överst, kartan går att använda */
.map-empty--hint {
    top: 64px;
    transform: translateX(-50%);
    padding: 10px 16px;
    pointer-events: none;
}

.map-empty--hint strong {
    font-size: 14px;
}

.map-empty--hint span {
    font-size: 13px;
}

/* Din position (bara i webbläsaren) */
.map-you-are-here {
    fill: var(--social-blue);
    fill-opacity: 1;
    stroke: #fff;
    stroke-width: 3;
}


/* 📍 Avståndet i popupen */
.map-popup-distance {
    color: var(--blue-text);
    font-size: 13px;
    font-weight: 800;
}

/* 📈 Trendar i popupen */
.map-popup-trending {
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--orange-soft);
    color: var(--orange-text);
    font-size: 12px;
    font-weight: 800;
}

/* ⭐ Populäraste rätten (samma form som .mh-featured på korten, mindre) */
a.map-popup-food {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 7px 10px;
    border-radius: 12px;

    background: var(--orange-soft);
    border: 1px solid rgba(255, 111, 0, .2);
    color: var(--dark-text) !important;
    text-decoration: none;
}

a.map-popup-food:hover {
    border-color: rgba(255, 111, 0, .5);
}

.map-popup-food-icon {
    flex-shrink: 0;
    font-size: 16px;
}

.map-popup-food-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.map-popup-food-text small {
    color: var(--orange-text);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.map-popup-food-text strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 800;
}

.map-popup-food-hype {
    flex-shrink: 0;
    color: var(--orange-text);
    font-size: 13px;
    font-weight: 900;
}


/* ---------- 📍 Närmast dig: panelen till vänster (dator) / ett kort nertill (mobil) ---------- */

.map-nearby {
    position: absolute;
    top: calc(var(--map-top-h, 120px) + 28px);
    left: 16px;
    z-index: 1001;

    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, calc(100% - 32px));
    max-height: calc(100% - var(--map-top-h, 120px) - 44px);
    box-sizing: border-box;
    padding: 12px;
    border-radius: 22px;
    border: 1px solid var(--border);
    background: var(--pure-white);
    box-shadow: 0 14px 40px rgba(17, 24, 39, .16);
}

.map-nearby[hidden],
.map-nearby-list[hidden],
.map-nearby-empty[hidden],
.map-nearby-start[hidden] {
    display: none;
}

.map-nearby-head {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.map-nearby-head h2 {
    margin: 0;
    color: var(--dark-text);
    font-size: 1.05rem;
    font-weight: 900;
}

/* Närmast dig | Matguider */
.map-panel-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 4px;
    border-radius: 13px;
    background: var(--surface-2);
}

.map-panel-tabs .map-panel-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    margin: 0;
    border: none;
    border-radius: 10px;
    background: none;
    color: var(--text-2);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.map-panel-tabs .map-panel-tab.is-active {
    background: var(--pure-white);
    color: var(--dark-text);
    font-weight: 800;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
    cursor: default;
}

.map-panel-tabs .map-panel-tab:not(.is-active):hover {
    color: var(--orange-text);
}

/* Utan Matguider-flik (JS döljer den tills guiderna finns): bara rubriken */
.map-panel-tabs:has(.map-guides-btn[hidden]) {
    display: block;
    padding: 0;
    background: none;
}

.map-panel-tabs:has(.map-guides-btn[hidden]) .map-panel-tab.is-active {
    justify-content: flex-start;
    min-height: 0;
    padding: 2px 4px;
    background: none;
    box-shadow: none;
    font-size: 1.05rem;
    font-weight: 900;
}

.map-nearby-note {
    padding: 0 4px;
    color: var(--text-muted);
    font-size: 12.5px;
}

.map-nearby-start {
    align-self: flex-start;
}

.map-nearby-start .nav-icon {
    width: 18px;
    height: 18px;
    color: var(--orange-text);
}

.map-nearby-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.map-nearby-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.map-nearby-item:hover {
    border-color: rgba(255, 111, 0, .35);
    background: var(--orange-soft);
}

.map-nearby-item:focus-visible {
    outline: 3px solid var(--hype-orange);
    outline-offset: 2px;
}

.map-nearby-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.map-nearby-text strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--dark-text);
    font-size: 14.5px;
    font-weight: 800;
}

.map-nearby-text small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 12.5px;
}

.map-nearby-distance {
    flex-shrink: 0;
    color: var(--orange-text);
    font-size: 13px;
    font-weight: 900;
    white-space: nowrap;
}

.map-nearby-empty {
    margin: 0;
    padding: 0 4px;
    color: var(--text-muted);
    font-size: 13.5px;
}

.map-nearby-empty a {
    color: var(--orange-text);
    font-weight: 700;
}

/* Matguiderna öppna: de ligger på samma plats */
.has-guides-open .map-nearby {
    visibility: hidden;
}


/* ---------- Leaflets kontroller i sajtens färger ---------- */

.hype-map .leaflet-bar {
    border: 1px solid rgb(var(--ink-rgb) / .12);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgb(0 0 0 / .18);
}

.hype-map .leaflet-bar a {
    width: 36px;
    height: 36px;
    line-height: 36px;
    background: var(--pure-white);
    color: var(--dark-text);
    border-bottom-color: var(--border);
}

.hype-map .leaflet-bar a:hover {
    background: var(--surface-2);
}

.hype-map .leaflet-control-attribution {
    background: rgb(var(--surface-rgb) / .85);
    color: var(--text-muted);
}

.hype-map .leaflet-control-attribution a {
    color: var(--blue-text);
}


/* ---------- Kartan i full storlek + toppkortet med taggarna ---------- */

.map-page {
    max-width: none;
}

.map-frame {
    border-radius: 24px;
}

.map-top {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    z-index: 1003;

    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 22px;
    border: 1px solid var(--border);
    background: rgb(var(--surface-rgb) / .95);
    box-shadow: 0 14px 40px rgba(17, 24, 39, .14);
    backdrop-filter: blur(10px);
}

.map-top-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
}

.map-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    color: var(--dark-text);
    font-size: 1.35rem;
    font-weight: 900;
    letter-spacing: -.01em;
}

.map-title .place-chip {
    font-size: 15px;
}

.map-total {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin: 0;
    color: var(--text-muted);
    font-size: 13.5px;
}

.map-total strong {
    color: var(--dark-text);
}

.map-total .place-chip {
    height: 32px;
    padding-right: 12px;
    font-size: 12.5px;
}

.map-total .place-chip-icon {
    width: 22px;
    height: 22px;
}

.map-clear {
    margin-left: auto;
    padding: 0;
    border: none;
    background: none;
    color: var(--text-muted);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

.map-clear:hover {
    color: var(--orange-text);
}

.map-clear[hidden],
.map-filter-open[hidden],
.map-filter-badge[hidden],
.map-sheet-backdrop[hidden] {
    display: none;
}

/* Taggarna: 1 Snabbval | 2 Pris | 3 Typ av ställe (sveps) */
.map-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.map-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: none;
}

.map-group + .map-group {
    padding-left: 10px;
    border-left: 1px solid var(--border);
}

.map-group-label,
.map-sheet-head,
.map-sheet-foot,
.map-filter-open {
    display: none;
}

.map-group--type {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent);
    padding-right: 28px;
}

.map-group--type::-webkit-scrollbar {
    display: none;
}

/* 1 · Snabbval: fyrkantiga, med en färgprick */
.map-quick {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--pure-white);
    color: var(--text-2);
    font: inherit;
    font-size: 13.5px;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
}

.map-quick::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--quick-dot, var(--hype-orange));
}

.map-quick--open { --quick-dot: #1f9d63; }
.map-quick--trending { --quick-dot: var(--hype-orange); }
.map-quick--unvisited { --quick-dot: #7c8cf8; }

/* 🐕🌱 Passar för (main/diet.py): emojin i stället för färgpricken */
.map-tag::before {
    content: none;
}

/* 2 · Pris: en sammanhängande väljare */
.map-seg {
    display: flex;
    gap: 2px;
    padding: 3px;
    border-radius: 12px;
    background: var(--surface-2);
}

.map-seg-btn {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 9px;
    border: none;
    border-radius: 9px;
    background: none;
    font: inherit;
    cursor: pointer;
}

/* 3 · Typ av ställe: runda med ikonbricka */
.map-type {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    padding: 0 13px 0 5px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--pure-white);
    color: var(--text-2);
    font: inherit;
    font-size: 13.5px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

.map-type-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--surface-2);
    font-size: 15px;
}

/* Valda */
.map-quick.is-selected,
.map-type.is-active {
    border: 1.5px solid var(--hype-orange);
    background: var(--orange-soft);
    color: var(--orange-text);
}

.map-type.is-active .map-type-icon {
    background: var(--hype-orange);
}

.map-seg-btn.is-selected {
    background: var(--pure-white);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12), inset 0 0 0 1.5px var(--hype-orange);
}

.map-quick:hover,
.map-type:hover {
    border-color: rgba(255, 111, 0, .45);
}

.map-quick:focus-visible,
.map-type:focus-visible,
.map-seg-btn:focus-visible,
.map-filter-open:focus-visible,
.map-clear:focus-visible {
    outline: 3px solid var(--hype-orange);
    outline-offset: 2px;
}

/* Förklaringen: ju större och mörkare nål, desto mer hajp */
.map-legend {
    position: absolute;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 8px 12px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgb(var(--surface-rgb) / .94);
    color: var(--text-2);
    font-size: 12.5px;
    pointer-events: none;
}

.map-legend-dots {
    display: flex;
    align-items: flex-end;
    gap: 5px;
}

.map-legend-dots i {
    display: block;
    border-radius: 50%;
}

.map-legend-dots .heat-0 { width: 12px; height: 12px; background: #ffb27a; }
.map-legend-dots .heat-1 { width: 16px; height: 16px; background: #ff8a33; }
.map-legend-dots .heat-2 { width: 20px; height: 20px; background: var(--hype-orange); }
.map-legend-dots .heat-3 { width: 24px; height: 24px; background: #e65f00; }

/* Leaflets +/− nere till höger, lite större */
.hype-map .leaflet-bottom.leaflet-right {
    margin: 0 16px 16px 0;
}

.hype-map .leaflet-bottom.leaflet-right .leaflet-control-zoom {
    margin: 0 0 6px;
}

.hype-map .leaflet-control-zoom a {
    width: 44px;
    height: 44px;
    line-height: 44px;
    font-size: 20px;
}

/* Remsorna ("Inga restauranger …") under toppkortet */
.map-empty--hint {
    top: calc(var(--map-top-h, 120px) + 28px);
}

/* Popupen: ett riktigt kort */
.hype-map .leaflet-popup-content-wrapper {
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(17, 24, 39, .25);
}

.map-popup-image {
    height: 130px;
}

.map-popup-body {
    padding: 14px 16px 16px;
}

.map-popup-name {
    font-size: 17px;
}

.map-popup-open {
    display: inline-block;
    margin-top: 8px !important;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--surface-2);
}

.map-popup-open.is-open {
    background: rgba(31, 157, 99, .12);
}

.map-popup-distance {
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-2);
}

.map-popup-links {
    align-items: center !important;
    margin-top: 12px !important;
}

.map-popup-link {
    padding: 9px 14px;
    border-radius: 12px;
    background: var(--hype-orange);
    color: #fff !important;
    font-size: 13.5px;
}

.map-popup-link:hover {
    background: #e65f00;
    text-decoration: none;
}


/* ---------- Mobil: kortet blir en rad, "Filter" öppnar ett ark ---------- */

@media (max-width: 899px) {
    .map-frame {
        border-radius: 18px;
    }

    .hype-map {
        /* Plats kvar för headern och bottenmenyn */
        height: max(460px, calc(100dvh - 180px));
    }

    .map-top {
        top: 10px;
        left: 10px;
        right: 10px;
        gap: 8px;
        padding: 0;
        border: none;
        background: none;
        box-shadow: none;
        backdrop-filter: none;
    }

    .map-top-row {
        flex-wrap: nowrap;
        gap: 8px;
        padding: 5px;
        border-radius: 18px;
        border: 1px solid var(--border);
        background: rgb(var(--surface-rgb) / .96);
        box-shadow: 0 10px 28px rgba(17, 24, 39, .14);
    }

    .map-title-text,
    .map-total .place-chip,
    .map-clear {
        display: none !important;
    }

    .map-title .place-chip {
        height: 40px;
        border: none;
        background: none;
    }

    .map-total {
        flex: 1;
        min-width: 0;
        font-size: 12.5px;
        white-space: nowrap;
        overflow: hidden;
    }

    .map-filter-open {
        display: inline-flex;
        align-items: center;
        gap: 7px;
        flex: none;
        min-height: 40px;
        padding: 0 12px;
        border: none;
        border-radius: 13px;
        background: var(--dark-text);
        color: var(--pure-white);
        font: inherit;
        font-size: 13.5px;
        font-weight: 800;
        cursor: pointer;
    }

    .map-filter-open .nav-icon {
        width: 17px;
        height: 17px;
    }

    .map-filter-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        border-radius: 999px;
        background: var(--hype-orange);
        color: #fff;
        font-size: 11px;
    }

    /* Raden under: snabbval + typerna att svepa (priset bara i arket) */
    .map-filters:not(.is-open) {
        overflow-x: auto;
        scrollbar-width: none;
        gap: 6px;
    }

    .map-filters:not(.is-open)::-webkit-scrollbar {
        display: none;
    }

    .map-filters:not(.is-open) .map-group--price,
    .map-filters:not(.is-open) .map-group--tags {
        display: none;   /* i arket ("Filter") — raden att svepa har snabbval och typer */
    }

    .map-filters:not(.is-open) .map-group {
        gap: 6px;
        padding: 0;
        border: none;
    }

    .map-filters:not(.is-open) .map-group--type {
        overflow: visible;
        padding: 0;
        -webkit-mask-image: none;
        mask-image: none;
    }

    .map-filters:not(.is-open) .map-quick,
    .map-filters:not(.is-open) .map-type {
        min-height: 36px;
        box-shadow: 0 4px 12px rgba(17, 24, 39, .1);
    }

    .map-filters:not(.is-open) .map-type-icon {
        width: 26px;
        height: 26px;
        font-size: 14px;
    }

    /* Arket */
    .map-filters.is-open {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 10001;
        flex-direction: column;
        align-items: stretch;
        gap: 18px;
        max-height: 85vh;
        overflow-y: auto;
        padding: 12px 18px calc(18px + env(safe-area-inset-bottom));
        box-sizing: border-box;
        border-radius: 26px 26px 0 0;
        background: var(--pure-white);
        box-shadow: 0 -12px 40px rgba(0, 0, 0, .2);
        animation: map-sheet-up .22s ease;
    }

    .map-filters.is-open .map-sheet-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .map-sheet-head h2 {
        margin: 0;
        color: var(--dark-text);
        font-size: 21px;
        font-weight: 900;
    }

    .map-sheet-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border: none;
        border-radius: 50%;
        background: var(--surface-2);
        color: var(--dark-text);
        cursor: pointer;
    }

    .map-sheet-close .nav-icon {
        width: 18px;
        height: 18px;
    }

    .map-filters.is-open .map-group {
        flex-wrap: wrap;
        gap: 8px;
        padding: 0;
        border: none;
    }

    .map-filters.is-open .map-group-label {
        display: block;
        flex-basis: 100%;
        color: var(--text-muted);
        font-size: 12.5px;
        font-weight: 800;
        letter-spacing: .06em;
        text-transform: uppercase;
    }

    .map-filters.is-open .map-group--tags .map-quick {
        flex: 1 1 calc(50% - 4px);
        min-height: 50px;
        border-radius: 14px;
        font-size: 15px;
    }

    .map-filters.is-open .map-group--quick .map-quick {
        flex-basis: 100%;
        min-height: 50px;
        border-radius: 14px;
        font-size: 15px;
    }

    .map-filters.is-open .map-seg {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        flex-basis: 100%;
        gap: 8px;
        padding: 0;
        background: none;
    }

    .map-filters.is-open .map-seg-btn {
        justify-content: center;
        min-height: 46px;
        border: 1px solid var(--border);
        border-radius: 14px;
        background: var(--pure-white);
    }

    .map-filters.is-open .map-seg-btn.is-selected {
        border: 2px solid var(--hype-orange);
        background: var(--orange-soft);
        box-shadow: none;
    }

    .map-filters.is-open .map-group--type {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        overflow: visible;
        padding: 0;
        -webkit-mask-image: none;
        mask-image: none;
    }

    .map-filters.is-open .map-group--type .map-group-label {
        grid-column: 1 / -1;
    }

    .map-filters.is-open .map-type {
        flex-direction: column;
        justify-content: center;
        gap: 4px;
        min-height: 76px;
        padding: 8px 4px;
        border-radius: 16px;
        font-size: 12px;
        white-space: normal;
        text-align: center;
    }

    .map-filters.is-open .map-sheet-foot {
        display: flex;
        gap: 10px;
    }

    .map-sheet-clear {
        min-height: 50px;
        padding: 0 18px;
        border: 1px solid var(--border);
        border-radius: 14px;
        background: none;
        color: var(--dark-text);
        font: inherit;
        font-weight: 700;
        cursor: pointer;
    }

    .map-sheet-done {
        flex: 1;
        justify-content: center;
        height: 50px;
        border-radius: 14px;
        font-size: 15px;
    }

    .map-sheet-backdrop {
        position: fixed;
        inset: 0;
        z-index: 10001;
        background: rgba(17, 17, 17, .45);
    }

    /* Arket öppet: ramen släpper sin egen stapling (isolation), så att arket och det mörka
       bakom hamnar över bottenmenyn (z-index 9999) — toppkortet över det mörka */
    .map-frame:has(.map-filters.is-open) {
        isolation: auto;
    }

    .map-top:has(.map-filters.is-open) {
        z-index: 10002;
    }

    html.map-sheet-open {
        overflow: hidden;
    }

    /* Hitta mig: en rund knapp till höger, under toppkortet */
    .map-locate {
        top: calc(var(--map-top-h, 100px) + 20px);
        right: 12px;
        width: 48px;
        height: 48px;
        padding: 0;
        justify-content: center;
        border-radius: 16px;
    }

    .map-locate span {
        display: none;   /* bara ikonen */
    }

    .map-legend {
        display: none;
    }

    /* Mobil: nyp för att zooma — knapparna tar bara plats. Upphovsraden längst ner, under kortet. */
    .hype-map .leaflet-control-zoom {
        display: none;
    }

    .hype-map .leaflet-bottom.leaflet-right {
        margin: 0;
    }

    /* Närmast dig: ett kort nertill (ovanför kartans upphovsrad), raderna sveps i sidled */
    .map-nearby {
        top: auto;
        left: 10px;
        right: 10px;
        bottom: 24px;
        width: auto;
        max-height: none;
        gap: 8px;
        padding: 10px;
        border-radius: 20px;
    }

    .map-nearby-head {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .map-panel-tabs {
        flex: 1;
    }

    .map-nearby-note {
        display: none;
    }

    .map-nearby-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
    }

    .map-nearby-list::-webkit-scrollbar {
        display: none;
    }

    .map-nearby-list li {
        flex: 0 0 78%;
        scroll-snap-align: start;
    }

    .map-nearby-item {
        height: 100%;
        border-color: var(--border);
    }

    /* 🎯 En restaurangs popup är öppen (map.js centerPopup): kortet glider undan, så att hela popupen får plats */
    .map-nearby {
        transition: transform .2s ease, opacity .2s ease;
    }

    html.map-popup-open .map-nearby {
        transform: translateY(calc(100% + 24px));
        opacity: 0;
        pointer-events: none;
    }

    .map-empty--hint {
        top: 120px;
    }
}

@keyframes map-sheet-up {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .map-filters.is-open {
        animation: none;
    }
}
