/* Fix 1: Premium Pin Styles */
.custom-bark-marker {
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
    border: none;
}

/* Optimized Enamel Pin Wrapper */
.enamel-pin-wrapper {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;

    /* No base transition or GPU reservation: avoids zoom-out layer pressure. */
}

/* Hover effects stay active for premium mode */
.enamel-pin-wrapper:hover {
    transform: scale(1.15) translateY(-2px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}


/* =========================================
   🛡️ LOW GRAPHICS OVERRIDE
   ========================================= */

/* 🚫 KILL SPINNING PINS IN REGULAR LOW-GFX */
body.low-graphics .enamel-pin-wrapper,
body.low-graphics .cluster-enamel-wrapper {
    transition: none !important;
    animation: none !important;
    transform: none !important;
    will-change: auto !important;
}

/* Ensure they appear instantly without the Leaflet "fade-in" */
body.low-graphics .leaflet-marker-icon,
body.low-graphics .leaflet-marker-shadow {
    transition: none !important;
    animation: none !important;
}

/* Kill Leaflet's own internal animation surfaces */
body.low-graphics .leaflet-zoom-animated {
    transition: none !important;
}

body.low-graphics .leaflet-marker-pane,
body.low-graphics .leaflet-marker-pane * {
    transition: none !important;
    animation: none !important;
    will-change: auto !important;
}

/* Kill the custom-bark-marker fade-in */
body.low-graphics .custom-bark-marker,
body.low-graphics .custom-bark-marker * {
    transition: none !important;
    animation: none !important;
}

/* Keep the pins flat and fast */
body.low-graphics .enamel-pin-wrapper:hover {
    transform: none !important;
}

/* 🛑 FILTER AND HIDE: Pure CSS visibility toggle — NO Leaflet API calls */
/* Uses visibility: hidden instead of opacity: 0 to avoid triggering ANY transitions/animations */
.marker-filter-hidden {
    visibility: hidden !important;
    pointer-events: none !important;
}

.enamel-pin-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    box-sizing: border-box;
    display: block;
    pointer-events: none;
}

.custom-bark-marker.unvisited-marker .enamel-pin-wrapper {
    opacity: 0.92;
    transform: scale(0.95);
}

/* 
 * Visited markers are now styled dynamically via the 'visited-pin' class
 * in styles.css. This class is intentionally inert to prevent recycling bugs.
 */
.custom-bark-marker.visited-marker .enamel-pin-wrapper {
    opacity: 1;
    transform: scale(1.0);
}

.custom-bark-marker.visited-marker {
    z-index: 500 !important;
}

.custom-bark-marker.active-pin:not(.visited-pin) .enamel-pin-wrapper {
    transform: scale(1.3) translateY(-4px);
    box-shadow:
        0 0 0 3px #FBBF24,
        0 15px 30px rgba(0, 0, 0, 0.6),
        0 0 25px rgba(250, 204, 21, 1);
    z-index: 1000 !important;
}

.custom-bark-marker.visited-pin.active-pin .enamel-pin-wrapper {
    transform: scale(1.12) translateY(-2px);
    box-shadow:
        0 0 0 3px #FBBF24,
        0 7px 16px rgba(0, 0, 0, 0.42),
        0 0 18px rgba(250, 204, 21, 0.8) !important;
    z-index: 1000 !important;
}

/* --- PREMIUM FILTER UI --- */
.premium-filters-section {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.filter-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.1);
    width: 100%;
    margin-bottom: 5px;
}

.premium-label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 800;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.premium-controls {
    display: flex;
    gap: 10px;
}

.premium-trail-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
}

.premium-trail-btn {
    align-items: center;
    justify-content: center;
    min-width: 0;
    white-space: nowrap;
    font-size: 11px;
    padding: 8px 7px;
}

.premium-select {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    font-size: 12px;
    color: #334155;
    background: white;
    outline: none;
    cursor: pointer;
}

/* Locked State Styles */
.premium-locked .premium-select {
    background: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
    opacity: 0.7;
}

.premium-locked .premium-trail-btn {
    background: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
    opacity: 0.72;
}

.premium-locked .premium-trail-btn.active {
    background: #f1f5f9;
    color: #94a3b8;
    box-shadow: none;
}

.premium-unlocked #premium-lock-icon {
    display: none;
    /* Hide the lock when logged in */
}

