/* Loomy360 Lead Forms — front-end styles.
 *
 * Typography is fully tokenized via CSS custom properties so every embed
 * surface (Elementor widget, Gutenberg block, [loomy_lead_form] shortcode)
 * can control label / heading / input / title sizing, weight, color, and
 * font family WITHOUT editing this file. Defaults below are deliberately
 * legible on ANY theme:
 *
 *   - We set an explicit sans-serif --loomy-font-family. Earlier builds set
 *     NO font-family, which meant labels inherited the host theme's font —
 *     on serif-heavy themes (e.g. GVS) that rendered the labels as tiny,
 *     hard-to-read serif text with no way to fix it. The explicit default
 *     fixes legibility out of the box; tenants who WANT the theme font flip
 *     "Inherit WP theme look-and-feel" (adds .loomy-form--inherit-theme).
 *   - Every size multiplies by --loomy-scale, so a single "font scale" knob
 *     (Comfortable / Large / Extra large) enlarges the whole form
 *     proportionally for non-technical operators. Per-element overrides
 *     (--loomy-label-size etc.) layer on top, and Elementor's native
 *     Typography controls override the element rules entirely (higher
 *     specificity via {{WRAPPER}}).
 */

.loomy360-form-wrap {
    --loomy-accent: #9B8AC4;
    --loomy-accent-text: #ffffff;
    --loomy-text: #0f172a;
    --loomy-muted: #64748b;
    --loomy-border: #e2e8f0;
    --loomy-bg: #ffffff;
    --loomy-error: #dc2626;

    /* Typography tokens — overridable per-embed (see header note). */
    --loomy-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --loomy-scale: 1;
    --loomy-title-size: 24px;
    --loomy-desc-size: 15px;
    --loomy-label-size: 14.5px;
    --loomy-label-weight: 600;
    --loomy-label-color: var(--loomy-text);
    --loomy-input-size: 15px;
    --loomy-heading-size: 17px;
    --loomy-help-size: 12.5px;
    /* Render text exactly as the admin typed it. Many themes force
     * text-transform:uppercase + wide letter-spacing on form labels, which
     * mangled admin-authored copy (ALL CAPS labels the operator never wanted).
     * Default to none/normal so the form is predictable on ANY theme; the
     * Elementor Typography control + the shortcode vars below can opt into
     * uppercase/spacing if a tenant actually wants it. */
    --loomy-text-transform: none;
    --loomy-letter-spacing: normal;

    color: var(--loomy-text);
    font-family: var(--loomy-font-family);
    box-sizing: border-box;
}
/* ── Theme-isolation reset ──────────────────────────────────────────────
 * Native embedding means the host theme's CSS cascades INTO the form. Real
 * themes directly style `label`/`input`/`select` with their own font, ALL-CAPS
 * text-transform, wide letter-spacing, serif families, and underline-only
 * borders — and a wrapper-level default cannot beat a direct rule on `input`
 * (an inherited value always loses to a direct element rule). So we lock the
 * bleed-prone properties DIRECTLY on the form's elements with !important.
 *
 * Crucially, every locked property reads a CSS VARIABLE — so the Elementor
 * widget / Gutenberg block / shortcode controls (which set the variables on
 * the wrap, NOT the property) still take effect over this reset. Result:
 * premium + predictable on ANY theme out of the box, fully customizable via
 * the visual controls, and the theme can never silently re-style the form.
 * Tenants who WANT the host theme's look flip "Inherit WP theme look-and-feel"
 * (the .loomy-form--inherit-theme block below relaxes these). */
.loomy360-form-wrap .loomy-label,
.loomy360-form-wrap .loomy-title,
.loomy360-form-wrap .loomy-desc,
.loomy360-form-wrap .loomy-heading,
.loomy360-form-wrap .loomy-heading-sub,
.loomy360-form-wrap .loomy-help,
.loomy360-form-wrap .loomy-checkbox-label,
.loomy360-form-wrap .loomy-input {
    font-family: var(--loomy-font-family) !important;
    text-transform: var(--loomy-text-transform) !important;
    letter-spacing: var(--loomy-letter-spacing) !important;
    font-style: normal !important;
}
.loomy360-form-wrap .loomy-label {
    font-size: calc(var(--loomy-label-size) * var(--loomy-scale)) !important;
    font-weight: var(--loomy-label-weight) !important;
    color: var(--loomy-label-color) !important;
}
.loomy360-form-wrap .loomy-title   { font-size: calc(var(--loomy-title-size) * var(--loomy-scale)) !important; }
.loomy360-form-wrap .loomy-desc    { font-size: calc(var(--loomy-desc-size) * var(--loomy-scale)) !important; }
.loomy360-form-wrap .loomy-heading { font-size: calc(var(--loomy-heading-size) * var(--loomy-scale)) !important; }
/* Inputs/selects/textareas: restore the clean boxed field even when the theme
 * imposed an underline-only / serif / uppercase style. */
