/**
 * Community Universal Map — CSS
 * Styles for the map wrapper, filter pills, legend, pins, popups and clusters.
 */

/* ── Wrapper ─────────────────────────────────────────────────────────── */
.comm-universal-map-wrapper {
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Map canvas ──────────────────────────────────────────────────────── */
.comm-universal-map {
    border: 1px solid #ddd;
    border-radius: 8px 8px 0 0;
    background: #eee;
    position: relative;
    z-index: 1;
}

/* ── Filter pill bar ─────────────────────────────────────────────────── */
.cum-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 8px 12px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
}

.cum-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 20px;
    border: 2px solid var(--cum-colour, #999);
    background: transparent;
    color: var(--cum-colour, #555);
    font-size: 0.82em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
    line-height: 1.4;
}

.cum-filter-btn--active {
    background: var(--cum-colour, #999);
    color: #fff;
}

.cum-filter-btn:focus-visible {
    outline: 3px solid var(--cum-colour, #999);
    outline-offset: 2px;
}

/* ── Legend bar ──────────────────────────────────────────────────────── */
.cum-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    padding: 8px 12px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    font-size: 0.83em;
    color: #444;
}

.cum-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.cum-legend-item::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--cum-colour, #999);
    flex-shrink: 0;
}

/* ── Map pins ────────────────────────────────────────────────────────── */
.cum-pin {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.85);
    transition: transform 0.15s ease;
    cursor: pointer;
}

.cum-pin:hover {
    transform: scale(1.12);
}

.cum-pin-single {
    width: 36px;
    height: 36px;
    font-size: 1.1em;
}

.cum-pin-multi {
    width: 44px;
    height: 44px;
    font-size: 0.75em;
    gap: 0;
}

/* Highlighted "current" pin gets a halo */
.cum-pin-current {
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.9), 0 3px 8px rgba(0, 0, 0, 0.5);
    transform: scale(1.15);
}

.cum-pin-count {
    font-size: 1.15em;
    font-weight: 800;
    line-height: 1;
}

.cum-pin-emoji {
    font-size: 0.85em;
    line-height: 1;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", sans-serif;
}

/* ── Cluster bubble ──────────────────────────────────────────────────── */
.cum-cluster {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: #fff;
    font-size: 1em;
    font-weight: 800;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
    border: 2px solid rgba(255, 255, 255, 0.85);
    cursor: pointer;
}

/* ── Map popup ───────────────────────────────────────────────────────── */
.cum-map-popup .leaflet-popup-content-wrapper {
    border-radius: 10px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    max-height: min(400px, 70vh);
    display: flex;
    flex-direction: column;
}

