/*
 * /map (jobmap/page.php + js/job-map.js). The header is position: fixed (header.php), the app fills the viewport below it.
 */

.jm-page {
    --jm-brand: #42b983;
    --jm-brand-600: #2f9a6b;
    --jm-brand-50: #effaf4;
    --jm-ink: #0f172a;
    --jm-text: #334155;
    --jm-muted: #64748b;
    --jm-border: #e2e8f0;
    --jm-soft: #f8fafc;
    --jm-header: 64px;
    --jm-panel: 400px;
}

.jm-page body {
    margin: 0;
}

.jm-visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Own stacking context: Leaflet panes / controls use z-index up to 1000 and must stay under the fixed site header */
.jm-app {
    position: relative;
    z-index: 0;
    isolation: isolate;
    display: flex;
    height: calc(100vh - var(--jm-header));
    height: calc(100dvh - var(--jm-header));
    min-height: 480px;
    margin-top: var(--jm-header);
    border-bottom: 1px solid var(--jm-border);
    font-family: inherit;
    color: var(--jm-text);
    text-align: left;
}

/* ───────────── side panel ───────────── */

.jm-panel {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    flex: 0 0 var(--jm-panel);
    width: var(--jm-panel);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #fff;
    border-right: 1px solid var(--jm-border);
}

.jm-panel-head {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 18px 18px 12px;
    background: #fff;
    border-bottom: 1px solid var(--jm-border);
}

.jm-title {
    margin: 0 0 4px;
    font-size: 24px;
    line-height: 1.2;
    font-weight: 700;
    color: var(--jm-ink);
    text-align: left;
}

.jm-intro {
    margin: 0 0 12px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--jm-muted);
}

.jm-intro strong {
    color: var(--jm-ink);
}

.jm-filters {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
}

.jm-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid var(--jm-border);
    border-radius: 10px;
    background: var(--jm-soft);
    color: var(--jm-muted);
}

.jm-search:focus-within {
    border-color: var(--jm-brand);
    box-shadow: 0 0 0 3px rgba(66, 185, 131, .18);
    background: #fff;
}

.jm-search input {
    flex: 1;
    min-width: 0;
    height: 40px;
    border: 0;
    outline: 0;
    background: transparent;
    font: inherit;
    font-size: 15px;
    color: var(--jm-ink);
}

.jm-filter-row {
    display: flex;
    gap: 8px;
}

.jm-filter-row > label {
    flex: 1;
    min-width: 0;
}

.jm-filter-row select {
    box-sizing: border-box;
    width: 100%;
    height: 36px;
    padding: 0 8px;
    border: 1px solid var(--jm-border);
    border-radius: 8px;
    background: #fff;
    font: inherit;
    font-size: 14px;
    color: var(--jm-text);
}

.jm-toggles {
    flex-wrap: wrap;
    gap: 6px 14px;
}

.jm-filter-row > .jm-check {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--jm-text);
    cursor: pointer;
    user-select: none;
}

/* css/app.css restyles every checkbox (appearance: none, scale(1.5), invisible when checked): back to native ones */
.jm-check input[type='checkbox'],
.jm-ms-option input[type='checkbox'] {
    -webkit-appearance: checkbox;
    appearance: auto;
    width: 16px;
    height: 16px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    transform: none;
    accent-color: var(--jm-brand);
}

/* Categories: searchable multiselect (button + popover with a search box and checkboxes) */
.jm-ms {
    position: relative;
    flex: 1;
    min-width: 0;
}

.jm-ms-toggle {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    height: 36px;
    padding: 0 6px 0 12px;
    border: 1px solid var(--jm-border);
    border-radius: 8px;
    background: #fff;
    font: inherit;
    font-size: 14px;
    color: var(--jm-text);
    text-align: left;
    cursor: pointer;
}

.jm-ms-toggle:focus-visible,
.jm-ms-toggle[aria-expanded='true'] {
    border-color: var(--jm-brand);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(66, 185, 131, .18);
}

