/**
 * Front-end styles.
 *
 * Looks like the site by default (CLAUDE.md §9): colours come from the theme's
 * presets with plain fallbacks — the suite's theme token contract
 * (plugins_wp docs/lynbro-ux-standard.md §4a: accent, border, danger, success,
 * radius md; older names primary/line kept second), fonts and sizes are inherited,
 * the submit button wears the theme's button style (wp-element-button), and
 * every rule sits in :where() so a theme or the block's own colour, typography
 * and spacing controls always win. What we style is layout, spacing and the
 * states a theme rarely covers — errors, the honeypot, the step indicator.
 */

:where(.lynbro-form-wrap) {
  --lynbro-brand: var(--wp--preset--color--accent, var(--wp--preset--color--primary, var(--wp--preset--color--contrast, #1a7f5a)));
  --lynbro-line: var(--wp--preset--color--border, var(--wp--preset--color--line, color-mix(in srgb, currentColor 18%, transparent)));
  --lynbro-error: var(--wp--preset--color--danger, var(--wp--preset--color--vivid-red, #c8102e));
  --lynbro-success: var(--wp--preset--color--success, var(--lynbro-brand));
  --lynbro-radius: var(--wp--custom--radius--md, var(--wp--custom--border--radius, 6px));
  margin: 0 0 1.5em;
}

@supports not (color: color-mix(in srgb, red, blue)) {
  :where(.lynbro-form-wrap) {
    --lynbro-line: var(--wp--preset--color--border, var(--wp--preset--color--line, #e2ebe6));
  }
}

:where(.lynbro-form) {
  display: block;
}

/* The honeypot must be unreachable for people and plausible for robots:
   off-screen rather than display:none, which some bots skip. */
:where(.lynbro-forms-hp) {
  position: absolute !important;
  left: -9999px !important;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

:where(.lynbro-form-note) {
  font-size: 0.875em;
  opacity: 0.75;
  margin: 0 0 1em;
}

:where(.lynbro-field) {
  margin: 0 0 1.15em;
}

/* Anything the script hides stays hidden. An author display rule (the step's
   display:flex, a theme's field layout) beats the browser's own [hidden] rule,
   so inactive quiz steps were all shown at once (best-choice.dk, 19.11). This
   one is not wrapped in :where on purpose, and it is the only !important here. */
.lynbro-form[hidden],
.lynbro-form [hidden] {
  display: none !important;
}

:where(.lynbro-field[hidden]) {
  display: none;
}

:where(.lynbro-field-label) {
  display: block;
  font-weight: 600;
  margin: 0 0 0.35em;
}

:where(.lynbro-field .lynbro-req) {
  color: var(--lynbro-error);
}

:where(.lynbro-field input[type="text"]),
:where(.lynbro-field input[type="email"]),
:where(.lynbro-field input[type="tel"]),
:where(.lynbro-field input[type="url"]),
:where(.lynbro-field input[type="number"]),
:where(.lynbro-field input[type="date"]),
:where(.lynbro-field input[type="time"]),
:where(.lynbro-field input[type="file"]),
:where(.lynbro-field select),
:where(.lynbro-field textarea) {
  font: inherit;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

:where(.lynbro-field-desc),
:where(.lynbro-field-hint) {
  font-size: 0.85em;
  opacity: 0.75;
  margin: 0.35em 0 0;
}

:where(.lynbro-field-error) {
  color: var(--lynbro-error);
  font-size: 0.875em;
  margin: 0.35em 0 0;
}

:where(.lynbro-field.has-error input),
:where(.lynbro-field.has-error select),
:where(.lynbro-field.has-error textarea) {
  border-color: var(--lynbro-error);
}

:where(.lynbro-choices) {
  display: grid;
  gap: 0.4em;
}

:where(.lynbro-choice) {
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
  font-weight: 400;
}

:where(.lynbro-choice input) {
  margin-top: 0.25em;
  flex: 0 0 auto;
}

:where(.lynbro-field-heading) {
  margin: 1.5em 0 0.5em;
}

:where(.lynbro-field-divider) {
  border: 0;
  border-top: 1px solid var(--lynbro-line);
  margin: 1.5em 0;
}

:where(.lynbro-form-actions) {
  display: flex;
  gap: 0.6em;
  flex-wrap: wrap;
  margin-top: 1.2em;
}

:where(.lynbro-form-notice) {
  padding: 0.9em 1.1em;
  border-radius: var(--lynbro-radius);
  border: 1px solid var(--lynbro-line);
  margin: 0 0 1.2em;
}

:where(.lynbro-form-notice.is-success) {
  border-color: var(--lynbro-success);
  background: color-mix(in srgb, var(--lynbro-success) 8%, transparent);
}

:where(.lynbro-form-notice.is-error) {
  border-color: var(--lynbro-error);
  background: color-mix(in srgb, var(--lynbro-error) 8%, transparent);
}

/* Two- and three-column rows, when the theme gives us the width for them. */
@media (min-width: 600px) {
  :where(.lynbro-form) {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.2em;
  }

  :where(.lynbro-form > *),
  :where(.lynbro-form-step) {
    flex: 0 0 100%;
  }

  :where(.lynbro-form-step) {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.2em;
  }

  :where(.lynbro-form-step > .lynbro-field.is-full),
  :where(.lynbro-form-step > .lynbro-form-actions) {
    flex: 0 0 100%;
  }

  :where(.lynbro-form-step > .lynbro-field.is-half) {
    flex: 1 1 calc(50% - 0.6em);
  }

  :where(.lynbro-form-step > .lynbro-field.is-third) {
    flex: 1 1 calc(33.333% - 0.8em);
  }
}

/* Step indicator */
:where(.lynbro-form-progress) {
  margin: 0 0 1.4em;
}

:where(.lynbro-form-progress.is-steps) {
  display: flex;
  gap: 0.5em;
  list-style: none;
  padding: 0;
  counter-reset: none;
}

:where(.lynbro-form-progress.is-steps li) {
  flex: 1 1 auto;
  height: 4px;
  border-radius: 2px;
  background: var(--lynbro-line);
}

:where(.lynbro-form-progress.is-steps li.is-active) {
  background: var(--lynbro-brand);
}

:where(.lynbro-form-progress.is-steps li span) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

:where(.lynbro-form-progress .bar) {
  height: 6px;
  border-radius: 3px;
  background: var(--lynbro-line);
  overflow: hidden;
}

:where(.lynbro-form-progress .bar span) {
  display: block;
  height: 100%;
  background: var(--lynbro-brand);
  transition: width 0.25s ease;
}

:where(.lynbro-form-progress .label) {
  font-size: 0.85em;
  opacity: 0.75;
  margin: 0.4em 0 0;
}

@media (prefers-reduced-motion: reduce) {
  :where(.lynbro-form-progress .bar span) {
    transition: none;
  }
}
