/*
 * Tutorial / coach-mark styling.
 *
 * Used by the public site (Tailwind/daisyUI light theme). The first block
 * below is `driver.js/dist/driver.css` inlined verbatim (MIT licensed; see
 * `node_modules/driver.js/LICENSE`) so we can ship the tour styles as a
 * single CSS file alongside our overrides without hooking a CSS bundler
 * into the esbuild precompile pipeline.
 *
 * Theming uses CSS custom properties scoped under `.cvl-tutorial`, so the
 * host page styles the popover without affecting Driver's defaults on
 * third-party pages.
 */

/* ---- driver.js/dist/driver.css (inlined) ----------------------------- */

.driver-active .driver-overlay,
.driver-active * {
    pointer-events: none;
}
.driver-active .driver-active-element,
.driver-active .driver-active-element *,
.driver-popover,
.driver-popover * {
    pointer-events: auto;
}
@keyframes animate-fade-in {
    0% {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
.driver-fade .driver-overlay {
    animation: animate-fade-in 0.2s ease-in-out;
}
.driver-fade .driver-popover {
    animation: animate-fade-in 0.2s;
}
.driver-popover {
    all: unset;
    box-sizing: border-box;
    color: #2d2d2d;
    margin: 0;
    padding: 15px;
    border-radius: 5px;
    min-width: 250px;
    max-width: 300px;
    box-shadow: 0 1px 10px #0006;
    z-index: 1000000000;
    position: fixed;
    top: 0;
    right: 0;
    background-color: #fff;
}
.driver-popover * {
    font-family:
        Helvetica Neue,
        Inter,
        ui-sans-serif,
        "Apple Color Emoji",
        Helvetica,
        Arial,
        sans-serif;
}

/* Action hints embed `<i class="fa-solid …">`; the universal rule above
   overrides Font Awesome's font-family and renders missing-glyph boxes. */
.driver-popover .fa-solid {
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
}
.driver-popover .fa-regular {
    font-family: "Font Awesome 6 Free";
    font-weight: 400;
}
.driver-popover .fa-brands {
    font-family: "Font Awesome 6 Brands";
    font-weight: 400;
}

.driver-popover-title {
    font: 19px/normal sans-serif;
    font-weight: 700;
    display: block;
    position: relative;
    line-height: 1.5;
    zoom: 1;
    margin: 0;
}
.driver-popover-close-btn {
    all: unset;
    position: absolute;
    top: 0;
    right: 0;
    width: 32px;
    height: 28px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 500;
    color: #d2d2d2;
    z-index: 1;
    text-align: center;
    transition: color;
    transition-duration: 0.2s;
}
.driver-popover-close-btn:hover,
.driver-popover-close-btn:focus {
    color: #2d2d2d;
}
.driver-popover-title[style*="block"] + .driver-popover-description {
    margin-top: 5px;
}
.driver-popover-description {
    margin-bottom: 0;
    font: 14px/normal sans-serif;
    line-height: 1.5;
    font-weight: 400;
    zoom: 1;
}
.driver-popover-footer {
    margin-top: 15px;
    text-align: right;
    zoom: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.driver-popover-progress-text {
    font-size: 13px;
    font-weight: 400;
    color: #727272;
    zoom: 1;
}
.driver-popover-footer button {
    all: unset;
    display: inline-block;
    box-sizing: border-box;
    padding: 3px 7px;
    text-decoration: none;
    text-shadow: 1px 1px 0 #fff;
    background-color: #fff;
    color: #2d2d2d;
    font: 12px/normal sans-serif;
    cursor: pointer;
    outline: 0;
    zoom: 1;
    line-height: 1.3;
    border: 1px solid #ccc;
    border-radius: 3px;
}
.driver-popover-footer .driver-popover-btn-disabled {
    opacity: 0.5;
    pointer-events: none;
}
:not(body):has(> .driver-active-element) {
    overflow: hidden !important;
}
/*
 * Driver.js's vendored rule above clips overflow on any non-body element
 * that has the active element as a direct child. That's correct for most
 * cases, but our action-gated tour steps frequently highlight elements
 * with absolutely-positioned popouts that extend BEYOND their parent
 * <form>'s bounding box:
 *   - The filter popover (`#cvl-filter-popover`) hangs below
 *     `<form id="map_filter">` (the search/filter form).
 *   - The language `<details id="cvl-header-language">` opens its option
 *     list below its wrapping `<form>` (the language switcher form).
 * With `overflow: hidden` on the form, those popouts render at full size
 * but are clipped to the form's tiny bounding box and never paint, so
 * visitors see a blank Driver overlay where the popout should be.
 * Restore `overflow: visible` on any form whose direct child is the
 * active tour element.
 */
form:has(> .driver-active-element) {
    overflow: visible !important;
}
/*
 * Header controls (search, filters, language, view toggle) live in a
 * sticky `z-index: 50` stacking context, so they would paint behind
 * Driver's overlay (z-index 10000) unless the header is lifted. Lifting
 * the whole header without a scrim made every toolbar button look
 * "highlighted"; the scrim dims the header interior while the active
 * step target (and its descendants, e.g. the language option list) stay
 * above the scrim.
 */
header:has(.driver-active-element) {
    z-index: 10001 !important;
    position: relative;
}

header:has(.driver-active-element)::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background-color: rgba(15, 23, 42, 0.55);
}

header:has(.driver-active-element) .driver-active-element {
    position: relative;
    z-index: 2;
}
/*
 * The language step asks the visitor to open `<details
 * id="cvl-header-language">`. Both the dropdown's option list and the
 * Driver popover want the same below-the-toggle slot, so when the
 * dropdown is open we slide the popover down past the option list
 * (~154px tall + a small gap) so the menu and popover stack vertically
 * without overlapping. Driver positions the popover with inline
 * `top`/`left`, so we shift via `transform` (which doesn't disturb
 * Driver's collision math) and add a short transition so the slide
 * feels intentional rather than jumpy.
 *
 * The body class `cvl-tutorial-language-menu-open` is toggled by a
 * `toggle` event listener in `public-tutorial.ts`. We use a class
 * hook instead of a `:has(#cvl-header-language[open])` selector
 * because :has matching can lag behind the `toggle` event in some
 * browser/cache combinations — listening directly to the toggle
 * event is deterministic.
 */
.driver-popover.cvl-tutorial {
    transition: transform 0.18s ease-out;
}
body.cvl-tutorial-language-menu-open .driver-popover.cvl-tutorial {
    transform: translateY(170px) !important;
}
/*
 * The "Program cards" step asks the visitor to click the highlighted
 * card to advance, but the card embeds a "See on Map" button and
 * per-location links that route to `?view=map&...` via Alpine handlers
 * (`@click.prevent`). Those handlers swap the visitor onto the map
 * view before the next tour step is ready, which leaves the popover
 * pointed at a now-detached card and effectively "breaks" the tour.
 *
 * While the program-card step is active we suppress pointer events on
 * those nested controls so clicks pass through to the card itself —
 * which is the configured `advanceOn` target. The next step
 * ("see-on-map") removes the class, restoring normal interaction.
 *
 * The body class `cvl-tutorial-program-card-step` is toggled by
 * `public-tutorial.ts` based on the active step id.
 */
body.cvl-tutorial-program-card-step .cvl-program-card.driver-active-element a,
body.cvl-tutorial-program-card-step
    .cvl-program-card.driver-active-element
    a
    *,
body.cvl-tutorial-program-card-step
    .cvl-program-card.driver-active-element
    button,
body.cvl-tutorial-program-card-step
    .cvl-program-card.driver-active-element
    button
    * {
    /*
     * Both the `<a>`/`<button>` itself AND its descendants need
     * `pointer-events: none` because the property isn't inherited —
     * a child with the default `pointer-events: auto` can still
     * intercept clicks even when its parent is set to `none`. Without
     * this, hit-testing lands on the icon or span text inside "See on
     * Map" and the Alpine handler fires.
     */
    pointer-events: none !important;
}
.driver-no-interaction,
.driver-no-interaction * {
    pointer-events: none !important;
}
/*
 * Map-gesture steps (pan / zoom / click-marker) target the full-viewport
 * `#map` element, which leaves Driver.js's auto-positioning nowhere good
 * for the popover — it lands mid-screen or at the bottom, eating exactly
 * the area mobile visitors reach with their thumb to perform the gesture
 * the step is teaching. Pin the popover to the top of the viewport for
 * those steps so the lower ~70 % of the map stays free for panning.
 *
 * `max(env(safe-area-inset-top), 0.5rem)` keeps the popover clear of
 * notches / status bars on devices that report a safe area, and falls
 * back to a small inset everywhere else. The arrow is hidden because the
 * popover is no longer attached to a specific point on the target — it's
 * the chapter-level instructions overlay, not a callout.
 *
 * The body class `cvl-tutorial-map-gesture-step` is toggled by
 * `public-tutorial.ts` based on the active step id.
 */
body.cvl-tutorial-map-gesture-step .driver-popover.cvl-tutorial {
    top: max(env(safe-area-inset-top), 0.5rem) !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translateX(-50%) !important;
}
body.cvl-tutorial-map-gesture-step .driver-popover-arrow {
    display: none !important;
}
.driver-popover-footer button:hover,
.driver-popover-footer button:focus {
    background-color: #f7f7f7;
}
.driver-popover-navigation-btns {
    display: flex;
    flex-grow: 1;
    justify-content: flex-end;
}
.driver-popover-navigation-btns button + button {
    margin-left: 4px;
}
.driver-popover-arrow {
    content: "";
    position: absolute;
    border: 5px solid #fff;
}
.driver-popover-arrow-side-over {
    display: none;
}
.driver-popover-arrow-side-left {
    left: 100%;
    border-right-color: transparent;
    border-bottom-color: transparent;
    border-top-color: transparent;
}
.driver-popover-arrow-side-right {
    right: 100%;
    border-left-color: transparent;
    border-bottom-color: transparent;
    border-top-color: transparent;
}
.driver-popover-arrow-side-top {
    top: 100%;
    border-right-color: transparent;
    border-bottom-color: transparent;
    border-left-color: transparent;
}
.driver-popover-arrow-side-bottom {
    bottom: 100%;
    border-left-color: transparent;
    border-top-color: transparent;
    border-right-color: transparent;
}
.driver-popover-arrow-side-center {
    display: none;
}
.driver-popover-arrow-side-left.driver-popover-arrow-align-start,
.driver-popover-arrow-side-right.driver-popover-arrow-align-start {
    top: 15px;
}
.driver-popover-arrow-side-top.driver-popover-arrow-align-start,
.driver-popover-arrow-side-bottom.driver-popover-arrow-align-start {
    left: 15px;
}
.driver-popover-arrow-align-end.driver-popover-arrow-side-left,
.driver-popover-arrow-align-end.driver-popover-arrow-side-right {
    bottom: 15px;
}
.driver-popover-arrow-side-top.driver-popover-arrow-align-end,
.driver-popover-arrow-side-bottom.driver-popover-arrow-align-end {
    right: 15px;
}
.driver-popover-arrow-side-left.driver-popover-arrow-align-center,
.driver-popover-arrow-side-right.driver-popover-arrow-align-center {
    top: 50%;
    margin-top: -5px;
}
.driver-popover-arrow-side-top.driver-popover-arrow-align-center,
.driver-popover-arrow-side-bottom.driver-popover-arrow-align-center {
    left: 50%;
    margin-left: -5px;
}
.driver-popover-arrow-none {
    display: none;
}

/* ---- Driver.js popover (shared overrides) ----------------------------- */

.driver-popover.cvl-tutorial {
    /* Layout + typography */
    --cvl-tutorial-bg: #ffffff;
    --cvl-tutorial-fg: #1f2937;
    --cvl-tutorial-muted: #4b5563;
    --cvl-tutorial-border: rgba(15, 23, 42, 0.08);
    --cvl-tutorial-accent: #0f766e;
    --cvl-tutorial-accent-fg: #ffffff;
    --cvl-tutorial-secondary-bg: rgba(15, 23, 42, 0.06);
    --cvl-tutorial-secondary-fg: #1f2937;

    background-color: var(--cvl-tutorial-bg);
    color: var(--cvl-tutorial-fg);
    border: 1px solid var(--cvl-tutorial-border);
    border-radius: 12px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
    padding: 16px 18px;
    max-width: 360px;
    font-family: inherit;
    line-height: 1.45;
}

.driver-popover.cvl-tutorial .driver-popover-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--cvl-tutorial-fg);
    margin: 0 0 6px 0;
}

