/* ==========================================================
   07 — Map Navigation, Icon Sizing, and Tooltips

   - Main navigation button stays in place
   - Directional arrows appear to its right
   - Navigation panel points toward the main button
   - Consistent 36px icon sizing
   - Keyboard-accessible hover/focus tooltips
   ========================================================== */

/* ----------------------------------------------------------
   07A — Shared icon sizing
   ---------------------------------------------------------- */

#rabid-map .rb-map-leaflet-btn {
    position: relative;
    display: inline-grid;
    place-items: center;
    flex: 0 0 36px;
    width: 36px;
    min-width: 36px;
    max-width: 36px;
    height: 36px;
    min-height: 36px;
    max-height: 36px;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    line-height: 1;
}

/* ----------------------------------------------------------
   07B — Navigation control positioning
   ---------------------------------------------------------- */

/* Only target the control containing the navigation arrows */
#rabid-map .rb-map-leaflet-controls:has(.rb-map-nav) {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    width: 42px;
    height: 42px;
    overflow: visible;
}

/* Keep the main navigation button fixed */
#rabid-map .rb-map-leaflet-controls:has(.rb-map-nav)>.rb-map-leaflet-btn {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
}

/* ----------------------------------------------------------
   07C — Floating directional arrow panel
   ---------------------------------------------------------- */

#rabid-map .rb-map-nav {
    position: absolute;
    top: 0;
    left: calc(100% + 8px);
    z-index: 1100;
    display: grid;
    grid-template-columns: repeat(2, 36px);
    grid-template-rows: repeat(2, 36px);
    gap: 4px;
    width: max-content;
    height: max-content;
    margin: 0;
    padding: 5px;
    background: #ffffff;
    border: 1px solid #c8d8e2;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgb(16 62 101 / 20%);
    overflow: visible;
}

/* Ensure collapsed navigation is actually hidden */
#rabid-map .rb-map-nav[hidden] {
    display: none !important;
}

/* Small arrow pointing toward the main control */
#rabid-map .rb-map-nav::before {
    content: "";
    position: absolute;
    top: 13px;
    left: -7px;
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-left: 1px solid #c8d8e2;
    border-bottom: 1px solid #c8d8e2;
    transform: rotate(45deg);
    pointer-events: none;
}

/* Directional arrow buttons */
#rabid-map .rb-map-nav .rb-map-leaflet-btn {
    position: relative;
    z-index: 1;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid #c8d8e2;
    border-radius: 4px;
    background: #ffffff;
    color: #103e65;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
}

/* Hover */
#rabid-map .rb-map-nav .rb-map-leaflet-btn:hover {
    background: #e8f3fb;
    border-color: #005a9c;
    color: #005a9c;
}

/* ----------------------------------------------------------
   07D — Tooltip styling
   ---------------------------------------------------------- */

#rabid-map .rb-map-leaflet-btn[data-tooltip]:hover::after,
#rabid-map .rb-map-leaflet-btn[data-tooltip]:focus-visible::after {
    content: attr(data-tooltip);
    position: absolute;
    z-index: 1300;
    top: 50%;
    left: calc(100% + 9px);
    transform: translateY(-50%);
    display: block;
    width: max-content;
    max-width: min(220px, 60vw);
    padding: 0.4rem 0.6rem;
    border-radius: 5px;
    background: #103e65;
    color: #ffffff;
    box-shadow: 0 3px 10px rgb(0 0 0 / 20%);
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.35;
    white-space: normal;
    text-align: left;
    pointer-events: none;
}

/* Keep the navigation and tooltip layers visible */
#rabid-map .rb-map-leaflet-controls,
#rabid-map .leaflet-top,
#rabid-map .leaflet-left {
    overflow: visible;
}

/* ----------------------------------------------------------
   07E — Keyboard accessibility
   ---------------------------------------------------------- */

#rabid-map .rb-map-leaflet-btn:focus-visible {
    outline: 3px solid #b84d00;
    outline-offset: 2px;
}

