/*
 * MSV Tours — styled dropdown (public/js/msv/select-menu.js).
 * Plain CSS (no build step), loaded wherever a <select data-select-menu> is:
 * the homepage booking widget (partials/booking-assets) and the contact form.
 *
 * The script swaps the native select for a .msv-menu button that keeps the
 * select's own classes, plus a .msv-menu-panel listbox appended to <body> (so a
 * card's overflow can't clip it).
 *   - Booking widget: the button is .msv-input .msv-menu — border, radius and
 *     focus glow from .msv-input (app.css), 44px height from here.
 *   - Contact form: the button keeps the form's Tailwind field classes (padding,
 *     border, ring), so it matches the inputs next to it; error colours come
 *     from msv-contact.css via the mirrored aria-invalid.
 * Unlayered rules here win over Tailwind utilities, which live in @layer.
 */

/* ── Field (closed) ───────────────────────────────────────────────────── */
.msv-menu {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    background-color: #fff;
    color: #1e293b;
    font-family: var(--font-sans);
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.msv-input.msv-menu {
    height: 2.75rem;                                /* = the other booking widget fields */
    padding: 0 0.75rem 0 0.875rem;
    font-weight: 500;
    line-height: 1.25;
}
.msv-menu:hover:not(:focus):not(.is-open):not([aria-invalid="true"]) { border-color: #cbd5e1; }

/* open: same green as focus — the widget's soft glow, the contact form's 2px ring */
.msv-menu.is-open { border-color: #059669; }
.msv-input.msv-menu.is-open,
.msv-input.msv-menu:focus-visible { box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15); }
.msv-menu.is-open:not(.msv-input) { box-shadow: 0 0 0 2px #047857; }

.msv-menu__value {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* placeholder colour = the neighbouring inputs' ::placeholder */
.msv-menu.is-placeholder .msv-menu__value { color: color-mix(in oklab, currentcolor 50%, transparent); font-weight: 400; }
.msv-input.msv-menu.is-placeholder .msv-menu__value { color: #94a3b8; }

.msv-menu__chevron {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 1.25rem;
    height: 1.25rem;
    color: #94a3b8;
    transition: transform 0.2s ease, color 0.15s;
}
.msv-menu__chevron svg { width: 1.25rem; height: 1.25rem; }
/* the text line sets the field height (like the inputs next to it), not the icon */
.msv-menu:not(.msv-input) .msv-menu__chevron { margin-block: -0.5rem; }
.msv-menu.is-open .msv-menu__chevron { transform: rotate(180deg); color: #047857; }

/* ── Options panel (open) ─────────────────────────────────────────────── */
.msv-menu-panel {
    position: absolute;
    z-index: 35;                 /* above page content (hero z-10), below the sticky header (z-40) */
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid #e2e8f0;
    border-radius: 0.875rem;
    background: #fff;
    box-shadow: 0 18px 40px -12px rgba(15, 23, 42, 0.22), 0 2px 6px -2px rgba(15, 23, 42, 0.06);
    font-family: var(--font-sans);
    animation: msv-menu-in 0.14s ease-out;
}
.msv-menu-panel[hidden] { display: none; }
.msv-menu-panel--up { animation-name: msv-menu-in-up; }
@keyframes msv-menu-in    { from { opacity: 0; transform: translateY(-4px); } }
@keyframes msv-menu-in-up { from { opacity: 0; transform: translateY(4px); } }

.msv-menu-panel__list {
    display: grid;
    gap: 0.125rem;
    margin: 0;
    padding: 0.35rem;
    list-style: none;
}
.msv-menu-panel__option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 2.75rem;                            /* 44px touch target */
    padding: 0.5rem 0.75rem;
    border-radius: 0.6rem;
    color: #1e293b;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.3;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s, color 0.15s;
}
.msv-menu-panel__option.is-active { background: #f0fdf4; }
@media (hover: hover) {
    .msv-menu-panel__option:hover { background: #f0fdf4; }
}
.msv-menu-panel__option[aria-selected="true"] {
    background: #ecfdf5;
    color: #065f46;
    font-weight: 600;
}
.msv-menu-panel__option[aria-selected="true"].is-active { background: #d1fae5; }
.msv-menu-panel__check {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 1.1rem;
    height: 1.1rem;
    color: #059669;
    visibility: hidden;
}
.msv-menu-panel__check svg { width: 1.1rem; height: 1.1rem; }
.msv-menu-panel__option[aria-selected="true"] .msv-menu-panel__check { visibility: visible; }

@media (prefers-reduced-motion: reduce) {
    .msv-menu-panel { animation: none; }
    .msv-menu__chevron,
    .msv-menu-panel__option { transition: none; }
}
