/* ══════════════════════════════════════════════════════
   Church Directory — Frontend Styles
   Design tokens: COGOP brand system
   ══════════════════════════════════════════════════════ */

.cd-directory {
    --cd-burgundy: #BF0A30;
    --cd-navy: #1a2744;
    --cd-gold: #c9a227;
    --cd-gray: #6b7280;
    --cd-warm-bg: #faf8f5;
    --cd-white: #ffffff;
    --cd-shadow: 0 2px 8px rgba(26, 39, 68, 0.08);
    --cd-shadow-lg: 0 8px 30px rgba(26, 39, 68, 0.12);
    --cd-radius: 12px;

    font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--cd-navy);
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
}

.cd-directory *, .cd-directory *::before, .cd-directory *::after {
    box-sizing: border-box;
}

.cd-directory h1, .cd-directory h2, .cd-directory h3, .cd-directory h4 {
    font-family: 'Playfair Display', serif;
    line-height: 1.2;
}

/* ── Filter Bar ──────────────────────────────────────── */

.cd-filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: stretch;
}

.cd-search-wrap {
    flex: 1;
    min-width: 200px;
    min-height: 46px;
    position: relative;
}

.cd-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cd-gray);
    pointer-events: none;
}

.cd-search-input {
    width: 100%;
    height: 100%;
    padding: 0 0.75rem 0 2.75rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--cd-navy);
    background: var(--cd-white);
    transition: border-color 0.2s;
    outline: none;
}

.cd-search-input:focus {
    border-color: var(--cd-burgundy);
}

.cd-search-input::placeholder {
    color: #9ca3af;
}

.cd-select {
    padding: 0 1rem;
    height: 46px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--cd-navy);
    background: var(--cd-white);
    cursor: pointer;
    min-width: 160px;
    outline: none;
}

.cd-select:focus {
    border-color: var(--cd-burgundy);
}

/* ── Near Me Button ─────────────────────────────────── */

.cd-locate-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0 1rem;
    height: 46px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--cd-navy);
    background: var(--cd-white);
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
    white-space: nowrap;
}

.cd-locate-btn:hover {
    border-color: var(--cd-burgundy);
    color: var(--cd-burgundy);
    background: var(--cd-white);
}

.cd-locate-btn.cd-locate-active {
    border-color: #4285F4;
    color: #4285F4;
    background: rgba(66, 133, 244, 0.06);
}

.cd-locate-btn.cd-locating {
    opacity: 0.7;
    pointer-events: none;
}

.cd-locate-btn svg {
    flex-shrink: 0;
}

/* ── Radius Select ──────────────────────────────────── */

.cd-radius-select {
    min-width: 130px;
}

/* ── User Location Marker (Leaflet) ─────────────────── */

.cd-user-marker {
    background: transparent !important;
    border: none !important;
}

.cd-user-dot {
    width: 16px;
    height: 16px;
    background: #4285F4;
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(66, 133, 244, 0.25), 0 2px 6px rgba(0, 0, 0, 0.3);
    animation: cd-pulse 2s ease-in-out infinite;
}

@keyframes cd-pulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(66, 133, 244, 0.25), 0 2px 6px rgba(0, 0, 0, 0.3); }
    50% { box-shadow: 0 0 0 10px rgba(66, 133, 244, 0.1), 0 2px 6px rgba(0, 0, 0, 0.3); }
}

/* ── Distance Badge on Cards ────────────────────────── */

.cd-card-distance {
    font-size: 0.8rem;
    color: #4285F4;
    font-weight: 600;
    margin: 0.4rem 0 0;
}

.cd-card-distance::before {
    content: '\1F4CD\00a0';
}

/* ── Distance in Popup ──────────────────────────────── */

.cd-popup-distance {
    font-size: 0.82rem;
    color: #4285F4;
    font-weight: 600;
    margin: 0.25rem 0;
}

/* ── Social Media Links ─────────────────────────────── */

