/* ==========================================================
   RABIES SURVEILLANCE MAP — HELP DIALOG
   Author: Roberto Flores
   Organization: Los Angeles County Department of Public Health

   Purpose:
   - Accessible, responsive help modal in normal/fullscreen map mode
   - Icon-led instruction headings and emphasized action terms
   - Optional per-step screenshots and captions; hide empty galleries
   - Keyboard focus, mobile scrolling, and reduced-motion support

   Load AFTER the main rabies map stylesheet. This file replaces
   earlier help-dialog, help-image, and help-heading-icon overrides.
   ========================================================== */

/* 01 — Theme and modal frame */
:is(#rabid-map, body) .rb-map-help {
    --rb-help-primary: #005a9c;
    --rb-help-deep: #103e65;
    --rb-help-ink: #344f62;
    --rb-help-border: #d5e4ed;
    --rb-help-focus: #f3a744;
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(10px, 3vw, 28px);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: rgb(9 27 44 / 78%);
    box-sizing: border-box;
}

:is(#rabid-map, body) .rb-map-help *,
:is(#rabid-map, body) .rb-map-help *::before,
:is(#rabid-map, body) .rb-map-help *::after {
    box-sizing: border-box;
}

:is(#rabid-map, body) .rb-map-help-dialog {
    display: flex;
    flex-direction: column;
    width: min(100%, 760px);
    max-height: min(90dvh, 900px);
    margin: auto;
    overflow: hidden;
    border: 1px solid #cbdde9;
    border-radius: 12px;
    background: #fff;
    color: #243e50;
    box-shadow: 0 20px 65px rgb(0 0 0 / 35%);
    font-family: inherit;
}

/* 02 — Fixed header and close button */
:is(#rabid-map, body) .rb-map-help-header {
    display: flex;
    flex: 0 0 auto;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 24px;
    background: var(--rb-help-primary);
    color: #fff;
}

:is(#rabid-map, body) .rb-map-help-header-text {
    flex: 1 1 auto;
    min-width: 0;
}

:is(#rabid-map, body) .rb-map-help-eyebrow {
    display: block;
    margin-bottom: 5px;
    color: #e0f0fb;
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .1em;
    line-height: 1.3;
}

:is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-header h3 {
    margin: 0;
    color: #fff;
    font-size: clamp(1.12rem, 2.5vw, 1.45rem);
    font-weight: 800;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

:is(#rabid-map, body) .rb-map-help .rb-map-help-close {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 8px 13px;
    border: 1px solid #c8e4f5;
    border-radius: 6px;
    background: #fff;
    color: #004875;
    font: inherit;
    font-size: .875rem;
    font-weight: 700;
    cursor: pointer;
}

:is(#rabid-map, body) .rb-map-help .rb-map-help-close:hover {
    background: #e9f5fc;
}

/* 03 — Scrollable body, section labels, and geographic note */
:is(#rabid-map, body) .rb-map-help-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 22px 24px 25px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

:is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-intro {
    margin: 0 0 20px;
    color: var(--rb-help-ink);
    font-size: .94rem;
    line-height: 1.65;
}

/* Only the explicit distance-note element receives the callout styling. */
:is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-distance-note {
    margin: 18px 0 0;
    padding: 12px 15px;
    border: 1px solid #d4e5ef;
    border-left: 4px solid var(--rb-help-primary);
    border-right: 4px solid var(--rb-help-primary);
    border-radius: 7px;
    background: #f1f7fb;
    color: #244c68;
    font-size: .78rem;
    font-weight: 700;
    line-height: 1.65;
}

:is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-section-title {
    margin: 0 0 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--rb-help-border);
    color: #004875;
    font-size: 1rem;
    font-weight: 800;
}

/* 04 — Numbered instructions and Font Awesome icons */
:is(#rabid-map, body) .rb-map-help-steps {
    margin: 0 0 23px;
    padding-left: 5px;
    list-style: decimal;
    list-style-type: none;
}

:is(#rabid-map, body) .rb-map-help-steps>li {
    margin: 0 0 16px;
    padding-left: 5px;
    font-size: .9rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

:is(#rabid-map, body) .rb-map-help-steps>li::marker {
    color: var(--rb-help-primary);
    font-weight: 800;
}

:is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-step-heading {
    display: flex;
    align-items: center;
    gap: .75rem;
}

:is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-step-icon {
    display: inline-flex;
    flex: 0 0 42px;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid #b9dce2;
    border-radius: 10px;
    background: #e8f5f7;
    color: var(--rb-help-primary);
    font-size: 1.1rem;
}

:is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-step-title {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    color: var(--rb-help-deep);
    font-size: .95rem;
    font-weight: 800;
    line-height: 1.4;
    text-transform: capitalize;
}

:is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-steps p {
    margin: 0;
    color: var(--rb-help-ink);
    font-size: .85rem;
    line-height: 1.6;
    padding-left: 3rem;
}

/* The regular heading <strong> must not turn keywords into block elements. */
:is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-steps p strong.rb-map-help-keyword {
    display: inline;
    margin: 0;
    padding: 0;
    color: var(--rb-help-deep);
    font-weight: 750;
    line-height: inherit;
    text-transform: none;
}

/* 05 — Optional images and captions */
:is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
    align-items: start;
    gap: .75rem;
    width: 100%;
    min-width: 0;
    margin: .85rem 0 1rem;
    padding-left: 3rem 
}

/* JS removes failed-image figures; hide the empty gallery and its margins. */
:is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-gallery:not(:has(figure img)) {
    display: none;
}

:is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-figure:not(:has(img)) {
    display: none;
}

:is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-figure {
    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding: 2px;
    overflow: hidden;
    border: 1px solid var(--rb-help-border);
    border-radius: 8px;
    background: #f5f9fc;
}

:is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-figure img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 200px;
    margin: 0;
    object-fit: contain;
    background: #fff;
}

:is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-figure figcaption {
    display: block;
    margin: 0;
    padding: .45rem .8rem;
    border-top: 1px solid #e4edf3;
    color: var(--rb-help-ink);
    font-size: .8rem;
    font-weight: 700;
    line-height: 1.5;
    overflow-wrap: anywhere;
    text-align: center;
}

/* 06 — Fixed footer and keyboard focus */
:is(#rabid-map, body) .rb-map-help-footer {
    display: flex;
    flex: 0 0 auto;
    justify-content: flex-end;
    padding: 13px 24px;
    border-top: 1px solid var(--rb-help-border);
    background: #f5f9fc;
}

:is(#rabid-map, body) .rb-map-help .rb-map-help-done {
    min-width: 100px;
    min-height: 44px;
    padding: 8px 18px;
    border: 1px solid var(--rb-help-primary);
    border-radius: 6px;
    background: var(--rb-help-primary);
    color: #fff;
    font: inherit;
    font-size: .875rem;
    font-weight: 700;
    cursor: pointer;
}

:is(#rabid-map, body) .rb-map-help .rb-map-help-done:hover {
    background: var(--rb-help-deep);
}

:is(#rabid-map, body) .rb-map-help button:focus-visible {
    outline: 3px solid var(--rb-help-focus);
    outline-offset: 2px;
}

/* 07 — Tablet / mobile */
@media (max-width: 768px) {
    :is(#rabid-map, body) .rb-map-help-dialog {
        max-height: calc(100dvh - 24px);
    }

    :is(#rabid-map, body) .rb-map-help-header {
        gap: 12px;
        padding: 16px 18px;
    }

    :is(#rabid-map, body) .rb-map-help-body {
        padding: 18px;
    }

    :is(#rabid-map, body) .rb-map-help-footer {
        padding: 12px 18px;
    }
}

@media (max-width: 580px) {
    :is(#rabid-map, body) .rb-map-help {
        align-items: stretch;
        padding: 8px;
    }

    :is(#rabid-map, body) .rb-map-help-dialog {
        width: 100%;
        max-height: calc(100dvh - 16px);
        border-radius: 9px;
    }

    :is(#rabid-map, body) .rb-map-help-header {
        align-items: center;
        gap: 10px;
        padding: 13px 14px;
    }

    :is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-header h3 {
        font-size: 1.06rem;
        line-height: 1.3;
    }

    :is(#rabid-map, body) .rb-map-help-eyebrow {
        font-size: .64rem;
        letter-spacing: .07em;
    }

    :is(#rabid-map, body) .rb-map-help .rb-map-help-close {
        padding: 8px 10px;
        font-size: .82rem;
    }

    :is(#rabid-map, body) .rb-map-help-body {
        padding: 15px 14px 18px;
    }

    :is(#rabid-map, body) .rb-map-help-steps {
        margin-bottom: 20px;
        padding-left: 22px;
    }

    :is(#rabid-map, body) .rb-map-help-steps>li {
        padding-left: 3px;
    }

    :is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-distance-note {
        padding: 11px 12px;
        font-size: .85rem;
    }

    :is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-gallery {
        grid-template-columns: minmax(0, 1fr);
        gap: .65rem;
    }

    :is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-figure img {
        max-height: 220px;
    }

    :is(#rabid-map, body) .rb-map-help-footer {
        padding: 10px 14px;
    }

    :is(#rabid-map, body) .rb-map-help .rb-map-help-done {
        width: 100%;
    }
}

@media (max-width: 480px) {
    :is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-step-heading {
        gap: .6rem;
    }

    :is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-step-icon {
        flex-basis: 36px;
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
}

@media (max-width: 360px) {
    :is(#rabid-map, body) .rb-map-help-header {
        padding: 11px;
    }

    :is(#rabid-map, body) .rb-map-help-dialog .rb-map-help-header h3 {
        font-size: .98rem;
    }

    :is(#rabid-map, body) .rb-map-help-body {
        padding: 13px 11px;
    }
}

/* 08 — Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {

    :is(#rabid-map, body) .rb-map-help *,
    :is(#rabid-map, body) .rb-map-help *::before,
    :is(#rabid-map, body) .rb-map-help *::after {
        scroll-behavior: auto !important;
        transition-duration: 0s !important;
        animation-duration: 0s !important;
    }
}