/*
 * AdOffer tab ("Lasche"): centred, as wide as its content, square at the top, rounded at the
 * bottom. Lives inside .header-container (block layout_header_bottom):
 * - desktop, not scrolled: hangs from the header bar over the top of .header-container
 * - desktop scrolled (body.fixed-header, .header-container is fixed): below .header-container
 * - desktop turning sticky: fades in below .header-container after its height transition
 * - mobile, not sticky: below .header-bar (scrolls with it), .mobile-logo-box gets the tab height as padding-top
 * - mobile sticky (body.fixed-header): below .header-container
 * so it stays visible while scrolling without a scroll listener of its own.
 */
.cc-adoffer {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 10px;
    width: max-content;
    max-width: calc(100vw - 32px);
    padding: 7px 38px 9px 18px;
    /* $fd-red: the theme's signal colour, used sparingly so the tab stands out */
    background-color: #EF2856;
    color: #fff;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
    font-family: 'Rounded-Bold', Arial, Helvetica, sans-serif;
    font-weight: bold;
    font-size: 15px;
    line-height: 1.3;
    text-align: center;
    pointer-events: auto;
}

.cc-adoffer__code {
    padding: 2px 8px;
    border: 1px dashed #fff;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-family: 'Rounded-Bold', Arial, Helvetica, sans-serif;
    font-size: 16px;
    letter-spacing: 0.05em;
    user-select: all;
}

.cc-adoffer__copy {
    padding: 3px 12px;
    border: 0;
    border-radius: 12px;
    background-color: #FFF4E5;
    color: #4F3429;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
}

.cc-adoffer__copy:hover,
.cc-adoffer__copy:focus-visible,
.cc-adoffer__copy.is-copied {
    background-color: #fff;
}

.cc-adoffer__redeemed {
    font-weight: bold;
}

.cc-adoffer__close {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 20px;
    line-height: 24px;
    cursor: pointer;
    opacity: 0.8;
}

.cc-adoffer__close:hover,
.cc-adoffer__close:focus-visible {
    opacity: 1;
}

@media (min-width: 992px) {
    /* not scrolled: .header-container is static, give the tab its anchor */
    body:not(.fixed-header) .header-container {
        position: relative;
    }

    body:not(.fixed-header) .cc-adoffer {
        top: 0;
    }

    /* turning sticky: the tab scrolls out with the header, then fades in below .header-container
       once its height transition (0.5s, theme head.scss) has finished. Not in the checkout, whose
       header is sticky from the start. */
    body.fixed-header:not(.is-checkout) .cc-adoffer {
        animation: cc-adoffer-fade-in 0.3s ease-out 0.5s both;
    }
}

@keyframes cc-adoffer-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media (max-width: 991.98px) {
    /* compact, so code and button fit into one line on a phone */
    .cc-adoffer {
        gap: 4px 8px;
        padding: 5px 30px 7px 12px;
        font-size: 14px;
        border-radius: 0 0 12px 12px;
    }

    .cc-adoffer__code {
        padding: 1px 6px;
        font-size: 14px;
    }

    .cc-adoffer__copy {
        padding: 2px 10px;
        font-size: 12px;
    }

    .cc-adoffer__close {
        right: 4px;
    }

    /* While .header-bar is visible the inline script in cc_adoffer_tab.tpl moves the tab INTO the bar,
       so it scrolls with it natively (no per-frame JS, no wobble); once the bar has vanished below
       the sticky .header-container it moves back into the container. top: 100% in both. */
    html.cc-adoffer-pushed .header-bar {
        position: relative;
    }

    /* the theme hides .header-bar when the header turns sticky; the tab must stay visible meanwhile */
    .header-bar > .cc-adoffer {
        visibility: visible;
    }

    /* the theme gives .mobile-logo-box no padding-top; beige like .mobile-logo-line, otherwise the
       white page shows behind the tab */
    html.cc-adoffer-pushed .mobile-logo-box {
        padding-top: var(--cc-adoffer-height, 0);
        background-color: #FFF4E5;
    }
}
