@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --phca-bg: #f7f8f5;
    --phca-primary: #1e3a5f;
    /* deep navy — matches site logo */
    --phca-primary-soft: rgba(30, 58, 95, 0.1);
    --phca-primary-dark: #0f2240;
    --phca-accent: #8db535;
    /* olive-green — matches EMAIL US button */
    --phca-accent-soft: rgba(141, 181, 53, 0.14);
    --phca-accent-dark: #6f9128;
    --phca-text: #1a2942;
    --phca-text-2: #3a4a64;
    --phca-muted: #6a7689;
    --phca-border: rgba(148, 163, 184, 0.22);
    --phca-border-soft: rgba(148, 163, 184, 0.14);
    --phca-glass: rgba(255, 255, 255, 0.92);
    --phca-shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.04);
    --phca-shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
    --phca-shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.1);
}

/* ============================================================
   Container & layout
   ============================================================ */

.phca-map-container {
    font-family: 'Outfit', system-ui, -apple-system, sans-serif;
    color: var(--phca-text);
    padding: 32px 20px;
    max-width: 1320px;
    margin: 0 auto;
    line-height: 1.5;
}

.phca-map-header {
    text-align: center;
    margin-bottom: 36px;
}

.phca-map-header h1 {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 800;
    color: var(--phca-primary);
    margin: 0 0 12px;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.phca-map-subtitle {
    color: var(--phca-muted);
    font-size: 1rem;
    font-weight: 400;
    margin: 0;
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
}

/* Member map uses full-width layout (popup replaces side panel). */
.phca-map-section-full {
    width: 100%;
}

/* Legacy two-column grid — only used if .phca-layout-grid is present (kept for back-compat) */
.phca-layout-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    align-items: start;
}

@media (min-width: 968px) {
    .phca-layout-grid {
        grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr);
        gap: 28px;
    }
}

.phca-glass-panel {
    background: var(--phca-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--phca-border);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--phca-shadow-md);
}

@media (min-width: 640px) {
    .phca-glass-panel {
        padding: 28px;
    }
}

/* ============================================================
   Map (Leaflet)
   ============================================================ */

.phca-county-map {
    width: 100%;
    height: clamp(440px, 65vh, 680px);
    border-radius: 14px;
    background: transparent;
}

.center-map-layout .phca-county-map {
    height: clamp(400px, 55vh, 540px);
}

/* Centers map is the hero element — let it run wider than the default container */
.center-map-layout .map-shell {
    padding: 16px;
}

/* ============================================================
   Training Center map — ZIP / radius search
   ============================================================ */

.phca-center-search {
    margin-bottom: 18px;
}

.phca-center-search-fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    align-items: end;
}

@media (min-width: 640px) {
    .phca-center-search-fields {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
        gap: 16px;
    }
}

.phca-search-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.phca-search-field label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--phca-muted);
}

.phca-search-field input,
.phca-search-field select {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--phca-border);
    border-radius: 10px;
    background: #fff;
    color: var(--phca-text);
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.2;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
    appearance: none;
    -webkit-appearance: none;
}

.phca-search-field select {
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236a7689' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    cursor: pointer;
}

.phca-search-field input:focus,
.phca-search-field select:focus {
    outline: none;
    border-color: var(--phca-accent);
    box-shadow: 0 0 0 3px var(--phca-accent-soft);
}

.phca-center-search-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.phca-search-btn,
.phca-search-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 20px;
    border-radius: 10px;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
    border: 1px solid transparent;
    white-space: nowrap;
}

.phca-search-btn {
    flex: 1 1 auto;
    background: var(--phca-primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(30, 58, 95, 0.22);
}

.phca-search-btn:hover:not(:disabled) {
    background: var(--phca-primary-dark);
    transform: translateY(-1px);
}

.phca-search-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

/* Loading state is driven by the form class so the label always resets reliably */
.phca-center-search.is-searching .phca-search-btn {
    position: relative;
    pointer-events: none;
    opacity: 0.88;
    cursor: wait;
}

.phca-center-search.is-searching .phca-search-btn .phca-search-btn-label {
    visibility: hidden;
}

.phca-center-search.is-searching .phca-search-btn::after {
    content: 'Searching…';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 600;
}

.phca-search-reset {
    flex: 1 1 auto;
    background: #fff;
    color: var(--phca-primary);
    border-color: var(--phca-border);
}

.phca-search-reset:hover {
    background: var(--phca-primary-soft);
    border-color: rgba(30, 58, 95, 0.25);
}

.phca-center-search-status {
    margin: 12px 0 0;
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--phca-muted);
    min-height: 0;
}

.phca-center-search-status:not(:empty) {
    min-height: 1.45em;
}

.phca-center-search-status.is-success {
    color: var(--phca-accent-dark);
    font-weight: 500;
}

.phca-center-search-status.is-error {
    color: #b91c1c;
    font-weight: 500;
}

.phca-center-search-status.is-muted {
    color: var(--phca-muted);
}

.phca-popup-distance {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--phca-border-soft);
    font-size: 12px;
    font-weight: 600;
    color: var(--phca-accent-dark);
}

