/*
 * Buy-pack landing (/buy-pack/{id}).
 * The artwork always fills the full device height; the form is anchored to
 * the bottom of the stage, where the artwork leaves room for it.
 */
.buy {
    --buy-accent: #4A4A6B;
    --buy-accent-dark: #3a3a5b;
    --buy-field-bg: #FEEBF5;
    --buy-bg-landscape: url('../../img/buy-pack-desktop.webp');
    --buy-bg-portrait: url('../../img/buy-pack-mobile.webp');
    /* Edge colour of the artwork; fills any space it does not cover. */
    --buy-fill: #f7f7f7;
    --buy-fade: linear-gradient(var(--buy-fill), var(--buy-fill));

    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: 'Hind Siliguri', sans-serif;
    background: #fff;
}

/* Alternate artwork + accent used when OTP is switched off. */
.buy--direct {
    --buy-accent: #E4106F;
    --buy-accent-dark: #c40d5e;
    --buy-bg-landscape: url('../../img/quiz-mind-bg-web-new.webp');
    --buy-bg-portrait: url('../../img/quiz-mind-bg-mobile.webp');
    --buy-fill: #fff;
    --buy-fade: linear-gradient(#fff, #fff);
}

.buy__stage {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    min-height: 320px;
    padding: 24px 16px clamp(20px, 7vh, 72px);
    /*
     * "contain", anchored to the top: the whole artwork is always visible, so
     * the QuizClub logo in its top-right corner can never be cropped. When the
     * screen is taller or wider than the artwork, the leftover space is filled
     * with the artwork's own white-to-cream colours.
     */
    background-color: var(--buy-fill);
    background-image: var(--buy-bg-landscape), var(--buy-fade);
    background-repeat: no-repeat;
    background-size: contain, 100% 100%;
    background-position: center top, center;
}

@media (orientation: portrait) {
    .buy__stage {
        background-image: var(--buy-bg-portrait), var(--buy-fade);
    }
}

.buy__form {
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.buy__field {
    display: flex;
    align-items: stretch;
    height: 52px;
    margin: 0 auto 12px;
    overflow: hidden;
    border: 2px solid var(--buy-accent);
    border-radius: 15px;
    background: var(--buy-field-bg);
}

.buy__field:focus-within {
    box-shadow: 0 0 0 3px rgba(74, 74, 107, .25);
}

.buy__field-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;
    background: #fff;
    color: var(--buy-accent);
    font-size: 20px;
}

.buy__input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0 14px;
    border: 0;
    background: transparent;
    color: var(--buy-accent);
    /* 16px stops iOS Safari from zooming into the field */
    font: 500 16px/1.2 'Hind Siliguri', sans-serif;
}

.buy__input::placeholder {
    color: var(--buy-accent);
    opacity: .7;
}

.buy__input:focus {
    outline: 0;
}

.buy__error {
    margin: 0 0 12px;
    color: #d93636;
    font-size: 14px;
}

.buy__submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 50px;
    padding: 10px 20px;
    border: 2px solid var(--buy-accent);
    border-radius: 15px;
    background: var(--buy-accent);
    color: #fff;
    font: 700 18px/1.4 'Hind Siliguri', sans-serif;
    cursor: pointer;
    transition: background-color .2s ease, transform .2s ease, box-shadow .2s ease;
}

.buy__submit:hover,
.buy__submit:focus-visible {
    border-color: var(--buy-accent-dark);
    background: var(--buy-accent-dark);
    box-shadow: 0 4px 8px rgba(74, 74, 107, .3);
    transform: translateY(-2px);
}

.buy__submit:focus-visible {
    outline: 3px solid #D41959;
    outline-offset: 2px;
}

.buy__submit:active {
    transform: none;
}

.buy__submit:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.buy__submit:disabled:hover {
    border-color: var(--buy-accent);
    background: var(--buy-accent);
}

.buy__submit.is-loading:disabled {
    opacity: .85;
    cursor: progress;
}

.buy__submit.is-loading {
    pointer-events: none;
    opacity: .85;
    transform: none;
}

.buy__loader {
    display: none;
    width: 18px;
    height: 18px;
    margin-right: 8px;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: buy-spin .7s linear infinite;
}

.buy__submit.is-loading .buy__loader {
    display: inline-block;
}

.buy__note {
    display: block;
    margin-top: 12px;
    color: #000;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
    letter-spacing: .5px;
}

.buy__footer {
    flex: 0 0 auto;
    padding: 10px 16px;
    background: #1b1e21;
    color: #fff;
    text-align: center;
    font-size: 14px;
}

@keyframes buy-spin {
    to { transform: rotate(360deg); }
}

/* Very short portrait screens (e.g. 320x568): less bottom padding keeps the form clear of the artwork */
@media (orientation: portrait) and (max-height: 600px) {
    .buy__stage { padding-bottom: 12px; }
}

/* Short landscape screens (phones on their side): tighter spacing */
@media (orientation: landscape) and (max-height: 520px) {
    /* The artwork is only ~330px tall here: put the field and button side by
       side so the form stays inside the empty bottom strip. */
    .buy__stage { align-items: center; padding: 12px 16px; }
    .buy__form {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 8px;
        align-items: center;
        max-width: 480px;
    }
    .buy__field { grid-row: 1; grid-column: 1; height: 46px; margin: 0; }
    .buy__submit { grid-row: 1; grid-column: 2; width: auto; min-height: 46px; padding: 8px 20px; }
    .buy__form > .buy__error { grid-row: 2; grid-column: 1 / -1; margin: 0; }
    .buy__note { grid-row: 3; grid-column: 1 / -1; margin: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .buy__submit { transition: none; }
    .buy__loader { animation-duration: 1.5s; }
}