/* ----------------------------------------------------------
   07F — Mobile
   ---------------------------------------------------------- */

@media (max-width: 480px) {
    #rabid-map .rb-map-nav {
        left: calc(100% + 5px);
        gap: 3px;
        padding: 4px;
    }

    #rabid-map .rb-map-leaflet-btn[data-tooltip]:hover::after,
    #rabid-map .rb-map-leaflet-btn[data-tooltip]:focus-visible::after {
        max-width: min(170px, 50vw);
        font-size: 0.72rem;
    }
}

/* ----------------------------------------------------------
   07G — Reduced motion
   ---------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    #rabid-map .rb-map-leaflet-btn {
        transition: none;
    }
}

#rabid-map .leaflet-top.leaflet-left {
    z-index: 1200;
}

#rabid-map .rb-map-leaflet-controls:has(.rb-map-nav) {
    z-index: 1201;
}

/* ==========================================================
   08 — Default Leaflet Zoom Controls

   Matches the custom Rabies map controls:
   - Consistent 36px width and height
   - Public Health blue icons
   - Accessible hover and focus tooltips
   - Matching hover, focus, and disabled states
   ========================================================== */

/* Zoom control container */
#rabid-map .leaflet-control-zoom {
    display: flex;
    flex-direction: column;
    gap: 3px;

    padding: 3px;
    margin: 0;

    background: #ffffff;
    border: 0;
    border-radius: 5px;

    box-shadow: 0 2px 9px rgb(16 62 101 / 18%);
    overflow: visible;
}

/* Shared Zoom In / Zoom Out styling */
#rabid-map .leaflet-control-zoom a.leaflet-control-zoom-in,
#rabid-map .leaflet-control-zoom a.leaflet-control-zoom-out {
    position: relative;

    display: inline-grid;
    place-items: center;

    flex: 0 0 36px;

    width: 36px;
    min-width: 36px;
    max-width: 36px;

    height: 36px;
    min-height: 36px;
    max-height: 36px;

    margin: 0;
    padding: 0;

    border: 1px solid #c8d8e2;
    border-radius: 4px;

    background: #ffffff;
    color: #103e65 !important;

    font-family: Arial, sans-serif;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;

    text-align: center;
    text-decoration: none;

    box-sizing: border-box;

    transition:
        background-color 180ms ease,
        border-color 180ms ease,
        color 180ms ease;
}

/* Center the default + and − symbols */
#rabid-map .leaflet-control-zoom a span {
    display: grid;
    place-items: center;

    width: 100%;
    height: 100%;

    font: inherit;
    line-height: 1;
}

/* Hover */
#rabid-map .leaflet-control-zoom a:hover:not(.leaflet-disabled) {
    background: #e8f3fb;
    border-color: #005a9c;
    color: #005a9c !important;
}

/* Keyboard focus */
#rabid-map .leaflet-control-zoom a:focus-visible {
    outline: 3px solid #b84d00;
    outline-offset: 3px;
}

/* Disabled state */
#rabid-map .leaflet-control-zoom a.leaflet-disabled {
    background: #f1f5f9;
    border-color: #d5dfe6;
    color: #64748b !important;
    cursor: not-allowed;
}

/* ==========================================================
   Zoom Control Hover and Focus Tooltips
   ========================================================== */

#rabid-map .leaflet-control-zoom a:hover::after,
#rabid-map .leaflet-control-zoom a:focus-visible::after {
    position: absolute;
    z-index: 1300;
    top: 50%;
    left: calc(100% + 9px);
    transform: translateY(-50%);
    display: block;
    width: max-content;
    max-width: min(220px, 60vw);

    padding: 0.4rem 0.6rem;
    border-radius: 5px;
    background: #103e65;
    color: #ffffff;
    box-shadow: 0 3px 10px rgb(0 0 0 / 20%);
    font-family: Arial, sans-serif;
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.35;

    white-space: normal;
    text-align: left;
    pointer-events: none;
}