.phca-search-origin-pin {
    display: flex;
    align-items: center;
    justify-content: center;
}

.phca-origin-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--phca-accent);
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(15, 34, 64, 0.35);
    display: block;
}

@media (max-width: 639px) {
    .phca-center-search-actions {
        width: 100%;
    }

    .phca-search-btn,
    .phca-search-reset {
        flex: 1 1 calc(50% - 5px);
    }
}

.phca-county-map .leaflet-container {
    background: transparent !important;
    font-family: 'Outfit', sans-serif !important;
    outline: none;
}

.phca-county-map .leaflet-interactive {
    cursor: pointer;
    transition: fill-opacity 0.2s ease, stroke-width 0.2s ease;
}

/* Tooltip on county hover */
.phca-county-tooltip {
    background: var(--phca-text) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 7px 12px !important;
    font-size: 12.5px !important;
    font-weight: 600 !important;
    font-family: 'Outfit', sans-serif !important;
    letter-spacing: 0.01em !important;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.22) !important;
}

.phca-county-tooltip::before {
    display: none !important;
}

/* Legend below the map */
.phca-map-legend {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 20px;
    font-size: 13px;
    color: var(--phca-muted);
    flex-wrap: wrap;
    font-weight: 500;
}

.phca-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.phca-swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    display: inline-block;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.phca-swatch.has-members {
    background: var(--phca-primary);
}

.phca-swatch.no-members {
    background: #cbd5e1;
}

.phca-map-error {
    padding: 40px;
    text-align: center;
    color: #b91c1c;
    font-weight: 500;
}

/* ============================================================
   Info panel (right column) — county header + member cards
   ============================================================ */

.info-section {
    max-height: 620px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
}

.info-section::-webkit-scrollbar {
    width: 6px;
}

.info-section::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 3px;
}

/* County header */
.phca-info-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--phca-border-soft);
}

.phca-info-title {
    min-width: 0;
}

.phca-info-eyebrow {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--phca-muted);
    display: block;
    margin-bottom: 4px;
}

/* HARD override — WP themes love to inject huge sizes for h1-h3 */
.phca-info-header h3,
.info-section h3 {
    margin: 0 !important;
    font-size: 1.6rem !important;
    line-height: 1.2 !important;
    font-weight: 700 !important;
    color: var(--phca-text) !important;
    font-family: 'Outfit', sans-serif !important;
    letter-spacing: -0.01em !important;
}

.phca-info-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--phca-primary);
    background: var(--phca-primary-soft);
    padding: 5px 11px;
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 4px;
}

/* Empty states */
.phca-empty-state,
.phca-empty-county {
    text-align: center;
    padding: 50px 16px 32px;
    color: var(--phca-muted);
}

.phca-empty-state-icon,
.phca-empty-icon {
    color: rgba(148, 163, 184, 0.55);
    width: 56px;
    height: 56px;
    margin: 0 auto 18px;
}

.phca-empty-state-icon svg,
.phca-empty-icon svg {
    width: 100%;
    height: 100%;
}

.phca-empty-state h3 {
    color: var(--phca-text) !important;
    font-size: 1.15rem !important;
    margin: 0 0 8px !important;
    font-weight: 700 !important;
    font-family: 'Outfit', sans-serif !important;
}

.phca-empty-state p,
.phca-empty-county p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

/* Member list */
.phca-member-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.phca-member-item {
    background: #fff;
    border: 1px solid var(--phca-border-soft);
    border-radius: 14px;
    padding: 16px 18px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    position: relative;
}

.phca-member-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--phca-shadow-md);
    border-color: rgba(37, 99, 235, 0.35);
}

.phca-member-head {
    margin-bottom: 10px;
}

/* HARD override — block theme styles on the name */
.phca-member-item .phca-member-name {
    display: block;
    font-family: 'Outfit', sans-serif !important;
    font-size: 0.98rem !important;
    line-height: 1.35 !important;
    font-weight: 700 !important;
    color: var(--phca-text) !important;
    text-decoration: none !important;
    letter-spacing: -0.005em !important;
}

.phca-member-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.phca-member-meta {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    color: var(--phca-muted);
    font-weight: 400;
    line-height: 1.45;
    margin: 0;
}

.phca-member-meta .phca-icon {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    margin-top: 2px;
    color: var(--phca-muted);
    opacity: 0.85;
}

.phca-member-meta a {
    color: var(--phca-text-2);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease;
}

.phca-member-meta a:hover {
    color: var(--phca-accent);
}

/* CTA button — site link */
.phca-member-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 7px 14px;
    background: var(--phca-accent-soft);
    color: var(--phca-accent) !important;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none !important;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
    font-family: 'Outfit', sans-serif;
    line-height: 1.2;
}

.phca-member-cta:hover {
    background: var(--phca-accent);
    color: #fff !important;
    transform: translateX(2px);
}

.phca-member-cta .phca-icon {
    width: 12px;
    height: 12px;
    color: currentColor;
}

/* ============================================================
   Training Center map — Leaflet pins + popup
   ============================================================ */

