/*
 * Checkout exit-intent offers (src/components/ExitOffers.astro, public/js/exit-offer.js).
 * Colours, type and radii come from the site tokens (base/_reset.scss).
 */
.exit-offer {
    --eo-accent: var(--c-primary, #0e6fe0);
    --eo-accent-strong: var(--c-primary-hover, #0a58b8);
    --eo-header-from: var(--c-primary, #0e6fe0);
    --eo-header-to: var(--c-primary-hover, #0a58b8);
    --eo-soft: var(--c-primary-soft, #e3eefc);
    --eo-badge-text: #ffffff;
    --eo-success: var(--c-success, #18794e);
    --eo-text: var(--c-text, #0b1a2e);
    --eo-muted: var(--c-text-muted, #4f5f76);
    --eo-line: var(--c-border, #d9e2ed);
    --eo-card: var(--c-bg, #f4f7fb);
    --eo-radius: var(--r-card, 20px);
    display: none;
    font-family: var(--font, 'Plus Jakarta Sans', system-ui, sans-serif);
    color: var(--eo-text);
}

.exit-offer--final {
    /* Final offer: the deep navy of the site's hero and footer. */
    --eo-accent: var(--c-navy, #0a1c33);
    --eo-accent-strong: #13304f;
    --eo-header-from: var(--c-navy, #0a1c33);
    --eo-header-to: #13304f;
    --eo-soft: var(--c-bg-alt, #e9f0f8);
}

.exit-offer.is-open {
    display: block;
}

html.exit-offer-locked,
html.exit-offer-locked body {
    overflow: hidden;
}

.exit-offer *,
.exit-offer *::before,
.exit-offer *::after {
    box-sizing: border-box;
}

.exit-offer__overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(20, 26, 20, 0.58);
    animation: exit-offer-fade 0.2s ease-out;
}

.exit-offer__dialog {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow: hidden;
    border-radius: var(--eo-radius);
    background: #ffffff;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
    animation: exit-offer-rise 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.exit-offer__dialog:focus {
    outline: none;
}

/* Header */
.exit-offer__header {
    position: relative;
    flex-shrink: 0;
    padding: 30px 56px 30px;
    text-align: center;
    color: #ffffff;
    background: linear-gradient(180deg, var(--eo-header-from) 0%, var(--eo-header-to) 100%);
}

.exit-offer__eyebrow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0;
    font-size: 30px;
    line-height: 1;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.exit-offer__eyebrow svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.exit-offer__headline {
    margin: 10px 0 0;
    font-size: 68px;
    line-height: 1;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #ffffff;
}

.exit-offer__lede {
    margin: 14px 0 0;
    font-size: 17px;
    line-height: 1.35;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.94);
}

.exit-offer__close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.16);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.exit-offer__close:hover {
    background: rgba(255, 255, 255, 0.28);
}

.exit-offer__close svg {
    width: 18px;
    height: 18px;
}

/* Body */
.exit-offer__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 28px 30px 24px;
}

.exit-offer__preview {
    margin: 0 0 16px;
    padding: 8px 12px;
    border: 1px dashed #c9a227;
    border-radius: 10px;
    background: #fdf8e6;
    font-size: 13px;
    line-height: 1.4;
    color: #5c4a0c;
}

.exit-offer__label {
    margin: 0;
    font-size: 13px;
    line-height: 1.3;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--eo-muted);
}

.exit-offer__product {
    display: grid;
    grid-template-columns: 72px 1fr;
    align-items: center;
    gap: 18px;
    padding: 16px 22px;
    border: 1px solid var(--eo-line);
    border-radius: var(--eo-radius);
    background: var(--eo-card);
}

.exit-offer__image {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 96px;
    overflow: hidden;
}

/* Product photos are square with wide transparent margins: crop the sides so the bottle reads. */
.exit-offer__image img {
    flex-shrink: 0;
    width: 135%;
    max-width: none;
    height: auto;
    object-fit: contain;
}

.exit-offer__name {
    margin: 4px 0 0;
    font-size: 21px;
    line-height: 1.2;
    font-weight: 700;
    color: var(--eo-text);
}

.exit-offer__meta {
    margin: 6px 0 0;
    font-size: 14px;
    line-height: 1.35;
    color: var(--eo-muted);
}

/* Several eligible products */
.exit-offer__items {
    display: grid;
    gap: 10px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.exit-offer__item {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    border: 1px solid var(--eo-line);
    border-radius: 16px;
    background: var(--eo-card);
}

.exit-offer__item .exit-offer__image {
    width: 44px;
    height: 56px;
}

.exit-offer__item .exit-offer__name {
    margin: 0;
    font-size: 16px;
}

.exit-offer__item .exit-offer__meta {
    margin-top: 2px;
    font-size: 13px;
}

.exit-offer__item-price {
    font-size: 17px;
    font-weight: 700;
    white-space: nowrap;
}

/* Coupon state */
.exit-offer__coupon {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 22px 0 18px;
    font-size: 18px;
    line-height: 1.3;
    font-weight: 700;
    color: var(--eo-text);
}

.exit-offer__coupon-icon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 2px dashed var(--eo-accent);
    border-radius: 50%;
    color: var(--eo-accent);
}

.exit-offer__coupon-icon svg {
    width: 14px;
    height: 14px;
}

.exit-offer__code {
    padding: 1px 8px;
    border: 1px dashed var(--eo-accent);
    border-radius: 6px;
    color: var(--eo-accent);
    letter-spacing: 0.03em;
}

.exit-offer__coupon.is-applied {
    color: var(--eo-success);
}

.exit-offer__coupon.is-applied .exit-offer__coupon-icon {
    border: 0;
    color: #ffffff;
    background: var(--eo-success);
}

.exit-offer__coupon.is-applied .exit-offer__code {
    padding: 0;
    border: 0;
    color: inherit;
}

/* Package options */
.exit-offer__options {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

.exit-offer__option {
    position: relative;
    display: grid;
    grid-template-columns: 22px 1fr auto;
    align-items: center;
    gap: 16px;
    min-height: 66px;
    padding: 14px 20px;
    border: 1.5px solid var(--eo-line);
    border-radius: 16px;
    background: #ffffff;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.exit-offer__option:hover {
    border-color: var(--eo-accent);
}

.exit-offer__option.is-selected {
    border: 2px solid var(--eo-accent);
    padding: 13.5px 19.5px;
    background: var(--eo-soft);
}

.exit-offer__option input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

.exit-offer__radio {
    position: relative;
    width: 22px;
    height: 22px;
    border: 2px solid #7a7a7a;
    border-radius: 50%;
    background: #ffffff;
}

.exit-offer__option.is-selected .exit-offer__radio {
    border-color: var(--eo-accent);
}

.exit-offer__option.is-selected .exit-offer__radio::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--eo-accent);
}

.exit-offer__option input:focus-visible + .exit-offer__radio {
    outline: 3px solid var(--eo-accent);
    outline-offset: 3px;
}

.exit-offer__option-main {
    min-width: 0;
}

.exit-offer__option-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    font-size: 19px;
    line-height: 1.2;
    font-weight: 700;
}

.exit-offer__badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: var(--eo-badge-text);
    background: var(--eo-accent);
}

.exit-offer__tag {
    display: inline-block;
    padding: 3px 8px;
    border: 1px solid var(--eo-line);
    border-radius: 999px;
    font-size: 11px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--eo-muted);
    background: #ffffff;
}

.exit-offer__option-sub {
    display: block;
    margin-top: 4px;
    font-size: 14px;
    line-height: 1.35;
    color: var(--eo-muted);
}

.exit-offer__option-price {
    font-size: 23px;
    line-height: 1;
    font-weight: 800;
    letter-spacing: -0.01em;
    text-align: right;
    white-space: nowrap;
}

.exit-offer__summary {
    cursor: default;
    grid-template-columns: 1fr auto;
}

.exit-offer__summary:hover {
    border-color: var(--eo-accent);
}

.exit-offer__note,
.exit-offer__fineprint {
    margin: 12px 0 0;
    font-size: 13px;
    line-height: 1.4;
    color: var(--eo-muted);
}

.exit-offer__note {
    color: var(--eo-text);
}

.exit-offer__error {
    margin: 14px 0 0;
    padding: 10px 14px;
    border: 1px solid #f0b8bf;
    border-radius: 10px;
    background: #fdf1f2;
    font-size: 14px;
    line-height: 1.4;
    color: #8a1c2b;
}

.exit-offer__cta {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 54px;
    margin-top: 22px;
    padding: 12px 20px;
    border: 0;
    border-radius: var(--r-pill, 999px);
    font-family: inherit;
    font-size: 19px;
    line-height: 1.2;
    font-weight: 800;
    color: #ffffff;
    background: var(--eo-accent);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.exit-offer__cta:hover {
    background: var(--eo-accent-strong);
}

.exit-offer__cta:disabled {
    cursor: progress;
    opacity: 0.75;
}

.exit-offer__cta.is-applied {
    cursor: default;
    opacity: 1;
    background: var(--eo-success);
}

.exit-offer__dismiss {
    display: block;
    margin: 16px auto 0;
    padding: 6px 8px;
    border: 0;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.3;
    color: var(--eo-muted);
    text-decoration: underline;
    text-underline-offset: 3px;
    background: none;
    cursor: pointer;
}

.exit-offer__dismiss:hover {
    color: var(--eo-text);
}

.exit-offer__close:focus-visible,
.exit-offer__cta:focus-visible,
.exit-offer__dismiss:focus-visible {
    outline: 3px solid var(--eo-accent);
    outline-offset: 3px;
}

.exit-offer__close:focus-visible {
    outline-color: #ffffff;
}

.exit-offer__sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Checkout summary: applied offer */
.checkout-promo__code {
    font-weight: 700;
    color: var(--c-success, #18794e);
}

.checkout-promo__remove {
    margin-left: 8px;
    padding: 0;
    border: 0;
    font-size: 14px;
    text-decoration: underline;
    color: #666666;
    background: none;
    cursor: pointer;
}

/* Checkout line price with an offer: original (struck, muted) and promotional price on one line. */
.checkout-line__prices {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: flex-end;
    gap: 2px 8px;
    text-align: right;
}

.checkout-line__regular {
    font-size: 14px;
    line-height: 20px;
    font-weight: 400;
    color: #8a8a8a;
    text-decoration: line-through;
    white-space: nowrap;
}

.checkout-line__promo {
    font-weight: 700;
    white-space: nowrap;
}

/* Phones: the price column of the line item is too narrow for two prices, so discounted
   lines show the prices (and Remove) on their own row under the product name. */
@media (max-width: 480px) {
    .checkout-item--promo .checkout-item__container {
        grid-template-columns: 70px minmax(0, 1fr);
        row-gap: 8px;
    }

    .checkout-item--promo .checkout-item__footer {
        grid-column: 2;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: baseline;
    }

    .checkout-item--promo .checkout-line__prices {
        flex-wrap: nowrap;
    }
}

@keyframes exit-offer-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@media (prefers-reduced-motion: reduce) {
    .exit-offer__overlay,
    .exit-offer__dialog {
        animation: none;
    }
}

/* Tablet / large phones */
@media (max-width: 600px) {
    .exit-offer__overlay {
        padding: 12px;
    }

    .exit-offer__dialog {
        max-height: calc(100vh - 24px);
        max-height: calc(100dvh - 24px);
        --eo-radius: 20px;
    }

    .exit-offer__header {
        padding: 26px 52px 24px;
    }

    .exit-offer__eyebrow {
        font-size: 26px;
    }

    .exit-offer__headline {
        font-size: 56px;
    }

    .exit-offer__lede {
        font-size: 16px;
    }

    .exit-offer__body {
        padding: 22px 18px 20px;
    }

    .exit-offer__product {
        grid-template-columns: 58px 1fr;
        gap: 12px;
        padding: 12px 16px;
    }

    .exit-offer__product .exit-offer__image {
        width: 58px;
        height: 78px;
    }

    .exit-offer__name {
        font-size: 18px;
    }

    .exit-offer__coupon {
        margin: 18px 0 14px;
        font-size: 16px;
    }

    .exit-offer__option {
        grid-template-columns: 20px 1fr auto;
        gap: 12px;
        padding: 12px 14px;
    }

    .exit-offer__option.is-selected {
        padding: 11.5px 13.5px;
    }

    .exit-offer__summary {
        grid-template-columns: 1fr auto;
    }

    .exit-offer__radio {
        width: 20px;
        height: 20px;
    }

    .exit-offer__option-title {
        gap: 4px 6px;
        font-size: 17px;
    }

    .exit-offer__badge,
    .exit-offer__tag {
        padding: 3px 7px;
        font-size: 9.5px;
        letter-spacing: 0.03em;
    }

    .exit-offer__option-sub {
        font-size: 13px;
    }

    .exit-offer__option-price {
        font-size: 20px;
    }

    .exit-offer__item {
        grid-template-columns: 40px 1fr auto;
        gap: 10px;
        padding: 10px 12px;
    }

    .exit-offer__cta {
        min-height: 52px;
        font-size: 17px;
    }
}

/* Small phones (320–375px) */
@media (max-width: 360px) {
    .exit-offer__header {
        padding: 22px 48px 20px;
    }

    .exit-offer__eyebrow {
        font-size: 22px;
    }

    .exit-offer__eyebrow svg {
        width: 22px;
        height: 22px;
    }

    .exit-offer__headline {
        font-size: 46px;
    }

    .exit-offer__lede {
        font-size: 15px;
    }

    .exit-offer__body {
        padding: 18px 14px 16px;
    }

    .exit-offer__option {
        gap: 10px;
        padding: 12px;
    }

    .exit-offer__option.is-selected {
        padding: 11.5px;
    }

    .exit-offer__option-title {
        font-size: 16px;
    }

    .exit-offer__option-price {
        font-size: 18px;
    }

    .exit-offer__item {
        grid-template-columns: 1fr auto;
    }

    .exit-offer__item .exit-offer__image {
        display: none;
    }
}

/* Short viewports (landscape phones, small laptops): compact header, body scrolls */
@media (max-height: 720px) {
    .exit-offer__header {
        padding-top: 20px;
        padding-bottom: 18px;
    }

    .exit-offer__eyebrow {
        font-size: 22px;
    }

    .exit-offer__headline {
        margin-top: 6px;
        font-size: 48px;
    }

    .exit-offer__lede {
        margin-top: 8px;
        font-size: 15px;
    }

    .exit-offer__body {
        padding-top: 18px;
    }
}

@media (max-height: 480px) {
    .exit-offer__lede {
        display: none;
    }

    .exit-offer__headline {
        font-size: 40px;
    }
}