.driver-popover.cvl-tutorial .driver-popover-description {
    font-size: 0.9rem;
    color: var(--cvl-tutorial-muted);
    margin: 0 0 12px 0;
}

.driver-popover.cvl-tutorial .driver-popover-progress-text {
    font-size: 0.75rem;
    color: var(--cvl-tutorial-muted);
}

.driver-popover.cvl-tutorial .driver-popover-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
}

.driver-popover.cvl-tutorial .driver-popover-footer,
.driver-popover.cvl-tutorial .driver-popover-navigation-btns {
    overflow: visible;
}

.driver-popover.cvl-tutorial .driver-popover-navigation-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.driver-popover.cvl-tutorial button {
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    text-shadow: none;
    line-height: 1.2;
    transition:
        background-color 120ms ease,
        border-color 120ms ease;
}

.driver-popover.cvl-tutorial button:focus-visible {
    outline: 2px solid var(--cvl-tutorial-accent);
    outline-offset: 2px;
}

.driver-popover.cvl-tutorial .driver-popover-prev-btn,
.driver-popover.cvl-tutorial .cvl-tutorial-skip-chapter,
.driver-popover.cvl-tutorial .cvl-tutorial-skip-tutorial {
    background-color: var(--cvl-tutorial-secondary-bg);
    color: var(--cvl-tutorial-secondary-fg);
    border-color: transparent;
}