.phca-leaflet-pin {
    display: flex;
    align-items: center;
    justify-content: center;
}

.phca-pin-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--phca-primary);
    /* Precise (ok) — solid navy, primary brand */
    border: 3px solid #fff;
    box-shadow: 0 2px 6px rgba(15, 34, 64, 0.3);
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    display: block;
}

.phca-leaflet-pin:hover .phca-pin-dot {
    transform: scale(1.4);
    background: var(--phca-accent);
    /* hover shifts to olive — pleasing brand-aligned swap */
    box-shadow: 0 4px 12px rgba(15, 34, 64, 0.4);
}

/* City-level (approx) — solid olive-green */
.phca-leaflet-pin.approx .phca-pin-dot {
    background: var(--phca-accent);
}

.phca-leaflet-pin.approx:hover .phca-pin-dot {
    background: var(--phca-primary);
}

/* County-centroid fallback — hollow navy ring (least precise, downplayed) */
.phca-leaflet-pin.county .phca-pin-dot {
    background: #fff;
    border-color: var(--phca-primary);
    border-width: 2px;
}

.phca-leaflet-pin.county:hover .phca-pin-dot {
    background: var(--phca-primary);
}

/* Leaflet popup card override */
.phca-leaflet-popup .leaflet-popup-content-wrapper {
    border-radius: 14px;
    padding: 4px;
    box-shadow: var(--phca-shadow-lg);
    background: #fff;
}

.phca-leaflet-popup .leaflet-popup-content {
    margin: 16px 18px;
    font-family: 'Outfit', sans-serif !important;
    line-height: 1.45;
}

.phca-leaflet-popup .leaflet-popup-tip {
    background: #fff;
}

.phca-popup-card h4 {
    margin: 0 0 10px !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    color: var(--phca-text) !important;
    font-family: 'Outfit', sans-serif !important;
    line-height: 1.3 !important;
}

.phca-popup-line {
    font-size: 12.5px;
    color: var(--phca-muted);
    margin: 4px 0;
    display: flex;
    align-items: flex-start;
    gap: 7px;
    line-height: 1.45;
}

.phca-popup-line .phca-icon {
    flex-shrink: 0;
    width: 13px;
    height: 13px;
    margin-top: 2px;
    color: var(--phca-muted);
    opacity: 0.85;
}

.phca-popup-line a {
    color: var(--phca-text-2);
    text-decoration: none;
    font-weight: 500;
}

.phca-popup-line a:hover {
    color: var(--phca-accent);
}

.phca-popup-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    padding: 6px 11px;
    background: var(--phca-accent-soft);
    color: var(--phca-accent) !important;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none !important;
    border-radius: 7px;
    transition: background 0.18s ease, color 0.18s ease;
}

.phca-popup-link:hover {
    background: var(--phca-accent);
    color: #fff !important;
}

/* ============================================================
   Responsive tweaks
   ============================================================ */

@media (max-width: 640px) {
    .phca-map-container {
        padding: 20px 14px;
    }

    .phca-glass-panel {
        padding: 20px;
        border-radius: 16px;
    }

    .phca-map-header {
        margin-bottom: 24px;
    }

    .info-section {
        max-height: none;
    }

    .phca-info-header h3,
    .info-section h3 {
        font-size: 1.35rem !important;
    }
}

/* ============================================================
   County-detail modal (replaces the right-side info panel)
   ============================================================ */
.phca-modal[hidden] {
    display: none !important;
}

body.phca-modal-open {
    overflow: hidden;
}

.phca-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    transition: opacity 0.22s ease;
}

.phca-modal.is-open {
    opacity: 1;
}

.phca-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 34, 64, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    cursor: pointer;
}

.phca-modal-panel {
    position: relative;
    z-index: 1;
    width: min(640px, 100%);
    max-height: calc(100vh - 48px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 30px 80px rgba(15, 34, 64, 0.3);
    transform: translateY(12px) scale(0.98);
    transition: transform 0.22s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.phca-modal.is-open .phca-modal-panel {
    transform: translateY(0) scale(1);
}

.phca-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 34, 64, 0.06);
    color: var(--phca-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
    z-index: 2;
}

.phca-modal-close:hover {
    background: var(--phca-primary);
    color: #fff;
    transform: rotate(90deg);
}

.phca-modal-close svg {
    width: 18px;
    height: 18px;
}

.phca-modal-body {
    padding: 28px 28px 24px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
}

.phca-modal-body::-webkit-scrollbar {
    width: 6px;
}

.phca-modal-body::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 3px;
}

/* Modal content uses the same .phca-info-header / .phca-member-list classes,
   so the existing typography just carries over. Only override what needs to differ inside a modal. */
.phca-modal-body .phca-info-header {
    padding-right: 40px;
    /* clear room for close button */
}

.phca-modal-body .phca-member-list {
    margin-top: 4px;
}

@media (max-width: 640px) {
    .phca-modal {
        padding: 12px;
    }

    .phca-modal-panel {
        max-height: calc(100vh - 24px);
        border-radius: 14px;
    }

    .phca-modal-body {
        padding: 22px 18px 18px;
    }
}