/**
 * Tiger Map Pro — front-end styles.
 *
 * Scoped under .tg-map so nothing leaks into the theme. Colours are driven by
 * CSS variables that Elementor's style controls write to .tg-map, so pins,
 * clusters and the geolocation marker all restyle with zero JS.
 */

.tg-map {
    --tiger-map-primary-color: #6366f1;
    --tiger-map-cluster-bg: var(--tiger-map-primary-color);
    --tiger-map-cluster-text: #ffffff;
    --tiger-map-cluster-size: 40px; /* small tier; md/lg scale up from this */
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* ---------- Toolbar / Find Near Me ---------- */
.tg-map-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.tg-map-geo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border: none;
    border-radius: 8px;
    background: #111827;
    color: #ffffff;
    font: inherit;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.15s ease;
}

.tg-map-geo:hover {
    transform: translateY(-1px);
    opacity: 0.92;
}

.tg-map-msg {
    font-size: 0.85em;
    opacity: 0.75;
}

/* ---------- Geocoding search ---------- */
.tg-map-search {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 8px;
    flex: 1 1 280px;
    max-width: 460px;
}

/* Selectors carry .tg-map + element (0,3,1 / 0,3,1) so the baseline outranks the
 * Elementor global kit form-field rule (`.elementor-kit-N input[type=text]`, 0,2,1)
 * that would otherwise force its own border + radius onto the field. Editor style
 * controls (ID-scoped) still override these freely. */
/* The hairline border is drawn with a box-shadow ring instead of `border`.
 * A 1px border on a rounded corner drops the top-left corner pixel when the
 * page renders at a fractional zoom (sub-pixel border + UA-forced overflow:clip
 * on inputs); a box-shadow ring hugs the radius and stays crisp at any zoom. */
.tg-map .tg-map-search input.tg-map-search-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 9px 12px;
    border: none;
    border-radius: 8px;
    box-shadow: 0 0 0 1px #d1d5db;
    font: inherit;
    line-height: 1.2;
    background: #fff;
    color: #111827;
}

.tg-map .tg-map-search input.tg-map-search-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--tiger-map-primary-color);
}

.tg-map .tg-map-search button.tg-map-search-btn {
    flex: 0 0 auto;
    padding: 9px 16px;
    border: none;
    border-radius: 8px;
    background: var(--tiger-map-primary-color);
    color: #fff;
    font: inherit;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
}

.tg-map-search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1000;
    margin: 0;
    padding: 4px;
    list-style: none;
    max-height: 280px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
}

.tg-map-search-item {
    padding: 9px 12px;
    border-radius: 7px;
    font-size: 0.9em;
    line-height: 1.35;
    color: #1f2937;
    cursor: pointer;
}

.tg-map-search-item:hover,
.tg-map-search-item:focus {
    background: color-mix(in srgb, var(--tiger-map-primary-color) 12%, #fff);
}

/* ---------- Map canvas (Leaflet mount point) ---------- */
.tg-map-canvas {
    position: relative; /* anchor for the fullscreen button overlay */
    width: 100%;
    height: 480px;
    min-height: 200px;
    flex: 1 1 auto;
    background: #e8eef3;
    z-index: 0; /* keep Leaflet panes under Elementor editor handles */
}

/* ---------- Fullscreen toggle (cross-provider) ----------
 * Selector intentionally carries element + two classes (0,2,1) so it outranks
 * Elementor's global kit button rule (`.elementor-kit-N button`, 0,2,0) that
 * would otherwise paint this control with the site's accent colour. */
.tg-map button.tg-map-fs {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 500; /* above tiles, below Leaflet popups (700) */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    color: #111827;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
    transition: background 0.15s ease, transform 0.15s ease;
}

.tg-map button.tg-map-fs:hover {
    background: #ffffff;
    transform: translateY(-1px);
}

/* Root in native fullscreen — make the canvas fill the viewport. */
.tg-map--fs,
.tg-map:fullscreen {
    width: 100%;
    height: 100%;
    background: #e8eef3;
}

.tg-map--fs .tg-map-canvas,
.tg-map:fullscreen .tg-map-canvas {
    height: 100% !important;
    border-radius: 0;
}

.tg-map-error {
    padding: 18px 20px;
    border: 1px dashed #d1d5db;
    border-radius: 10px;
    background: #f9fafb;
    color: #6b7280;
    font-size: 0.95em;
    text-align: center;
}

/* ---------- Custom SVG pin ---------- */
.tg-map-pin-wrap {
    background: none;
    border: none;
}

.tg-map-pin {
    display: block;
    color: var(--tiger-map-primary-color);
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
    line-height: 0;
}

/* ---------- Cluster bubbles ---------- */
.tg-map-cluster-wrap {
    background: none;
    border: none;
}

.tg-map-cluster {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--tiger-map-cluster-size);
    height: var(--tiger-map-cluster-size);
    border-radius: 50%;
    background: var(--tiger-map-cluster-bg);
    color: var(--tiger-map-cluster-text);
    font-weight: 700;
    font-size: 13px;
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--tiger-map-cluster-bg) 35%, transparent);
}

/* Medium/large tiers scale up from the base size var so the hierarchy survives
 * when the editor's "Bubble Size" control overrides --tiger-map-cluster-size. */
.tg-map-cluster--md {
    width: calc(var(--tiger-map-cluster-size) + 6px);
    height: calc(var(--tiger-map-cluster-size) + 6px);
    font-size: 14px;
}

.tg-map-cluster--lg {
    width: calc(var(--tiger-map-cluster-size) + 14px);
    height: calc(var(--tiger-map-cluster-size) + 14px);
    font-size: 15px;
}

/* ---------- Popups ---------- */
.tg-map-popup {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 220px;
}

.tg-map-popup-img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    border-radius: 6px;
}

.tg-map-popup-title {
    font-size: 1.02em;
    line-height: 1.3;
}

.tg-map-popup-text {
    margin: 0;
    font-size: 0.88em;
    opacity: 0.8;
}

.tg-map-popup-link {
    align-self: flex-start;
    font-weight: 600;
    color: var(--tiger-map-primary-color);
    text-decoration: none;
}

.tg-map-popup-link:hover {
    text-decoration: underline;
}

/* ---------- Responsive ---------- */
@media (max-width: 767px) {
    .tg-map-canvas {
        height: 360px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tg-map-geo {
        transition: none;
    }
}
