/* Brimpton Airfield — SumUp payment basket.
   Mobile-first: most pilots pay from a phone, often on poor signal in the
   cockpit. Everything below 40rem is the primary case; wider screens are the
   enhancement. */

.sumuppay {
    --sp-line: #d9dee3;
    --sp-ink: #1c2530;
    --sp-muted: #5b6875;
    --sp-accent: #0b5c8a;
    --sp-accent-ink: #fff;
    --sp-bg: #fff;
    --sp-soft: #f5f7f9;
    --sp-error: #b3261e;
    --sp-tap: 2.75rem; /* 44px minimum touch target */
    --sp-pad: 1rem;    /* gutter - templates often give none on mobile */

    margin: 0 auto;
    color: var(--sp-ink);
    font-size: 1rem;
    line-height: 1.5;

    /* The module supplies its own gutter rather than trusting the template.
       Doubling up with a template that already pads is harmless; running text
       to the screen edge is not. */
    padding-left: var(--sp-pad);
    padding-right: var(--sp-pad);

    /* Nothing inside may push the page sideways. */
    max-width: min(46rem, 100%);
    overflow-x: clip;
}

/* Every descendant sized predictably - Joomla templates vary wildly and a
   stray content-box input is a common cause of horizontal overflow. */
.sumuppay *,
.sumuppay *::before,
.sumuppay *::after {
    box-sizing: border-box;
}

/* The single most common overflow cause: a flex child will not shrink below
   its content width unless min-width is cleared. */
.sumuppay > *,
.sumuppay__item > *,
.sumuppay__item-main > *,
.sumuppay__item-controls > *,
.sumuppay__paybar > * {
    min-width: 0;
}

.sumuppay__intro {
    margin-bottom: 1.25rem;
}

.sumuppay__intro > *:last-child {
    margin-bottom: 0;
}

.sumuppay__step {
    margin: 0 0 1.75rem;
}

.sumuppay__heading {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin: 0 0 .75rem;
    padding-bottom: .4rem;
    border-bottom: 2px solid var(--sp-accent);
}

/* ---- Fee list -------------------------------------------------------- */

.sumuppay__cat {
    border: 1px solid var(--sp-line);
    border-radius: 6px;
    padding: .25rem .75rem .75rem;
    margin: 0 0 .85rem;
    min-width: 0;
}

.sumuppay__cat > legend {
    font-weight: 600;
    font-size: .9rem;
    padding: 0 .35rem;
    width: auto;
    max-width: 100%;
    border: 0;
    margin: 0;
}

/* Mobile: label on its own line, controls beneath. Never side-by-side at
   narrow widths - that is what was forcing the overflow. */
.sumuppay__item {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    padding: .7rem 0;
    border-bottom: 1px solid var(--sp-soft);
    min-width: 0;
}

.sumuppay__item:last-child {
    border-bottom: 0;
}

.sumuppay__item-main {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .75rem;
    margin: 0;
    font-weight: 400;
    min-width: 0;
}

.sumuppay__item-label {
    min-width: 0;
    overflow-wrap: anywhere; /* long fee names must wrap, not overflow */
}

.sumuppay__item-price {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--sp-muted);
    white-space: nowrap;
    flex: 0 0 auto;
}

.sumuppay__item-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    min-width: 0;
}

.sumuppay__qty-wrap {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin: 0;
    min-width: 0;
}

.sumuppay__qty-label {
    font-size: .82rem;
    color: var(--sp-muted);
    white-space: nowrap;
}

/* 16px font size on inputs is required - anything smaller makes iOS Safari
   zoom the whole page on focus, which then reads as "broken layout". */
.sumuppay__qty,
.sumuppay__amount,
.sumuppay__variant,
.sumuppay__field input {
    font-size: 1rem;
    padding: .5rem;
    border: 1px solid var(--sp-line);
    border-radius: 4px;
    background: var(--sp-bg);
    color: var(--sp-ink);
    min-height: var(--sp-tap);
    max-width: 100%;
}

/* iOS centres date inputs by default, which looks like a mistake next to
   left-aligned text fields. */
.sumuppay__field input {
    text-align: left;
}

/* Quantity is a native <select> so phones show the OS picker. Sized generously
   as a touch target and given a visible chevron so it reads as tappable. */
.sumuppay__qty {
    width: 5rem;
    padding-right: 1.75rem;
    font-weight: 600;
    text-align: center;
    text-align-last: center;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%235b6875' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .6rem center;
    background-size: .7rem;
}

/* Selecting a quantity should be visibly different from leaving it at zero.
   Keyed on "0" rather than :not("1") so an unrendered select is not highlighted
   before the script has run. */
.sumuppay__qty[data-zero="0"] {
    border-color: var(--sp-accent);
    border-width: 2px;
    color: var(--sp-accent);
}

