/*
  Craft Blocks — lightweight forms UI
  -----------------------------------
  - `.cb-form` base styles (fields, inputs, buttons, honeypot)
  - `.cb-form-popup` accessible modal dialog (backdrop + centered card)
  - `.cb-form-inline` accordion expander (animated height)
  - `.cb-form__success` success state shown in place of the form on submit

  The form intentionally keeps its look minimal and inherits typography from
  the site. Button uses the existing `cb-btn` class so host-site button
  presets still apply.
*/

.cb-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font-family: inherit;
  color: inherit;
}

.cb-form__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.cb-form__errors {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: rgba(220, 38, 38, 0.08);
  color: #b91c1c;
  font-size: 0.9375rem;
}

.cb-form__errors:not([hidden]) {
  display: block;
}

.cb-form__fields {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.cb-form__field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.cb-form__label,
.cb-form__legend {
  font-weight: 500;
  font-size: 0.9375rem;
  line-height: 1.3;
}

.cb-form__req {
  color: #dc2626;
  margin-left: 0.15rem;
}

.cb-form__input {
  appearance: none;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 0.5rem;
  background: #ffffff;
  color: inherit;
  font: inherit;
  padding: 0.625rem 0.75rem;
  line-height: 1.4;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  width: 100%;
  box-sizing: border-box;
}

.cb-form__textarea {
  resize: vertical;
  min-height: 5rem;
}

.cb-form__select {
  padding-right: 2rem;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 0.75rem 0.75rem;
}

.cb-form__input:focus {
  outline: none;
  border-color: currentColor;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

.cb-form__group {
  border: 0;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.cb-form__group--check,
.cb-form__group--radio {
  gap: 0.5rem;
}

.cb-form__radio,
.cb-form__check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
  cursor: pointer;
}

.cb-form__help {
  font-size: 0.8125rem;
  color: rgba(0, 0, 0, 0.6);
}

.cb-form__field--error .cb-form__input {
  border-color: #dc2626;
}

.cb-form__field--error .cb-form__help {
  color: #b91c1c;
}

.cb-form__actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.cb-form__submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 0.5rem;
  background: #111827;
  color: #ffffff;
  cursor: pointer;
  transition: opacity 150ms ease;
}

.cb-form__submit:disabled {
  opacity: 0.6;
  cursor: wait;
}

.cb-form__hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.cb-form__success {
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  background: rgba(16, 185, 129, 0.1);
  color: #047857;
  font-size: 1rem;
}

/* ---- Popup ---- */

.cb-form-popup {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.cb-form-popup[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
}

.cb-form-popup__dialog {
  background: #ffffff;
  color: #111827;
  border-radius: 0.875rem;
  padding: 1.5rem;
  width: 100%;
  max-width: 32rem;
  max-height: calc(100vh - 2rem);
  overflow: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  transform: translateY(10px);
  transition: transform 200ms ease;
  position: relative;
}

.cb-form-popup[aria-hidden="false"] .cb-form-popup__dialog {
  transform: translateY(0);
}

.cb-form-popup__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 0;
  background: rgba(0, 0, 0, 0.05);
  color: inherit;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cb-form-popup__close:hover {
  background: rgba(0, 0, 0, 0.1);
}

/* ---- Inline accordion ---- */

.cb-form-inline {
  overflow: hidden;
  max-height: 0;
  transition: max-height 350ms ease;
  margin-top: 0.5rem;
}

.cb-form-inline[aria-hidden="false"] {
  max-height: 1200px;
}

.cb-form-inline__body {
  padding: 1rem 0;
}