.loomy360-form-wrap .loomy-input {
    font-size: calc(var(--loomy-input-size) * var(--loomy-scale)) !important;
    font-weight: 400 !important;
    line-height: 1.4 !important;
    color: var(--loomy-text) !important;
    background: var(--loomy-bg) !important;
    border: 1px solid var(--loomy-border) !important;
    border-radius: 8px !important;
    padding: 10px 12px !important;
}
.loomy360-form-wrap *, .loomy360-form-wrap *::before, .loomy360-form-wrap *::after { box-sizing: border-box; }

.loomy360-form-loading {
    padding: 24px;
    text-align: center;
    color: var(--loomy-muted);
    font-size: 14px;
}
.loomy360-form-error {
    padding: 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    border-radius: 8px;
    font-size: 14px;
}

.loomy-title {
    font-size: calc(var(--loomy-title-size) * var(--loomy-scale));
    line-height: 1.25;
    font-weight: 700;
    margin: 0 0 6px 0;
}
.loomy-desc {
    font-size: calc(var(--loomy-desc-size) * var(--loomy-scale));
    color: var(--loomy-muted);
    margin: 0 0 16px 0;
}

/* 2-column field layout — fields with width=half pair into a grid.
 * Stacks on mobile (<= 640px) so phones don't get cramped inputs. */
.loomy-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 16px;
    row-gap: 0;
}
.loomy-field {
    margin-bottom: 14px;
    grid-column: 1 / -1; /* default: full width */
}
.loomy-field--half { grid-column: span 1; }
@media (max-width: 640px) {
    .loomy-field--half { grid-column: 1 / -1; }
}
/* Status/error rows always span full so the user can read them. */
.loomy-form-error,
.loomy-field-content,
.loomy-field-heading,
.loomy-field-consent,
.loomy-submit,
[data-loomy-success] { grid-column: 1 / -1; }
.loomy-label {
    display: block;
    font-size: calc(var(--loomy-label-size) * var(--loomy-scale));
    font-weight: var(--loomy-label-weight);
    color: var(--loomy-label-color);
    line-height: 1.35;
    margin-bottom: 6px;
}
.loomy-req { color: var(--loomy-error); }
.loomy-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--loomy-border);
    border-radius: 8px;
    font-size: calc(var(--loomy-input-size) * var(--loomy-scale));
    line-height: 1.4;
    background: var(--loomy-bg);
    color: var(--loomy-text);
    transition: border-color .15s, box-shadow .15s;
}
.loomy-input:focus {
    outline: none;
    border-color: var(--loomy-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--loomy-accent) 25%, transparent);
}
textarea.loomy-input { resize: vertical; min-height: 96px; }
select.loomy-input { appearance: none; background-image: linear-gradient(45deg,transparent 50%,#94a3b8 50%),linear-gradient(135deg,#94a3b8 50%,transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 14px) 50%; background-size: 4px 4px; background-repeat: no-repeat; padding-right: 32px; }

.loomy-checkbox-label { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.loomy-checkbox-label input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--loomy-accent); }

.loomy-help { font-size: calc(var(--loomy-help-size) * var(--loomy-scale)); color: var(--loomy-muted); margin-top: 4px; }
.loomy-error { font-size: 12px; color: var(--loomy-error); margin-top: 4px; min-height: 0; }
.loomy-error:empty { display: none; }
.loomy-form-error {
    color: var(--loomy-error);
    background: #fef2f2;
    border: 1px solid #fecaca;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 12px;
}
.loomy-form-error:empty { display: none; }

.loomy-submit {
    display: inline-block;
    padding: 11px 20px;
    background: var(--loomy-accent);
    color: var(--loomy-accent-text);
    border: 0;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: filter .15s, transform .05s;
    margin-top: 6px;
}
.loomy-submit:hover:not(:disabled) { filter: brightness(0.95); }
.loomy-submit:active:not(:disabled) { transform: translateY(1px); }
.loomy-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.loomy-success {
    padding: 28px 20px;
    text-align: center;
    color: #047857;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 12px;
}
.loomy-success svg { color: #059669; margin-bottom: 8px; }
.loomy-success-text { font-size: 15px; font-weight: 600; }

/* ── 1.1.0: new field types ───────────────────────────────────────────── */

/* Heading — section break inside the form */
.loomy-field-heading { margin: 18px 0 8px 0; }
.loomy-heading {
    font-size: calc(var(--loomy-heading-size) * var(--loomy-scale));
    font-weight: 700;
    color: var(--loomy-text);
    margin: 0 0 4px 0;
    padding: 8px 0 6px;
    border-bottom: 1px solid var(--loomy-border);
}
.loomy-heading-sub { font-size: calc(var(--loomy-help-size) * var(--loomy-scale)); color: var(--loomy-muted); margin: 0; }

/* Content — inline paragraph / instructions / legal copy */
.loomy-field-content { margin: 6px 0 14px 0; }
.loomy-content { font-size: 14px; line-height: 1.55; color: var(--loomy-text); }
.loomy-content p { margin: 0 0 8px 0; }
.loomy-content p:last-child { margin-bottom: 0; }
.loomy-content a { color: var(--loomy-accent); text-decoration: underline; }

/* Checkboxes (plural) — multi-choice */
.loomy-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0;
}
.loomy-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.45;
    color: var(--loomy-text);
}
.loomy-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 1px;
    accent-color: var(--loomy-accent);
    flex-shrink: 0;
}
.loomy-checkbox-label span { flex: 1; }

