/* Monday forms: styles for QuestionRenderer output (WCAG 2.2 AAA target).
   Concrete loads this automatically with the block. Every selector is .mf-* scoped,
   so legacy forms are unaffected.

   Colours come from the theme's own variables, so each display mode keeps its own target:
     Lights on      AA (4.5:1)   text --body-copy 10:1+, red --dark-red 5.9:1+, gold --gold-text 5.3:1+
     High contrast  AAA (7:1)    text 13.9:1+, red (#80def0) 12.2:1+, gold (white) 18.7:1+
     Lights off     no target    the theme's colours as they are
     Calm           no target    the theme's deliberately softer colours, never overridden
   The theme's brand --red is only 3.7:1 in Lights on, so required text and errors use its --dark-red there. */

.mf-form {
    --mf-text: var(--body-copy, #313131);
    --mf-error: var(--dark-red, #aa002d);
    --mf-error-bg: transparent;
    --mf-rule: var(--body-copy, #313131);
    --mf-focus: var(--yellow, #ffdc31);
    line-height: 1.5;                  /* 1.4.8 */
    text-align: left;                  /* 1.4.8: never justify */
}
.lights_off .mf-form,
.calm .mf-form,
.high_contrast .mf-form { --mf-error: var(--red); }
/* Forms in red sections: errors get a white background so they stay readable (--dark-red on white: 7.4:1) */
.red .mf-form { --mf-error: var(--dark-red, #aa002d); --mf-error-bg: #ffffff; }

/* ---------- Fields ---------- */
.mf-field { margin: 0 0 2rem; max-width: 40em; }
.mf-field--error { border-left: 5px solid var(--mf-error); padding-left: 1rem; }

.mf-label, .mf-legend { display: block; font-weight: 700; margin-bottom: .25rem; max-width: 70ch; color: var(--mf-text); }
.mf-legend { font-size: 1.15em; padding: 0; float: none; width: auto; }
.mf-label__status { font-weight: 400; }
/* "This question requires an answer." in the mode's red: --dark-red in Lights on (the theme's .required
   uses --red, which is below AA there), the theme's own --red in every other mode. */
.mf-form .mf-label__status.required { color: var(--mf-error); }
.red .mf-form .mf-label__status.required { color: inherit; }
/* "Optional:" in --gold-text: the theme's darker gold for text (#7A530D in Lights on, 5.3:1+),
   with each mode's own value elsewhere. Named here as well as by the theme's .gold class, so it also
   shows where the theme CSS isn't loaded (the builder preview). High contrast keeps the theme's white. */
.mf-form .mf-label__status.optional { font-weight: 700; color: var(--gold-text, #7A530D); }
.high_contrast .mf-form .mf-label__status.optional { color: var(--white, #fff); }

/* The theme gives every fieldset a left border; groups here don't need one */
.mf-form .mf-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

.mf-hint { color: var(--mf-text); margin-bottom: .5rem; max-width: 70ch; font-weight: 400; }
.mf-error {
    color: var(--mf-error);
    background: var(--mf-error-bg);
    font-weight: 700;
    margin: 0 0 .5rem;
    max-width: 70ch;
}
.red .mf-error { padding: .25rem .5rem; }

/* Text fields: the theme's .input supplies the look; these add AAA sizing and error state */
.mf-form .mf-input { min-height: 2.75rem; }   /* 44px target (2.5.5); otherwise the theme's .input look */
.mf-form .mf-textarea { min-height: 8rem; }
.mf-form .mf-input--error { border-color: var(--mf-error); border-width: 4px; }

/* Radios / checkboxes use the theme's 44px custom controls (.checkbox_item / .checkbox_label) */
.mf-choices { display: flex; flex-direction: column; gap: .5rem; margin-top:1em;}
.mf-choice__hint { padding-left: 50px; margin-top: -.25rem; }   /* line up with the label text */
.mf-choice--disabled .mf-choice__label { cursor: not-allowed; }

/* Dividers (hr.mf-divider) use the theme's own hr style: the site's short red rule. */

/* ---------- Sport selector: each tile is its checkbox's label ----------
   The theme styles the tiles (.sport_option) and the chosen state ([data-selected="true"]).
   These rules make the whole tile clickable, show keyboard focus on it, and add a tick so the
   chosen state isn't shown by colour alone (WCAG 1.4.1). */
fieldset.sport_selector { border: 0; padding: 0; margin: 0; min-width: 0; }
.sport_option .sport_option__label {
    display: block;
    margin: -0.5em calc(-1 * var(--half-padding, 9px));
    padding: 0.5em var(--half-padding, 9px);
    cursor: pointer;
}
.sport_option:has(.sport_option__input:focus-visible) {
    outline: 3px solid var(--body-copy, #313131);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px var(--yellow, #ffdc31);
}
/* The tick sits on the tile's corner, out of the text flow, so choosing a sport never changes
   the tile's size or moves the tiles after it. Hidden from screen readers ("checked" is announced). */
.sport_option .sport_option__input:checked + .sport_option__label::after {
    content: "\2713";
    content: "\2713" / "";
    position: absolute;
    top: -0.5em;
    right: -0.5em;
    width: 1.5em;
    height: 1.5em;
    line-height: 1.5em;
    border-radius: 50%;
    text-align: center;
    font-size: 0.85em;
    font-weight: 700;
    background: var(--body-copy, #313131);
    color: var(--body-bg, #fbfbfb);
    box-shadow: 0 0 0 2px var(--body-bg, #fbfbfb);
    pointer-events: none;
}
@media (forced-colors: active) {
    .sport_option:has(.sport_option__input:focus-visible) { outline-color: Highlight; }
}

/* ---------- Conditional reveal: directly after the option that controls it ---------- */
.mf-conditional { margin: .5rem 0 1rem 20px; padding-left: 28px; border-left: 4px solid var(--mf-rule); }
.mf-js .mf-conditional--hidden { display: none; }   /* without JavaScript, everything stays visible */

/* ---------- Help ---------- */
.mf-help { margin-bottom: .75rem; }
.mf-help__summary {
    display: list-item;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: .2em;
    padding: .5rem 0;
    min-height: 2.75rem;
    box-sizing: border-box;
}
.mf-help__text { border-left: 4px solid var(--mf-rule); padding: .5rem 1rem; margin-top: .25rem; max-width: 70ch; }

/* ---------- Error summary ---------- */
.mf-error-summary {
    border: 5px solid var(--mf-error);
    background: var(--mf-error-bg);
    padding: 1rem 1.25rem;
    margin-bottom: 2rem;
    max-width: 40em;
}
.mf-error-summary__title { margin-top: 0; color: var(--mf-text); }
.red .mf-error-summary__title { color: #313131; }
.mf-error-summary__list { margin-bottom: 0; }
.mf-error-summary__list a, .mf-error-summary p { color: var(--mf-error); font-weight: 700; }

/* ---------- "We have kept your answers" notice ---------- */
/* The live region stays rendered while empty (so it's announced when filled); styled only once it has content */
.mf-notice:not(:empty) {
    border-left: 5px solid var(--mf-rule);
    padding: .75rem 1rem;
    margin-bottom: 2rem;
    max-width: 40em;
}
.mf-notice__text { margin: 0 0 .5rem; color: var(--mf-text); font-weight: 700; }
.mf-notice__button {
    min-height: 2.75rem;
    padding: .5rem 0;
    background: none;
    border: 0;
    color: var(--mf-text);
    font: inherit;
    text-decoration: underline;
    text-underline-offset: .2em;
    cursor: pointer;
}
.mf-form .mf-notice__button:focus-visible {
    outline: 3px solid var(--mf-text);
    outline-offset: 2px;
    box-shadow: 0 0 0 7px var(--mf-focus);
    background: var(--mf-focus);
    color: #0b0c0c;
    text-decoration: none;
}

/* ---------- Step x of y (2.4.8): caption at the start of each page heading ---------- */
.mf-step {
    display: block;
    font-size: 1rem;
    font-weight: 400;
    color: var(--mf-text);
    margin-bottom: .25rem;
    letter-spacing: normal;
    text-transform: none;
}

/* ---------- Check your answers (3.3.6) ---------- */
/* While reviewing, only the review (and any error summary) is shown. Hidden fields still submit. */
.mf-form.mf-reviewing > :not(.mf-review):not(.mf-error-summary) { display: none !important; }

.mf-review { max-width: 50em; container-type: inline-size; }
.mf-review__title { margin-top: 0; color: var(--mf-text); }
.mf-summary-list { margin: 0 0 2rem; padding: 0; }
.mf-summary-list__row {
    display: grid;
    grid-template-columns: 1fr;
    gap: .25rem;
    padding: .75rem 0;
    border-bottom: 2px solid var(--mf-rule);
}
.mf-summary-list__key { font-weight: 700; margin: 0; color: var(--mf-text); }
.mf-summary-list__value { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--mf-text); }
.mf-summary-list__value--empty { font-style: italic; }
.mf-summary-list__actions { margin: 0; }
.mf-summary-list__actions a {
    display: inline-block;
    min-height: 2.75rem;              /* 44px target */
    min-width: 2.75rem;
    padding: .5rem 0;
    box-sizing: border-box;
    color: var(--mf-text);
    text-decoration: underline;
    text-underline-offset: .2em;
}
/* Columns depend on the review's own width, so a form in a narrow column still stacks */
@container (min-width: 36em) {
    .mf-summary-list__row { grid-template-columns: minmax(0, 35%) minmax(0, 1fr) auto; gap: 1rem; align-items: start; }
    .mf-summary-list__actions { text-align: right; }
    .mf-summary-list__actions a { padding-top: 0; }   /* line up with the question and answer */
}

/* ---------- Focus (2.4.7): never removed ----------
   Text fields carry the theme's .input class and use its own focus style (inset border + yellow ring),
   so they look like every other field on the site. The rules below are only for things the theme
   doesn't style. */
.mf-form .mf-help__summary:focus-visible,
.mf-form .mf-error-summary a:focus-visible,
.mf-form .mf-summary-list__actions a:focus-visible,
.mf-error-summary:focus,
.mf-form [tabindex="-1"]:focus {
    outline: 3px solid var(--mf-text);
    outline-offset: 2px;
    box-shadow: 0 0 0 7px var(--mf-focus);
}
/* Headings only receive focus from the script (to move screen readers along); no ring needed */
.mf-form :is(h1, h2, h3, h4, h5, h6)[tabindex="-1"]:focus { outline: none; box-shadow: none; }
.mf-form .mf-error-summary a:focus-visible,
.mf-form .mf-summary-list__actions a:focus-visible,
.mf-form .mf-help__summary:focus-visible { background: var(--mf-focus); color: #0b0c0c; text-decoration: none; }

.mf-visually-hidden {
    position: absolute !important; width: 1px !important; height: 1px !important;
    margin: 0 !important; padding: 0 !important; overflow: hidden !important;
    clip: rect(0 0 0 0) !important; clip-path: inset(50%) !important; white-space: nowrap !important; border: 0 !important;
}

/* 2.4.12: keep focused fields clear of the sticky site header (adjust to its height) */
html:has(.mf-form) { scroll-padding-top: 9rem; }

@media (prefers-reduced-motion: reduce) {
    .mf-form *, .mf-form *::before, .mf-form *::after { transition: none !important; animation: none !important; }
    html:has(.mf-form) { scroll-behavior: auto !important; }
}

@media (forced-colors: active) {
    .mf-field--error, .mf-error-summary, .mf-form .mf-input--error { border-color: CanvasText; }
    .mf-error-summary:focus { outline-color: Highlight; }
    /* Forced colours drop box-shadows, and the theme's .input:focus removes the outline,
       so fields would show no focus at all: give them a system-coloured outline here only. */
    .mf-form .mf-input:focus { outline: 3px solid Highlight; outline-offset: 2px; }
}
