/*
 * Styling mirrors iungo.org (Kadence theme + Kadence Advanced Form "basic" style).
 * Palette, fonts and button treatment are taken from the site's global CSS variables.
 */
:root {
    --global-palette1: #ff5e4d; /* accent / buttons */
    --global-palette2: #e04838; /* accent hover */
    --global-palette3: #ffffff;
    --global-palette4: #021d28; /* headings & body text */
    --global-palette5: #021d28;
    --global-palette6: #527c90; /* muted text, focus borders */
    --global-palette7: #f9f9fc; /* page background */
    --global-palette9: #ffffff;
    --global-palette11: #13612e; /* success */
    --global-gray-200: #edf2f7;
    --global-gray-400: #cbd5e0;
    --global-body-font-family: Inter, sans-serif;
    --global-heading-font-family: 'Plus Jakarta Sans', sans-serif;
    --global-content-narrow-width: 744px;
    --global-content-edge-padding: 1.5rem;
    --form-error-color: #be001b;
    --form-error-background: #fde4e9;
    --form-required-color: #b32d2e;
    --form-success-background: #e7f4ec;
    --form-card-border: #dadce0;
    --form-card-gap: .75rem;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
}

body {
    background: var(--global-palette7);
    color: var(--global-palette4);
    font-family: var(--global-body-font-family);
    font-size: 16px;
    line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--global-heading-font-family);
    font-weight: 700;
    color: var(--global-palette4);
    margin: 0 0 .5em;
}

h1 {
    font-size: 36px;
    line-height: 1.2;
}

h2 {
    font-size: 28px;
    line-height: 1.25;
}

h1:focus {
    outline: none;
}

a {
    color: var(--global-palette1);
}

    a:hover {
        color: var(--global-palette2);
    }

@media (min-width: 768px) {
    h1 {
        font-size: 48px;
        line-height: 1.15;
    }
}

/* ---------- Page structure ---------- */

.form-shell {
    max-width: var(--global-content-narrow-width);
    margin: 0 auto;
}

.form-title {
    margin-bottom: 1.5rem;
}

/* Card boxes: the section heading and every question sit in their own bordered card. */
.form-card,
.form-field {
    background: var(--global-palette9);
    border: 1px solid var(--form-card-border);
    border-radius: 8px;
    padding: 1.25rem;
}

@media (min-width: 768px) {
    .form-card,
    .form-field {
        padding: 1.5rem;
    }
}

.form-section {
    display: flex;
    flex-direction: column;
    gap: var(--form-card-gap);
}

.form-section-header .form-section-title {
    margin-bottom: .25em;
}

.form-section-header .form-message {
    margin-top: 1.25rem;
}

.form-step {
    color: var(--global-palette6);
    font-size: .875rem;
    font-weight: 500;
    letter-spacing: .04em;
    text-transform: uppercase;
    margin: 0 0 .5rem;
}

.form-section-title {
    font-size: 24px;
    line-height: 1.3;
}

.form-section-description {
    color: var(--global-palette6);
    margin: 0;
}

.form-intro {
    margin-bottom: 2rem;
}

/* Descriptions from the form JSON: paragraphs, bullet lists and links */
.rich-text p,
.rich-text ul {
    margin: 0 0 .75em;
}

.rich-text ul {
    padding-left: 1.25em;
}

.rich-text li + li {
    margin-top: .2em;
}

.rich-text > :last-child {
    margin-bottom: 0;
}

.rich-text a {
    overflow-wrap: anywhere;
}

.form-list {
    padding-left: 1.25rem;
}

    .form-list li + li {
        margin-top: .5rem;
    }

/* ---------- Fields (Kadence basic form style) ---------- */

.form-body {
    display: flex;
    flex-direction: column;
    gap: var(--form-card-gap);
    line-height: 1.6;
}

.form-field {
    display: flex;
    flex-direction: column;
    max-width: 100%;
    transition: border-color .2s ease;
}

    .form-field:focus-within {
        border-color: var(--global-palette6);
    }

    .form-field fieldset {
        border: 0;
        margin: 0;
        padding: 0;
        min-width: 0;
    }

.form-label {
    display: block;
    padding: 0;
    margin: 0 0 .25em;
    font-size: 1.0625rem;
    font-weight: 500;
}

.form-required {
    margin-left: 2px;
    color: var(--form-required-color);
}

.form-help {
    color: var(--global-palette4);
    font-size: .9rem;
    line-height: 1.55;
    margin: 0 0 1em;
}

.form-info {
    display: flex;
    flex-direction: column;
}

.form-info-link {
    align-self: flex-start;
    margin-top: .75em;
    text-decoration: none;
}

.form-field input[type=text],
.form-field input[type=email],
.form-field input[type=date],
.form-field input[type=file],
.form-field select,
.form-field textarea {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    color: var(--global-palette5);
    background: var(--global-palette9);
    border: 1px solid var(--global-gray-400);
    border-radius: 3px;
    padding: .4em .5em;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.6;
    box-shadow: 0 0 0 -7px rgba(0, 0, 0, 0);
}

.form-field select {
    padding-right: 35px;
    background: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNSIgaGVpZ2h0PSIyNSIgZmlsbD0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2U9IiNiYmIiPjxwYXRoIGQ9Ik02IDlsNiA2IDYtNiIvPjwvc3ZnPg==) no-repeat calc(100% - 6px) 50%, var(--global-palette9);
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    color: var(--global-palette4);
    border-color: var(--global-palette6);
    outline: 0;
    box-shadow: 0 5px 15px -7px rgba(0, 0, 0, .1);
}

