/* ==========================================================================
   Newsletter popup — letter card in an envelope
   Desktop: laid out in mockup pixels via --u (1u = popup width / 896).
   Phones: the card stacks naturally and the envelope sits underneath.
   ========================================================================== */

html.nl-open {
    overflow: hidden;
}

.nl-popup {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    overflow-y: auto;
}

.nl-popup[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

.nl-popup::backdrop {
    background: rgba(70, 66, 60, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.nl-popup[open]::backdrop {
    animation: nl-fade 0.35s ease;
}

.nl-envelope {
    position: relative;
    container-type: inline-size;
    width: min(860px, 94vw);
    aspect-ratio: 896 / 747;
    margin: auto;
}

.nl-popup[open] .nl-envelope {
    animation: nl-fade 0.35s ease;
}

.nl-envelope__back,
.nl-envelope__front {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.nl-envelope__back {
    z-index: 0;
    filter: drop-shadow(0 24px 40px rgba(0, 0, 0, 0.25));
}

.nl-envelope__front {
    z-index: 2;
}

/* Letter card */
.nl-card {
    --u: calc(100cqw / 896);
    position: absolute;
    z-index: 1;
    top: 0;
    left: calc(77 * var(--u));
    width: calc(743 * var(--u));
    height: calc(600 * var(--u));
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: calc(76 * var(--u)) calc(40 * var(--u)) 0;
    background: #f2ede6;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    text-align: center;
}

.nl-popup[open] .nl-card {
    animation: nl-rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) 0.15s both;
}

.nl-card__close {
    position: absolute;
    top: calc(22 * var(--u));
    right: calc(22 * var(--u));
    width: max(32px, calc(40 * var(--u)));
    height: max(32px, calc(40 * var(--u)));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1f1f1f;
    transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.nl-card__close:hover {
    opacity: 0.6;
    transform: rotate(90deg);
}

.nl-card__close svg {
    width: 70%;
    height: 70%;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.3;
}

.nl-card__photo {
    width: calc(128 * var(--u));
    height: calc(128 * var(--u));
    object-fit: cover;
}

.nl-card__rule {
    display: block;
    width: 1px;
    height: calc(32 * var(--u));
    margin-top: calc(28 * var(--u));
    background: #555;
}

.nl-card__title {
    margin-top: calc(14 * var(--u));
    font-family: var(--font-display);
    font-size: max(30px, calc(54 * var(--u)));
    font-weight: 500;
    line-height: 1.1;
    color: #1f1f1f;
}

.nl-card__lead {
    margin-top: calc(12 * var(--u));
    font-family: var(--font-serif);
    font-size: max(16px, calc(23 * var(--u)));
    line-height: 1.35;
    color: #3f3f3f;
}

.nl-card__form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    width: calc(510 * var(--u));
    min-height: max(44px, calc(61 * var(--u)));
    margin-top: calc(26 * var(--u));
    border: 1px solid #b9b2a9;
}

.nl-card__input {
    min-width: 0;
    padding: 0 calc(30 * var(--u));
    border: 0;
    background: transparent;
    font-family: var(--font-serif);
    font-size: max(16px, calc(20 * var(--u)));
    font-style: italic;
    color: #1f1f1f;
}

.nl-card__input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.4);
}

.nl-card__button {
    min-width: calc(165 * var(--u));
    padding: 0 calc(22 * var(--u));
    border-left: 1px solid #b9b2a9;
    font-family: var(--font-sans);
    font-size: max(11px, calc(13 * var(--u)));
    font-weight: 500;
    letter-spacing: 0.26em;
    text-transform: uppercase;
    color: #1f1f1f;
    transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease);
}

.nl-card__button:hover,
.nl-card__button:focus-visible {
    background: var(--color-charcoal);
    color: var(--color-cream);
    outline: none;
}

.nl-card__button[disabled] {
    opacity: 0.6;
    cursor: progress;
}

.nl-card__message {
    max-width: calc(560 * var(--u));
    min-height: 1.4em;
    margin-top: calc(12 * var(--u));
    font-family: var(--font-text);
    font-size: max(13px, calc(15 * var(--u)));
    line-height: 1.4;
}

.nl-card__message.is-error {
    color: var(--color-error);
}

/* Thank-you state */
.nl-popup.is-done .nl-card__form {
    display: none;
}

.nl-popup.is-done .nl-card__lead {
    max-width: calc(520 * var(--u));
}

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

@keyframes nl-rise {
    from { opacity: 0; transform: translateY(14%); }
    to { opacity: 1; transform: translateY(0); }
}

/* Phones: natural-height card, envelope anchored below it */
@media (max-width: 600px) {
    .nl-popup[open] {
        align-items: flex-end;
        padding-bottom: 24px;
    }

    .nl-envelope {
        aspect-ratio: auto;
    }

    .nl-envelope__back,
    .nl-envelope__front {
        inset: auto 0 0 0;
        height: calc(100cqw * 747 / 896);
    }

    .nl-card {
        position: relative;
        left: auto;
        width: 82.9%;
        height: auto;
        margin: 0 auto;
        padding: 56px 20px calc(100cqw * 0.34);
    }

    .nl-card__photo {
        width: 88px;
        height: 88px;
    }

    .nl-card__rule {
        height: 24px;
        margin-top: 18px;
    }

    .nl-card__title {
        margin-top: 10px;
    }

    .nl-card__form {
        width: 100%;
        grid-template-columns: minmax(0, 1fr);
        margin-top: 20px;
    }

    .nl-card__input {
        min-height: 46px;
        padding: 0 14px;
        text-align: center;
    }

    .nl-card__button {
        min-height: 46px;
        border-left: 0;
        border-top: 1px solid #b9b2a9;
    }
}