.jm-ms.has-value .jm-ms-toggle {
    border-color: var(--jm-brand);
    background: var(--jm-brand-50);
    color: var(--jm-brand-600);
    font-weight: 600;
}

.jm-ms-label {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.jm-ms-toggle svg {
    flex: 0 0 auto;
    color: var(--jm-muted);
}

.jm-ms-pop {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 20;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    width: max(100%, 280px);
    max-width: calc(100vw - 36px);
    padding: 8px;
    border: 1px solid var(--jm-border);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .18);
}

.jm-ms-pop[hidden] {
    display: none;
}

.jm-ms-search {
    box-sizing: border-box;
    width: 100%;
    height: 36px;
    margin: 0 0 6px;
    padding: 0 10px;
    border: 1px solid var(--jm-border);
    border-radius: 8px;
    background: var(--jm-soft);
    font: inherit;
    font-size: 14px;
    color: var(--jm-ink);
    outline: 0;
}

.jm-ms-search:focus {
    border-color: var(--jm-brand);
    background: #fff;
}

.jm-ms-list {
    max-height: 280px;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    list-style: none;
}

.jm-ms-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 6px;
    font-size: 14px;
    color: var(--jm-text);
    cursor: pointer;
    user-select: none;
}

.jm-ms-option:hover,
.jm-ms-option:focus-within {
    background: var(--jm-soft);
}

.jm-ms-option.is-checked {
    color: var(--jm-ink);
    font-weight: 600;
}

.jm-ms-option-label {
    flex: 1;
    min-width: 0;
}

.jm-ms-count {
    font-size: 12px;
    font-weight: 400;
    color: var(--jm-muted);
}

.jm-ms-empty {
    padding: 10px 8px;
    font-size: 13px;
    color: var(--jm-muted);
}

.jm-ms-actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--jm-border);
}

.jm-ms-actions button {
    padding: 7px 14px;
    border: 0;
    border-radius: 8px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.jm-ms-clear {
    background: none;
    color: var(--jm-muted);
}

.jm-ms-clear:hover:not(:disabled) {
    color: var(--jm-ink);
}

.jm-ms-clear:disabled {
    opacity: .4;
    cursor: default;
}

.jm-ms-done {
    background: var(--jm-brand);
    color: #fff;
}

.jm-ms-done:hover {
    background: var(--jm-brand-600);
}

.jm-results-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 12px 18px 6px;
}

.jm-count {
    font-size: 14px;
    color: var(--jm-muted);
}

.jm-count strong {
    color: var(--jm-ink);
}

.jm-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid var(--jm-border);
    border-radius: 999px;
    background: #fff;
    font: inherit;
    font-size: 13px;
    color: var(--jm-text);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.jm-chip:hover {
    border-color: var(--jm-brand);
    background: var(--jm-brand-50);
}

.jm-chip span {
    color: var(--jm-muted);
    font-size: 12px;
}

.jm-place-chip {
    border-color: var(--jm-brand);
    background: var(--jm-brand-50);
    color: var(--jm-brand-600);
}

.jm-place-chip[hidden] {
    display: none;
}

/* ───────────── job list ───────────── */

.jm-list {
    margin: 0;
    padding: 0 10px;
    list-style: none;
}

.jm-job {
    position: relative;
    margin: 0;
    padding: 0;
    border-bottom: 1px solid var(--jm-border);
}

.jm-job:last-child {
    border-bottom: 0;
}

.jm-job-link {
    display: flex;
    gap: 12px;
    padding: 12px 8px 34px;
    border-radius: 10px;
    color: inherit;
    text-decoration: none;
}

.jm-job-link:hover {
    background: var(--jm-soft);
}

.jm-job-link:hover .jm-job-title {
    color: var(--jm-brand-600);
}

.jm-avatar {
    flex: 0 0 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--jm-brand-50);
    color: var(--jm-brand-600);
    font-weight: 700;
    font-size: 17px;
}

.jm-job-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.jm-job-title {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.3;
    color: var(--jm-ink);
}

.jm-job-company {
    font-size: 14px;
    color: var(--jm-text);
}