.driver-popover.cvl-tutorial .driver-popover-prev-btn:hover,
.driver-popover.cvl-tutorial .cvl-tutorial-skip-chapter:hover,
.driver-popover.cvl-tutorial .cvl-tutorial-skip-tutorial:hover {
    background-color: rgba(15, 23, 42, 0.12);
}

.driver-popover.cvl-tutorial .driver-popover-next-btn {
    background-color: var(--cvl-tutorial-accent);
    color: var(--cvl-tutorial-accent-fg);
    border-color: var(--cvl-tutorial-accent);
}

.driver-popover.cvl-tutorial .driver-popover-next-btn:hover:not(:disabled) {
    background-color: color-mix(in srgb, var(--cvl-tutorial-accent) 88%, black);
}

/*
 * Locked Next on `manualAdvance` steps: the button stays in the DOM (so
 * `unlockNextButtonForCurrentStep` can enable it) but is hidden until the
 * gated action fires. `tutorial-core.ts` sets both `:disabled` and
 * `driver-popover-btn-disabled` on first render.
 */
.driver-popover.cvl-tutorial .driver-popover-next-btn[hidden],
.driver-popover.cvl-tutorial .driver-popover-next-btn.cvl-tutorial-next-locked,
.driver-popover.cvl-tutorial .driver-popover-next-btn:disabled,
.driver-popover.cvl-tutorial
    .driver-popover-next-btn.driver-popover-btn-disabled {
    display: none !important;
}

