/* ==========================================================================
   Public form primitives
   Used by <x-web.field>, <x-web.error-summary>, <x-web.honeypot> and the
   public forms built on them (contact, join, partnerships, membership,
   appointment, comments). Colours and shapes come from tokens.css.
   Logical properties only, so the same rules work in LTR and RTL.
   ========================================================================== */

/* ---- Layout helpers ---------------------------------------------------- */
.wf-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 20px;
}

.wf-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--violet-800);
    letter-spacing: .02em;
    margin-block: 26px 14px;
    padding-block-end: 8px;
    border-block-end: 1px solid var(--ui-line);
    text-align: start;
}

.wf-section-title:first-child {
    margin-block-start: 0;
}

.wf-note {
    font-size: var(--fs-sm);
    color: var(--ink-muted);
    margin-block: 0 16px;
    text-align: start;
}

/* ---- Field ------------------------------------------------------------- */
.wf-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-block-end: 18px;
    min-inline-size: 0;
}

.wf-label {
    font-size: var(--fs-sm);
    font-weight: 600;
    line-height: 1.4;
    color: var(--ink);
    text-align: start;
    margin: 0;
}

.wf-req {
    color: var(--danger);
    font-weight: 700;
    margin-inline-start: 3px;
}

.wf-opt {
    font-size: var(--fs-xs);
    font-weight: 400;
    color: var(--ink-muted);
    margin-inline-start: 4px;
}

/* Two classes so page stylesheets (".x-form input") can't override the look. */
.wf-field .wf-control {
    inline-size: 100%;
    min-block-size: 48px;
    padding-block: 11px;
    padding-inline: 14px;
    font: inherit;
    font-size: var(--fs-base); /* 16px: no zoom-on-focus in iOS Safari */
    line-height: 1.5;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--ink-subtle);
    border-radius: var(--radius-md);
    box-shadow: none;
    outline: none;
    text-align: start;
    transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}

.wf-field .wf-control[dir="ltr"] {
    text-align: left;
}

.wf-field textarea.wf-control {
    min-block-size: 120px;
    resize: vertical;
}

.wf-field select.wf-control {
    cursor: pointer;
    appearance: auto;
}

.wf-field .wf-control[type="file"] {
    padding-block: 10px;
    font-size: var(--fs-sm);
    cursor: pointer;
    background: var(--surface-soft);
}

.wf-field .wf-control::placeholder {
    color: var(--ink-subtle);
    opacity: 1;
}

.wf-field .wf-control:hover {
    border-color: var(--ink-muted);
}

.wf-field .wf-control:focus,
.wf-field .wf-control:focus-visible {
    border-color: var(--violet-600);
    box-shadow: var(--focus-ring);
    background: var(--surface);
    outline: none;
}

/* Error state */
.wf-field .wf-control.is-invalid {
    border-color: var(--danger);
    background: color-mix(in srgb, var(--danger) 4%, var(--surface));
}

.wf-field .wf-control.is-invalid:focus {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 28%, transparent);
}

.wf-help,
.wf-error {
    margin: 0;
    font-size: var(--fs-xs);
    line-height: 1.5;
    text-align: start;
}

.wf-help {
    color: var(--ink-muted);
}

.wf-error {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    color: var(--danger);
    font-weight: 500;
}

.wf-error i {
    margin-block-start: 3px;
}

/* ---- Radio / checkbox groups ------------------------------------------ */
.wf-fieldset {
    border: 0;
    padding: 0;
    margin: 0 0 18px;
    min-inline-size: 0;
}

.wf-fieldset > .wf-legend {
    float: none;
    inline-size: auto;
    padding: 0;
    margin-block-end: 6px;
    font-size: var(--fs-sm);
    font-weight: 600;
    line-height: 1.4;
    color: var(--ink);
    text-align: start;
}

.wf-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
}

.wf-choices--stack {
    flex-direction: column;
    gap: 2px;
}

.wf-choices--grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 8px;
}

/* The whole label is the hit area: at least 44px tall. */
.wf-choice {
    display: flex;
    align-items: center;
    gap: 10px;
    min-block-size: 44px;
    padding-inline: 6px 10px;
    margin: 0;
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    font-weight: 500;
    line-height: 1.4;
    color: var(--ink);
    cursor: pointer;
    text-align: start;
}

.wf-choice:hover {
    background: var(--surface-soft);
}

.wf-choice input[type="radio"],
.wf-choice input[type="checkbox"] {
    flex: none;
    inline-size: 20px;
    block-size: 20px;
    min-block-size: 0;
    margin: 0;
    padding: 0;
    accent-color: var(--violet-600);
    cursor: pointer;
}

.wf-choice input[type="radio"]:focus-visible,
.wf-choice input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--violet-600);
    outline-offset: 2px;
}

.wf-fieldset.has-error .wf-legend {
    color: var(--danger);
}

/* ---- Error summary ----------------------------------------------------- */
.wf-summary {
    margin-block-end: 22px;
    padding-block: 14px;
    padding-inline: 16px;
    background: color-mix(in srgb, var(--danger) 6%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
    border-inline-start: 4px solid var(--danger);
    border-radius: var(--radius-md);
    color: var(--ink);
    text-align: start;
}

.wf-summary:focus {
    outline: 2px solid var(--danger);
    outline-offset: 2px;
}

.wf-summary__title {
    margin: 0 0 6px;
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--danger);
}

.wf-summary__list {
    margin: 0;
    padding-inline-start: 1.25em;
    font-size: var(--fs-sm);
    line-height: 1.6;
}

/* ---- Submit ------------------------------------------------------------ */
.wf-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-block-size: 48px;
    padding-block: 12px;
    padding-inline: 32px;
    border: 0;
    border-radius: var(--radius-md);
    background: var(--gradient-brand);
    color: #fff;
    font: inherit;
    font-size: var(--fs-base);
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-md);
}

.wf-submit:hover {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: var(--shadow-card);
}

.wf-submit:focus-visible {
    outline: 2px solid var(--violet-400);
    outline-offset: 3px;
}

.wf-submit[disabled] {
    opacity: .7;
    cursor: progress;
    transform: none;
}

/* ---- Accessibility helpers -------------------------------------------- */
.wf-sr-only {
    position: absolute !important;
    inline-size: 1px !important;
    block-size: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Honeypot: off-screen for people, still in the DOM for bots. */
.wf-hp {
    /* Visually hidden trap field: clipped, not moved off-screen (no page overflow). */
    position: absolute !important;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

@media (max-width: 640px) {
    .wf-row {
        grid-template-columns: 1fr;
    }

    .wf-submit {
        inline-size: 100%;
    }
}
