/* =========================================================
   NÜMO — Checkout modal
   Mobile-first:
     • <600px → fullscreen sheet with sticky header + sticky CTA
     • ≥600px → centered modal with breathing room
   Inputs are 16px+ so iOS doesn't auto-zoom on focus.
   ========================================================= */

body.nco-open { overflow: hidden; }

.nco {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: stretch;       /* card fills the overlay on mobile */
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
    font-family: "Manrope", system-ui, sans-serif;
    color: #f4ece4;
}
.nco.is-open { opacity: 1; pointer-events: auto; }

.nco__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 6, 10, .82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    cursor: pointer;
}

/* ----- The card (single flex column: head / body / foot) ----- */
.nco__card {
    position: relative;
    z-index: 1;
    flex: 1 1 100%;
    display: flex;
    flex-direction: column;
    background: #0c0a0e;
    width: 100%;
    overflow: hidden;
    /* The fullscreen variant aligns to viewport edges (no border, no
       rounded corners). Desktop gets a proper modal frame below. */
}

/* ----- Header (sticky-ish: stays at top of card) ----- */
.nco__head {
    position: relative;
    flex: 0 0 auto;
    padding: 18px 22px 18px;
    padding-top: calc(18px + env(safe-area-inset-top));
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    background: #0c0a0e;
}
.nco__close {
    position: absolute;
    z-index: 6;                 /* stays clickable above the loading veil */
    top: calc(14px + env(safe-area-inset-top));
    right: 14px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, .06);
    color: #f4ece4;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .2s ease, transform .15s ease;
}
.nco__close:hover { background: rgba(255, 255, 255, .12); transform: scale(1.05); }
.nco__close:active { transform: scale(0.95); }
.nco__close svg { width: 18px; height: 18px; }

.nco__eyebrow {
    margin: 0 0 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.24em;
    color: #c5704d;
    text-transform: uppercase;
}
.nco__head-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}
.nco__product {
    margin: 0;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.01em;
    color: #f4ece4;
    /* Soft wrap if the title is long on narrow screens */
    flex: 1 1 auto;
    min-width: 0;
}
.nco__price {
    margin: 0;
    font-weight: 800;
    font-size: 24px;
    color: #f4ece4;
    letter-spacing: 0.01em;
    white-space: nowrap;
    flex: 0 0 auto;
}

/* ----- Scrollable body ----- */
.nco__body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 22px 28px;
}

/* Layout wrapper: single column (flex) on mobile — form, then order summary,
   then the CTA. On desktop it becomes a 2-column grid (see the ≥760px query):
   form + card on the left, sticky order summary on the right. */
.nco__grid {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.nco__section {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, .06);
}
.nco__section:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}
/* Express checkout section — Apple/Google/Amazon Pay buttons sit here.
   The element renders nothing when no wallet is available, in which
   case JS toggles [hidden] on this section and the layout collapses.
   Doubled class: it must outrank `.nco__section:first-child` (0,2,0),
   which otherwise zeroes the card's top padding and leaves the legend
   glued to the border. */
.nco__section.nco__section--express {
    background: linear-gradient(180deg, rgba(197, 112, 77, .07), rgba(197, 112, 77, .03));
    border: 1px solid rgba(197, 112, 77, .16);
    border-radius: 12px;
    padding: 16px 16px 2px;
    margin: 0 0 20px;
}
.nco__section--express .nco__legend {
    margin-bottom: 14px;
    color: #c5704d;
}
/* The 80px reservation below is for the card form; the express mount only
   ever holds the 48px wallet button — reserving more leaves a dead band
   between the button and the separator. */
.nco__section--express .nco__pay-mount { min-height: 0; margin-bottom: 4px; }

/* Shipping-zone notice under the wallet button. The "invalid address" error
   inside the Apple/Google Pay sheet is native OS UI we cannot reword, so we
   set the expectation upfront instead. */
.nco__express-note {
    margin: 10px 2px 0;
    font-size: 12px;
    line-height: 1.45;
    color: #8e827a;
}

