/* Form builder pages (cms/form_page.html). Uses the brand variables from core/css/global.css. */

.form-page {
    --form-border: #d9e2ea;
    --form-border-strong: #b7c6d3;
    --form-text: #2b3640;
    --form-muted: #66727d;
    --form-error: #c0392b;
    --form-radius: 10px;
    --form-focus: 0 0 0 0.2rem rgba(37, 141, 204, 0.25);
    padding-bottom: 4rem;
    color: var(--form-text);
}

/* Header */

.form-hero {
    padding: 48px 0 40px;
    margin-bottom: 2.5rem;
}

.form-hero__eyebrow {
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--brand-green);
}

.form-hero__title {
    margin: 0;
    max-width: 22em;
    font-size: clamp(1.75rem, 3.2vw, 2.6rem);
    line-height: 1.2;
}

/* Section sidebar */

.form-steps {
    position: sticky;
    top: 1.5rem;
    padding: 1.5rem;
    background: var(--brand-lightgrey);
    border: 1px solid var(--form-border);
    border-radius: var(--form-radius);
}

.form-steps__title {
    margin-bottom: 1rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--form-muted);
}

.form-steps__list {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: step;
}

.form-steps__list li[hidden] {
    display: none;
}

.form-steps__list a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.25rem;
    color: var(--form-muted);
    text-decoration: none;
    border-radius: 6px;
    transition: color 0.15s;
}

.form-steps__list a::before {
    counter-increment: step;
    content: counter(step);
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 1.9rem;
    height: 1.9rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--form-muted);
    background: white;
    border: 2px solid var(--form-border-strong);
    border-radius: 50%;
    transition: all 0.15s;
}

.form-steps__list a:hover {
    color: var(--brand-blue);
}

.form-steps__list a.is-active {
    color: var(--form-text);
    font-weight: 700;
}

.form-steps__list a.is-active::before {
    color: white;
    background: var(--brand-blue);
    border-color: var(--brand-blue);
}

.form-steps__list a.is-complete::before {
    content: "\2713";
    color: white;
    background: var(--brand-green);
    border-color: var(--brand-green);
}

.form-steps__note {
    margin: 1.25rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--form-border);
    font-size: 0.85rem;
    color: var(--form-muted);
}

/* Intro and error summary */

.form-intro {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1.25rem 1.5rem;
    background: var(--brand-lightblue);
    border-left: 4px solid var(--brand-blue);
    border-radius: 0 var(--form-radius) var(--form-radius) 0;
}

.form-intro__icon {
    margin-top: 0.2rem;
    font-size: 1.2rem;
    color: var(--brand-blue);
}

.form-intro__body {
    line-height: 1.6;
}

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

.form-error-summary {
    margin-bottom: 2rem;
    padding: 1.25rem 1.5rem;
    background: #fdf1f0;
    border: 1px solid #f1c1bb;
    border-left: 4px solid var(--form-error);
    border-radius: 0 var(--form-radius) var(--form-radius) 0;
}

.form-error-summary:focus {
    outline: none;
}

.form-error-summary__title {
    margin-bottom: 0.5rem;
    font-weight: 700;
    color: var(--form-error);
}

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

.form-error-summary a {
    color: var(--form-error);
}

/* Sections */

.conditional-form {
    counter-reset: section;
}

.form-section {
    margin-bottom: 1.5rem;
    padding: 2rem;
    background: white;
    border: 1px solid var(--form-border);
    border-radius: var(--form-radius);
    box-shadow: 0 1px 3px rgba(20, 40, 60, 0.05);
    scroll-margin-top: 1.5rem;
    animation: form-reveal 0.25s ease-out;
}

.form-section[hidden],
.form-question[hidden] {
    display: none;
}

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

.form-section__header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    /* Floating the legend keeps it inside the card instead of on its border. */
    float: left;
    width: 100%;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--form-border);
}

/* Hidden sections don't count, so the numbers stay in sequence. */
.form-section__number {
    counter-increment: section;
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    font-size: 1rem;
    font-weight: 700;
    color: white;
    background: var(--brand-blue);
    border-radius: 50%;
}

.form-section__number::before {
    content: counter(section);
}

.form-section__heading {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--form-text);
}

