/* ─── compliance-map.css ───────────────────────────────────────────────────────
 * Sprint 83 — NB-1: Compliance Map Phase 1
 * Sprint 83.5 — Spec alignment: 5-status colors, panel slide, map dim,
 *               keyboard focus, reduced motion, spec CSS variables
 * ────────────────────────────────────────────────────────────────────────────── */

/* ── Map Color Variables (Sprint 74 Spec) ───────────────────────────────────── */

:root {
    --map-compliant: #6D9276;               /* brand primary — sage green          */
    --map-attention: hsl(40, 55%, 52%);     /* warm clay — earthy, not neon        */
    --map-critical:  hsl(0, 50%, 52%);      /* muted brick — visible, not screaming */
    --map-pending:   hsl(210, 35%, 55%);    /* steel blue — zinc-family cool       */
    --map-inactive:  hsl(215, 10%, 32%);    /* zinc-700 — sits into the surface    */
}

/* ── Tax/HR Toggle ──────────────────────────────────────────────────────────── */

.map-mode-toggle {
    display: inline-flex;
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 1rem;
}

.map-mode-btn {
    padding: 0.4rem 1rem;
    font-size: 0.78rem;
    font-weight: 600;
    border: none;
    background: var(--clr-surface);
    color: var(--clr-text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.map-mode-btn.active {
    background: var(--clr-primary);
    color: #fff;
}

.map-mode-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Map Layout ───────────────────────────────────────────────────────────── */

.compliance-map-container {
    position: relative;
    min-height: 500px;
}

/* Map dimming + pointer blocking when panel is open (Sprint 74 spec §7.4) */
.compliance-map-container.has-selection .map-panel {
    opacity: 0.7;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.compliance-map-container.has-selection .map-panel:hover {
    opacity: 0.85;
}

/* ── Stat Cards ─────────────────────────────────────────────────────────────── */

.map-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.map-stat-card {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.map-stat-card:hover {
    border-color: var(--clr-primary);
    box-shadow: 0 2px 8px rgba(109, 146, 118, 0.12);
}

.map-stat-value {
    font-family: 'Outfit', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--clr-text-main);
    line-height: 1.1;
}

.map-stat-label {
    font-size: 0.78rem;
    color: var(--clr-text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.map-stat-value.text-alert { color: var(--clr-alert); }
.map-stat-value.text-success { color: var(--clr-success); }
.map-stat-value.text-primary { color: var(--clr-primary); }

/* ── SVG Map ────────────────────────────────────────────────────────────────── */

.map-panel {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    position: relative;
}

.compliance-map-svg {
    width: 100%;
    max-width: 960px;
    height: auto;
    margin: 0 auto;
    display: block;
    cursor: default;
}

.map-state {
    fill: var(--map-inactive);
    stroke: var(--clr-surface);
    stroke-width: 1.5;
    cursor: pointer;
    transition: fill 0.2s ease, opacity 0.15s ease, filter 0.2s ease;
}

/* 5-status health colors (Sprint 74 spec §2.3) */
.map-state.health-compliant {
    fill: var(--map-compliant);
    opacity: 0.85;
}

.map-state.health-attention {
    fill: var(--map-attention);
    opacity: 0.85;
}

.map-state.health-critical {
    fill: var(--map-critical);
    opacity: 0.85;
}

.map-state.health-pending {
    fill: var(--map-pending);
    opacity: 0.85;
}

.map-state.health-none {
    fill: var(--map-inactive);
    opacity: 0.5;
    cursor: default;
}

/* Hover effect — only for states with data */
.map-state:not(.health-none):hover {
    opacity: 1;
    filter: brightness(1.15);
    stroke: var(--clr-text-main);
    stroke-width: 2;
    transform-origin: center;
}

/* Keyboard focus ring */
.map-state:focus {
    outline: none;
}

.map-state:not(.health-none):focus-visible {
    stroke: hsl(210, 80%, 50%);
    stroke-width: 2.5;
    filter: drop-shadow(0 0 4px hsla(210, 80%, 50%, 0.4));
}

.map-state.selected {
    opacity: 1;
    stroke: hsl(210, 80%, 50%);
    stroke-width: 2.5;
    filter: drop-shadow(0 0 4px hsla(210, 80%, 50%, 0.4));
}

/* Pulse animation for critical states */
@keyframes pulse-critical {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 0.6; }
}

.map-state.health-critical:not(.selected):not(:hover) {
    animation: pulse-critical 2.5s ease-in-out infinite;
}

/* ── Map Legend ──────────────────────────────────────────────────────────────── */

.map-legend {
    display: flex;
    gap: 1.25rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--clr-border);
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--clr-text-muted);
}

.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.legend-swatch.compliant { background: var(--map-compliant); }
.legend-swatch.attention { background: var(--map-attention); }
.legend-swatch.critical { background: var(--map-critical); }
.legend-swatch.pending { background: var(--map-pending); }
.legend-swatch.none { background: var(--map-inactive); opacity: 0.5; }

/* ── Tooltip ────────────────────────────────────────────────────────────────── */

.map-tooltip {
    position: fixed;
    background: var(--clr-bg);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.85rem;
    font-size: 0.8rem;
    line-height: 1.5;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: opacity 0.15s;
    max-width: 240px;
}

.map-tooltip.visible { opacity: 1; }

.map-tooltip .tooltip-title {
    font-weight: 600;
    color: var(--clr-text-main);
    margin-bottom: 0.15rem;
}

.map-tooltip .tooltip-detail {
    color: var(--clr-text-muted);
    font-size: 0.72rem;
}

/* ── Detail Panel (Right Side) ──────────────────────────────────────────────── */

.map-detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    height: 100vh;
    background: var(--clr-surface);
    border-left: 1px solid var(--clr-border);
    overflow-y: auto;
    z-index: 50;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s ease;
}

.map-detail-panel.--open {
    transform: translateX(0);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.25);
}