/* ----- Order summary — a self-contained panel (its own column on desktop,
   a boxed block above the CTA on mobile). Doubled class beats
   `.nco__section:first-child`, which would otherwise strip its box. ----- */
.nco__section.nco__section--summary {
    margin: 0;
    padding: 16px 16px 14px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 12px;
    background: rgba(255, 255, 255, .02);
}
.nco__section--summary .nco__legend { margin-bottom: 12px; }

.nco__sum-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
    color: #c8bdb1;
    padding: 5px 0;
}
.nco__sum-row small {
    color: #8e827a;
    font-size: 12px;
    font-weight: 500;
}
.nco__sum-row > span:last-child {
    font-weight: 600;
    color: #f4ece4;
    white-space: nowrap;
}
/* Free-shipping saving cue: struck zone rate + copper "Gratis". */
.nco__sum-row s { color: #8e827a; font-weight: 400; margin-right: 6px; }
.nco__free { color: #c5704d; }
/* Quantity-discount row — amount in brand copper. */
.nco__sum-row .nco__discount { color: #c5704d; }
.nco__sum-row[hidden] { display: none; }
.nco__sum-row--total {
    margin-top: 6px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    font-size: 16px;
    color: #f4ece4;
    font-weight: 700;
}
.nco__sum-row--total > span:last-child {
    font-size: 18px;
    font-weight: 800;
    color: #c5704d;
}
.nco__ship-note {
    margin: 10px 0 0;
    font-size: 12px;
    line-height: 1.45;
    color: #8e827a;
}
.nco__ship-note[hidden] { display: none; }

/* The express section is born hidden and revealed by the element's 'ready'
   event only when a wallet is available — ease it in so the late arrival
   reads as intentional, not as a layout glitch. */
.nco__section--express:not([hidden]) {
    animation: ncoExpressIn .3s ease both;
}
@keyframes ncoExpressIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: none; }
}
.nco__separator {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #8e827a;
    padding: 12px 0 14px;
}
.nco__separator::before,
.nco__separator::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: rgba(255, 255, 255, .08);
}
.nco__legend {
    margin: 0 0 14px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.22em;
    color: #8e827a;
    text-transform: uppercase;
}

/* ----- Form fields ----- */
.nco__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}
.nco__field > span {
    font-size: 13px;
    color: #c8bdb1;
    letter-spacing: 0.02em;
}
.nco__field > span em { color: #8e827a; font-style: normal; }
.nco__field-hint {
    font-size: 11.5px;
    color: #9e9186;
    line-height: 1.35;
    margin-top: 1px;
}

.nco__field input,
.nco__field select {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid rgba(255, 255, 255, .12);
    background: #07060a;
    color: #f4ece4;
    font: inherit;
    /* 16px keeps iOS from auto-zooming on focus */
    font-size: 16px;
    line-height: 1.2;
    padding: 14px 14px;
    border-radius: 10px;
    min-height: 50px;
    transition: border-color .15s ease, background .15s ease;
    width: 100%;
}
.nco__field input::placeholder {
    color: #6f655d;
    opacity: 1;
}
.nco__field select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='8' viewBox='0 0 14 8' fill='none' stroke='%23c8bdb1' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><polyline points='1,1 7,7 13,1'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 38px;
    cursor: pointer;
}
.nco__field select option {
    background: #0c0a0e;
    color: #f4ece4;
}
.nco__field input:focus,
.nco__field select:focus {
    outline: none;
    border-color: #c5704d;
    background: #0a0810;
    box-shadow: 0 0 0 3px rgba(197, 112, 77, .18);
}
.nco__field input:invalid:not(:placeholder-shown) {
    border-color: rgba(227, 107, 107, .5);
}
.nco__row {
    display: flex;
    gap: 12px;
}
.nco__field--grow { flex: 1 1 auto; min-width: 0; }
.nco__field--cp   { flex: 0 0 40%; }

/* Stripe PaymentElement mount */
.nco__pay-mount { min-height: 80px; }

/* ----- Pay CTA — a grid/flex item under the form (desktop) / last block
   (mobile). Spacing is handled by the .nco__grid gap, not a pinned footer. ----- */
.nco__foot {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Always rendered (role="alert") so screen readers announce text changes.
   Collapsed to zero height when empty; the box only appears once .is-shown
   is added together with the message. (display:none would drop it from the
   a11y tree and the alert would never fire on some SR/browser combos.) */
.nco__error {
    margin: 0;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #f4c3c3;
    font-size: 13.5px;
    line-height: 1.4;
    max-height: 0;
    overflow: hidden;
    transition: max-height .2s ease, padding .2s ease;
}
.nco__error.is-shown {
    padding: 10px 14px;
    max-height: 200px;
    background: rgba(227, 107, 107, .12);
    border-color: rgba(227, 107, 107, .3);
}

.nco__submit {
    margin: 0;
    padding: 16px 28px;
    min-height: 54px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(180deg, #d88a63, #c5704d);
    color: #fff;
    font-family: inherit;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
    /* Inset highlight gives the gradient a machined top edge. */
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 14px 30px -12px rgba(197, 112, 77, .45);
    transition: transform .15s ease, box-shadow .2s ease, opacity .15s ease;
    position: relative;
    overflow: hidden;
}
.nco__submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 20px 40px -12px rgba(197, 112, 77, .55);
}
.nco__submit:active:not(:disabled) { transform: translateY(1px); }
.nco__submit:disabled { opacity: 0.7; cursor: progress; }

.nco__submit-spinner {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2.5px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: nco-spin .8s linear infinite;
}
.nco__submit.is-loading .nco__submit-label { visibility: hidden; }
.nco__submit.is-loading .nco__submit-spinner { display: block; }
@keyframes nco-spin { to { transform: rotate(360deg); } }

.nco__legal {
    margin: 0;
    font-size: 11px;
    letter-spacing: 0.04em;
    color: #8e827a;
    text-align: center;
    line-height: 1.4;
}
.nco__legal-lock {
    width: 11px;
    height: 11px;
    vertical-align: -1px;
    margin-right: 5px;
}

/* ----- Loading veil — opaque cover over the whole card while Stripe mounts
   and detects wallets. Lifts (fades out, click-through) once setPayReady(true)
   fires, revealing the finished checkout in one go. The close button sits
   above it (z-index) so the buyer can always bail out. ----- */
.nco__loading {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: #0c0a0e;
    transition: opacity .3s ease;
}
.nco__loading.is-done {
    opacity: 0;
    pointer-events: none;
}
.nco__loading-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid rgba(197, 112, 77, .22);
    border-top-color: #c5704d;
    border-radius: 50%;
    animation: nco-spin .8s linear infinite;
}
.nco__loading-text {
    margin: 0;
    font-size: 13px;
    letter-spacing: 0.06em;
    color: #8e827a;
}

/* ===== Desktop = centered modal ===== */
@media (min-width: 600px) {
    .nco {
        align-items: flex-start;
        padding: 48px 16px;
    }
    .nco__card {
        flex: 0 0 auto;
        max-width: 480px;
        max-height: calc(100vh - 96px);
        max-height: calc(100dvh - 96px);
        border-radius: 14px;
        border: 1px solid rgba(255, 255, 255, .08);
        box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .7);
    }
    .nco__head { padding-top: 22px; }
    .nco__close { top: 14px; right: 14px; }
}

/* ===== Wide desktop = two columns (form + card left, summary right) ===== */
@media (min-width: 760px) {
    .nco__card { max-width: 840px; }
    .nco__grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 300px;
        column-gap: 32px;
        row-gap: 22px;
        align-items: start;
    }
    .nco__main { grid-column: 1; grid-row: 1; min-width: 0; }
    .nco__aside {
        grid-column: 2;
        grid-row: 1 / span 2;
        position: sticky;
        top: 0;
        align-self: start;
    }
    .nco__foot { grid-column: 1; grid-row: 2; }
}

@media (prefers-reduced-motion: reduce) {
    .nco, .nco__submit, .nco__close { transition: none; }
    .nco__submit-spinner, .nco__loading-spinner { animation: none; }
}