.cd-social-links {
    display: flex;
    gap: 0.5rem;
    margin: 0.5rem 0;
    flex-wrap: wrap;
}

.cd-card-body .cd-social-links {
    margin: 0.5rem 0 0;
}

.cd-social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: var(--cd-white) !important;
    text-decoration: none !important;
    transition: opacity 0.2s;
}

.cd-social-link:hover {
    opacity: 0.8;
}

.cd-social-fb { background: #1877F2; }
.cd-social-ig { background: #E4405F; }
.cd-social-x  { background: #000000; }
.cd-social-yt { background: #FF0000; }

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

.cd-map-container {
    position: relative;
    border-radius: var(--cd-radius);
    overflow: hidden;
    box-shadow: var(--cd-shadow);
    margin-bottom: 1.5rem;
}

/* Map overlay locate button */
.cd-map-locate {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    z-index: 1000;
    width: 40px;
    height: 40px;
    border-radius: 4px;
    border: none;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: color 0.2s, background 0.2s;
    padding: 0;
}
.cd-map-locate:hover {
    color: var(--cd-navy);
    background: #f5f5f5;
}
.cd-map-locate.cd-map-locate-active {
    color: var(--cd-burgundy);
}
.cd-map-locate.cd-map-locating {
    animation: cd-pulse 1s infinite;
}
@keyframes cd-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.cd-map {
    width: 100%;
    height: 450px;
    background: #e8eaed;
}

/* Leaflet custom marker */
.cd-marker-icon {
    background: transparent !important;
    border: none !important;
}

/* Map popup styling */
.cd-popup .leaflet-popup-content-wrapper {
    border-radius: 10px;
    padding: 0;
    overflow: hidden;
    box-shadow: var(--cd-shadow-lg);
}

.cd-popup .leaflet-popup-content {
    margin: 0;
    min-width: 220px;
    max-height: 380px;
    overflow-y: auto;
}

.cd-popup-content {
    font-family: 'Source Sans 3', sans-serif;
    padding: 0 0 1rem;
}

.cd-popup-img-wrap {
    width: 100%;
    height: 180px;
    overflow: hidden;
    flex-shrink: 0;
}

.cd-popup-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.cd-popup-content > *:not(.cd-popup-img-wrap) {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
}

.cd-popup-content > .cd-popup-dir {
    margin-left: 1.25rem;
    margin-right: 1.25rem;
    padding-left: 0;
    padding-right: 0;
}

.cd-popup-name {
    font-family: 'Playfair Display', serif;
    font-size: 1.05rem;
    font-weight: 700;
    margin: 1rem 0 0.25rem;
    color: var(--cd-navy);
}

.cd-popup-pastor {
    font-size: 0.85rem;
    color: var(--cd-burgundy);
    font-weight: 600;
    margin: 0 0 0.4rem;
}

.cd-popup-addr,
.cd-popup-phone,
.cd-popup-website,
.cd-popup-times {
    font-size: 0.82rem;
    color: var(--cd-gray);
    margin: 0.3rem 0;
    line-height: 1.4;
}

.cd-popup-times {
    white-space: pre-line;
}

.cd-popup-phone a {
    color: var(--cd-navy);
    text-decoration: none;
    font-weight: 500;
}

.cd-popup-phone a:hover {
    color: var(--cd-burgundy);
}

.cd-popup-website a {
    color: var(--cd-navy);
    text-decoration: none;
    font-weight: 500;
}
.cd-popup-website a:hover {
    color: var(--cd-burgundy);
}

.cd-popup-dir {
    display: block;
    text-align: center;
    padding: 0.6rem;
    margin: 0.75rem 0 0;
    background: var(--cd-burgundy);
    color: var(--cd-white) !important;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none !important;
    transition: background 0.2s;
}

.cd-popup-dir:hover {
    background: #a00828;
}

/* ── Carousel ────────────────────────────────────────── */

.cd-carousel-section {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.cd-carousel-track {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    padding: 0.5rem 0;
    flex: 1;
    scrollbar-width: none;
}

.cd-carousel-track::-webkit-scrollbar {
    display: none;
}

.cd-carousel-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #e5e7eb;
    background: var(--cd-white);
    color: var(--cd-navy);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.cd-carousel-btn:hover {
    border-color: var(--cd-burgundy);
    color: var(--cd-burgundy);
    background: var(--cd-white);
}

.cd-carousel-btn svg {
    stroke: currentColor;
}

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

.cd-card {
    flex: 0 0 260px;
    scroll-snap-align: start;
    background: var(--cd-white);
    border-radius: var(--cd-radius);
    box-shadow: var(--cd-shadow);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    border: 2px solid transparent;
}

.cd-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--cd-shadow-lg);
}

.cd-card-active {
    border-color: var(--cd-burgundy);
    box-shadow: 0 4px 20px rgba(191, 10, 48, 0.2);
}

.cd-card-img-wrap {
    width: 100%;
    height: 200px;
    overflow: hidden;
    flex-shrink: 0;
    background: linear-gradient(135deg, rgba(26, 39, 68, 0.06) 0%, rgba(191, 10, 48, 0.06) 100%);
}

.cd-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.cd-card-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(26, 39, 68, 0.06) 0%, rgba(191, 10, 48, 0.06) 100%);
    color: var(--cd-gray);
}

.cd-card-body {
    padding: 1rem;
}

.cd-card-name {
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--cd-navy);
    margin: 0 0 0.25rem;
    line-height: 1.3;
}