.detail-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: var(--clr-surface);
    z-index: 1;
}

.detail-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.detail-header .health-badge {
    font-size: 0.65rem;
    padding: 0.15rem 0.5rem;
    border-radius: 99px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.health-badge.compliant { background: var(--clr-success-bg); color: var(--clr-success); }
.health-badge.attention { background: #fef3c7; color: #b45309; }
.health-badge.critical { background: var(--clr-alert-bg); color: var(--clr-alert); }
.health-badge.pending { background: hsl(210, 60%, 92%); color: hsl(210, 60%, 40%); }

.detail-body {
    padding: 1rem 1.25rem;
}

.detail-section {
    margin-bottom: 1.25rem;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section-title {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--clr-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

/* ── Jurisdiction Card in Detail Panel ──────────────────────────────────────── */

.jurisdiction-card {
    background: var(--clr-bg);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    margin-bottom: 0.75rem;
    transition: border-color 0.15s;
}

.jurisdiction-card:last-child {
    margin-bottom: 0;
}

.jurisdiction-card:hover {
    border-color: var(--clr-primary);
}

.jurisdiction-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
    font-weight: 600;
    font-size: 0.85rem;
}

.jurisdiction-card-header .level-badge {
    font-size: 0.62rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    background: var(--clr-surface-hover);
    color: var(--clr-text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.jurisdiction-card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem 0.75rem;
    font-size: 0.78rem;
}

.jurisdiction-card-grid .field-label {
    color: var(--clr-text-muted);
}

.jurisdiction-card-grid .field-value {
    font-weight: 500;
}

.jurisdiction-card-grid .field-value.alert { color: var(--clr-alert); font-weight: 600; }
.jurisdiction-card-grid .field-value.pending-color { color: hsl(210, 60%, 50%); }

.jurisdiction-card-actions {
    margin-top: 0.6rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--clr-border);
}

.jurisdiction-card-actions .link-cell {
    color: var(--clr-primary);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.78rem;
}

.jurisdiction-card-actions .link-cell:hover {
    text-decoration: underline;
}

/* ── Status Dots ────────────────────────────────────────────────────────────── */

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.35rem;
    vertical-align: middle;
}

.status-dot.active { background: var(--map-compliant); }
.status-dot.monitoring { background: var(--map-attention); }
.status-dot.inactive { background: var(--clr-text-muted); }
.status-dot.other { background: var(--clr-border); }

/* POA status badges */
.poa-badge {
    display: inline-block;
    font-size: 0.68rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
}

.poa-badge.accepted { background: var(--clr-success-bg); color: var(--clr-success); }
.poa-badge.expired { background: var(--clr-alert-bg); color: var(--clr-alert); }
.poa-badge.pending { background: hsl(210, 60%, 92%); color: hsl(210, 60%, 40%); }
.poa-badge.draft { background: var(--clr-surface-hover); color: var(--clr-text-muted); }

/* ── Empty State ────────────────────────────────────────────────────────────── */

.map-empty-hint {
    text-align: center;
    color: var(--clr-text-muted);
    font-size: 0.85rem;
    padding: 2rem;
}

.map-empty-hint i { margin-bottom: 0.5rem; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
    .map-stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .map-detail-panel {
        width: 340px;
    }
}

@media (max-width: 640px) {
    .map-stats-row {
        grid-template-columns: 1fr;
    }
}

/* ── Reduced Motion (Sprint 74 spec Appendix B) ────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .map-state,
    .map-stat-card,
    .compliance-map-container,
    .map-detail-panel,
    .map-tooltip {
        transition: none !important;
        animation: none !important;
    }
}