.form-section__header + * {
    clear: both;
}

.form-section__description {
    margin: -0.75rem 0 1.5rem;
    color: var(--form-muted);
}

/* Questions */

.form-question {
    margin-bottom: 1.75rem;
    animation: form-reveal 0.25s ease-out;
}

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

.form-question__label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 700;
    line-height: 1.4;
}

.form-question__help {
    margin: -0.15rem 0 0.6rem;
    font-size: 0.875rem;
    color: var(--form-muted);
}

.form-required {
    color: var(--form-error);
    font-weight: 700;
}

.form-page .form-control,
.form-page .form-select {
    padding: 0.7rem 0.9rem;
    font-size: 1rem;
    color: var(--form-text);
    border: 1px solid var(--form-border-strong);
    border-radius: 8px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-page .form-control:hover,
.form-page .form-select:hover {
    border-color: var(--brand-blue);
}

.form-page .form-control:focus,
.form-page .form-select:focus {
    border-color: var(--brand-blue);
    box-shadow: var(--form-focus);
}

.form-page textarea.form-control {
    min-height: 7.5rem;
    resize: vertical;
}

.form-question__control--number .form-control {
    max-width: 10rem;
}

.form-question__error {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--form-error);
}

.form-question.has-error .form-control,
.form-question.has-error .form-select,
.form-question.has-error .form-option {
    border-color: var(--form-error);
}

/* Radio and checkbox choices as selectable tiles */

.form-options {
    display: grid;
    gap: 0.6rem;
}

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

.form-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin: 0;
    padding: 0.8rem 1rem;
    background: white;
    border: 1px solid var(--form-border-strong);
    border-radius: 8px;
    cursor: pointer;
    line-height: 1.4;
    transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

.form-option:hover {
    border-color: var(--brand-blue);
    background: #f7fbfe;
}

.form-option:has(input:checked) {
    border-color: var(--brand-blue);
    background: var(--brand-lightblue);
    box-shadow: inset 0 0 0 1px var(--brand-blue);
}

.form-option:has(input:focus-visible) {
    box-shadow: var(--form-focus);
}

.form-option .form-check-input {
    flex: none;
    width: 1.15rem;
    height: 1.15rem;
    margin: 0.1rem 0 0;
    border-color: var(--form-border-strong);
    cursor: pointer;
}

.form-option .form-check-input:checked {
    background-color: var(--brand-blue);
    border-color: var(--brand-blue);
}

.form-option .form-check-input:focus {
    box-shadow: none;
}

.form-option--single {
    background: var(--brand-lightgrey);
}

/* Submit */

.form-submit {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.5rem 2rem;
    background: var(--brand-lightgrey);
    border: 1px solid var(--form-border);
    border-radius: var(--form-radius);
}

.form-submit__note {
    margin: 0;
    color: var(--form-muted);
}

.form-submit__button {
    padding: 0.75rem 2.25rem;
    font-size: 1.05rem;
    font-weight: 700;
    border-radius: 8px;
}

.form-submit__button:focus-visible {
    box-shadow: var(--form-focus);
}

@media (max-width: 575.98px) {
    .form-section,
    .form-submit {
        padding: 1.25rem;
    }

    .form-submit__button {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .form-section,
    .form-question {
        animation: none;
    }
}

/* Thank-you page */

.form-thanks {
    max-width: 640px;
    margin: 0 auto 4rem;
    padding: 3rem 2rem;
    text-align: center;
    background: white;
    border: 1px solid #d9e2ea;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(20, 40, 60, 0.05);
}

.form-thanks__icon {
    display: inline-grid;
    place-items: center;
    width: 4rem;
    height: 4rem;
    margin-bottom: 1.25rem;
    font-size: 1.75rem;
    color: white;
    background: var(--brand-green);
    border-radius: 50%;
}

.form-thanks__title {
    margin-bottom: 1rem;
    font-weight: 700;
    color: var(--brand-blue);
}

.form-thanks__body {
    color: var(--brand-grey);
    line-height: 1.6;
}

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

/* hCaptcha widget, above the submit bar */

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

.form-captcha .h-captcha {
    min-height: 78px; /* the widget's height, so the page doesn't jump while it loads */
}