.jm-job-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    margin-top: 3px;
    font-size: 12px;
    color: var(--jm-muted);
}

.jm-tag {
    padding: 1px 7px;
    border-radius: 999px;
    font-weight: 600;
}

.jm-tag-salary {
    background: #fef3c7;
    color: #92400e;
}

.jm-tag-remote {
    background: #e0f2fe;
    color: #075985;
}

/* Location button + board link sit on top of the link area (no button / link inside a link) */
.jm-job-foot {
    position: absolute;
    left: 60px;
    right: 10px;
    bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    font-size: 12px;
    white-space: nowrap;
}

.jm-job-board {
    flex: 0 1 auto;
    max-width: 55%;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #92400e;
    font-weight: 600;
    text-decoration: none;
}

a.jm-job-board:hover {
    text-decoration: underline;
}

/* Jobs of paid job boards */
.jm-job-featured {
    margin: 6px 0;
    border: 1px solid #fcd34d;
    border-radius: 12px;
    background: #fffbeb;
}

.jm-job-featured + .jm-job {
    border-top: 0;
}

.jm-job-featured .jm-job-link:hover {
    background: #fef3c7;
}

.jm-job-featured .jm-avatar {
    background: #fde68a;
    color: #92400e;
}

.jm-tag-featured,
.jm-badge-featured {
    background: #f59e0b;
    color: #fff;
}

.jm-badge-featured {
    display: inline-block;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    vertical-align: 1px;
}

.jm-popup li.jm-popup-featured a {
    background: #fffbeb;
}

.jm-popup li.jm-popup-featured a:hover {
    background: #fef3c7;
}

.jm-check-featured {
    font-weight: 600;
}

.jm-check-featured span {
    color: var(--jm-muted);
    font-weight: 400;
}

.jm-check[hidden] {
    display: none !important;
}

/* Places / clusters with featured jobs: gold ring + star */
.jm-pin.jm-pin-featured {
    box-shadow: 0 0 0 3px #f59e0b, 0 2px 8px rgba(15, 23, 42, .35);
}

.jm-job-place svg {
    margin-right: 3px;
    vertical-align: -2px;
}

.jm-pin-star {
    position: absolute;
    top: -9px;
    right: -9px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #f59e0b;
    color: #fff;
    font-size: 10px;
    font-style: normal;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .3);
}

.jm-job-place {
    display: inline-block;
    flex: 0 1 auto;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: 12px;
    color: var(--jm-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.jm-job-place:hover {
    color: var(--jm-brand-600);
    text-decoration: underline;
}

.jm-more {
    margin: 10px 18px;
    padding: 10px;
    border: 1px solid var(--jm-border);
    border-radius: 10px;
    background: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--jm-brand-600);
    cursor: pointer;
}

.jm-more:hover {
    background: var(--jm-brand-50);
}

.jm-more[hidden] {
    display: none;
}

.jm-panel-foot {
    margin-top: auto;
    padding: 16px 18px 20px;
    border-top: 1px solid var(--jm-border);
    background: var(--jm-soft);
}

.jm-panel-foot h2 {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--jm-ink);
    text-align: left;
}

.jm-top-places {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 12px;
    padding: 0;
    list-style: none;
}

.jm-remote-note {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--jm-muted);
}

.jm-remote-note a,
.jm-about a {
    color: var(--jm-brand-600);
}

/* ───────────── map ───────────── */

.jm-map-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.jm-map {
    position: absolute;
    inset: 0;
    background: #e8eef3;
}

.jm-map-status {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 1100;
    transform: translate(-50%, -50%);
    max-width: 80%;
    padding: 12px 18px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .95);
    box-shadow: 0 6px 24px rgba(15, 23, 42, .15);
    font-size: 14px;
    color: var(--jm-text);
    text-align: center;
}

.jm-map-status[hidden] {
    display: none;
}

.jm-map-status.is-error {
    color: #b91c1c;
}

.jm-view-toggle {
    display: none;
}

