/*
 * Subscribe Form: a gradient card with a title and tagline on one side and an
 * email field with a button on the other.
 */

.subscribe-form {
    padding-top: 40px;
}

.subscribe-form__card {
    position: relative;
    border-radius: 24px;
    padding: 44px 48px;
    overflow: hidden;
    background: linear-gradient(130deg, #eeebff, #fdf2f5 70%);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 40px;
    align-items: center;
}

.subscribe-form__title {
    margin: 0;
    font-size: 28px;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.035em;
}

.subscribe-form__tagline {
    margin: 10px 0 0;
    font-size: 15px;
    line-height: 1.6;
    color: #4c4956;
}

.subscribe-form__form {
    margin: 0;
}

/* The pill that holds the email field and the button. */
.subscribe-form__field {
    display: flex;
    gap: 8px;
    padding: 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(22, 21, 28, 0.08);
}

.subscribe-form__field:focus-within {
    border-color: var(--accent);
}

.subscribe-form__field--invalid {
    border-color: #d64550;
}

.subscribe-form__input {
    flex: 1;
    min-width: 0;
    padding: 11px 16px;
    border: 0;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    color: var(--ink);
}

.subscribe-form__input:focus {
    outline: none;
}

.subscribe-form__button {
    position: relative;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    /* Wide enough for every label, so changing it never resizes the pill. */
    min-width: 140px;
    padding: 11px 22px;
    border: 0;
    border-radius: 999px;
    background: var(--ink);
    color: var(--bg);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.25s ease;
}

.subscribe-form__button:hover {
    background: #2e2c35;
}

.subscribe-form__button:disabled {
    cursor: default;
}

.subscribe-form__button--busy .subscribe-form__button-label {
    animation: subscribe-form-pulse 0.9s ease-in-out infinite;
}

/* Subscribed: the button turns green, pops, and a tick draws itself beside the label. */
.subscribe-form__button--done,
.subscribe-form__button--done:hover {
    background: #1f9d63;
    animation: subscribe-form-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.subscribe-form__check {
    display: none;
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.subscribe-form__check path {
    stroke-dasharray: 16;
    stroke-dashoffset: 16;
}

.subscribe-form__button--done .subscribe-form__check {
    display: block;
}

.subscribe-form__button--done .subscribe-form__check path {
    animation: subscribe-form-tick 0.35s 0.15s ease-out forwards;
}

/*
 * Room for one line of message, kept whether or not there is a message, so
 * one appearing moves nothing.
 */
.subscribe-form__status {
    min-height: 1.5em;
    margin: 10px 0 0 16px;
}

.subscribe-form__message {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

.subscribe-form__message--error {
    color: #d64550;
    animation: subscribe-form-message-in 0.25s ease-out both;
}

/* Said to screen readers, shown by the button instead. */
.subscribe-form__message--quiet {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

@keyframes subscribe-form-message-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

@keyframes subscribe-form-pop {
    0% { transform: scale(0.94); }
    60% { transform: scale(1.06); }
    100% { transform: scale(1); }
}

@keyframes subscribe-form-tick {
    to { stroke-dashoffset: 0; }
}

@keyframes subscribe-form-pulse {
    50% { opacity: 0.55; }
}

@media (prefers-reduced-motion: reduce) {
    .subscribe-form__button--done,
    .subscribe-form__button--done:hover,
    .subscribe-form__button--busy .subscribe-form__button-label,
    .subscribe-form__message--error {
        animation: none;
    }

    .subscribe-form__button--done .subscribe-form__check path {
        animation: none;
        stroke-dashoffset: 0;
    }
}

/* Visible to nobody: a field for bots to fall into. */
.subscribe-form__trap {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* The label is for screen readers; the placeholder says the same to everyone else. */
.subscribe-form__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

@media (max-width: 767px) {
    .subscribe-form__card {
        grid-template-columns: minmax(0, 1fr);
        gap: 24px;
        padding: 32px 24px;
    }

    .subscribe-form__title { font-size: 24px; }

    /* A message may wrap on a narrow card; keep room for two lines. */
    .subscribe-form__status { min-height: 3em; }
}