/* Consent — checkbox + rich-HTML label (with link) */
.loomy-field-consent { margin: 12px 0; }
.loomy-consent-label { align-items: flex-start; }
.loomy-consent-text { flex: 1; }
.loomy-consent-text p { margin: 0 0 8px 0; line-height: 1.55; }
.loomy-consent-text p:last-child { margin-bottom: 0; }
.loomy-consent-text br { line-height: 1.55; }
.loomy-consent-text h2,
.loomy-consent-text h3,
.loomy-consent-text h4 {
    font-size: 15px;
    font-weight: 600;
    margin: 12px 0 4px 0;
    color: var(--loomy-text);
}
.loomy-consent-text ul,
.loomy-consent-text ol { margin: 0 0 8px 0; padding-left: 22px; }
.loomy-consent-text ul { list-style: disc; }
.loomy-consent-text ol { list-style: decimal; }
.loomy-consent-text a { color: var(--loomy-accent); text-decoration: underline; }

/* ── 1.2.0: step-through (one-question-at-a-time) mode ──────────────── */

.loomy-step-progress { margin-bottom: 18px; }
.loomy-step-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--loomy-muted);
    margin-bottom: 6px;
}
.loomy-step-bar {
    height: 6px;
    background: #f1f5f9;
    border-radius: 999px;
    overflow: hidden;
}
.loomy-step-bar-fill {
    height: 100%;
    background: var(--loomy-accent);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.loomy-step-actions {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--loomy-border);
}
.loomy-step-back,
.loomy-step-next {
    display: inline-flex;
    align-items: center;
    padding: 10px 18px;
    border-radius: 8px;
    border: 0;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s, transform 0.05s;
}
.loomy-step-back {
    background: #f1f5f9;
    color: #475569;
}
.loomy-step-back:hover:not(:disabled) { background: #e2e8f0; }
.loomy-step-back:disabled { opacity: 0.4; cursor: not-allowed; }
.loomy-step-next {
    background: var(--loomy-accent);
    color: var(--loomy-accent-text);
}
.loomy-step-next:hover { filter: brightness(0.95); }
.loomy-form-step .loomy-field { margin-bottom: 0; }
.loomy-form-step label.loomy-label {
    /* Step mode shows one question at a time, so the label reads a touch
     * larger than the stacked layout — but still proportional to the
     * tenant's chosen scale + label size. */
    font-size: calc(var(--loomy-label-size) * var(--loomy-scale) * 1.12);
    font-weight: var(--loomy-label-weight);
    color: var(--loomy-label-color);
    margin-bottom: 10px;
}

/* ── Theme inheritance — when the tenant flips "Inherit WP theme look-and-
 * feel", we relax Loomy's defaults so the host theme's typography +
 * spacing + button styling take over. Inputs still get a sensible border
 * (themes rarely style raw <input>) but font/color/background fall
 * through to the parent. */
.loomy-form--inherit-theme {
    color: inherit;
    background: transparent;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}
.loomy-form--inherit-theme .loomy-title,
.loomy-form--inherit-theme .loomy-desc,
.loomy-form--inherit-theme .loomy-label,
.loomy-form--inherit-theme .loomy-help { color: inherit; }
.loomy-form--inherit-theme .loomy-input,
.loomy-form--inherit-theme .loomy-textarea,
.loomy-form--inherit-theme .loomy-select {
    background: transparent;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
}
.loomy-form--inherit-theme .loomy-submit {
    /* Keep the accent color (configured per-tenant) but let everything
     * else come from the theme (border-radius, padding, font). */
    background: var(--loomy-accent);
    color: var(--loomy-accent-text);
    border: none;
    font-family: inherit;
    font-weight: inherit;
}