.driver-popover.cvl-tutorial .driver-popover-close-btn {
    color: var(--cvl-tutorial-muted);
    background: transparent;
    padding: 4px 8px;
    border-radius: 4px;
}

.driver-popover.cvl-tutorial .driver-popover-close-btn:hover {
    color: var(--cvl-tutorial-fg);
    background: var(--cvl-tutorial-secondary-bg);
}

/* Tighten the focus indicator. The close button's hit box is intentionally
   large (32x28 plus padding) so it's easy to click, but the default outline
   wraps that entire box and looks like a chunky stray rectangle around a
   tiny icon. Inset a 2px ring instead, so the cue hugs the X glyph and
   matches the rounded corners we set above. */
.driver-popover.cvl-tutorial .driver-popover-close-btn:focus-visible {
    outline: 2px solid var(--cvl-tutorial-accent);
    outline-offset: -2px;
}

.driver-popover.cvl-tutorial .cvl-tutorial-chapter-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--cvl-tutorial-accent);
    margin: 0 0 4px 0;
}

.driver-popover.cvl-tutorial .cvl-tutorial-action-hint {
    margin: 8px 0 0 0;
    padding: 6px 10px;
    border-radius: 8px;
    background-color: var(--cvl-tutorial-secondary-bg);
    color: var(--cvl-tutorial-fg);
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.35;
    border-left: 3px solid var(--cvl-tutorial-accent);
}

