/**
 * Phase 5 — Interactive Permit Map (permit-map.css)
 * Loaded on /permits/map/ (virtual URL, coc_permit_map query var).
 *
 * Layout: full-viewport map canvas below the site header, filter chips
 * overlaid top-left, sticky watch widget bottom-right, slideout right-edge
 * on desktop / bottom-sheet on mobile.
 */

/* ===== Root layout ============================================== */

.coc-permit-map-root {
    position: relative;
    width: 100%;
    /* JS-driven height via fitRootToViewport() takes over on load. The calc()
     * fallback covers the pre-hydration frame; no min-height so landscape
     * mobile isn't forced past the viewport. */
    height: calc(100vh - 90px);
    overflow: hidden;
    background: #e2e8f0;
}

.coc-pm-canvas {
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* ===== Filter chip bar ========================================== */

.coc-pm-filters {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.15);
    max-width: min(360px, calc(100vw - 24px));
    font-size: 13px;
    line-height: 1.4;
    color: #0f172a;
}

.coc-pm-filters__title {
    font-weight: 600;
    font-size: 14px;
    margin: 0;
    letter-spacing: -0.01em;
}

.coc-pm-filters__group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.coc-pm-filters__group--layers {
    padding-top: 6px;
    border-top: 1px solid #e2e8f0;
    gap: 12px;
}

.coc-pm-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: #f1f5f9;
    color: #0f172a;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.coc-pm-chip:hover { background: #e2e8f0; }

.coc-pm-chip.is-active {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
}

.coc-pm-chip.is-active .coc-pm-chip__dot {
    outline: 2px solid #ffffff;
    outline-offset: 1px;
}

.coc-pm-chip__dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.coc-pm-select {
    padding: 5px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    color: #0f172a;
    font-size: 12.5px;
    font-family: inherit;
    min-width: 130px;
}

.coc-pm-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12.5px;
    color: #475569;
    cursor: pointer;
    user-select: none;
}

.coc-pm-toggle input {
    accent-color: #0f172a;
}

/* Hide Land use toggle until data pipeline exists (ClickUp wdu9v7b09n) */
.coc-pm-toggle:has(input[data-layer="landuse"]) { display: none; }

/* ===== Pin (Leaflet divIcon) ==================================== */

.coc-pm-pin {
    background: transparent !important;
    border: 0 !important;
}

.coc-pm-tooltip {
    background: #0f172a;
    color: #ffffff;
    border: 0;
    padding: 3px 8px;
    font-size: 12px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.coc-pm-tooltip::before { display: none; }

/* ===== Slideout ================================================= */

.coc-pm-slideout {
    position: absolute;
    top: 12px;
    right: 12px;
    bottom: 12px;
    width: min(420px, calc(100vw - 24px));
    z-index: 700;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.22);
    overflow: hidden;
    font-size: 14px;
    color: #0f172a;
}

.coc-pm-slideout[hidden] { display: none; }

.coc-pm-slideout__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid #e2e8f0;
}

.coc-pm-slideout__eyebrow {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 4px;
}

.coc-pm-slideout__title {
    font-size: 18px;
    line-height: 1.3;
    margin: 0;
    color: #0f172a;
    font-weight: 700;
}

.coc-pm-slideout__close {
    background: transparent;
    border: 0;
    font-size: 24px;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
}

.coc-pm-slideout__close:hover { background: #f1f5f9; color: #0f172a; }

.coc-pm-slideout__body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 18px 8px;
}

.coc-pm-slideout__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 18px 14px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.coc-pm-slideout__loading {
    color: #64748b;
    font-size: 13px;
    padding: 20px 0;
    text-align: center;
}

.coc-pm-slideout__deeplink {
    color: #2563eb;
    font-size: 13px;
    text-decoration: none;
    font-weight: 500;
}

.coc-pm-slideout__deeplink:hover { text-decoration: underline; }

/* ===== Detail rows ============================================== */

.coc-pm-rows {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px 12px;
    margin: 0 0 12px;
}

.coc-pm-rows dt {
    color: #64748b;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding-top: 2px;
}

.coc-pm-rows dd {
    margin: 0;
    color: #0f172a;
    font-size: 13.5px;
}

.coc-pm-rows dd a { color: #2563eb; text-decoration: none; }
.coc-pm-rows dd a:hover { text-decoration: underline; }

.coc-pm-desc {
    padding: 10px 12px;
    background: #f8fafc;
    border-radius: 8px;
    color: #334155;
    font-size: 13px;
    line-height: 1.55;
    margin-bottom: 12px;
}

.coc-pm-insp h4 {
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    margin: 0 0 6px;
}

.coc-pm-insp ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.coc-pm-insp li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 12.5px;
    border-bottom: 1px solid #f1f5f9;
}

