/**
 * Horizon Core — email capture modal.
 *
 * Capture scope §3b, HORIZON-20260831-145.
 *
 * ⛔ NO DEPENDENCY HANDLE is declared for this file (see capture-placements.php):
 * `wp_enqueue_style()` silently drops a stylesheet whose dependency is not
 * registered, which left the CMP banner unstyled on a live client site for three
 * weeks. So everything here is self-namespaced under .hp-capture-modal and reads
 * only `var(--hp-*)` tokens, each with a literal fallback.
 *
 * ⛔⛔ THE DIALOG PAINTS ITS OWN BACKGROUND, AND THE SECTION INSIDE KEEPS ITS OWN.
 * `-20260831-129` shipped the band with a wrapper background plus
 * `background: transparent` on the section, and produced heading contrast of
 * **1.05**. A section carries its background and its text colours as a matched
 * pair. This file therefore paints the dialog SURFACE only, and never reaches
 * inside `.hp-email-section` to alter it.
 */

.hp-capture-modal[hidden] {
    display: none;
}

.hp-capture-modal {
    position: fixed;
    inset: 0;
    /*
     * ⛔⛔ BELOW THE AGE GATE, DELIBERATELY (HORIZON-20260831-145).
     *
     * Measured on a live page: `.hp-age-gate` is `z-index: 99999`. This file
     * shipped at 99999 too, and the two TIED — only DOM order put the marketing
     * modal on top of the 18+ legal gate, which is both fragile and the wrong way
     * round. A signup form must never paint over an age affirmation.
     *
     * 9990 clears the theme header and the links-panel trigger while staying
     * under the gate. ⚠️ The stacking is the second line of defence; the first is
     * in hp-capture-modal.js, which does not OPEN at all while the gate is up.
     */
    z-index: 9990;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.hp-capture-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.hp-capture-modal__dialog {
    position: relative;
    /*
     * ⚠️ A max-width HERE is not the house "no max-width on content bodies" rule.
     * That rule is about page content; a dialog that spans a 1440px viewport is
     * unusable. The page body is untouched.
     */
    width: min(40rem, 100%);
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    border-radius: var(--hp-r-md, 8px);
    /* The dialog's own surface. The section inside still supplies its own. */
    background: var(--hp-bg-surface, #ffffff);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.hp-capture-modal__close {
    position: absolute;
    top: .25rem;
    right: .5rem;
    z-index: 1;
    background: none;
    border: 0;
    padding: .5rem;
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    color: var(--hp-text, #1d1812);
    /* 44px hit area: the close control is the one thing that must always work. */
    min-width: 44px;
    min-height: 44px;
}

.hp-capture-modal__close:focus-visible {
    outline: 2px solid var(--hp-accent, #8a6a1f);
    outline-offset: 2px;
}

/* Entry transition, opt-out below. */
.hp-capture-modal__dialog {
    transition: transform .18s ease, opacity .18s ease;
}

.hp-capture-modal[data-hp-entering] .hp-capture-modal__dialog {
    transform: translateY(8px);
    opacity: 0;
}

/*
 * ⛔ prefers-reduced-motion is required by the scope, and this is the whole of
 * it: no transform, no fade, the dialog simply appears.
 */
@media (prefers-reduced-motion: reduce) {
    .hp-capture-modal__dialog {
        transition: none;
    }

    .hp-capture-modal[data-hp-entering] .hp-capture-modal__dialog {
        transform: none;
        opacity: 1;
    }
}

/* A modal is never useful on paper. */
@media print {
    .hp-capture-modal {
        display: none;
    }
}

/*
 * The card reveal (HORIZON-20261003-051). Four face-down cards, one flips, the rest
 * settle. Same rules as the rest of this file: self-namespaced, tokens with literal
 * fallbacks, no dependency handle. The dialog supplies the surface; this block sets
 * its own text colour against it so the pair stays matched.
 */
.hp-capture-reveal {
    padding: 2rem 1.5rem 1rem;
    text-align: center;
    color: var(--hp-text, #1d1812);
}

.hp-capture-reveal__title {
    margin: 0 0 1.25rem;
    font-size: 1.35rem;
    line-height: 1.25;
    color: inherit;
}

.hp-capture-reveal__cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .75rem;
    perspective: 900px;
}

.hp-capture-card {
    appearance: none;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    aspect-ratio: 3 / 4;
    font: inherit;
    /* 44px minimum hit area at the narrowest width. */
    min-height: 44px;
    transition: transform .18s ease, opacity .25s ease;
}

.hp-capture-card:hover:not(:disabled),
.hp-capture-card:focus-visible {
    transform: translateY(-6px);
}

.hp-capture-card:focus-visible {
    outline: 2px solid var(--hp-accent, #8a6a1f);
    outline-offset: 3px;
}

.hp-capture-card:disabled {
    cursor: default;
}

.hp-capture-card__inner {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform .6s ease;
}

.hp-capture-card[data-flipped] .hp-capture-card__inner {
    transform: rotateY(180deg);
}

.hp-capture-card__face {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--hp-r-md, 8px);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    font-weight: 700;
    line-height: 1.1;
}

.hp-capture-card__back {
    background: var(--hp-accent, #8a6a1f);
    color: var(--hp-on-accent, #ffffff);
    font-size: 2rem;
}

.hp-capture-card__front {
    transform: rotateY(180deg);
    background: var(--hp-bg-surface, #ffffff);
    color: var(--hp-text, #1d1812);
    border: 2px solid var(--hp-accent, #8a6a1f);
    font-size: 1.1rem;
    padding: .25rem;
}

/* The cards that were not picked step back. */
.hp-capture-card[data-settled] {
    opacity: .35;
    transform: scale(.94);
}

.hp-capture-reveal__result {
    margin: 1.25rem 0 0;
    font-weight: 600;
}

.hp-capture-reveal__form[hidden] {
    display: none;
}

@media (max-width: 480px) {
    .hp-capture-reveal {
        padding: 2.5rem 1rem .75rem;
    }

    .hp-capture-reveal__cards {
        gap: .5rem;
    }

    .hp-capture-card__front {
        font-size: .9rem;
    }
}

/*
 * ⛔ prefers-reduced-motion: no flip and no lift. The picked card swaps faces at
 * once and the others dim without moving, so the offer is shown instantly.
 */
@media (prefers-reduced-motion: reduce) {
    .hp-capture-card,
    .hp-capture-card__inner {
        transition: none;
    }

    .hp-capture-card:hover:not(:disabled),
    .hp-capture-card:focus-visible,
    .hp-capture-card[data-settled] {
        transform: none;
    }

    .hp-capture-card[data-flipped] .hp-capture-card__inner {
        transform: none;
    }

    .hp-capture-card[data-flipped] .hp-capture-card__back {
        display: none;
    }

    .hp-capture-card[data-flipped] .hp-capture-card__front {
        transform: none;
    }
}

/*
 * The claim step (HORIZON-20261003-051): code, countdown, claim button and the result
 * line. Colours come from the same tokens as the cards, so the pair stays matched.
 */
.hp-capture-reveal__claim[hidden],
.hp-capture-reveal__claim [hidden] {
    display: none;
}

.hp-capture-reveal__claim-title {
    margin: 0 0 1rem;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
}

.hp-capture-reveal__code {
    display: inline-block;
    margin: 0 0 .75rem;
    padding: .6rem 1rem;
    border: 2px dashed var(--hp-accent, #8a6a1f);
    border-radius: var(--hp-r-md, 8px);
    font-weight: 700;
    letter-spacing: .08em;
    word-break: break-all;
}

.hp-capture-reveal__timer {
    margin: 0 0 1rem;
    font-variant-numeric: tabular-nums;
}

.hp-capture-reveal__claim-btn {
    appearance: none;
    min-height: 44px;
    padding: .75rem 1.5rem;
    border: 0;
    border-radius: var(--hp-r-md, 8px);
    background: var(--hp-accent, #8a6a1f);
    color: var(--hp-on-accent, #ffffff);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.hp-capture-reveal__claim-btn:disabled {
    opacity: .5;
    cursor: default;
}

.hp-capture-reveal__claim-btn:focus-visible,
.hp-capture-reveal__cart:focus-visible {
    outline: 2px solid var(--hp-accent, #8a6a1f);
    outline-offset: 3px;
}

.hp-capture-reveal__claim-msg {
    margin: 1rem 0 0;
    line-height: 1.5;
}

.hp-capture-reveal__cart {
    display: inline-block;
    margin-top: 1rem;
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

[data-hp-reveal-error] {
    margin: 0 1.5rem .5rem;
    font-weight: 600;
    color: var(--hp-danger, #b00020);
}
