@font-face {
    font-family: "Mark-Regular";
    font-style: normal;
    font-weight: normal;
    font-display: swap;
    src: url("/forms/vcheck/static/Mark-Regular.ttf") format("truetype")
}

@font-face {
    font-family: "Mark-Heavy";
    font-style: normal;
    font-weight: bold;
    font-display: swap;
    src: url("/forms/vcheck/static/Mark-Heavy.ttf") format("truetype")
}

@property --font-main { syntax: "<string>#"; inherits: true; initial-value: "Mark-Regular", "Arial", "sans-serif"; }
@property --font-bold { syntax: "<string>#"; inherits: true; initial-value: "Mark-Heavy", "Arial", "sans-serif"; }
@property --font-size { syntax: "<length>"; inherits: true; initial-value: 16px; }
@property --color-main { syntax: "<color>"; inherits: true; initial-value: #c9150f; }
@property --color-normal { syntax: "<color>"; inherits: true; initial-value: #000000; }
@property --color-contrast { syntax: "<color>"; inherits: true; initial-value: #ffffff; }
@property --color-muted { syntax: "<color>"; inherits: true; initial-value: #555555; }
@property --color-invalid { syntax: "<color>"; inherits: true; initial-value: #c00000; }

/* Light tint of the campaign colour for areas such as the confirmation box. It is derived here
   instead of being registered, because it depends on --color-main of the campaign stylesheet. */
:root {
    --color-main-soft: color-mix(in srgb, var(--color-main) 8%, transparent);
    /* Neutral grey fill of the input fields, so they are recognisable at any campaign colour and on
       any page behind the transparent frame. The focus tint stays opaque to keep the contrast. */
    --color-field: #ededed;
    --color-field-focus: color-mix(in srgb, var(--color-main) 14%, var(--color-field));
}

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

/* The form is embedded as an iframe into third-party pages: it stays transparent, so the page
   behind it shows through, and it keeps the light colour scheme, because browsers paint an
   opaque backdrop when the scheme of the frame differs from the one of the embedding page. */
html {
    font-family: var(--font-main);
    font-size: var(--font-size);
    line-height: 1.45;
    color: var(--color-normal);
    background: transparent;
    color-scheme: light;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 1rem;
    background: transparent;
    overflow-wrap: anywhere;
}

::selection {
    background-color: var(--color-main);
    color: var(--color-contrast);
}

/* The font classes of a campaign change the font variables for the whole document, so the legal
   footer outside of the form uses the campaign font as well. */
.vcheck-page {
    font-family: var(--font-main);
    max-inline-size: 48rem;
    margin-inline: auto;
    container-type: inline-size;
}

.font-sans_serif,
:root:has(.vcheck-page.font-sans_serif) {
    --font-main: "Arial", "Helvetica";
    --font-bold: "Arial", "Helvetica";
}

.font-serif,
:root:has(.vcheck-page.font-serif) {
    --font-main: "Times New Roman", "Times";
    --font-bold: "Times New Roman", "Times";
}

.font-monospace,
:root:has(.vcheck-page.font-monospace) {
    --font-main: "Courier New", "Courier";
    --font-bold: "Courier New", "Courier";
}

.logo--left {
    text-align: start;
}

.logo--center {
    text-align: center;
}

.logo--right {
    text-align: end;
}

/* The logo keeps the height configured in the campaign, but never overflows a narrow frame. */
.logo img {
    max-inline-size: 100%;
    vertical-align: middle;
}

h1,
h2 {
    font-family: var(--font-bold);
    font-weight: bold;
    line-height: 1.2;
}

h1 {
    font-size: 1.5em;
    margin-block: 1rem 0.5rem;
}

h2 {
    font-size: 1.2em;
    margin-block: 0 1rem;
    padding-block-end: 0.375rem;
    border-block-end: 2px solid var(--color-main);
}

a {
    color: var(--color-main);
    text-underline-offset: 0.15em;

    &:hover {
        text-decoration-thickness: 2px;
    }

    &:focus-visible {
        outline: 2px solid var(--color-main);
        outline-offset: 2px;
        border-radius: 0.125rem;
    }
}

.section {
    margin-block: 2rem;
}

/* The contact fields share a grid: one column in narrow frames, and from a medium width four
   columns, so that related short fields such as street and house number share a row. */
.form-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem 1.25rem;
}

@container (min-width: 34rem) {
    .form-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .form-grid > * {
        grid-column: span 4;
    }

    .form-grid > .span-1 {
        grid-column: span 1;
    }

    .form-grid > .span-2 {
        grid-column: span 2;
    }

    .form-grid > .span-3 {
        grid-column: span 3;
    }
}

.form-line {
    margin: 0;
}

.label-line {
    display: block;
    margin-block-end: 0.25rem;
    font-size: 0.9375rem;
}

select,
input:not([type="checkbox"], [type="hidden"]),
textarea {
    display: block;
    inline-size: 100%;
    min-block-size: 2.75rem;
    margin: 0;
    padding: 0.5rem 0.75rem;
    font: inherit;
    color: inherit;
    background-color: var(--color-field);
    border: none;
    border-block-end: 1px solid var(--color-normal);
    border-radius: 0;
    box-shadow: inset 0 -1px 0 transparent;
    transition: border-color 0.15s, box-shadow 0.15s;

    &::placeholder {
        color: var(--color-muted);
        opacity: 1;
    }

    &:hover {
        border-block-end-color: var(--color-main);
    }

    /* A clearly visible focus mark in the campaign colour; the underline grows to two pixels
       without shifting the layout. */
    &:focus-visible {
        outline: none;
        border-block-end-color: var(--color-main);
        box-shadow: inset 0 -1px 0 var(--color-main);
        background-color: var(--color-field-focus);
    }

    &:user-invalid {
        border-block-end-color: var(--color-invalid);
        box-shadow: inset 0 -1px 0 var(--color-invalid);
    }
}

select {
    cursor: pointer;
}

/* Input and toggle form one field. The popup contributes to the iframe's measured height
   and wraps long place names instead of extending beyond a narrow embedding page. */
.city-combobox-line {
    display: flex;
    align-items: stretch;
}

.city-combobox-line > input {
    min-inline-size: 0;
    flex: 1;
}

.city-toggle {
    flex: 0 0 2.75rem;
    min-block-size: 2.75rem;
    padding: 0.5rem;
    border: none;
    border-block-end: 1px solid var(--color-normal);
    background: var(--color-field);
    color: var(--color-main);
    font: inherit;
    cursor: pointer;
}

.city-toggle:focus-visible {
    outline: 2px solid var(--color-main);
    outline-offset: -2px;
}

.city-options {
    margin-block-start: 0.25rem;
    border: 1px solid var(--color-main);
    background: var(--color-contrast);
    max-block-size: 14rem;
    overflow-y: auto;
    overflow-wrap: anywhere;
}

.city-options > [role="option"] {
    padding: 0.625rem 0.75rem;
    cursor: pointer;
}

.city-options > [role="option"]:hover,
.city-options > [aria-selected="true"] {
    background: var(--color-main-soft);
    box-shadow: inset 3px 0 0 var(--color-main);
}

.city-toggle[hidden],
.city-options[hidden] {
    display: none;
}

.label-line:has(+ .city-combobox input:required):after {
    content: ' *';
}

textarea {
    resize: vertical;
}

.hint {
    margin: 0.375rem 0 0;
    font-size: 0.875rem;
    color: var(--color-muted);
}

/* A field with a hint puts the hint button right behind the label. The grid keeps the DOM order
   label, field, button, text, so the sibling selectors of the required mark ("label + input")
   still match, while the button is placed in the label row. */
.has-hint {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 0.5rem;
    row-gap: 0.25rem;

    & > .label-line {
        grid-area: 1 / 1;
        margin-block-end: 0;
    }

    & > .hint-toggle {
        grid-area: 1 / 2;
        justify-self: start;
    }

    & > :is(select, input, textarea) {
        grid-area: 2 / 1 / 3 / -1;
    }

    & > .field-hint {
        grid-area: 3 / 1 / 4 / -1;
    }
}

/* Without the script (class "js" on the root element, set by hint-toggle.js) there is no button
   and the hint stays visible below the field. */
.hint-toggle {
    display: none;
    position: relative;
    align-items: center;
    justify-content: center;
    flex: none;
    inline-size: 0.9375rem;
    block-size: 0.9375rem;
    padding: 0;
    border: 1px solid var(--color-main);
    border-radius: 50%;
    background-color: var(--color-contrast);
    color: var(--color-main);
    font-family: var(--font-bold);
    font-weight: bold;
    font-size: 0.625rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s;

    /* Enlarges the touch target beyond the visible circle without moving the layout. */
    &::before {
        content: "";
        position: absolute;
        inset: -0.5625rem -0.8125rem;
    }

    /* Hovering and the open state take over the tint of the hint text, so the button and the text
       it opens visibly belong together without a strong colour change. */
    &:hover,
    &[aria-expanded="true"] {
        background-color: var(--color-main-soft);
    }

    &:focus-visible {
        outline: 2px solid var(--color-main);
        outline-offset: 2px;
    }
}

.js .hint-toggle {
    display: inline-flex;
}

/* The hint is tinted and has an accent bar like the messages, so it is distinguishable from the
   grey input fields. The button state decides about its visibility. */
.field-hint {
    margin: 0;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    color: var(--color-normal);
    background-color: var(--color-main-soft);
    border-inline-start: 4px solid var(--color-main);
}

.js .hint-toggle[aria-expanded="false"] ~ .field-hint {
    display: none;
}

.consent {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    margin-block-end: 1rem;

    & label {
        cursor: pointer;
    }
}

input[type="checkbox"] {
    flex-shrink: 0;
    inline-size: 1.25rem;
    block-size: 1.25rem;
    /* Aligns the box with the first text line of the label. */
    margin: 0.1rem 0 0;
    accent-color: var(--color-main);
    cursor: pointer;

    &:focus-visible {
        outline: 2px solid var(--color-main);
        outline-offset: 2px;
    }
}

label:has(+ input:required):after,
input:required + label:after {
    content: ' *';
}

label:has(+ select:required):after,
select:required + label:after {
    content: ' *';
}

.frc-captcha {
    max-inline-size: 100%;
}

.call-to-action,
.form-reload {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-block-size: 3rem;
    padding: 0.5rem 1.75rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-family: var(--font-bold);
    font-weight: bold;
    color: var(--color-main);
    background-color: transparent;
    border: 2px solid var(--color-main);
    transition: background-color 0.15s, color 0.15s;

    &:hover {
        background-color: var(--color-main);
        color: var(--color-contrast);
    }

    &:focus-visible {
        outline: 2px solid var(--color-main);
        outline-offset: 3px;
    }
}

/* The submit button is the main action of the form: very large and centred. In narrow frames it
   uses the full width, in wide frames it is limited to a fixed width. */
.call-to-action {
    display: flex;
    inline-size: min(100%, 36rem);
    min-block-size: 5rem;
    margin-inline: auto;
    padding-inline: 2.5rem;
    font-size: 1.75rem;
    letter-spacing: 2px;
}

/* htmx marks the form while it is being submitted; the button shows that the request runs and
   ignores further clicks, so the interested party does not register twice. */
.htmx-request .call-to-action {
    opacity: 0.6;
    cursor: progress;
    pointer-events: none;
}

.form-reload {
    margin-block-start: 0.5rem;
    font-size: 1rem;
}

.success,
.error {
    margin-block: 1rem;
    padding: 1rem 1.25rem;
    border-inline-start: 4px solid var(--color-main);
    background-color: var(--color-main-soft);

    & p {
        margin-block: 0 0.75rem;
    }

    & p:last-child {
        margin-block-end: 0;
    }
}

.error {
    border-inline-start-color: var(--color-invalid);
    background-color: color-mix(in srgb, var(--color-invalid) 6%, transparent);
}

/* The confirmation text of a campaign keeps the line breaks entered in the administration. */
.confirmation {
    white-space: pre-line;
}

.preview-notice {
    max-inline-size: 48rem;
    margin: 0 auto 1rem;
    padding: 0.5rem 0.75rem;
    border: 1px dashed var(--color-main);
    font-size: 0.875rem;
}

.legal-page {
    max-inline-size: 48rem;
    margin-inline: auto;
}

.legal-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1.5rem;
    max-inline-size: 48rem;
    margin: 2rem auto 0;
    padding-block-start: 1rem;
    border-block-start: 1px solid color-mix(in srgb, var(--color-normal) 15%, transparent);
    font-size: 0.875rem;

    & a {
        color: var(--color-muted);

        &:hover {
            color: var(--color-main);
        }
    }
}