/* Inline icon-only stand-in for the view-toggle label, used inside action
   hints like "Click {icon} to switch to the list." The icon is always
   visible; the text label is hidden on mobile (matching the icon-only
   toolbar button at that width) and revealed at md+ where the toolbar
   button itself also shows its text. Inline-flex aligns the icon with
   the surrounding hint baseline. */
.driver-popover.cvl-tutorial .cvl-tutorial-action-hint-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--cvl-tutorial-accent);
}

.driver-popover.cvl-tutorial .cvl-tutorial-action-hint-toggle-label {
    display: none;
}

@media (min-width: 768px) {
    .driver-popover.cvl-tutorial .cvl-tutorial-action-hint-toggle-label {
        display: inline;
    }
}

.driver-popover.cvl-tutorial .cvl-tutorial-extra {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    font-size: 0.78rem;
}

.driver-popover.cvl-tutorial .cvl-tutorial-extra button {
    background: transparent;
    color: var(--cvl-tutorial-muted);
    border: none;
    padding: 0;
    font-size: 0.78rem;
    text-decoration: underline;
}

.driver-popover.cvl-tutorial .cvl-tutorial-extra button:hover {
    color: var(--cvl-tutorial-fg);
    text-decoration: none;
}

/* ---- First-run prompt + restart toast ------------------------------- */

.cvl-tutorial-prompt-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background-color: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    /* The inner card carries its own theme; the overlay stays neutral so it
       reads as a modal in both contexts. */
}

.cvl-tutorial-prompt-card {
    background: #ffffff;
    color: #1f2937;
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
    max-width: 480px;
    width: 100%;
    padding: 24px 24px 20px 24px;
    font-family: inherit;
    line-height: 1.5;
}

/* Header row holds the title and (optionally) the language switcher, with
   the title anchored to the leading edge and the switcher to the trailing
   edge. `gap` keeps them from touching when the title wraps. */
.cvl-tutorial-prompt-card .cvl-tutorial-prompt-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.cvl-tutorial-prompt-card .cvl-tutorial-prompt-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
}

.cvl-tutorial-prompt-card .cvl-tutorial-prompt-body {
    margin: 0 0 18px 0;
    color: #4b5563;
    font-size: 0.95rem;
}

.cvl-tutorial-prompt-card .cvl-tutorial-prompt-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

