/**
 * IMS Catalog Promo
 *
 * Horizontal card with cover thumbnail, title/subtitle, and three CTA buttons
 * (Browse online · Download · Request print copy).
 *
 * Layout breakpoints:
 *  - >= 768px: cover | copy | actions in a single row
 *  - <  768px: stacks vertically, actions wrap full-width
 */

.ims-catalog-promo {
    width: 100%;
}

.ims-catalog-promo__card {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 16px 20px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* Cover
 *
 * The cover slot keeps a fixed footprint in the flex row (so the title/buttons
 * stay aligned), but the image inside is positioned absolutely, anchored at
 * the bottom of the slot, and rendered taller than the slot itself. This lets
 * the catalog cover "escape" the card and stick out above its top edge -
 * giving it a more product-shot feel without growing the card's height.
 *
 * `position: relative` on the slot, plus `overflow: visible` on both the
 * slot and the card (default), are what allow the overflow to render.
 */
.ims-catalog-promo__cover {
    flex: 0 0 auto;
    width: 110px;
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    position: relative;
}

.ims-catalog-promo__cover-img {
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: auto;
    height: 140px;
    max-width: none;
    max-height: none;
    display: block;
    object-fit: contain;
    filter: drop-shadow( 0 8px 16px rgba( 0, 0, 0, 0.22 ) );
}

.ims-catalog-promo__cover-placeholder {
    width: 72px;
    height: 96px;
    background: #f3f4f6;
    border: 1px dashed #d1d5db;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #9ca3af;
    letter-spacing: 0.08em;
}

/* Copy
 *
 * `padding-left` adds a little extra indent on top of the card's flex `gap`,
 * so the title doesn't visually butt up against the cover - especially now
 * that the cover image overhangs the top of the card and reads as a
 * "thicker" element on the left.
 */
.ims-catalog-promo__copy {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-left: 12px;
}

.ims-catalog-promo__title {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: #111111;
    line-height: 1.3;
}

.ims-catalog-promo__subtitle {
    display: block;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.45;
}

/* Actions */
.ims-catalog-promo__actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.ims-catalog-promo__btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
    white-space: nowrap;
}

.ims-catalog-promo__btn:focus-visible {
    outline: 2px solid var(--wp--preset--color--primary, #FAB000);
    outline-offset: 2px;
}

.ims-catalog-promo__btn-icon {
    display: inline-block;
    flex: 0 0 auto;
}

.ims-catalog-promo__btn-arrow {
    display: inline-block;
    margin-left: 2px;
    transform: translateY(-0.5px);
}

/* Ghost (white / outlined) */
.ims-catalog-promo__btn--ghost {
    background: #ffffff;
    color: #111111;
    border: 1px solid #d1d5db;
}

.ims-catalog-promo__btn--ghost:hover,
.ims-catalog-promo__btn--ghost:focus-visible {
    background: #f9fafb;
    border-color: #9ca3af;
    color: #111111;
}

/* Solid (dark filled) */
.ims-catalog-promo__btn--solid {
    background: #111111;
    color: #ffffff;
    border: 1px solid #111111;
}

.ims-catalog-promo__btn--solid:hover,
.ims-catalog-promo__btn--solid:focus-visible {
    background: #000000;
    border-color: #000000;
    color: #ffffff;
}

/* Disabled (no destination configured - visible to admins so they can fix it) */
.ims-catalog-promo__btn--disabled,
.ims-catalog-promo__btn--disabled:hover,
.ims-catalog-promo__btn--disabled:focus-visible {
    background: #f3f4f6;
    color: #9ca3af;
    border-color: #e5e7eb;
    cursor: not-allowed;
    box-shadow: none;
}

/* Cart button (Request print copy) - loading state.
 *
 * The catalog promo's cart button is visually identical to `.ims-catalog-promo__btn--solid`;
 * we only need a subtle loading state while the AJAX add-to-cart is in flight.
 * Crucially, we do NOT inherit any styling from the listing-card's
 * `.ims-add-to-cart` - see render.php for the rationale.
 */
.ims-catalog-promo__btn--cart.is-loading {
    opacity: 0.65;
    cursor: progress;
}

/* ---------------------------------------------------------------------------
 * Catalog request confirmation modal
 *
 * Pops after a successful add-to-cart. Replaces the global toast for this
 * specific button because the message is more nuanced than "added to cart" -
 * the customer needs to understand that the product is free but still
 * requires a shipping address.
 * ---------------------------------------------------------------------------
 */
.ims-catalog-promo-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba( 17, 17, 17, 0.55 );
    opacity: 0;
    transition: opacity 160ms ease;
}

.ims-catalog-promo-modal-overlay.is-open {
    opacity: 1;
}