.coc-pm-insp__date { color: #64748b; font-variant-numeric: tabular-nums; }
.coc-pm-insp__stage { flex: 1; color: #0f172a; }

.coc-pm-insp__outcome {
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 4px;
    background: #e2e8f0;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.coc-pm-insp__outcome[data-outcome*="pass"]        { background: #d1fae5; color: #065f46; }
.coc-pm-insp__outcome[data-outcome*="fail"]        { background: #fee2e2; color: #991b1b; }
.coc-pm-insp__outcome[data-outcome*="deficien"]    { background: #fef3c7; color: #92400e; }

/* ===== Watch button ============================================= */

.coc-pm-watch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: #ffffff;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.coc-pm-watch[hidden] { display: none; }
.coc-pm-watch:hover { background: #f8fafc; }

.coc-pm-watch.is-watched {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
}

.coc-pm-watch__icon svg { display: block; }

/* ===== Sticky widget ============================================ */

.coc-pm-watch-widget {
    position: absolute;
    right: 16px;
    bottom: 16px;
    z-index: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #0f172a;
    color: #ffffff;
    border: 0;
    border-radius: 999px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.30);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.coc-pm-watch-widget[hidden] { display: none; }
.coc-pm-watch-widget:hover { background: #1e293b; }

.coc-pm-watch-widget__star {
    font-size: 15px;
    color: #fbbf24;
}

.coc-pm-watch-widget__sep {
    opacity: 0.55;
    margin: 0 3px;
}

.coc-pm-watch-widget.has-changes {
    background: #16a34a;
}

.coc-pm-watch-widget.has-changes:hover {
    background: #15803d;
}

.coc-pm-watch-panel {
    position: absolute;
    right: 16px;
    bottom: 62px;
    width: min(320px, calc(100vw - 32px));
    max-height: min(60vh, 480px);
    z-index: 650;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.24);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.coc-pm-watch-panel[hidden] { display: none; }

.coc-pm-watch-panel__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid #e2e8f0;
}

.coc-pm-watch-panel__head h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
}

.coc-pm-watch-panel__close {
    background: transparent;
    border: 0;
    font-size: 22px;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
}

.coc-pm-watch-panel__list {
    flex: 1;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 4px 0;
}

.coc-pm-watch-panel__list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
}

.coc-pm-watch-panel__list li.is-changed {
    background: #f0fdf4;
    border-left: 3px solid #16a34a;
    padding-left: 11px;
}

.coc-pm-watch-panel__list a {
    color: #0f172a;
    font-weight: 500;
    text-decoration: none;
    font-variant-numeric: tabular-nums;
}

.coc-pm-watch-panel__list a:hover { color: #2563eb; }

.coc-pm-watch-panel__status {
    flex: 1;
    color: #64748b;
    font-size: 12px;
}

.coc-pm-watch-panel__remove {
    background: transparent;
    border: 0;
    color: #94a3b8;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
}

.coc-pm-watch-panel__remove:hover { color: #dc2626; background: #fee2e2; }

.coc-pm-watch-panel__note {
    margin: 0;
    padding: 10px 14px;
    background: #f8fafc;
    color: #64748b;
    font-size: 11.5px;
    line-height: 1.4;
    border-top: 1px solid #e2e8f0;
}

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

/* ===== Attribution ============================================== */

.coc-pm-attribution {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 500;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 6px;
    font-size: 11px;
    color: #475569;
    max-width: 420px;
    line-height: 1.4;
}

.coc-pm-attribution a { color: #2563eb; text-decoration: none; }
.coc-pm-attribution a:hover { text-decoration: underline; }

/* ===== Mobile ==================================================== */

@media (max-width: 640px) {

    .coc-permit-map-root {
        height: calc(100vh - 70px);
    }

    .coc-pm-filters {
        top: 8px;
        left: 8px;
        right: 8px;
        max-width: none;
        padding: 10px;
        gap: 8px;
    }

    .coc-pm-filters__title { font-size: 13px; }

    .coc-pm-slideout {
        top: auto;
        left: 8px;
        right: 8px;
        bottom: 8px;
        width: auto;
        max-height: 60vh;
        border-radius: 14px 14px 6px 6px;
    }

    .coc-pm-watch-widget {
        right: 10px;
        bottom: 10px;
        font-size: 12.5px;
        padding: 8px 12px;
    }

    .coc-pm-watch-panel {
        right: 10px;
        left: 10px;
        bottom: 54px;
        width: auto;
    }

    .coc-pm-attribution {
        left: 8px;
        right: 8px;
        max-width: none;
        font-size: 10.5px;
    }
}