/* Zoom In tooltip */
#rabid-map .leaflet-control-zoom-in:hover::after,
#rabid-map .leaflet-control-zoom-in:focus-visible::after {
    content: "Zoom in";
}

/* Zoom Out tooltip */
#rabid-map .leaflet-control-zoom-out:hover::after,
#rabid-map .leaflet-control-zoom-out:focus-visible::after {
    content: "Zoom out";
}

/* ==========================================================
   Responsive Tooltips
   ========================================================== */

@media (max-width: 480px) {

    #rabid-map .leaflet-control-zoom a:hover::after,
    #rabid-map .leaflet-control-zoom a:focus-visible::after {
        max-width: min(170px, 50vw);
        font-size: 0.72rem;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    #rabid-map .leaflet-control-zoom a {
        transition: none;
    }
}



/* ==========================================================
   Rabies Map — Detection Status Badge
   ========================================================== */

#rabid-map .live-map-box {
    position: relative;
}

#rabid-map .rb-map-status {
    position: absolute;
    left: 2px;
    bottom: 2px;
    z-index: 1000;
    width: max-content;
    max-width: calc(100% - 28px);
    margin: 0 !important;
    padding: 8px 12px;
    background: #fff;
    color: #003b69;
    border: 1px solid #b8d7ea;
    border-left: 4px solid #005a9c;
    border-right: 4px solid #005a9c;
    border-radius: 6px;

    box-shadow: 0 3px 12px rgb(0 0 0 / 16%);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.4;
    /*text-transform: capitalize;*/
    pointer-events: none;
}

@media (max-width: 576px) {
    #rabid-map .rb-map-status {
        left: 8px;
        bottom: 30px;
        padding: 6px 9px !important;
        font-size: 0.72rem;
    }
}

/* ==========================================================
   Latest Displayed Rabies Detection
   - Gold outer ring; preserves bat/raccoon marker colors
   - Only the newest dated marker in current displayed results
   - No animation for visitors who prefer reduced motion
   ========================================================== */
#rabid-map .rb-map-detection-icon.rb-map-detection-latest {
    z-index: 1;
}

#rabid-map .rb-map-detection-icon.rb-map-detection-latest .rb-map-detection-dot {
    position: relative;
    border-color: #fff;
    box-shadow: 0 0 0 3px #d8941f, 0 2px 8px rgb(0 0 0 / 24%);
}

#rabid-map .rb-map-detection-icon.rb-map-detection-latest .rb-map-detection-dot::after {
    content: '';
    position: absolute;
    inset: -8px;
    border: 2px solid #d8941f;
    border-radius: 50%;
    pointer-events: none;
    animation: rb-latest-pulse 2.4s ease-out infinite;
}

#rabid-map .rb-map-detection-icon.rb-map-detection-latest.rb-map-detection-selected .rb-map-detection-dot {
    box-shadow: 0 0 0 3px #103e65, 0 0 0 6px #d8941f;
}

#rabid-map .rb-map-popup__latest {
    display: inline-block;
    margin: 0.25rem 0 .65rem;
    padding: .28rem .55rem;
    border: 1px solid #e8ca8d;
    border-radius: 4px;
    background: #fff8e9;
    color: #704800;
    font-size: .76rem;
    font-weight: 700;
    line-height: 1.4;
}

@keyframes rb-latest-pulse {
    0% {
        transform: scale(.68);
        opacity: .85;
    }

    75%,
    100% {
        transform: scale(1.65);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    #rabid-map .rb-map-detection-icon.rb-map-detection-latest .rb-map-detection-dot::after {
        animation: none;
        inset: -6px;
        opacity: 1;
    }
}

/* Mobile panel is positioned beneath the Leaflet map. Keep status in normal flow. */
@media (max-width: 768px) {
    #rabid-map .live-map-box>.rb-map-status {
        position: relative;
        inset: auto;
        order: 2;
        width: auto;
        max-width: 100%;
        margin: 0 !important;
        border-radius: 0;
        box-shadow: none;
        pointer-events: none;
        padding-top: 8px;
    }
}