/* Wraps the extra action (e.g. language switcher) inside the header so it
   stays vertically aligned with the title baseline. `flex-shrink: 0` keeps
   the toggle from collapsing when the title wraps to two lines. */
.cvl-tutorial-prompt-card .cvl-tutorial-prompt-extra {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.cvl-tutorial-prompt-card button {
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    line-height: 1.2;
}

.cvl-tutorial-prompt-card .cvl-tutorial-prompt-start {
    background-color: #0f766e;
    color: #ffffff;
    border-color: #0f766e;
}

.cvl-tutorial-prompt-card .cvl-tutorial-prompt-start:hover {
    background-color: #115e59;
}

.cvl-tutorial-prompt-card .cvl-tutorial-prompt-later {
    background-color: rgba(15, 23, 42, 0.06);
    color: #1f2937;
}

.cvl-tutorial-prompt-card .cvl-tutorial-prompt-later:hover {
    background-color: rgba(15, 23, 42, 0.12);
}

/* ---- First-run prompt language switcher ----------------------------- */

/* Wraps the inline language form. Anchors the dropdown so the option list
   can position absolutely below the toggle without breaking out of the card. */
.cvl-tutorial-prompt-card .cvl-tutorial-prompt-language {
    margin: 0;
    position: relative;
}

.cvl-tutorial-prompt-card .cvl-tutorial-prompt-language-details {
    position: relative;
}

.cvl-tutorial-prompt-card .cvl-tutorial-prompt-language-sr-prefix {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Hide the native disclosure marker so our chevron icon is the only one. */
.cvl-tutorial-prompt-card .cvl-tutorial-prompt-language-details > summary {
    list-style: none;
}
.cvl-tutorial-prompt-card
    .cvl-tutorial-prompt-language-details
    > summary::-webkit-details-marker {
    display: none;
}

.cvl-tutorial-prompt-card .cvl-tutorial-prompt-language-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.2;
    color: #1f2937;
    background-color: rgba(15, 23, 42, 0.04);
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
}

.cvl-tutorial-prompt-card .cvl-tutorial-prompt-language-toggle:hover,
.cvl-tutorial-prompt-card
    .cvl-tutorial-prompt-language-details[open]
    > .cvl-tutorial-prompt-language-toggle {
    background-color: rgba(15, 23, 42, 0.1);
}

.cvl-tutorial-prompt-card .cvl-tutorial-prompt-language-current {
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cvl-tutorial-prompt-card .cvl-tutorial-prompt-language-caret {
    font-size: 0.7rem;
    opacity: 0.7;
    transition: transform 200ms ease;
}

.cvl-tutorial-prompt-card
    .cvl-tutorial-prompt-language-details[open]
    .cvl-tutorial-prompt-language-caret {
    transform: rotate(180deg);
}

.cvl-tutorial-prompt-card .cvl-tutorial-prompt-language-list {
    position: absolute;
    inset-inline-end: 0;
    top: calc(100% + 4px);
    min-width: 11rem;
    padding: 4px;
    background: #ffffff;
    color: #1f2937;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cvl-tutorial-prompt-card .cvl-tutorial-prompt-language-current-item,
.cvl-tutorial-prompt-card .cvl-tutorial-prompt-language-option {
    width: 100%;
    text-align: start;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.2;
    border: 1px solid transparent;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.cvl-tutorial-prompt-card .cvl-tutorial-prompt-language-current-item {
    cursor: default;
    background-color: rgba(15, 118, 110, 0.1);
    color: #0f766e;
    font-weight: 600;
}

.cvl-tutorial-prompt-card .cvl-tutorial-prompt-language-option:hover,
.cvl-tutorial-prompt-card .cvl-tutorial-prompt-language-option:focus-visible {
    background-color: rgba(15, 23, 42, 0.08);
    outline: none;
}

/* ---- Search-step discoverability (pulse + click callout) ------------- */

/*
 * Pulse the outline on #search. Do NOT set a static `box-shadow` with
 * `!important` on the same element — that blocks the animation in browsers.
 */
@keyframes cvl-tutorial-search-pulse {
    0%,
    100% {
        outline-width: 2px;
        outline-color: #0f766e;
    }
    50% {
        outline-width: 4px;
        outline-color: #14b8a6;
    }
}

/* Outer ring on the search wrapper — opacity pulse always runs visibly. */
@keyframes cvl-tutorial-search-ring-breathe {
    0%,
    100% {
        opacity: 0.35;
    }
    50% {
        opacity: 1;
    }
}

/*
 * Glow on #search during the search-bar step. Loaded after Tailwind in
 * `index.html`. Highlight class toggled from `public-tutorial.ts`.
 */
body.cvl-tutorial-search-step #map_filter .join,
body.cvl-tutorial-search-step #cvl-search-field {
    overflow: visible !important;
}

body.cvl-tutorial-search-step #cvl-search-field.cvl-tutorial-search-highlight::after,
body.cvl-tutorial-search-step #cvl-search-field.driver-active-element::after {
    content: "";
    position: absolute;
    inset: -5px;
    border-radius: 0.5rem;
    border: 3px solid #0f766e;
    pointer-events: none;
    z-index: 0;
    animation: cvl-tutorial-search-ring-breathe 1.25s ease-in-out infinite;
}

body.cvl-tutorial-search-step
    #cvl-search-field.cvl-tutorial-search-highlight
    input#search,
body.cvl-tutorial-search-step #cvl-search-field.driver-active-element input#search {
    animation: cvl-tutorial-search-pulse 1.25s ease-in-out infinite !important;
    outline-style: solid !important;
    outline-offset: 2px !important;
    border-color: #0d9488 !important;
    position: relative;
    z-index: 1;
}

/* Magnifying glass sits beside the input, not inside it — keep above the input surface. */
body.cvl-tutorial-search-step #cvl-search-field .fa-magnifying-glass {
    z-index: 2;
}