.form-field input[type=file] {
    padding: .3em .5em;
}

    .form-field input[type=file]::file-selector-button {
        margin-right: 1em;
        border: none;
        border-radius: 3px;
        padding: .2em 1em;
        font: inherit;
        font-size: 90%;
        background: var(--global-gray-200);
        color: var(--global-palette4);
        cursor: pointer;
        transition: background .2s ease-in-out;
    }

        .form-field input[type=file]::file-selector-button:hover {
            background: var(--global-gray-400);
        }

.form-file-status {
    margin: .4em 0 0;
    font-size: 90%;
    color: var(--global-palette6);
}

    .form-file-status:empty {
        display: none;
    }

.form-file-uploaded {
    color: var(--global-palette11);
}

/* Radio buttons & checkboxes */

.form-options {
    display: flex;
    flex-direction: column;
    gap: .35em;
    margin-top: .25em;
}

.form-option {
    display: flex;
    align-items: flex-start;
}

    .form-option label {
        flex-grow: 1;
        padding-left: .5em;
        cursor: pointer;
    }

    .form-option input[type=radio],
    .form-option input[type=checkbox] {
        -webkit-appearance: none;
        appearance: none;
        flex-shrink: 0;
        margin: 0;
        width: 1em;
        height: 1em;
        background: var(--global-palette9);
        border: 1px solid var(--global-gray-400);
        border-radius: 50%;
        /* Centre the 1em control on the first 1.6em line of the label, so it stays aligned when labels wrap. */
        margin-top: .3em;
        display: grid;
        place-content: center;
        cursor: pointer;
    }

    .form-option input[type=checkbox] {
        border-radius: 3px;
    }

        .form-option input[type=radio]::before,
        .form-option input[type=checkbox]::before {
            content: "";
            width: .4em;
            height: .4em;
            border-radius: 50%;
            transform: scale(0);
            transition: 120ms transform ease-in-out;
            box-shadow: inset 1em 1em #fff;
        }

        .form-option input[type=checkbox]::before {
            width: .55em;
            height: .55em;
            border-radius: 0;
            clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
        }

        .form-option input[type=radio]:checked,
        .form-option input[type=checkbox]:checked {
            border-color: var(--global-palette1);
            background: var(--global-palette1);
        }

            .form-option input[type=radio]:checked::before,
            .form-option input[type=checkbox]:checked::before {
                transform: scale(1);
            }

        .form-option input:focus-visible {
            outline: 2px solid var(--global-palette6);
            outline-offset: 2px;
        }

/* Validation */

.form-field.form-field--invalid {
    border-color: var(--form-error-color);
}

.form-field--invalid input[type=text],
.form-field--invalid input[type=email],
.form-field--invalid input[type=date],
.form-field--invalid input[type=file],
.form-field--invalid select,
.form-field--invalid .form-option input {
    border-color: var(--form-error-color);
}

.form-error {
    color: var(--form-error-color);
    font-size: .875rem;
    margin: .35em 0 0;
}

.form-message {
    border-radius: 3px;
    padding: 1em;
    margin-top: 1rem;
}

    .form-message ul {
        margin: 0;
        padding-left: 1.25rem;
    }

    .form-message h2 {
        font-size: 1.5rem;
        color: inherit;
    }

    .form-message p:last-child {
        margin-bottom: 0;
    }

.form-message-title {
    font-weight: 700;
    margin: 0 0 .5em;
}

.form-message--warning {
    background: var(--form-error-background);
    color: var(--form-error-color);
}

.form-message--success {
    background: var(--form-success-background);
    color: var(--global-palette11);
    margin-top: 0;
}

/* ---------- Buttons (iungo.org global button style) ---------- */

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: .5em;
}

.form-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .4em 1.5em;
    border: 0;
    border-radius: 8px;
    background: var(--global-palette1);
    color: var(--global-palette3);
    font-family: inherit;
    font-size: 1.125rem;
    line-height: 1.6;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 4px 14px -2px rgba(255, 94, 77, .3);
    transition: all .2s ease;
}

    .form-button:hover,
    .form-button:focus-visible {
        background: var(--global-palette2);
        box-shadow: 0 8px 22px -2px rgba(255, 94, 77, .3);
    }

    .form-button:focus-visible {
        outline: 2px solid var(--global-palette4);
        outline-offset: 2px;
    }

    .form-button:disabled {
        opacity: .6;
        cursor: default;
    }

.form-button--outline {
    background: transparent;
    color: var(--global-palette1);
    border: 2px solid var(--global-palette1);
    padding: calc(.4em - 2px) calc(1.5em - 2px);
    box-shadow: none;
    margin-right: auto; /* Back sits on the left, Next/Submit on the right */
}

    .form-button--outline:hover,
    .form-button--outline:focus-visible {
        background: transparent;
        color: var(--global-palette2);
        border-color: var(--global-palette2);
        box-shadow: none;
    }

/* ---------- Blazor framework UI ---------- */

/* Shown in index.html while the app downloads */
.app-loading {
    margin: 4rem auto;
    text-align: center;
    color: var(--global-palette6);
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }
