/* ============================================================================
   VoucherRedeem — the one place a code is typed.

   A Confirm-class overlay: above the Moon Store (30000), below Confirm
   (100000). Every box is sized on first paint; the error line reserves its own
   height so a refusal never moves the buttons.
   ========================================================================== */

.voucher-redeem {
    position: fixed;
    inset: 0;
    z-index: 40000;
    display: grid;
    place-items: center;
    box-sizing: border-box;
    padding: max(var(--mf-safe-top, 0px), 16px) max(var(--mf-safe-right, 0px), 16px)
             max(var(--mf-safe-bottom, 0px), 16px) max(var(--mf-safe-left, 0px), 16px);
    background: rgba(4, 2, 12, 0.8);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    animation: voucher-redeem-fade 140ms ease-out;
}

.voucher-redeem-panel {
    width: min(440px, 100%);
    max-height: 100%;
    overflow-y: auto;
    box-sizing: border-box;
    padding: 22px 24px 20px;
    border: 1px solid rgba(255, 224, 151, 0.42);
    border-radius: 18px;
    color: #fff9e8;
    text-align: center;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.07), transparent 42%),
        linear-gradient(155deg, #211536 0%, #120c21 58%, #0b0814 100%);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), 0 0 40px rgba(154, 100, 231, 0.18);
    animation: voucher-redeem-rise 180ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

.voucher-redeem-eyebrow {
    margin: 0 0 6px;
    color: #e7ca82;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.2em;
}

.voucher-redeem-title {
    margin: 0 0 14px;
    color: #fffaf0;
    font-family: 'Cinzel', Georgia, serif;
    font-size: clamp(1.3rem, 4.5vw, 1.7rem);
    font-weight: 800;
    line-height: 1.1;
}

.voucher-redeem-label {
    display: block;
    margin: 0 0 6px;
    color: rgba(232, 220, 250, 0.82);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.voucher-redeem-input {
    display: block;
    width: 100%;
    min-height: var(--mf-touch, 44px);
    box-sizing: border-box;
    margin: 0;
    padding: 0 14px;
    border: 1px solid rgba(214, 176, 92, 0.55);
    border-radius: 12px;
    background: rgba(8, 5, 16, 0.75);
    color: #fff1be;
    font: 600 1.15rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: 0.12em;
    text-align: center;
    text-transform: uppercase;
    outline: none;
}

.voucher-redeem-input::placeholder {
    color: rgba(255, 241, 190, 0.32);
    letter-spacing: 0.12em;
}

.voucher-redeem-input:focus-visible {
    border-color: #ffe5a0;
    box-shadow: 0 0 0 3px rgba(200, 178, 255, 0.35);
}

.voucher-redeem-help {
    margin: 8px 0 0;
    color: rgba(232, 220, 250, 0.72);
    font-size: 0.82rem;
    line-height: 1.35;
}

/* Reserved height: the line exists empty, so its text never moves anything. */
.voucher-redeem-error {
    margin: 6px 0 12px;
    min-height: 1.4em;
    color: #ff9d9d;
    font-size: 0.86rem;
    font-weight: 700;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.voucher-redeem-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.voucher-redeem-actions .btn {
    min-height: var(--mf-touch, 44px);
    min-width: 120px;
    padding: 0 18px;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@keyframes voucher-redeem-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes voucher-redeem-rise {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

@media (orientation: landscape) and (max-height: 560px) {
    .voucher-redeem-panel {
        padding: 12px 16px;
    }
    .voucher-redeem-title { margin-bottom: 8px; font-size: 1.15rem; }
    .voucher-redeem-help { margin-top: 5px; font-size: 0.76rem; }
    .voucher-redeem-error { margin: 4px 0 8px; font-size: 0.8rem; }
}

/* The shortest page boxes we ship (an iPhone in landscape with the URL bar and
   a tab strip: 280px) hold the whole dialog only with the vertical rhythm
   pulled in; the panel must never scroll, so every row keeps its height and
   the gaps give. Measured: 244px of content in a 242px box before this tier. */
@media (orientation: landscape) and (max-height: 320px) {
    .voucher-redeem-panel { padding: 8px 16px; }
    .voucher-redeem-eyebrow { margin-bottom: 3px; }
    .voucher-redeem-title { margin-bottom: 5px; }
    .voucher-redeem-label { margin-bottom: 4px; }
    .voucher-redeem-help { margin-top: 3px; }
    .voucher-redeem-error { margin: 2px 0 6px; }
    .voucher-redeem-actions { gap: 8px; }
}

/* ============================================================================
   THE KEYBOARD IS UP: one row, nothing decorative.

   Two triggers, one layout. iOS keeps the layout viewport and shrinks only the
   visual one, so `voucher-redeem.js` sizes the overlay to the visual viewport
   and marks it `data-keyboard="open"`. Android Chrome shrinks the layout
   viewport itself, so the same rules ride a `max-height` band. Either way the
   player is looking at ~90-170px of page above the keys, and what they need
   in it is the field they are typing into and the two buttons — the eyebrow,
   title, label and help line have already been read. The error line keeps
   its reserved row beneath, so a refusal still moves nothing.

   Measured on the owner's profile (932x300 page box, keyboard leaving ~170px;
   the URL-bar-only 852x344 leaves ~210px): the row is 44px of input and
   buttons plus the 20px error line plus 20px of padding — 84px, which fits
   the shortest keyboard-up box any profile in mobileViewports.js produces.
   ========================================================================== */
.voucher-redeem[data-keyboard="open"] {
    /* The overlay's inline top/left/width/height come from the visual
       viewport; `inset: 0` must not fight them. */
    inset: auto;
    padding: 6px max(var(--mf-safe-right, 0px), 8px) 6px max(var(--mf-safe-left, 0px), 8px);
    /* No fade-in for a re-layout that happens mid-typing. */
    animation: none;
}

.voucher-redeem[data-keyboard="open"] .voucher-redeem-panel{
    width: min(680px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 10px;
    row-gap: 0;
    padding: 10px 12px;
    animation: none;
}

.voucher-redeem[data-keyboard="open"] .voucher-redeem-eyebrow,
.voucher-redeem[data-keyboard="open"] .voucher-redeem-title,
.voucher-redeem[data-keyboard="open"] .voucher-redeem-label,
.voucher-redeem[data-keyboard="open"] .voucher-redeem-help{
    display: none;
}

.voucher-redeem[data-keyboard="open"] .voucher-redeem-input{
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
}

.voucher-redeem[data-keyboard="open"] .voucher-redeem-actions{
    grid-column: 2;
    grid-row: 1;
    flex-wrap: nowrap;
    gap: 8px;
}

.voucher-redeem[data-keyboard="open"] .voucher-redeem-actions .btn{
    min-width: 0;
    padding: 0 14px;
    white-space: nowrap;
}

.voucher-redeem[data-keyboard="open"] .voucher-redeem-error{
    grid-column: 1 / -1;
    grid-row: 2;
    margin: 4px 0 0;
    min-height: 1.4em;
    text-align: left;
}

/* Android (and any engine that shrinks the LAYOUT viewport for the keyboard):
   the same compact row, keyed on the height the page is left with. Nothing
   Moonfall ships gives a landscape phone a 230px page box without a keyboard —
   the shortest measured profile is 275px. */
@media (max-height: 230px) {
    .voucher-redeem {
        padding: 6px max(var(--mf-safe-right, 0px), 8px) 6px max(var(--mf-safe-left, 0px), 8px);
    }
    .voucher-redeem-panel {
        width: min(680px, 100%);
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        column-gap: 10px;
        row-gap: 0;
        padding: 10px 12px;
    }
    .voucher-redeem-eyebrow,
    .voucher-redeem-title,
    .voucher-redeem-label,
    .voucher-redeem-help {
        display: none;
    }
    .voucher-redeem-input { grid-column: 1; grid-row: 1; min-width: 0; }
    .voucher-redeem-actions { grid-column: 2; grid-row: 1; flex-wrap: nowrap; gap: 8px; }
    .voucher-redeem-actions .btn { min-width: 0; padding: 0 14px; white-space: nowrap; }
    .voucher-redeem-error { grid-column: 1 / -1; grid-row: 2; margin: 4px 0 0; min-height: 1.4em; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
    .voucher-redeem,
    .voucher-redeem-panel {
        animation: none;
    }
}