.sumuppay__amount {
    width: 7rem;
}

.sumuppay__variant {
    flex: 1 1 10rem;
    min-width: 0;
    max-width: 100%;
}

.sumuppay__open {
    display: flex;
    align-items: center;
    gap: .3rem;
}

/* Description for a custom amount - full width, since "Hangar rent, June" needs
   more room than a price does. */
.sumuppay__desc-wrap {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    margin: 0;
    flex: 1 1 100%;
    min-width: 0;
}

.sumuppay__desc-label {
    font-size: .82rem;
    color: var(--sp-muted);
}

.sumuppay__desc {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    font-size: 1rem;
    padding: .5rem;
    min-height: var(--sp-tap);
    border: 1px solid var(--sp-line);
    border-radius: 4px;
    background: var(--sp-bg);
    color: var(--sp-ink);
}

.sumuppay__cur {
    font-weight: 600;
}

.sumuppay__note {
    margin: 0;
    font-size: .82rem;
    color: var(--sp-muted);
    overflow-wrap: anywhere;
}

/* ---- Details --------------------------------------------------------- */

.sumuppay__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: .85rem;
}

.sumuppay__field {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    margin: 0;
    min-width: 0;
}

.sumuppay__field > span {
    font-size: .85rem;
    color: var(--sp-muted);
}

.sumuppay__reg {
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 600;
}

/* ---- Summary --------------------------------------------------------- */

/* The basket needs to read as one contained block, especially on a phone where
   there is no surrounding page furniture to give it edges. */
.sumuppay__summary-wrap {
    border: 1px solid var(--sp-line);
    border-radius: 6px;
    background: var(--sp-bg);
    padding: .25rem .85rem;
    margin-bottom: .85rem;
    min-width: 0;
    overflow-x: auto;
}

.sumuppay__summary {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    table-layout: fixed; /* stops long labels widening the table */
}

/* Collapses to nothing when the basket is empty, so the card does not sit
   there as a blank box. */
.sumuppay__summary:empty,
.sumuppay__lines:empty {
    display: none;
}

.sumuppay__summary td,
.sumuppay__summary th {
    /* Templates (Bootstrap/Cassiopeia) colour table cells themselves; pin
       them to the module's palette so the text always contrasts with the box. */
    color: var(--sp-ink);
    background: transparent;
    padding: .5rem .25rem;
    text-align: left;
    border-bottom: 1px solid var(--sp-soft);
    overflow-wrap: anywhere;
}

.sumuppay__summary tr:last-child td,
.sumuppay__summary tbody tr:last-child td {
    border-bottom: 0;
}

.sumuppay__line-qty {
    width: 3rem;
    color: var(--sp-muted);
}

.sumuppay__line-total,
.sumuppay__total {
    width: 5.5rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.sumuppay__summary tfoot th,
.sumuppay__summary tfoot td {
    border-top: 2px solid var(--sp-ink);
    border-bottom: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

.sumuppay__empty {
    color: var(--sp-muted);
    font-size: .9rem;
    margin: .6rem .25rem;
    text-align: center;
}

.sumuppay__alert {
    background: #fdecea;
    border: 1px solid var(--sp-error);
    color: var(--sp-error);
    border-radius: 4px;
    padding: .6rem .8rem;
    margin: .75rem 0;
    font-size: .92rem;
    overflow-wrap: anywhere;
}

.sumuppay__alert--notice {
    background: #eef4fb;
    border-color: var(--sp-accent);
    color: var(--sp-accent);
}

/* ---- Pay bar (sticky on mobile) -------------------------------------- */

.sumuppay__paybar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-top: .5rem;
}

.sumuppay__paybar-total {
    display: none; /* the summary table already shows it on desktop */
    flex-direction: column;
    line-height: 1.15;
}

.sumuppay__paybar-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--sp-muted);
}