/* ---- Filters-step discoverability (pulse on filter chips) -------------- */

@keyframes cvl-tutorial-filter-chip-pulse {
    0%,
    100% {
        box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.65);
        border-color: #0d9488;
        background-color: rgba(20, 184, 166, 0.14);
    }
    50% {
        box-shadow:
            0 0 0 4px rgba(15, 118, 110, 0.9),
            0 0 10px 2px rgba(19, 168, 158, 0.4);
        border-color: #14b8a6;
        background-color: rgba(20, 184, 166, 0.28);
    }
}

@keyframes cvl-tutorial-next-btn-ring-pulse {
    0%,
    100% {
        box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.65);
    }
    50% {
        box-shadow:
            0 0 0 4px rgba(15, 118, 110, 0.9),
            0 0 12px 3px rgba(19, 168, 158, 0.45);
    }
}

/*
 * Pulse each category / city / county chip so visitors know to click one.
 * Avoid a static box-shadow !important on the same nodes (blocks animation).
 */
/*
 * Disable the filter panel's close control while the filters step is
 * active. `public-tutorial.ts` also sets `disabled` on the button; CSS
 * blocks stray pointer hits and shows a non-interactive affordance.
 */
body.cvl-tutorial-filters-step #cvl-filter-popover-close,
body.cvl-tutorial-filters-step #cvl-filter-popover-close * {
    pointer-events: none !important;
    cursor: not-allowed;
    opacity: 0.45;
}

body.cvl-tutorial-filters-step form#map_filter {
    overflow: visible !important;
}

body.cvl-tutorial-filters-step #cvl-filter-popover.cvl-tutorial-filters-highlight,
body.cvl-tutorial-filters-step #cvl-filter-popover.driver-active-element {
    overflow: visible !important;
    position: absolute;
}

body.cvl-tutorial-filters-step
    #cvl-filter-popover:not(:has(input:checked))
    fieldset
    label
    > span {
    animation: cvl-tutorial-filter-chip-pulse 1.25s ease-in-out infinite;
}

