/**
 * Frontend form: structure + spacing only. Visual styling comes from the active theme.
 * Low specificity (:where) so theme rules for inputs, buttons, headings, and colors win.
 */

:where(.cwp-form) {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  max-width: min(
    100%,
    var(--wp--style--global--wide-size, var(--wp--style--global--content-size, 100%))
  );
  margin-block: 0 1.5em;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  box-sizing: border-box;
}

:where(.cwp-form),
:where(.cwp-form) *,
:where(.cwp-form) *::before,
:where(.cwp-form) *::after {
  box-sizing: border-box;
}

:where(.cwp-form__header) {
  margin-block: 0 1em;
  padding-block-end: 0.75em;
  border-block-end: 1px solid
    color-mix(in srgb, currentColor 14%, transparent);
}

:where(.cwp-form__title) {
  margin: 0;
  padding: 0;
}

:where(.cwp-layout) {
  display: flex;
  flex-direction: column;
  gap: 1em;
}

:where(.cwp-field) {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35em;
  margin: 0;
}

:where(.cwp-field--submit) {
  margin-block-start: 0.25em;
  padding-block-start: 0.75em;
  border-block-start: 1px solid
    color-mix(in srgb, currentColor 12%, transparent);
}

:where(.cwp-label) {
  display: block;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  color: inherit;
}

:where(.cwp-form .cwp-input:not([type="radio"]):not([type="checkbox"])) {
  width: 100%;
  max-width: 100%;
  margin: 0;
  font: inherit;
  line-height: inherit;
  color: inherit;
}

:where(.cwp-form textarea.cwp-input) {
  display: block;
  min-block-size: 5em;
  max-block-size: 24rem;
  resize: vertical;
}

:where(.cwp-form select.cwp-input) {
  cursor: pointer;
}

:where(.cwp-choice-group) {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  margin-block-start: 0.15em;
}

:where(.cwp-choice) {
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
  margin: 0;
}

:where(.cwp-choice .cwp-input[type="radio"]),
:where(.cwp-choice .cwp-input[type="checkbox"]) {
  width: 1.125em;
  height: 1.125em;
  min-height: 0;
  margin-block-start: 0.2em;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: currentColor;
}

:where(.cwp-choice__label) {
  font: inherit;
  font-weight: inherit;
  line-height: inherit;
  color: inherit;
  cursor: pointer;
  flex: 1;
}

:where(.cwp-acceptance) {
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
  margin-block-start: 0.15em;
}

:where(.cwp-acceptance .cwp-input[type="checkbox"]) {
  width: 1.125em;
  height: 1.125em;
  min-height: 0;
  margin-block-start: 0.15em;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: currentColor;
}

:where(.cwp-acceptance__label) {
  font: inherit;
  font-weight: inherit;
  line-height: inherit;
  color: inherit;
  cursor: pointer;
}

:where(.cwp-quiz) {
  display: flex;
  flex-direction: column;
  gap: 0.45em;
}

:where(.cwp-quiz__question) {
  margin: 0;
  font: inherit;
  font-weight: inherit;
  color: inherit;
}

:where(.cwp-file-wrap) {
  display: block;
}

:where(.cwp-actions) {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  margin-block-start: 0.35em;
}

:where(.cwp-submit-btn) {
  cursor: pointer;
  font: inherit;
}

.cwp-hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden;
}

:where(.cwp-message) {
  margin-block: 0 1em;
  padding: 0.65em 0.85em;
  font: inherit;
  font-size: 0.95em;
  line-height: inherit;
  color: inherit;
  border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
  background: color-mix(in srgb, currentColor 5%, transparent);
}

:where(.cwp-message.cwp-error) {
  border-color: color-mix(in srgb, #d63638 45%, currentColor);
  background: color-mix(in srgb, #d63638 8%, transparent);
}

:where(.cwp-message.cwp-success) {
  border-color: color-mix(in srgb, #008a20 45%, currentColor);
  background: color-mix(in srgb, #008a20 8%, transparent);
}

:where(.cwp-layout > p) {
  margin: 0 0 1em;
}

:where(.cwp-layout > p:last-child) {
  margin-bottom: 0;
}

:where(.cwp-layout > p > label) {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35em;
  font: inherit;
  font-weight: inherit;
  margin: 0;
}

:where(.cwp-layout > p > label .cwp-choice-group) {
  font-weight: inherit;
}