/* Pins: one per place with its job count. Cities solid, states / countries (centroids) outlined. */
.jm-pin,
.jm-cluster {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
    font-size: 12px;
    line-height: 1;
    box-sizing: border-box;
}

.jm-pin {
    background: var(--jm-brand);
    color: #fff;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .35);
}

.jm-pin-r,
.jm-pin-c {
    background: #fff;
    color: var(--jm-brand-600);
    border: 2px dashed var(--jm-brand);
}

.jm-pin:hover {
    transform: scale(1.08);
}

.jm-cluster {
    background: rgba(66, 185, 131, .25);
    color: #fff;
}

.jm-cluster span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: calc(100% - 10px);
    height: calc(100% - 10px);
    border-radius: 50%;
    background: var(--jm-brand-600);
    box-shadow: 0 2px 8px rgba(15, 23, 42, .3);
}

.jm-locate {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: #fff;
    color: var(--jm-text);
    cursor: pointer;
}

.jm-locate:hover {
    background: #f4f4f4;
}

.jm-locate.is-loading {
    color: var(--jm-brand);
    animation: jm-pulse 1s infinite;
}

@keyframes jm-pulse {
    50% { opacity: .4; }
}

/* ───────────── popup ───────────── */

.jm-popup {
    font-family: inherit;
}

.jm-popup-head {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--jm-border);
}

.jm-popup-head strong {
    font-size: 14px;
    color: var(--jm-ink);
}

.jm-popup-head span {
    font-size: 12px;
    color: var(--jm-muted);
}

.jm-popup ul {
    max-height: 260px;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.jm-popup li a {
    display: flex;
    flex-direction: column;
    padding: 6px 4px;
    border-radius: 6px;
    text-decoration: none;
}

.jm-popup li a:hover {
    background: var(--jm-soft);
}

.jm-popup-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--jm-ink);
}

.jm-popup li a:hover .jm-popup-title {
    color: var(--jm-brand-600);
}

.jm-popup-meta {
    font-size: 12px;
    color: var(--jm-muted);
}

.jm-popup-all {
    width: 100%;
    margin-top: 8px;
    padding: 8px;
    border: 0;
    border-radius: 8px;
    background: var(--jm-brand);
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.jm-popup-all:hover {
    background: var(--jm-brand-600);
}

.jm-popup-all-quiet {
    background: var(--jm-brand-50);
    color: var(--jm-brand-600);
}

.jm-popup-all-quiet:hover {
    background: #dcf2e7;
}

/* ───────────── about (SEO text under the app) ───────────── */

.jm-about {
    max-width: 820px;
    margin: 40px auto;
    padding: 0 20px;
    font-size: 15px;
    line-height: 1.7;
    color: var(--jm-text);
    text-align: left;
}

.jm-about h2 {
    font-size: 20px;
    color: var(--jm-ink);
    text-align: left;
    margin-left: 0;
    margin-top: 0;
    font-weight: 600;
    font-style: normal;
    line-height: 1.2;
    margin-bottom: 12px;
}

/* ───────────── mobile: map full screen, list toggled with the floating button ───────────── */

@media (max-width: 860px) {
    .jm-page {
        --jm-header: 60px;
    }

    .jm-panel {
        display: none;
        flex: 1 1 auto;
        width: 100%;
        border-right: 0;
    }

    /* The list covers the map instead of replacing it: the map keeps its size, so its bounds still drive the list */
    .jm-show-list .jm-panel {
        position: absolute;
        inset: 0;
        z-index: 1050;
        display: flex;
        padding-bottom: 80px;
    }

    .jm-panel-head {
        position: static;
    }

    .jm-view-toggle {
        position: absolute;
        left: 50%;
        bottom: 22px;
        z-index: 1100;
        display: block;
        transform: translateX(-50%);
        padding: 11px 22px;
        border: 0;
        border-radius: 999px;
        background: var(--jm-ink);
        color: #fff;
        font: inherit;
        font-size: 15px;
        font-weight: 600;
        box-shadow: 0 6px 20px rgba(15, 23, 42, .35);
        cursor: pointer;
    }
}