/* After the first selection, steer attention to the enabled Next control. */
body.cvl-tutorial-filters-step:has(#cvl-filter-popover input:checked)
    #cvl-filter-popover
    fieldset
    label
    > span {
    animation: none;
}

/*
 * Hide Next/Done until the gated action unlocks it (`manualAdvance` steps).
 * The body class is toggled in `public-tutorial.ts` / lock helpers; the
 * pulse class is added when unlocked.
 */
body.cvl-tutorial-primary-action-locked
    .driver-popover.cvl-tutorial
    .driver-popover-next-btn:not(.cvl-tutorial-primary-btn-pulse) {
    display: none !important;
}

/* Pulse Next/Done after unlock — ring on ::after matches filter-chip glow. */
.driver-popover.cvl-tutorial
    .driver-popover-next-btn.cvl-tutorial-primary-btn-pulse:not(:disabled):not(
        .cvl-tutorial-next-locked
    ) {
    position: relative;
    isolation: isolate;
    overflow: visible;
}

.driver-popover.cvl-tutorial
    .driver-popover-next-btn.cvl-tutorial-primary-btn-pulse:not(:disabled):not(
        .cvl-tutorial-next-locked
    )::after {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 11px;
    pointer-events: none;
    z-index: -1;
    animation: cvl-tutorial-next-btn-ring-pulse 1.25s ease-in-out infinite;
}

.cvl-tutorial-click-callout {
    position: fixed;
    z-index: 1000000001;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: max-content;
    max-width: min(90vw, 220px);
    text-align: center;
    font-family: inherit;
    /* Horizontal centering only — vertical position comes from top/bottom. */
    transform: translateX(-50%);
    margin-top: 4px;
}

.cvl-tutorial-click-callout__text {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    background-color: var(--cvl-tutorial-accent, #0f766e);
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.2;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.22);
    animation: cvl-tutorial-click-callout-bounce 1.2s ease-in-out infinite;
}

.cvl-tutorial-click-callout::after {
    content: "";
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 10px solid var(--cvl-tutorial-accent, #0f766e);
}

.cvl-tutorial-click-callout[data-placement="below"] {
    flex-direction: column-reverse;
}

.cvl-tutorial-click-callout[data-placement="below"]::after {
    border-top: none;
    border-bottom: 10px solid var(--cvl-tutorial-accent, #0f766e);
}

@keyframes cvl-tutorial-click-callout-bounce {
    0%,
    100% {
        margin-top: 2px;
    }
    50% {
        margin-top: 0px;
    }
}

/* Reduce motion preference: disable Driver's animation, leave layout. */
@media (prefers-reduced-motion: reduce) {
    .driver-popover.cvl-tutorial,
    .driver-popover.cvl-tutorial * {
        transition-duration: 0ms !important;
        animation-duration: 0ms !important;
    }

    body.cvl-tutorial-search-step
        #cvl-search-field.cvl-tutorial-search-highlight::after,
    body.cvl-tutorial-search-step #cvl-search-field.driver-active-element::after {
        animation: none;
        opacity: 0.85;
    }

    body.cvl-tutorial-search-step
        #cvl-search-field.cvl-tutorial-search-highlight
        input#search,
    body.cvl-tutorial-search-step #cvl-search-field.driver-active-element input#search {
        animation: none !important;
        outline-width: 3px !important;
        outline-color: #0f766e !important;
    }

    body.cvl-tutorial-filters-step #cvl-filter-popover fieldset label > span {
        animation: none;
        box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.8);
        border-color: #0f766e;
    }

    .driver-popover.cvl-tutorial
        .driver-popover-next-btn.cvl-tutorial-primary-btn-pulse:not(:disabled)::after {
        animation: none;
        box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.5);
    }

    .cvl-tutorial-click-callout__text {
        animation: none;
    }
}