/* --- MOBILE RESPONSIVENESS FOR PREMIUM FILTERS --- */
@media (max-width: 600px) {
    .premium-controls {
        flex-direction: column;
        gap: 8px;
    }

    .premium-trail-controls {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .premium-select {
        width: 100%;
        font-size: 14px;
        /* Slightly larger text on mobile prevents iOS Safari from auto-zooming when clicked */
        padding: 10px;
    }
}

/* --- TRIP PLANNER VISUALS --- */
/* Trip stop badges moved to TripLayerManager (Fix #19). Old .trip-stop-badge
 * was a child of the park marker icon and got destroyed by cluster rebuilds.
 * See styles.css "TRIP OVERLAY" section for the replacement. */

.trip-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(50px);
    background: #1e293b;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 99999;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.trip-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* --- UI/UX MASTERCLASS REFACTOR --- */
.trip-node-card {
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.stop-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-radius: 10px;
    transition: background 0.2s ease;
}

.stop-item:hover {
    background: rgba(0, 0, 0, 0.02);
}

.stop-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    opacity: 0.3;
    transition: opacity 0.2s ease;
}

.stop-item:hover .stop-controls {
    opacity: 1;
}

.ghost-btn {
    background: transparent;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 14px;
    color: #64748b;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ghost-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #334155;
}

.planner-metadata {
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
}

/* =========================================
    PREMIUM B.A.R.K. LOGO CLUSTERS (V2)
   ========================================= */

.bark-cluster-marker {
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
    border: none;
}

/* The Main Enamel Pin (Flat Metal Style) */
.cluster-enamel-wrapper {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    position: relative;

    /* Heavy black metal base */
    border: 3px solid #111111;
    background-color: #111111;

    /* THE FIX: Deep, heavy drop shadow + a microscopic dark inner shadow 
       to create a physical "lip", making it look recessed like a coin. */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4), inset 0 3px 6px rgba(0, 0, 0, 0.3);

    /* Flexbox to keep the logo perfectly in the middle */
    display: flex;
    justify-content: center;
    align-items: center;

    transition: none;
}

/* The Logo Image */
.cluster-enamel-wrapper img {
    /* THE FIX: Scaled to 98% instead of 100%. 
       This prevents the image from warping over the edges, 
       keeping it completely flat in the center of the black rim. */
    width: 98%;
    height: 98%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
    pointer-events: none;
    margin: 0;
    padding: 0;
    border: none;
}

/* The Metallic Number Badge (Docked top-right) */
.cluster-count-badge {
    position: absolute;
    top: -8px;
    /* Slightly adjusted to clear the thicker border */
    right: -8px;

    background: linear-gradient(135deg, #0f172a 0%, #334155 100%);

    /* 4. THE FIX: Match the badge border to the heavy black rim */
    border: 2px solid #111111;
    border-radius: 50%;

    min-width: 24px;
    height: 24px;
    padding: 0 4px;

    color: #ffffff;
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 12px;

    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

/* Hover "Pop" Effect */
.cluster-enamel-wrapper:hover {
    transform: scale(1.12);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

/* Hardware Guard for Clusters */
body.low-graphics .cluster-enamel-wrapper,
body.low-graphics .cluster-count-badge {
    box-shadow: none !important;
    transform: none !important;
    transition: none !important;
}

body.low-graphics .cluster-count-badge {
    background: #1e293b !important;
    /* Flat slate color instead of gradient */
}

/* =========================================
    🛡️ ULTRA-LOW PERFORMANCE SLEDGEHAMMER
   ========================================= */

/* The Ultra-Low Sledgehammer: Kill every single animation and decorative effect */
body.ultra-low * {
    transition: none !important;
    animation: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
    border-radius: 0 !important;
    /* Round corners are surprisingly expensive to render */
}

/* Stop smooth image scaling during zooms */
body.ultra-low img {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Hide non-essential decorative UI */
body.ultra-low .streak-badge,
body.ultra-low .confetti-canvas,
body.ultra-low .glass-overlay,
body.ultra-low .cluster-count-badge {
    display: none !important;
}

/* Hardware Guard for Clusters (Already handles some, but ultra-low is global) */
body.ultra-low .cluster-enamel-wrapper {
    box-shadow: none !important;
    transform: none !important;
    transition: none !important;
    border-width: 1px !important;
}
