/* ==========================================================================
   Contactformulier - the form sits on one green shape.
   Copied from _design/site/assets/css/pages/contact-form.css. The rules
   start from the section CSS class "contact-form-page", as in home.css.

   The form comes from Contact Form 7. A form template with the design
   classes (.form-grid, .field, .input, ...) gets the rules of main.css.
   Part 2 maps the own classes of Contact Form 7 to the same look, so a
   form template without the design classes also fits the design.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Prototype rules
   -------------------------------------------------------------------------- */

/* The edge of a field carries the contrast, not its colour. A muted
   green-grey line has 3.2:1 on the panel and 3.7:1 on the white field
   (WCAG 1.4.11 asks 3:1). The brand green on a 1 px edge has only 2.5:1
   on the panel and looked loud on every field. The brand green shows in
   a state only: focus and the chosen option. */
.contact-form-page {
    --field-edge: #6f8b84;
    --field-edge-hover: #4f6d66; /* 4.9:1 on the panel */
    --field-edge-focus: var(--color-cta-active); /* #007a48: 4.7:1 on the panel */
    --field-lift: 0 1px 2px rgba(56, 68, 76, 0.08);
}
.contact-form-page .h2 {
    margin-bottom: var(--space-6);
}

/* An intro text between the title and the form (for example the date of
   the event) keeps the same gap to the first field as the title has. */
.contact-form-page .panel > p:has(+ .wpcf7) {
    margin-bottom: var(--space-6);
}

/* Label sits 12 px above the field and rows are 116 px apart in the design. */
.contact-form-page .form-grid {
    row-gap: clamp(1rem, 0.4rem + 1.4vw, 1.75rem);
}

.contact-form-page .field {
    gap: var(--space-3);
}

/* the captcha next to the submit button; a form template can use it */
.contact-form-page__captcha {
    flex: 0 1 18rem;
}

.contact-form-page .form-note {
    margin-top: var(--space-5);
}

/* The design sets the question field and the captcha row closer to the row above. */
.contact-form-page .field--full:not(.form-actions) {
    margin-top: -0.25rem;
}

.contact-form-page .form-actions {
    margin-top: -0.8rem;
}

.contact-form-page .panel--compact {
    padding-bottom: calc(clamp(2rem, 1rem + 4vw, 6.25rem) + 0.45rem);
}

/* --------------------------------------------------------------------------
   2. Contact Form 7
   -------------------------------------------------------------------------- */

/* Labels are semibold, so a label and a placeholder do not read as the
   same kind of text. */
.contact-form-page .wpcf7-form .field__label,
.contact-form-page .wpcf7-form .col-form-label,
.contact-form-page .dscf7-captcha-container span.dscf7_lt,
.contact-form-page .dscf7captcha {
    font-weight: var(--weight-semibold);
    color: var(--color-ink);
}

/* Contact Form 7 wraps every line in <p>; the grid sets the spacing. */
.contact-form-page .wpcf7-form p {
    margin: 0;
}

.contact-form-page .wpcf7-form br {
    display: none;
}

/* A form template without .form-grid: every row of the old Bootstrap
   template (.form-group.row) becomes one field of a two-column grid. */
.contact-form-page .wpcf7-form:not(:has(.form-grid)) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(1rem, 0.4rem + 1.4vw, 1.75rem) var(--space-4);
}

@media (min-width: 768px) {
    .contact-form-page .wpcf7-form:not(:has(.form-grid)) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* the status message and the hidden fields span the grid */
    .contact-form-page .wpcf7-form:not(:has(.form-grid)) > :not(.form-group) {
        grid-column: 1 / -1;
    }
}

/* Undo the Bootstrap columns of utility.css inside the form. */
.contact-form-page .wpcf7-form .row {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin: 0;
}

.contact-form-page .wpcf7-form .row > *,
.contact-form-page .wpcf7-form [class*="col-"] {
    flex: none;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
}

/* the submit row sits at the bottom right, next to the captcha */
.contact-form-page .wpcf7-form .form-group:has(.wpcf7-submit) {
    align-self: end;
}

/* the line with the submit button, in both kinds of form template */
.contact-form-page .wpcf7-form p:has(> .wpcf7-submit) {
    display: flex;
    align-items: center;
}

@media (min-width: 768px) {
    .contact-form-page .wpcf7-form p:has(> .wpcf7-submit) {
        justify-content: flex-end;
    }
}

/* A form template with the design classes: Contact Form 7 puts the label
   and the field of a .field in one <p>, so that <p> gets the gap of the
   .field. The captcha of plugin version 2 is a <p> with its own row
   layout (see below). */