.cum-map-popup .leaflet-popup-content {
    margin: 0;
    min-width: 240px;
    max-width: 330px;
    max-height: min(400px, 70vh);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.cum-popup-wrap {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    color: #333;
}

.cum-popup-header {
    padding: 8px 12px;
    font-size: 0.75em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #fff;
}

.cum-popup-type-event      { background: #c1440e; }
.cum-popup-type-venue      { background: #2980b9; }
.cum-popup-type-org        { background: #8e44ad; }
.cum-popup-type-business   { background: #27ae60; }
.cum-popup-type-property   { background: #16a085; }
.cum-popup-type-classified { background: #f39c12; }
.cum-popup-type-market     { background: #16a34a; }
.cum-popup-type-campsite   { background: #2d6a4f; }
.cum-popup-type-picnic     { background: #d17a22; }
.cum-popup-type-hike       { background: #22577a; }

.cum-popup-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cum-popup-item {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
}

.cum-popup-item:last-child {
    border-bottom: none;
}

.cum-popup-thumb-link {
    flex-shrink: 0;
}

.cum-popup-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 5px;
    display: block;
}

.cum-popup-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: hidden;
}

.cum-popup-title {
    font-weight: 700;
    color: #222;
    text-decoration: none;
    font-size: 0.9em;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cum-popup-title:hover {
    color: #c1440e;
    text-decoration: underline;
}

.cum-popup-meta {
    font-size: 0.78em;
    color: #666;
}

.cum-popup-loc {
    font-size: 0.75em;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cum-popup-more {
    padding: 8px 12px;
    font-size: 0.78em;
    color: #888;
    border-top: 1px solid #f0f0f0;
    font-style: italic;
}

/* ── Mobile: two-finger gesture hint ────────────────────────────────── */
.cum-gesture-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.9em;
    white-space: nowrap;
    z-index: 1001;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.cum-gesture-hint--active {
    opacity: 1;
}

/* ── Marketplace Popup Elements ────────────────────────────────────── */
.cum-popup-market-wrap {
    max-width: 320px;
}

.cum-popup-market-hero {
    width: 100%;
    height: 120px;
    overflow: hidden;
    background: #f1f5f9;
}

.cum-popup-market-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cum-popup-market-body {
    padding: 12px;
}

.cum-popup-market-title-wrap {
    margin-bottom: 8px;
}

.cum-popup-market-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    text-decoration: none;
    line-height: 1.3;
}

.cum-popup-market-title:hover {
    color: #16a34a;
    text-decoration: underline;
}

.cum-popup-market-line {
    font-size: 12px;
    color: #334155;
    margin-bottom: 5px;
    line-height: 1.4;
}

.cum-popup-market-line a {
    color: #16a34a;
    text-decoration: none;
}

.cum-popup-market-line a:hover {
    text-decoration: underline;
}

.cum-popup-sub {
    color: #64748b;
    font-size: 11px;
}

.cum-popup-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.cum-spot-badge-avail {
    background: #dcfce7;
    color: #15803d;
}

.cum-spot-badge-full {
    background: #fee2e2;
    color: #b91c1c;
}

.cum-popup-market-desc {
    font-size: 12px;
    color: #475569;
    margin: 8px 0;
    line-height: 1.45;
    max-height: 70px;
    overflow-y: auto;
}

.cum-popup-market-facilities {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px;
    margin: 8px 0;
    font-size: 11px;
    color: #475569;
}

.cum-popup-fac-row {
    margin-bottom: 4px;
}

.cum-popup-fac-row:last-child {
    margin-bottom: 0;
}

.cum-popup-market-ads {
    margin-top: 10px;
    border-top: 1px solid #e2e8f0;
    padding-top: 8px;
}

.cum-popup-market-ads-header {
    font-size: 12px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 6px;
}

.cum-popup-market-no-ads {
    margin: 8px 0;
    font-size: 11px;
    color: #64748b;
    font-style: italic;
}

.cum-popup-market-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
}

.cum-popup-sold-badge {
    display: inline-block;
    width: fit-content;
    margin-top: 4px;
    padding: 2px 6px;
    border-radius: 3px;
    background: #c1440e;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.3;
}

.cum-popup-btn {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    line-height: 1.2;
}

.cum-popup-btn-primary {
    background: #2f4f2f;
    color: #fff;
    border: 1px solid #243d24;
}

.leaflet-popup-content a.cum-popup-btn-primary,
.leaflet-popup-content a.cum-popup-btn-primary:visited {
    color: #fff !important;
}

.cum-popup-btn-primary:hover,
.cum-popup-btn-primary:focus {
    background: #243d24;
    color: #fff;
    text-decoration: none;
}

.cum-popup-btn-secondary {
    background: #c1440e;
    color: #fff;
    border: 1px solid #a6390b;
}

.leaflet-popup-content a.cum-popup-btn-secondary,
.leaflet-popup-content a.cum-popup-btn-secondary:visited {
    color: #fff !important;
}

.cum-popup-btn-secondary:hover,
.cum-popup-btn-secondary:focus {
    background: #a6390b;
    color: #fff;
    text-decoration: none;
}

.cum-popup-btn-disabled {
    background: #f1f5f9;
    color: #94a3b8;
    border: 1px solid #e2e8f0;
    cursor: not-allowed;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .cum-filters,
    .cum-legend {
        padding: 6px 8px;
        gap: 5px 8px;
        font-size: 0.78em;
    }

    .cum-filter-btn {
        padding: 3px 9px;
        font-size: 0.78em;
    }
}
