/*
 * Popup forms: Create Group, Join Group, Edit Group (ACF forms), the password prompt and comments.
 * Replaces the theme's floating labels with standard labels above the field. Theme rules being
 * overridden: pages/page.less (.popup__inner .acf-form ..., #custom-popup .acf-label with !important).
 * Selectors use :is(#ids) so they outrank #custom-popup rules; !important only where the theme uses it.
 * Fields hidden with Bootstrap's .hide stay hidden (nothing here sets display on .acf-field).
 */

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) {
    --mm-dark: #1b1b1b;
    --mm-accent: #3ec7c2;
    --mm-accent-dark: #2a9d99;
    --mm-accent-soft: rgba(62, 199, 194, .14);
    --mm-text: #6d6d6d;
    --mm-line: #d9d9d9;
    --mm-error: #e5484d;
}

/* ---------- Layout ---------- */

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form {
    max-width: 460px;
    margin: 0 auto;
    text-align: left;
}

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-fields,
:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-fields > .acf-field {
    border: 0;
}

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-field {
    position: relative;
    margin: 0 0 18px;
    padding: 0 !important;
    border: 0 !important;
}

/* ---------- Labels and help text ---------- */

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-label {
    position: static !important;
    top: auto !important;
    left: auto !important;
    display: block;
    margin: 0 0 6px;
    padding: 0;
    background: none;
    z-index: auto;
}

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-label label {
    display: block;
    margin: 0;
    color: var(--mm-dark);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .2px;
    text-transform: none;
}

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-label .acf-required {
    margin-left: 2px;
    color: var(--mm-error);
}

/* Help text is always visible (the theme only showed it on focus, and only for some fields) */
:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-label p,
:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-label p.description {
    display: block !important;
    width: auto;
    margin: 3px 0 0;
    padding: 0;
    border-radius: 0;
    background: none;
    color: var(--mm-text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
    text-align: left;
    text-transform: none;
}

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-label p::before {
    content: none;
}

.acf-fields div[data-type="email"] .acf-label {
    display: block;
}

/* ---------- Inputs ---------- */

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form :is(input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], input[type="tel"], input.input, textarea, select) {
    display: block;
    width: 100%;
    max-width: none;
    height: 48px;
    min-height: 0;
    margin: 0;
    padding: 0 14px !important;
    border: 1px solid var(--mm-line);
    border-radius: 10px;
    background: #fff;
    color: var(--mm-dark);
    font-family: inherit;
    font-size: 16px; /* stops iOS zoom */
    font-weight: 400;
    line-height: 46px;
    text-align: left;
    box-shadow: none;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form textarea {
    height: auto;
    min-height: 104px;
    padding: 11px 14px !important;
    line-height: 1.45;
    resize: vertical;
}

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form :is(input, textarea, select):focus {
    border-color: var(--mm-accent);
    border-radius: 10px;
    box-shadow: 0 0 0 3px var(--mm-accent-soft);
}

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form :is(input, textarea)::placeholder {
    color: #a8a8a8;
    opacity: 1;
    text-transform: none; /* the theme uppercases placeholders */
    font-weight: 400;
    letter-spacing: 0;
}

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-date-picker input.input {
    padding-right: 42px !important;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236d6d6d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E") no-repeat right 14px center;
    cursor: pointer;
}

/* Show / hide password */
.mm-pw-wrap {
    position: relative;
    display: block;
}

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .mm-pw-wrap input {
    padding-right: 70px !important;
}

.mm-pw-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    min-width: 56px;
    height: 36px;
    padding: 0 10px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--mm-accent-dark, #2a9d99);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.mm-pw-toggle:hover,
.mm-pw-toggle:focus-visible {
    background: rgba(62, 199, 194, .14);
    outline: none;
}

/* ---------- Errors ---------- */

/* Field error: under the label, not floating in the corner */
:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-field .acf-notice.-error {
    position: static;
    display: block;
    margin: 0 0 6px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    color: var(--mm-error);
}

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-field .acf-notice.-error p {
    margin: 0;
    padding: 0;
    color: var(--mm-error);
    font-size: 13px;
    font-weight: 600;
}

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-field.acf-error :is(input, textarea, select) {
    border-color: var(--mm-error);
}

/* Form-level message ("Validation failed...") */
:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form > .acf-notice,
:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-fields > .acf-notice,
:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-notice.acf-error-message:not(.acf-field .acf-notice) {
    position: static;
    display: block;
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid rgba(229, 72, 77, .35);
    border-radius: 10px;
    background: #fdecec;
    color: #b4232a;
}

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-notice p {
    margin: 0;
    font-size: 14px;
}

/* Password prompt notices ("Incorrect password...", "Forgot password?") */
#input-password .notices {
    margin-top: 8px;
    padding: 0;
    color: var(--mm-text);
    font-size: 13px;
}

#input-password .notices a {
    color: var(--mm-accent-dark);
    text-transform: none;
}

#input-password .header-details {
    margin: 0 0 14px;
    color: var(--mm-dark);
    font-size: 20px;
    font-weight: 700;
    text-align: center;
}

/* ---------- Submit ---------- */

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-form-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 22px;
    text-align: center;
}

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-form-submit .button,
:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-form-submit input[type="submit"] {
    display: block;
    width: 100%;
    height: 52px;
    margin: 0;
    padding: 0 24px !important;
    border: 1px solid var(--mm-dark);
    border-radius: 12px;
    background: var(--mm-dark);
    color: #fff !important;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700 !important;
    line-height: 50px;
    letter-spacing: .3px;
    text-align: center;
    text-transform: none;
    box-shadow: none;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, opacity .15s ease;
    -webkit-appearance: none;
    appearance: none;
}

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-form-submit .button:hover,
:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-form-submit input[type="submit"]:hover {
    border-color: var(--mm-accent-dark);
    background: var(--mm-accent-dark);
}

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-form-submit .button.disabled,
:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-form-submit .button:disabled {
    opacity: .6;
    cursor: wait;
}

:is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-spinner {
    flex: 0 0 auto;
}

/* ---------- Turnstile + honeypot ---------- */

.mm-captcha {
    margin: 6px 0 0;
}

.mm-captcha:empty {
    display: none;
}

.mm-hp {
    position: absolute !important;
    left: -10000px !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* The old reCAPTCHA widget, while still in use */
:is(#create-group, #join-group, #comment-box) .acf-field[data-type="recaptcha"] .g-recaptcha > div,
#comment-box #comment-grecaptcha > div {
    margin: 4px auto 0 !important;
}

/* ---------- Phones ---------- */

@media (max-width: 575px) {
    :is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form {
        max-width: none;
    }

    :is(#create-group, #join-group, #input-password, #comment-box, #custom-popup) .acf-form .acf-field {
        margin-bottom: 16px;
    }

    :is(#create-group, #join-group, #comment-box) .acf-field[data-type="recaptcha"] .g-recaptcha,
    #comment-box #comment-grecaptcha {
        transform: scale(.92);
        transform-origin: center top;
    }
}