body.ims-catalog-promo-modal-open {
    overflow: hidden;
}

.ims-catalog-promo-modal {
    position: relative;
    width: 100%;
    max-width: 460px;
    padding: 28px 28px 24px;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba( 0, 0, 0, 0.25 );
    transform: translateY( 8px );
    transition: transform 180ms ease;
}

.ims-catalog-promo-modal-overlay.is-open .ims-catalog-promo-modal {
    transform: translateY( 0 );
}

.ims-catalog-promo-modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #6b7280;
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease;
}

.ims-catalog-promo-modal__close:hover,
.ims-catalog-promo-modal__close:focus-visible {
    background: #f3f4f6;
    color: #111111;
    outline: none;
}

.ims-catalog-promo-modal__icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #ecfdf5;
    color: #047857;
    margin-bottom: 14px;
}

.ims-catalog-promo-modal__title {
    margin: 0 0 10px;
    font-size: 19px;
    font-weight: 700;
    color: #111111;
    line-height: 1.3;
}

.ims-catalog-promo-modal__body {
    margin: 0 0 10px;
    font-size: 14px;
    line-height: 1.55;
    color: #1f2937;
}

.ims-catalog-promo-modal__body--muted {
    color: #6b7280;
    font-size: 13px;
}

.ims-catalog-promo-modal__actions {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.ims-catalog-promo-modal__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
    white-space: nowrap;
}

.ims-catalog-promo-modal__btn:focus-visible {
    outline: 2px solid var( --wp--preset--color--primary, #FAB000 );
    outline-offset: 2px;
}

.ims-catalog-promo-modal__btn--primary {
    background: #111111;
    color: #ffffff;
    border-color: #111111;
}

.ims-catalog-promo-modal__btn--primary:hover,
.ims-catalog-promo-modal__btn--primary:focus-visible {
    background: #000000;
    color: #ffffff;
    border-color: #000000;
}

.ims-catalog-promo-modal__btn--ghost {
    background: #ffffff;
    color: #111111;
    border-color: #d1d5db;
}

.ims-catalog-promo-modal__btn--ghost:hover,
.ims-catalog-promo-modal__btn--ghost:focus-visible {
    background: #f9fafb;
    border-color: #9ca3af;
    color: #111111;
}

.ims-catalog-promo-modal__btn--text {
    background: transparent;
    color: #6b7280;
    border-color: transparent;
    margin-left: auto;
    padding: 9px 8px;
}

.ims-catalog-promo-modal__btn--text:hover,
.ims-catalog-promo-modal__btn--text:focus-visible {
    color: #111111;
    background: transparent;
}

@media ( max-width: 540px ) {
    .ims-catalog-promo-modal {
        padding: 24px 22px 20px;
    }

    .ims-catalog-promo-modal__title {
        font-size: 17px;
    }

    .ims-catalog-promo-modal__btn {
        flex: 1 1 100%;
        justify-content: center;
    }

    .ims-catalog-promo-modal__btn--text {
        margin-left: 0;
    }
}

/* Admin notice (visible only to logged-in editors) */
.ims-catalog-promo__admin-notice {
    margin: 8px 4px 0;
    padding: 8px 12px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 6px;
    color: #9a3412;
    font-size: 12.5px;
    line-height: 1.4;
}

.ims-catalog-promo__admin-notice strong {
    margin-right: 4px;
}

/* Editor preview parity */
.ims-catalog-promo--editor .ims-catalog-promo__title,
.ims-catalog-promo--editor .ims-catalog-promo__subtitle {
    cursor: text;
}

.ims-catalog-promo--editor .ims-catalog-promo__btn {
    cursor: default;
}

/* Responsive */
@media ( max-width: 900px ) {
    .ims-catalog-promo__card {
        flex-wrap: wrap;
        gap: 16px;
    }

    .ims-catalog-promo__copy {
        flex: 1 1 calc( 100% - 120px );
    }

    .ims-catalog-promo__actions {
        flex: 1 1 100%;
        justify-content: flex-start;
    }
}

@media ( max-width: 540px ) {
    .ims-catalog-promo__card {
        padding: 14px 16px;
        gap: 14px;
    }

    .ims-catalog-promo__cover {
        width: 84px;
        height: 72px;
    }

    .ims-catalog-promo__cover-img {
        height: 110px;
    }

    .ims-catalog-promo__copy {
        flex: 1 1 calc( 100% - 100px );
    }

    .ims-catalog-promo__title {
        font-size: 15px;
    }

    .ims-catalog-promo__subtitle {
        font-size: 12.5px;
    }

    .ims-catalog-promo__btn {
        flex: 1 1 auto;
        justify-content: center;
    }
}
