/*
 * Form Builder — public form styles. Markup: includes/forms/render.php (the form) and
 * includes/custom_pages/render.php zin_cp_w_form (the section around it: .zfw-*).
 *
 * Colours, fonts, corners and shadows come ONLY from the template's --z-* tokens (with neutral
 * fallbacks), so a form follows the market's template and Light/Dark mode by itself. The error
 * colour is red mixed toward the text colour: darker on light templates, lighter on dark ones.
 * Inputs are 16px so iOS never zooms on focus.
 */

/* ------------------------------------------------------------ section frame (.zfw) */
.zfw__inner { max-width: var(--zfw-w, 820px); margin: 0 auto; }
.zfw--narrow { --zfw-w: 640px; }
.zfw--medium { --zfw-w: 820px; }
.zfw--wide   { --zfw-w: 1080px; }
.zfw--split  { --zfw-w: 1160px; }
.zfw--split .zfw__inner { display: grid; gap: 32px; }
@media (min-width: 960px) {
    .zfw--split .zfw__inner { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 56px; align-items: start; }
    .zfw--split .zfw__intro { position: sticky; top: 96px; }
}
.zfw--split .zfw__intro .zt-heading { margin-bottom: 0; }
.zfw__points { list-style: none; margin: 24px 0 0; padding: 0; display: grid; gap: 12px; }
.zfw__points li { display: flex; gap: 10px; align-items: flex-start; color: var(--z-muted, #64748b); line-height: 1.5; }
.zfw__points li::before {
    content: ""; flex: none; width: 18px; height: 18px; margin-top: 2px; border-radius: 50%;
    background: var(--z-accent-soft, rgba(37, 99, 235, .12));
    box-shadow: inset 0 0 0 5px var(--z-accent-soft, rgba(37, 99, 235, .12)), inset 0 0 0 9px var(--z-accent, #2563eb);
}
.zcp-bg--brand .zfw__points li { color: inherit; opacity: .92; }
.zfw__card {
    background: var(--z-surface, #fff);
    color: var(--z-text, #0f172a);
    border: 1px solid var(--z-border, #e2e8f0);
    border-radius: var(--z-radius-lg, 18px);
    box-shadow: var(--z-shadow, 0 10px 30px rgba(15, 23, 42, .08));
    padding: 22px 18px;
}
@media (min-width: 640px) { .zfw__card { padding: 32px; } }
@media (min-width: 1024px) { .zfw__card { padding: 40px; } }
.zfw__card--plain { background: transparent; border: 0; box-shadow: none; padding: 0; }
.zfw .zt-heading { margin-bottom: 28px; }
.zf-missing {
    border: 1px dashed var(--z-border, #cbd5e1); border-radius: var(--z-radius, 10px);
    padding: 18px; text-align: center; color: var(--z-muted, #64748b); font-size: .95rem;
}

/* ------------------------------------------------------------ the form */
.zf {
    --zf-danger: #dc2626;
    --zf-danger: color-mix(in srgb, #dc2626 72%, var(--z-text, #0f172a));
    --zf-radius: var(--z-radius, 10px);
    position: relative;
    scroll-margin-top: 110px;          /* the thank-you / first error scroll clear of sticky site headers */
    font-family: var(--z-font-body, inherit);
    color: var(--z-text, #0f172a);
    text-align: left;
}
.zf *, .zf *::before, .zf *::after { box-sizing: border-box; }
.zf [hidden] { display: none !important; }
.zf-hp { position: absolute !important; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

.zf-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 16px; }
.zf-field { grid-column: 1 / -1; min-width: 0; margin: 0; padding: 0; border: 0; scroll-margin-top: 110px; }
@media (min-width: 640px) { .zf-field--half { grid-column: span 1; } }
.zf-field[data-zf-cond]:not([hidden]) { animation: zf-reveal .22s ease both; }
@keyframes zf-reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.zf-label {
    display: block; width: 100%; padding: 0; margin: 0 0 7px;
    font-size: .95rem; font-weight: 650; line-height: 1.35; color: var(--z-text, #0f172a);
}
legend.zf-label { float: left; }
legend.zf-label + * { clear: both; }
.zf-req { color: var(--zf-danger); font-weight: 700; }
.zf-opt { color: var(--z-muted, #64748b); font-weight: 400; font-size: .85em; }
.zf-help { margin: -2px 0 8px; color: var(--z-muted, #64748b); font-size: .875rem; line-height: 1.5; clear: both; }

.zf-input {
    display: block; width: 100%; min-height: 48px; margin: 0;
    padding: 12px 14px;
    font: inherit; font-size: 16px; line-height: 1.4;
    color: var(--z-text, #0f172a);
    background: var(--z-surface, #fff);
    border: 1px solid var(--z-border, #cbd5e1);
    border-radius: var(--zf-radius);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, .04);
    transition: border-color .15s ease, box-shadow .15s ease;
    -webkit-appearance: none; appearance: none;
}
.zf-input::placeholder { color: var(--z-muted, #64748b); opacity: .75; }
.zf-input:hover { border-color: color-mix(in srgb, var(--z-border, #cbd5e1) 55%, var(--z-text, #0f172a)); }
.zf-input:focus { outline: none; border-color: var(--z-accent, #2563eb); box-shadow: 0 0 0 3px var(--z-accent-soft, rgba(37, 99, 235, .18)); }
.zf-textarea { min-height: 120px; resize: vertical; }
.zf-input[type="date"], .zf-input[type="time"] { min-height: 48px; }
.zf-input::-webkit-date-and-time-value { text-align: left; }
.zf-select-wrap { position: relative; }
.zf-select { padding-right: 42px; cursor: pointer; }
.zf-select-wrap::after {
    content: ""; position: absolute; right: 16px; top: 50%; width: 8px; height: 8px; pointer-events: none;
    border-right: 2px solid var(--z-muted, #64748b); border-bottom: 2px solid var(--z-muted, #64748b);
    transform: translateY(-70%) rotate(45deg);
}

/* choices */
.zf-choices { display: grid; gap: 10px; }
@media (min-width: 640px) {
    .zf-choices--cols2, .zf-choices--cols3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 900px) { .zf-choices--cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.zf-choice {
    position: relative; display: flex; align-items: flex-start; gap: 11px; min-height: 48px;
    padding: 12px 14px; cursor: pointer; line-height: 1.4;
    background: var(--z-surface, #fff);
    border: 1px solid var(--z-border, #cbd5e1);
    border-radius: var(--zf-radius);
    transition: border-color .15s ease, background-color .15s ease;
}
.zf-choice:hover { border-color: color-mix(in srgb, var(--z-border, #cbd5e1) 50%, var(--z-accent, #2563eb)); }
.zf-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.zf-choice__mark {
    flex: none; display: grid; place-items: center; width: 20px; height: 20px; margin-top: 1px;
    background: var(--z-surface, #fff);
    border: 2px solid color-mix(in srgb, var(--z-border, #cbd5e1) 40%, var(--z-muted, #64748b));
    border-radius: 6px;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.zf-choice input[type="radio"] + .zf-choice__mark { border-radius: 50%; }
.zf-choice input:checked + .zf-choice__mark { background: var(--z-accent, #2563eb); border-color: var(--z-accent, #2563eb); }
.zf-choice input[type="checkbox"]:checked + .zf-choice__mark::after {
    content: ""; width: 5px; height: 10px; margin-top: -2px;
    border: solid var(--z-accent-ink, #fff); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.zf-choice input[type="radio"]:checked + .zf-choice__mark { box-shadow: inset 0 0 0 4px var(--z-surface, #fff); }
.zf-choice input:focus-visible + .zf-choice__mark { outline: 3px solid var(--z-focus, var(--z-accent, #2563eb)); outline-offset: 2px; }
.zf-choice:has(input:checked) {
    border-color: var(--z-accent, #2563eb);
    background: color-mix(in srgb, var(--z-accent, #2563eb) 7%, var(--z-surface, #fff));
}
.zf-choice__text { min-width: 0; overflow-wrap: anywhere; }
.zf-choice--consent { border: 0; padding: 0; min-height: 0; background: none; }
.zf-choice--consent:has(input:checked) { background: none; }
.zf-choice--consent .zf-choice__text { color: var(--z-text, #0f172a); font-size: .95rem; }
.zf-choice--consent a { color: var(--z-accent-text, var(--z-accent, #2563eb)); text-decoration: underline; }

/* file uploads — the real <input type=file> covers the drop zone, so a click opens the picker and a
   dropped file lands in it natively; zin-form.js keeps the chosen files in the list below. */
.zf-drop {
    position: relative; display: flex; align-items: center; justify-content: center; min-height: 104px; padding: 18px;
    text-align: center; color: var(--z-muted, #64748b);
    background: color-mix(in srgb, var(--z-surface-2, #f8fafc) 70%, var(--z-surface, #fff));
    border: 2px dashed color-mix(in srgb, var(--z-border, #cbd5e1) 70%, var(--z-muted, #64748b));
    border-radius: var(--zf-radius);
    transition: border-color .15s ease, background-color .15s ease;
}
.zf-drop:hover, .zf-drop.is-over { border-color: var(--z-accent, #2563eb); background: color-mix(in srgb, var(--z-accent, #2563eb) 6%, var(--z-surface, #fff)); }
.zf-file-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }
.zf-file-input:focus-visible + .zf-drop__body { outline: 3px solid var(--z-focus, var(--z-accent, #2563eb)); outline-offset: 6px; border-radius: 8px; }
.zf-drop__body { display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.zf-drop__icon { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: var(--z-accent, #2563eb); background: var(--z-accent-soft, rgba(37, 99, 235, .12)); }
.zf-drop__text { font-size: .95rem; line-height: 1.4; }
.zf-drop__text strong { color: var(--z-accent-text, var(--z-accent, #2563eb)); font-weight: 700; }
.zf-drop__hint { margin: 7px 0 0; font-size: .82rem; color: var(--z-muted, #64748b); }
.zf-field--file.is-full .zf-drop { min-height: 64px; opacity: .6; }
.zf-field--file.is-invalid .zf-drop { border-color: var(--zf-danger); }
.zf-files { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.zf-files:empty { display: none; }
.zf-file {
    display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 8px; min-width: 0;
    background: var(--z-surface, #fff); border: 1px solid var(--z-border, #e2e8f0); border-radius: var(--zf-radius);
}
.zf-file__thumb {
    flex: none; display: grid; place-items: center; width: 44px; height: 44px; overflow: hidden; border-radius: 8px;
    font-size: .68rem; font-weight: 800; letter-spacing: .04em; color: var(--z-accent, #2563eb); background: var(--z-accent-soft, rgba(37, 99, 235, .12));
}
.zf-file__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.zf-file__meta { flex: 1; min-width: 0; display: grid; gap: 2px; }
.zf-file__name { font-size: .92rem; font-weight: 600; color: var(--z-text, #0f172a); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zf-file__size { font-size: .8rem; color: var(--z-muted, #64748b); }
.zf-file__remove {
    flex: none; display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 8px; cursor: pointer;
    color: var(--z-muted, #64748b); background: transparent;
}
.zf-file__remove:hover { color: var(--zf-danger); background: color-mix(in srgb, #dc2626 8%, transparent); }
.zf--on-brand .zf-drop { color: inherit; }

/* display blocks */
.zf-block--heading .zf-block__title {
    margin: 10px 0 0; padding-bottom: 8px; font-size: 1.15rem; font-weight: 700;
    font-family: var(--z-font-display, inherit); color: var(--z-text, #0f172a);
    border-bottom: 1px solid var(--z-border, #e2e8f0);
}
.zf-block--text p { margin: 0; color: var(--z-muted, #64748b); line-height: 1.6; }
.zf-block--text a { color: var(--z-accent-text, var(--z-accent, #2563eb)); }
.zf-block--divider hr { border: 0; border-top: 1px solid var(--z-border, #e2e8f0); margin: 4px 0; }

/* errors */
.zf-field.is-invalid .zf-input,
.zf-field.is-invalid .zf-choice { border-color: var(--zf-danger); }
.zf-field.is-invalid .zf-input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, #dc2626 22%, transparent); }
.zf-field.is-invalid .zf-choice--consent .zf-choice__mark { border-color: var(--zf-danger); }
.zf-error { margin: 7px 0 0; color: var(--zf-danger); font-size: .86rem; font-weight: 600; line-height: 1.4; }
.zf-summary {
    margin-top: 20px; padding: 12px 14px; font-size: .92rem; font-weight: 600;
    color: var(--zf-danger);
    background: color-mix(in srgb, #dc2626 8%, var(--z-surface, #fff));
    border: 1px solid color-mix(in srgb, #dc2626 35%, var(--z-border, #e2e8f0));
    border-radius: var(--zf-radius);
}
.zf-summary:focus { outline: none; }

/* submit */
.zf-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 26px; }
.zf-submit { position: relative; min-width: 170px; min-height: 50px; justify-content: center; cursor: pointer; }
.zf-submit[disabled] { opacity: .75; cursor: progress; }
.zf-spinner {
    display: none; width: 18px; height: 18px; margin-left: 10px; border-radius: 50%;
    border: 2px solid currentColor; border-right-color: transparent; animation: zf-spin .7s linear infinite;
}
.zf-submit.is-busy .zf-spinner { display: inline-block; }
@keyframes zf-spin { to { transform: rotate(360deg); } }

/* thank-you */
.zf-success { padding: 28px 8px; text-align: center; animation: zf-reveal .3s ease both; }
.zf-success:focus { outline: none; }
.zf-success__icon {
    display: inline-grid; place-items: center; width: 60px; height: 60px; margin-bottom: 14px; border-radius: 50%;
    color: var(--z-accent, #2563eb);
    background: var(--z-accent-soft, rgba(37, 99, 235, .12));
}
.zf-success__title { margin: 0 0 8px; font-size: 1.45rem; font-weight: 800; font-family: var(--z-font-display, inherit); color: var(--z-text, #0f172a); }
.zf-success__text { margin: 0 auto; max-width: 520px; color: var(--z-muted, #64748b); line-height: 1.6; }
.zf-success__again { margin: 18px 0 0; font-size: .92rem; }
.zf-success__again a { color: var(--z-accent-text, var(--z-accent, #2563eb)); font-weight: 600; }

/* a plain form straight on a brand-colour band */
.zf--on-brand :is(.zf-label, .zf-help, .zf-opt, .zf-block__title, .zf-block--text p, .zf-success__title, .zf-success__text, .zf-success__again a, .zf-choice--consent .zf-choice__text) { color: inherit; }
.zf--on-brand .zf-success__icon { background: rgba(255, 255, 255, .18); color: inherit; }

@media (prefers-reduced-motion: reduce) {
    .zf-field[data-zf-cond]:not([hidden]), .zf-success { animation: none; }
    .zf-spinner { animation-duration: 1.6s; }
}