.sumuppay__paybar-value {
    font-size: 1.25rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.sumuppay__start {
    min-height: var(--sp-tap);
    padding: .6rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: 0;
    border-radius: 6px;
    background: var(--sp-accent);
    color: var(--sp-accent-ink);
    cursor: pointer;
    flex: 1 1 auto;
}

.sumuppay__start[disabled] {
    opacity: .45;
    cursor: not-allowed;
}

@media (max-width: 40rem) {
    .sumuppay__paybar.is-active {
        position: sticky;
        bottom: 0;
        z-index: 20;
        /* Negative margin cancels the module gutter so the bar spans the full
           width, then re-applies it as padding to keep contents aligned. */
        margin: .5rem calc(-1 * var(--sp-pad)) 0;
        padding: .7rem var(--sp-pad);
        /* clears the iPhone home indicator */
        padding-bottom: calc(.7rem + env(safe-area-inset-bottom, 0px));
        background: var(--sp-bg);
        border-top: 1px solid var(--sp-line);
        box-shadow: 0 -4px 14px rgba(0, 0, 0, .10);
    }

    .sumuppay__paybar.is-active .sumuppay__paybar-total {
        display: flex;
    }

    .sumuppay__paybar.is-active .sumuppay__start {
        flex: 0 1 auto;
    }
}

/* ---- Widget & receipt ------------------------------------------------ */

.sumuppay__widget {
    margin-top: 1.25rem;
    padding: .75rem;
    background: var(--sp-soft);
    border-radius: 6px;
    min-width: 0;
}

/* SumUp injects its own iframe - keep it inside the viewport whatever width
   it asks for. */
.sumuppay__widget iframe,
.sumuppay__widget-target {
    max-width: 100%;
}

.sumuppay__cancel {
    display: block;
    width: 100%;
    min-height: var(--sp-tap);
    margin: .5rem auto 0;
    background: none;
    border: 0;
    color: var(--sp-accent);
    text-decoration: underline;
    cursor: pointer;
    font-size: 1rem;
}

.sumuppay__receipt {
    margin-top: 1.25rem;
    padding: 1rem;
    border: 2px solid #1e7a3c;
    border-radius: 6px;
    background: #f2fbf5;
    overflow-wrap: anywhere;
}

.sumuppay__receipt h4 {
    margin-top: 0;
    color: #1e7a3c;
}

.sumuppay__receipt-lines {
    margin: .5rem 0;
    padding-left: 1.1rem;
}

.sumuppay__legal {
    font-size: .8rem;
    color: var(--sp-muted);
    border-top: 1px solid var(--sp-line);
    padding-top: .75rem;
    margin-bottom: 0;
}

/* ---- Wider screens --------------------------------------------------- */

@media (min-width: 40rem) {
    .sumuppay {
        --sp-pad: 0rem; /* centred with room to spare - no gutter needed */
    }

    .sumuppay__heading {
        font-size: 1.05rem;
    }

    .sumuppay__cat {
        padding: .5rem 1rem 1rem;
    }

    /* Label and controls share a row once there is room for both. */
    .sumuppay__item {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: .75rem;
    }

    .sumuppay__item-main {
        flex: 1 1 14rem;
    }

    .sumuppay__item-controls {
        flex: 0 0 auto;
    }

    /* The custom-amount row needs the description on its own full-width line
       even on desktop - a one-line explanation deserves the space. */
    .sumuppay__item--open .sumuppay__item-controls {
        flex: 1 1 100%;
        flex-wrap: wrap;
    }

    .sumuppay__note {
        flex: 1 1 100%;
    }

    .sumuppay__grid {
        grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
        gap: 1rem;
    }

    .sumuppay__paybar {
        justify-content: flex-start;
    }

    .sumuppay__start {
        flex: 0 0 auto;
    }

    .sumuppay__cancel {
        width: auto;
    }

    .sumuppay__widget {
        padding: 1rem;
    }
}

/* ---- During payment ------------------------------------------------ */

/* Once the card form is up, only the amount and the form are shown. The fee
   list, details and item table come back with "Change my order". */
.sumuppay.is-paying .sumuppay__intro,
.sumuppay.is-paying [data-step="items"],
.sumuppay.is-paying [data-step="details"],
.sumuppay.is-paying .sumuppay__summary-wrap,
.sumuppay.is-paying .sumuppay__paybar {
    display: none !important;
}

.sumuppay__payline {
    margin: 0 .25rem .75rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--sp-ink);
}

/* ---- Dark mode ------------------------------------------------------- */

/* Opt-in only. Following the OS setting made the module go dark inside the
   site's light template, and the template's own table text colour then left
   dark text on a dark box. If the site template ever goes dark, add the class
   "sumuppay--dark" to the .sumuppay wrapper in tmpl/default.php. */
.sumuppay.sumuppay--dark {
    color-scheme: dark;
    --sp-ink: #e8edf2;
    --sp-muted: #9aa7b4;
    --sp-line: #3a444f;
    --sp-soft: #232b34;
    --sp-bg: #171d24;
    --sp-accent: #5db3e0;
    --sp-accent-ink: #0b1219;
}

.sumuppay--dark .sumuppay__receipt {
    background: #17281d;
}

.sumuppay--dark .sumuppay__alert {
    background: #2b1a19;
}

.sumuppay--dark .sumuppay__alert--notice {
    background: #17242e;
}

/* Respect reduced-motion for the smooth scrolls triggered in JS. */
@media (prefers-reduced-motion: reduce) {
    .sumuppay * {
        scroll-behavior: auto !important;
    }
}
