/* Ticketing and the discovery map.
 *
 * Theme-agnostic on purpose. The app ships three themes (magazine -- the
 * default -- otter and pebble) chosen by the mm_theme cookie, and only two of
 * them define --accent-sun. Putting these rules in one theme file meant the
 * map had no height and the ticket badge no colour for everybody on the
 * default theme, with nothing in the console to say so.
 *
 * Loaded after the theme stylesheet, so a theme can still override any of it.
 */

:root {
    /* One ticketing colour, used by the card badge, the Book button, the
       Bookable filter pill and the map pin. Falls back for themes without
       --accent-sun. */
    --mm-ticket: var(--accent-sun, #E59500);
    --mm-ticket-contrast: #ffffff;
}

/* --- Card badge --------------------------------------------------------- */
/* Takes the prime top-left slot and pushes duration below it; hence it
   precedes .badge-duration in the DOM. */
.badge-tickets {
    top: 8px;
    left: 8px;
    background: var(--mm-ticket);
    color: var(--mm-ticket-contrast);
}

.badge-tickets ~ .badge-duration {
    top: 38px;
}

/* --- Book button -------------------------------------------------------- */
.btn-book {
    background: var(--mm-ticket);
    color: var(--mm-ticket-contrast);
    box-shadow: 0 4px 12px rgba(229, 149, 0, 0.3);
}

.btn-book:active {
    transform: scale(0.98);
}

/* Two lines, not one sentence. "Book now from €22.00" read as a run-on label
   and was the widest thing in a row that also has to hold Save and Navigate.
   Stacked, the price reads as what it is -- a qualifier on the action. */
.btn-book__label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
    white-space: nowrap;
    min-width: 0;
}

/* Last resort on a very narrow phone: clip the label rather than let the row
   push Navigate off-screen. */
.btn-book__label > span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-book .price-from {
    font-weight: 500;
    font-size: 13px;
    opacity: 0.9;
}

/* --- The sticky footer with a Book button in it -------------------------- */
/* Three controls on a phone: buy, save, navigate. Buying is the primary
   action and takes the width; Navigate is already an icon; so Save is the one
   that gives up its label. It keeps the same bookmark glyph as the hero
   button, which is where the meaning was carried anyway.
 *
 * Everything here hangs off .footer-row--booking rather than off the button,
 * because the save button is re-rendered by htmx on every save and would
 * arrive with no idea whether the page is bookable. A class on the row
 * survives the swap; a class on the button would not.
 *
 * The `flex` declarations replace inline styles that used to sit on these
 * elements -- inline wins over any class, so the collapsed state could not
 * have overridden them. */
.sticky-footer .btn-book {
    flex: 1;
    /* The base .btn padding is built for one line of text; with two it would
       stand a head taller than the 56px Navigate circle beside it. */
    padding: 10px 16px;
    min-height: 56px;
    gap: 8px;
    /* A flex item defaults to min-width:auto, i.e. "never narrower than my
       content". With a nowrap label that made the ROW wider than the phone and
       pushed Navigate off the right edge at 320px. */
    min-width: 0;
}

.sticky-footer .btn-book svg {
    flex-shrink: 0;
}

/* Under ~360px the label and the ticket glyph cannot both fit beside two 56px
   circles, and the label loses characters first ("Jetzt buc..."). The word is
   what gets read; the glyph is decoration, so on the narrowest phones the
   glyph goes instead of the verb. */
@media (max-width: 359px) {
    .sticky-footer .btn-book svg {
        display: none;
    }
}

#footer-bookmark {
    display: flex;
    flex: 1;
}

/* The button, the signed-out link, and the htmx loading placeholder alike. */
#footer-bookmark > * {
    display: flex;
    flex: 1;
}

.footer-row--booking #footer-bookmark,
.footer-row--booking #footer-bookmark > * {
    flex: 0 0 auto;
}