.cd-card-pastor {
    font-size: 0.85rem;
    color: var(--cd-burgundy);
    font-weight: 600;
    margin: 0 0 0.5rem;
}

.cd-card-location,
.cd-card-phone,
.cd-card-website,
.cd-card-times {
    font-size: 0.82rem;
    color: var(--cd-gray);
    margin: 0.2rem 0;
    line-height: 1.4;
}

.cd-card-phone::before {
    content: '\260E\00a0';
}

.cd-card-website a {
    color: var(--cd-navy);
    text-decoration: none;
}
.cd-card-website a:hover {
    color: var(--cd-burgundy);
}

.cd-card-times::before {
    content: '\23F0\00a0';
}

.cd-card-no-loc {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    color: #b45309;
    background: #fef3c7;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    margin-top: 0.4rem;
    line-height: 1;
}

.cd-card-no-loc svg {
    flex-shrink: 0;
}

.cd-unmapped-note {
    color: #b45309;
    font-weight: 600;
}

/* ── Results Info ────────────────────────────────────── */

.cd-results-info {
    font-size: 0.9rem;
    color: var(--cd-gray);
    text-align: center;
    margin-bottom: 1rem;
}

/* ── Loading ─────────────────────────────────────────── */

.cd-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 2rem;
    color: var(--cd-gray);
    font-size: 0.95rem;
}

.cd-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--cd-burgundy);
    border-radius: 50%;
    animation: cd-spin 0.8s linear infinite;
}

@keyframes cd-spin {
    to { transform: rotate(360deg); }
}

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

.cd-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    color: var(--cd-gray);
    text-align: center;
    gap: 0.75rem;
}

.cd-empty svg {
    opacity: 0.4;
}

.cd-empty p {
    font-size: 1rem;
    margin: 0;
}

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

/* Tablet */
@media (max-width: 900px) {
    .cd-map {
        height: 350px;
    }

    .cd-card {
        flex: 0 0 220px;
    }

    .cd-filter-bar {
        gap: 0.75rem;
    }
}