.contact-form-page .wpcf7-form .field > p:not(.dscf7captcha) {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.contact-form-page .wpcf7-form .col-form-label {
    display: block;
    font-size: var(--text-body);
    line-height: 1.3;
}

.contact-form-page .wpcf7-form-control-wrap {
    display: block;
}

.contact-form-page .wpcf7-form-control-wrap + .wpcf7-form-control-wrap {
    margin-top: var(--space-3);
}

/* text, e-mail, phone, number, date, select and textarea: the .input look.
   The fields are white, so a visitor sees at once where to type. The
   edge is the muted green-grey of --field-edge, with a light shadow so
   the field sits on the panel. Typed text is medium weight in ink; the
   placeholder is regular weight in the muted colour. */
.contact-form-page .wpcf7-text,
.contact-form-page .wpcf7-number,
.contact-form-page .wpcf7-date,
.contact-form-page .wpcf7-datepicker,
.contact-form-page .wpcf7-select,
.contact-form-page .wpcf7-textarea {
    width: 100% !important; /* the captcha plugin sets an inline width */
    min-height: 2.95rem;
    margin: 0 !important;
    padding: 0.55em 1em;
    font: inherit;
    font-size: var(--text-body);
    font-weight: var(--weight-medium);
    line-height: 1.3;
    color: var(--color-ink);
    background-color: var(--color-white);
    border: 1px solid var(--field-edge);
    border-radius: var(--radius-sm);
    box-shadow: var(--field-lift);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.contact-form-page .wpcf7-form-control::placeholder {
    font-weight: var(--weight-regular);
    color: var(--color-muted);
    opacity: 1;
}

.contact-form-page .wpcf7-form-control:not(.wpcf7-submit):not(.wpcf7-radio):not(.wpcf7-checkbox):hover {
    border-color: var(--field-edge-hover);
}

.contact-form-page .wpcf7-form-control:not(.wpcf7-submit):focus {
    outline: none;
    border-color: var(--field-edge-focus);
    box-shadow: var(--field-lift), 0 0 0 3px var(--color-focus-ring);
}

/* the date field shows a calendar in brand green at its right end. A form
   template with its own <i class="calender-icon"> image keeps that image. */
.contact-form-page p:not(:has(> .calender-icon)) > .wpcf7-form-control-wrap > .wpcf7-datepicker {
    padding-right: 3em;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300ae6b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='5' width='17' height='15.5' rx='2.5'/%3E%3Cpath d='M3.5 10h17M8 3v4M16 3v4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1em center;
    background-size: 1.35em auto;
    cursor: pointer;
}

.contact-form-page .wpcf7-textarea {
    display: block;
    height: 7.75rem; /* Contact Form 7 sets rows="10" */
    min-height: 7.75rem;
    resize: vertical;
}

.contact-form-page .wpcf7-select {
    appearance: none;
    padding-right: 3em;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 14' fill='none' stroke='%23008f58' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 2l10 10L22 2'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1.1em center;
    background-size: 1.3em auto;
}

/* radio buttons and checkboxes: one white chip per option, as the options
   of the configurator. The chip of the chosen option is light green. */
.contact-form-page .wpcf7-radio,
.contact-form-page .wpcf7-checkbox {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.contact-form-page .wpcf7-list-item {
    margin: 0;
}

.contact-form-page .wpcf7-list-item label {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 2.5rem;
    padding: 0.35em 1em 0.35em 0.6rem;
    line-height: 1.25;
    background: var(--color-white);
    border: 1px solid var(--field-edge);
    border-radius: var(--radius-sm);
    box-shadow: var(--field-lift);
    cursor: pointer;
    transition: background-color var(--transition), border-color var(--transition);
}

.contact-form-page .wpcf7-list-item label:hover {
    border-color: var(--field-edge-hover);
}

/* the chosen option keeps the brand green edge */
.contact-form-page .wpcf7-list-item label:has(input:checked) {
    background: var(--color-green-20);
    border-color: var(--color-green);
}

.contact-form-page .wpcf7-list-item input {
    appearance: none;
    flex: none;
    width: 1.3rem;
    height: 1.3rem;
    margin: 0;
    background: var(--color-white);
    border: 1px solid var(--field-edge);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color var(--transition), box-shadow var(--transition);
}

/* the chosen radio button: a green dot inside a white ring */
.contact-form-page .wpcf7-list-item input:checked {
    border-color: var(--color-green);
    background: var(--color-green);
    box-shadow: inset 0 0 0 0.22rem var(--color-white);
}

.contact-form-page .wpcf7-list-item input[type="checkbox"] {
    border-radius: 4px;
}

.contact-form-page .wpcf7-list-item input[type="checkbox"]:checked {
    background: var(--color-green) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 80% no-repeat;
    border-color: var(--color-green);
    box-shadow: none;
}

.contact-form-page .wpcf7-list-item input:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
}

/* the calendar icon next to the date field: an image inside
   <i class="calender-icon"> in the form markup. Without a width the
   image fills the column. It sits at the right end of the field. */
.contact-form-page p:has(> .calender-icon) {
    position: relative;
}

.contact-form-page .calender-icon {
    position: absolute;
    right: var(--space-3);
    bottom: 0.9rem;
    line-height: 0;
    cursor: pointer;
}

.contact-form-page .calender-icon img {
    width: 1.25rem;
    height: auto;
}

/* the math captcha of plugin version 2 (in this repository and on
   staging): question text, refresh icon and the answer field */
.contact-form-page .dscf7captcha {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
}

.contact-form-page .dscf7captcha .wpcf7-form-control-wrap {
    flex: 1 1 100%;
    max-width: 18rem;
}

.contact-form-page .dscf7_captcha_icon {
    width: 1.25rem;
    height: auto;
}

/* the math captcha of plugin version 3 (on production): the question with
   the refresh icon as the label, and the answer field below it. Version 3
   wraps the captcha in .dscf7-captcha-container and styles it as a grey
   box with its own field look. The selectors repeat those of the plugin,
   so they win over them. */
.contact-form-page .dscf7-captcha-container {
    width: auto;
    max-width: 18rem;
    padding: 0;
    background: none;
    border-radius: 0;
}

.contact-form-page .dscf7-captcha-container span.dscf7_lt {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-body);
    line-height: 1.3;
}

.contact-form-page .dscf7-captcha-container span.dscf7_lt .dscf7_refresh_captcha {
    position: static;
    flex: none;
    width: 1.25rem;
}

.contact-form-page .dscf7-captcha-container span.wpcf7-form-control-wrap input {
    height: auto;
    min-height: 2.95rem;
    margin-top: var(--space-3) !important; /* the .input look sets margin: 0 */
    padding: 0.55em 1em;
    border: 1px solid var(--field-edge);
    border-radius: var(--radius-sm);
}

.contact-form-page .dscf7-captcha-container span.wpcf7-form-control-wrap input:hover {
    border-color: var(--field-edge-hover);
}

.contact-form-page .dscf7-captcha-container span.wpcf7-form-control-wrap input:focus {
    border-color: var(--field-edge-focus);
}

.contact-form-page .dscf7-captcha-container .wpcf7-not-valid-tip {
    font-size: var(--text-xs);
}

/* the submit button: the .btn look. An <input> has no icon element, so
   the arrow of .btn__icon is a background image (white, as the label). */
.contact-form-page .wpcf7-submit {
    min-height: 3rem;
    padding: 0.55em 3.3em 0.55em 1.25em;
    font: inherit;
    font-size: var(--text-body);
    font-weight: var(--weight-bold);
    line-height: 1.2;
    color: var(--color-white);
    background: var(--color-cta) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 24' fill='none' stroke='%23fff' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12h21'/%3E%3Cpath d='M15.5 4l8.5 8-8.5 8'/%3E%3C/svg%3E") right 1.05em center / 1.35em 1.15em no-repeat;
    border: 1.5px solid var(--color-cta);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: background-color var(--transition), border-color var(--transition), background-position var(--transition);
}

.contact-form-page .wpcf7-submit:hover {
    background-color: var(--color-cta-hover);
    background-position: right calc(1.05em - 3px) center;
    border-color: var(--color-cta-hover);
}

.contact-form-page .wpcf7-submit:active {
    background-color: var(--color-cta-active);
    border-color: var(--color-cta-active);
}

.contact-form-page .wpcf7-submit:focus-visible {
    outline-offset: 3px;
}

/* the spinner of Contact Form 7 sits after the button; from 768 px it
   sits before it, so the button keeps the right edge of the column */
.contact-form-page .wpcf7-spinner {
    margin: 0 0 0 var(--space-3);
}

@media (min-width: 768px) {
    .contact-form-page .wpcf7-spinner {
        order: -1;
        margin: 0 var(--space-3) 0 0;
    }
}

/* validation: a red field border and a red tip under the field. The
   selectors repeat those of the field, hover and focus rules above with
   one class more, so an invalid field keeps its red edge at rest, on
   hover and on focus. The focus halo stays. */
.contact-form-page .wpcf7-form-control.wpcf7-not-valid,
.contact-form-page .wpcf7-form-control.wpcf7-not-valid:not(.wpcf7-submit):not(.wpcf7-radio):not(.wpcf7-checkbox):hover,
.contact-form-page .wpcf7-form-control.wpcf7-not-valid:not(.wpcf7-submit):focus,
.contact-form-page .dscf7-captcha-container span.wpcf7-form-control-wrap input.wpcf7-not-valid,
.contact-form-page .dscf7-captcha-container span.wpcf7-form-control-wrap input.wpcf7-not-valid:hover,
.contact-form-page .dscf7-captcha-container span.wpcf7-form-control-wrap input.wpcf7-not-valid:focus {
    border-color: var(--color-error);
}

.contact-form-page .wpcf7-not-valid-tip {
    display: block;
    margin-top: var(--space-2);
    font-size: var(--text-xs);
    color: var(--color-error);
}

/* the status message under the form */
.contact-form-page .wpcf7 form .wpcf7-response-output {
    margin: var(--space-5) 0 0;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-body);
    border: 1px solid var(--color-green-text-lg);
    border-radius: var(--radius-sm);
}

.contact-form-page .wpcf7 form.invalid .wpcf7-response-output,
.contact-form-page .wpcf7 form.unaccepted .wpcf7-response-output,
.contact-form-page .wpcf7 form.failed .wpcf7-response-output,
.contact-form-page .wpcf7 form.aborted .wpcf7-response-output,
.contact-form-page .wpcf7 form.spam .wpcf7-response-output {
    border-color: var(--color-error);
}