/* Matches .btn-navigate-icon, so the two secondary controls read as a pair. */
.footer-row--booking #footer-bookmark .btn {
    width: 56px;
    height: 56px;
    padding: 0;
    gap: 0;
    border-radius: 50%;
}

.footer-row--booking #footer-bookmark .btn-label {
    display: none;
}

/* --- Bookable filter pill ----------------------------------------------- */
.filter-pill-book {
    color: var(--mm-ticket);
    border-color: var(--mm-ticket);
    background: rgba(229, 149, 0, 0.08);
}

.filter-pill-book.active {
    background: var(--mm-ticket);
    border-color: var(--mm-ticket);
    color: var(--mm-ticket-contrast);
}

/* --- Map pin ------------------------------------------------------------ */
.pin-bubble {
    position: relative;
}

.pin-ticket {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--mm-ticket);
    border: 2px solid #fff;
    box-sizing: border-box;
}

/* --- Discovery map ------------------------------------------------------ */
.discovery-map-panel {
    margin: 0 16px 16px;
    border-radius: var(--radius-md, 16px);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* An explicit height is load-bearing: Leaflet binds happily to a zero-height
   container and reports success, so a missing height looks like "no map"
   rather than an error. */
.discovery-map {
    height: 220px;
    width: 100%;
    background: var(--pebble-stone, #f1f1f1);
}

@media (min-width: 768px) {
    .discovery-map {
        height: 320px;
    }
}


/* --- Booking sheet ------------------------------------------------------ */
/* The ticket picker over the place page, so buying costs no navigation. The
   deal page is still the canonical offer -- this is the same picker, in
   different chrome, for someone who is already looking at the venue. */
.booking-sheet {
    position: fixed;
    inset: 0;
    z-index: 200;  /* over .sticky-footer, which the sheet has to cover */
    display: flex;
    align-items: flex-end;
}

/* A class selector outranks the UA rule behind the `hidden` attribute, so
   without this the closed sheet keeps its full-screen scrim over the page and
   swallows every tap -- including the one on Book now. */
.booking-sheet[hidden] {
    display: none;
}

.booking-sheet__scrim {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.booking-sheet.is-open .booking-sheet__scrim {
    opacity: 1;
}

.booking-sheet__panel {
    position: relative;
    width: 100%;
    max-height: 92vh;
    /* dvh where it exists: on iOS Safari the toolbar makes 92vh taller than
       the visible page, which buries the pay button off the bottom edge. */
    max-height: 92dvh;
    display: flex;
    flex-direction: column;
    background: var(--pebble-surface, #fff);
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.25);
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.booking-sheet.is-open .booking-sheet__panel {
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .booking-sheet__scrim,
    .booking-sheet__panel {
        transition: none;
    }
}

/* Desktop: a sheet glued to the bottom of a 1400px window is a long way from
   the button that opened it. Centre it instead. */
@media (min-width: 768px) {
    .booking-sheet {
        align-items: center;
        justify-content: center;
        padding: 24px;
    }

    .booking-sheet__panel {
        max-width: 560px;
        border-radius: 24px;
        transform: translateY(16px) scale(0.98);
        opacity: 0;
        transition: transform 0.2s ease, opacity 0.2s ease;
    }

    .booking-sheet.is-open .booking-sheet__panel {
        transform: none;
        opacity: 1;
    }
}

.booking-sheet__grip {
    width: 40px;
    height: 4px;
    flex-shrink: 0;
    margin: 10px auto 0;
    border-radius: 2px;
    background: var(--pebble-shadow, #d9d9d9);
}

/* The only scrolling element: the panel itself stays put so the grip and the
   close button are always reachable, however long the slot list is. */
.booking-sheet__body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
}

.booking-sheet__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.booking-sheet__eyebrow {
    margin: 0;
    font-size: 13px;
    color: var(--river-mid, #667);
}

.booking-sheet__title {
    margin: 2px 0 0;
    font-size: 20px;
    line-height: 1.25;
    font-weight: 800;
    color: var(--river-deep, #1a2e35);
}

.booking-sheet__close {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background: var(--pebble-bg, #f2f2f2);
    color: var(--river-deep, #1a2e35);
}

.booking-sheet__foot {
    margin-top: 20px;
}

.booking-sheet__empty,
.booking-sheet__loading {
    padding: 24px 0;
    text-align: center;
    color: var(--river-mid, #667);
}

/* Visible while htmx is fetching -- hx-indicator toggles .htmx-request on the
   sheet, and the placeholder underneath is what the panel shows meanwhile. */
.booking-sheet__more {
    display: block;
    margin-top: 16px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--river-mid, #667);
}

/* --- Bootstrap shim, inside the sheet only ------------------------------ */
/* The ticket picker was written for the deal page, which is a Bootstrap page.
   The place page is not, so the handful of Bootstrap utilities the picker
   leans on arrive as dead classes: the pay button stops being full width,
   muted text stops being muted, and the spacing collapses.
 *
 * Supplying them here beats either of the alternatives. Loading Bootstrap on
 * the place page would restyle a page that has its own design system;
 * rewriting the picker would mean editing a template that takes money, to fix
 * a page that does not. Scoped to .booking-sheet so nothing here can reach the
 * rest of the place page.
 *
 * Keep this list honest: it exists to match Bootstrap, not to art-direct. If
 * the picker starts using a utility that is not here, add it. */
.booking-sheet .w-100 { width: 100%; }
.booking-sheet .d-flex { display: flex; }
.booking-sheet .justify-content-between { justify-content: space-between; }
.booking-sheet .text-center { text-align: center; }
.booking-sheet .text-uppercase { text-transform: uppercase; }
.booking-sheet .fw-semibold { font-weight: 600; }
.booking-sheet .fw-bold { font-weight: 700; }
.booking-sheet .small { font-size: 0.875em; }
.booking-sheet .text-body-secondary { color: var(--river-mid, #6c757d); }
.booking-sheet .border { border: 1px solid var(--pebble-shadow, #dee2e6); }

.booking-sheet .mb-0 { margin-bottom: 0; }
.booking-sheet .mb-2 { margin-bottom: 0.5rem; }
.booking-sheet .mb-3 { margin-bottom: 1rem; }
.booking-sheet .mt-2 { margin-top: 0.5rem; }
.booking-sheet .mt-3 { margin-top: 1rem; }
.booking-sheet .pt-3 { padding-top: 1rem; }
.booking-sheet .py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.booking-sheet .p-4 { padding: 1.5rem; }

.booking-sheet .card {
    border: 1px solid var(--pebble-shadow, #dee2e6);
    border-radius: 12px;
    background: var(--pebble-surface, #fff);
}

.booking-sheet .card-body { padding: 1rem; }

.booking-sheet .form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
}

.booking-sheet .form-control {
    display: block;
    width: 100%;
    padding: 0.6rem 0.75rem;
    font-size: 1rem;  /* 16px, or iOS zooms the page on focus */
    border: 1px solid var(--pebble-shadow, #dee2e6);
    border-radius: 10px;
    background: var(--pebble-surface, #fff);
    color: inherit;
}

.booking-sheet .form-text {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: var(--river-mid, #6c757d);
}

.booking-sheet .form-check {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.booking-sheet .form-check-input {
    flex-shrink: 0;
    width: 1.15rem;
    height: 1.15rem;
    margin-top: 0.15rem;
}

/* The pay button is the one place the shim must not lose to the theme: .btn
   here is the place page's pill, which is what we want, but it is inline-flex
   and would shrink to its text without this. */
.booking-sheet .btn-lg {
    width: 100%;
    padding: 16px 24px;
    font-size: 17px;
}

/* Bootstrap Icons are not loaded here (the place page ships Tabler), so these
   render as an empty box with a stray gap. Decorative either way. */
.booking-sheet .bi { display: none; }