/* Large phone / small tablet */
@media (max-width: 768px) {
    .cd-filter-bar {
        flex-wrap: wrap;
    }

    .cd-search-wrap {
        flex: 1 1 100%;
        min-width: unset;
        order: 2;
    }

    .cd-locate-btn {
        order: 1;
        flex: 1;
    }

    .cd-select {
        flex: 1;
        min-width: unset;
        order: 3;
    }

    .cd-radius-select {
        order: 4;
        min-width: unset;
    }

    .cd-popup .leaflet-popup-content {
        min-width: 200px;
        max-height: 340px;
    }

    .cd-popup-content {
        padding: 0 0 0.75rem;
    }

    .cd-popup-content > *:not(.cd-popup-img-wrap) {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .cd-popup-content > .cd-popup-dir {
        margin-left: 1rem;
        margin-right: 1rem;
        padding-left: 0;
        padding-right: 0;
    }

    .cd-popup-img-wrap {
        height: 150px;
    }
}

/* Phone */
@media (max-width: 600px) {
    .cd-directory {
        padding: 0 0.5rem;
    }

    .cd-filter-bar {
        flex-direction: column;
        gap: 0.5rem;
    }

    .cd-search-wrap {
        order: unset;
        min-height: 48px;
    }

    .cd-select {
        width: 100%;
        min-width: unset;
        height: 48px;
        font-size: 1rem;
        order: unset;
    }

    .cd-locate-btn {
        width: 100%;
        justify-content: center;
        height: 48px;
        font-size: 1rem;
        order: unset;
    }

    .cd-radius-select {
        width: 100%;
        min-width: unset;
        order: unset;
    }

    .cd-search-input {
        font-size: 1rem;
        height: 48px;
    }

    .cd-map-container {
        border-radius: 8px;
        margin-bottom: 1rem;
    }

    .cd-map {
        height: 300px;
    }

    .cd-carousel-section {
        gap: 0;
        margin-bottom: 0.75rem;
    }

    .cd-carousel-track {
        gap: 0.75rem;
        padding: 0.25rem 0;
    }

    .cd-card {
        flex: 0 0 75vw;
        max-width: 280px;
    }

    .cd-card-img-wrap {
        height: 160px;
    }

    .cd-card-body {
        padding: 0.75rem;
    }

    .cd-card:hover {
        transform: none;
    }

    .cd-carousel-btn {
        display: none;
    }

    .cd-popup .leaflet-popup-content {
        min-width: 180px;
        max-height: 300px;
    }

    .cd-popup-content {
        padding: 0 0 0.75rem;
    }

    .cd-popup-content > *:not(.cd-popup-img-wrap) {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    .cd-popup-content > .cd-popup-dir {
        margin-left: 0.85rem;
        margin-right: 0.85rem;
        padding-left: 0;
        padding-right: 0;
    }

    .cd-popup-img-wrap {
        height: 140px;
    }

    .cd-popup-name {
        font-size: 0.95rem;
    }

    .cd-popup-pastor,
    .cd-popup-addr,
    .cd-popup-phone,
    .cd-popup-website,
    .cd-popup-times {
        font-size: 0.8rem;
    }

    .cd-popup-dir {
        padding: 0.65rem;
        font-size: 0.9rem;
    }

    .cd-results-info {
        font-size: 0.82rem;
    }

    .cd-empty {
        padding: 2rem 1rem;
    }
}

/* Small phone */
@media (max-width: 360px) {
    .cd-map {
        height: 250px;
    }

    .cd-card {
        flex: 0 0 85vw;
    }
}

/* Touch devices — disable hover lift on cards */
@media (hover: none) {
    .cd-card:hover {
        transform: none;
        box-shadow: var(--cd-shadow);
    }

    .cd-card-active:hover {
        box-shadow: 0 4px 20px rgba(191, 10, 48, 0.2);
    }
}

/* ── Google Maps popup overrides (when using Google provider) ── */

.gm-style .gm-style-iw-c {
    border-radius: 10px !important;
    padding: 0 !important;
}

.gm-style .gm-style-iw-d {
    overflow: auto !important;
    padding: 0 !important;
}

.gm-style .gm-style-iw-t::after {
    display: none;
}
