/* ============================================================================
   HubSpot Form Styles — Zion Design System Adaptation
   ----------------------------------------------------------------------------
   Targets HubSpot's default markup (`.hs-input`, `.hs-button`, `.field`,
   `.hs-richtext`, `.hs-form-required`, etc.) and restyles it to match the
   Zion design system. Assumes Basecoat 0.3.2 and css/zion/custom.css are
   already loaded — values below are sourced from those tokens.

   All selectors are scoped to descendants of `.hs-form` so the sheet cannot
   leak onto generic `label`, `.field`, `ul.no-list`, etc. elsewhere.
   ============================================================================ */

/* ============================================================================
   Buttons (.hs-button)
   Mirrors Basecoat `.btn` (primary variant) + custom.css transition behaviour.
   ============================================================================ */
.hs-form .hs-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  gap: 0.5rem;
  height: 2.25rem; /* 36px */
  padding: 0.5rem 1rem;
  margin: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem; /* text-sm */
  line-height: 1.25rem;
  font-weight: 500;
  white-space: nowrap;
  color: var(--primary-foreground);
  background-color: var(--primary);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease, filter 150ms ease, border-color 150ms ease;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.hs-form .hs-button:hover,
.hs-form .hs-button:focus {
  filter: brightness(0.9);
}

.hs-form .hs-button:active {
  filter: brightness(0.85);
}

.hs-form .hs-button:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px var(--ring);
}

.hs-form .hs-button:disabled {
  pointer-events: none;
  opacity: 0.5;
}

/* HubSpot's `.large` size modifier */
.hs-form .hs-button.large {
  height: 2.5rem; /* 40px */
  padding: 0.625rem 1.5rem;
  font-size: 0.9375rem;
  border-radius: var(--radius-lg);
}

/* ============================================================================
   Labels & required marker
   ============================================================================ */
.hs-form label {
  display: block;
  width: auto;
  padding-top: 0;
  margin-bottom: 0.25rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25rem;
  color: var(--foreground);
}

.hs-form .hs-form-required {
  margin-left: 0.125rem;
  color: var(--destructive);
}

.hs-form .hs-error-msgs label,
.hs-form .hs-error-msg {
  font-weight: 400;
  color: var(--destructive);
}

.hs-form .hs-error-msg {
  font-size: 0.75rem;
}

/* Reset HubSpot's `<div class="input">` field wrapper — custom.css's `.input`
   selector otherwise applies the full input styling (border, padding, bg) to
   the wrapper, producing a double-bordered appearance around every field. */
.hs-form .hs-form-field > .input {
  display: block;
  width: auto;
  padding: 0;
  background-color: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transition: none;
}

/* ============================================================================
   Inputs (.hs-input)
   Mirrors Basecoat `.input` + custom.css overrides.
   `height` is omitted intentionally — custom.css applies `height: auto !important`
   to text/email/select/textarea, so an explicit height here would be dead.
   The natural box (padding + line-height + border) renders ~36px.
   ============================================================================ */
.hs-form .hs-input {
  display: block;
  width: 100%;
  max-width: 100%;
  padding: 0.5rem 0.75rem;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: normal;
  color: var(--foreground);
  background-color: var(--background);
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease, color 150ms ease;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.hs-form .hs-input:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px var(--ring);
}

.hs-form .hs-input::placeholder,
.hs-form .hs-input::-webkit-input-placeholder {
  color: var(--muted-foreground);
  opacity: 1;
}

.hs-form .hs-input:-moz-placeholder {
  color: var(--muted-foreground);
  opacity: 1;
}

.hs-form .hs-input option:disabled {
  color: var(--muted-foreground);
}

.hs-form select.hs-input,
.hs-form select.is-placeholder {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2.25rem;
  background-image: var(--chevron-down-icon-50);
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
  background-size: 1rem;
}

.hs-form select.is-placeholder {
  color: var(--muted-foreground);
}

.hs-form select.is-placeholder:focus {
  color: var(--foreground);
}

.hs-form select[multiple].hs-input {
  height: auto;
  background-image: none;
  padding-right: 0.75rem;
}

.hs-form textarea.hs-input {
  height: auto;
  min-height: 4rem;
  resize: vertical;
}

/* Checkboxes — mirrors Basecoat's `.input[type=checkbox]:not([role=switch])`.
   HubSpot inputs use `.hs-input`, so Basecoat's selector doesn't match and we
   re-implement the same primary-coloured, masked-check look here.
   `flex-shrink: 0` is required because the boolean-checkbox label is an
   inline-flex container; without it, long label text squashes the checkbox. */
.hs-form .hs-input[type="checkbox"]:not([role="switch"]) {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  padding: 0;
  margin: 0.125rem 0.5rem 0.125rem 0;
  vertical-align: middle;
  cursor: pointer;
  background-color: var(--background);
  border: 1px solid var(--input);
  border-radius: 4px;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.hs-form .hs-input[type="checkbox"]:not([role="switch"]):checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.hs-form .hs-input[type="checkbox"]:not([role="switch"]):checked::after {
  content: "";
  display: block;
  width: 0.875rem;
  height: 0.875rem;
  background-color: var(--primary-foreground);
  -webkit-mask-image: var(--check-icon);
  mask-image: var(--check-icon);
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: 0.875rem;
  mask-size: 0.875rem;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

.hs-form .hs-input[type="checkbox"]:not([role="switch"]):focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px var(--ring);
}

/* Radios — same approach: replicate Basecoat's radio styling on `.hs-input`. */
.hs-form .hs-input[type="radio"] {
  flex-shrink: 0;
  aspect-ratio: 1;
  width: 1rem;
  height: 1rem;
  padding: 0;
  margin: 0.125rem 0.5rem 0.125rem 0;
  vertical-align: middle;
  cursor: pointer;
  position: relative;
  background-color: var(--background);
  border: 1px solid var(--input);
  border-radius: 9999px;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.hs-form .hs-input[type="radio"]:checked::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.5rem;
  height: 0.5rem;
  background-color: var(--primary);
  border-radius: 9999px;
  transform: translate(-50%, -50%);
}

.hs-form .hs-input[type="radio"]:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px var(--ring);
}

/* File inputs — strip the input chrome */
.hs-form .hs-input[type="file"] {
  height: auto;
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
  line-height: 1.5;
}

/* Invalid state */
.hs-form input.hs-input.error,
.hs-form textarea.hs-input.error,
.hs-form select.hs-input.error,
.hs-form div.field.error input,
.hs-form div.field.error textarea,
.hs-form div.field.error .chzn-choices {
  border-color: var(--destructive);
}

.hs-form input.hs-input.error:focus,
.hs-form textarea.hs-input.error:focus,
.hs-form select.hs-input.error:focus,
.hs-form div.field.error input:focus,
.hs-form div.field.error textarea:focus,
.hs-form div.field.error .chzn-choices:focus {
  border-color: var(--destructive);
  box-shadow: 0 0 0 2px color-mix(in oklch, var(--destructive) 30%, transparent);
}

/* Width override for dependent fields (replaces 90% fixed width) */
.hs-form .hs-custom-style .hs-dependent-field > div input.hs-input:not([type="checkbox"]):not([type="radio"]) {
  width: 100%;
}

/* ============================================================================
   Field structure
   ============================================================================ */
.hs-form .field {
  margin-bottom: 1rem;
}

.hs-form .hs-field-desc {
  margin: 0 0 0.375rem;
  font-family: inherit;
  font-size: 0.75rem; /* text-xs */
  line-height: 1rem;
  color: var(--muted-foreground);
}

.hs-form .actions {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  padding: 0;
}

/* ============================================================================
   Inputs list (checkbox / radio groups, boolean checkbox)
   ============================================================================ */
.hs-form .inputs-list {
  margin: 0 0 0.5rem;
  padding-left: 0;
  width: 100%;
  list-style: none;
}

.hs-form .inputs-list > li {
  display: block;
  padding: 0;
  width: 100%;
}

.hs-form .inputs-list > li + li {
  padding-top: 0.25rem;
}

.hs-form .inputs-list:first-child {
  padding-top: 0.375rem;
}

.hs-form .inputs-list label {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.5rem;
  width: auto;
  margin-bottom: 0;
  padding: 0;
  font-weight: 400;
  line-height: 1.25rem;
  white-space: normal;
}

.hs-form ul.no-list {
  list-style: none;
}

/* Boolean checkbox label (legal consent, marketing consent, T&Cs) */
.hs-form .hs-form-booleancheckbox-display {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-weight: 400;
  cursor: pointer;
}

/* ============================================================================
   Rich text & legal consent
   ============================================================================ */
.hs-form .hs-richtext {
  margin-bottom: 0.5rem;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.5rem;
  color: var(--muted-foreground);
}

.hs-form .hs-richtext hr {
  margin: 0.75rem 0;
  width: 100%;
}

.hs-form .hs-richtext a,
.hs-form .legal-consent-container a {
  color: var(--primary-blue);
}

.hs-form .hs-richtext a:hover,
.hs-form .legal-consent-container a:hover {
  text-decoration-line: underline;
}

/* ============================================================================
   RTL form support
   ============================================================================ */
.hs-form form.hs-form-rtl .field {
  flex: 0 1 100%;
}

.hs-form form.hs-form-rtl .hs-input[type="checkbox"],
.hs-form form.hs-form-rtl .hs-input[type="radio"] {
  margin: 0.1875rem 0.5rem 0.1875rem 0.5rem;
}

.hs-form form.hs-form-rtl fieldset {
  display: flex;
}

.hs-form form.hs-form-rtl fieldset[class^="form-columns-"] .input {
  margin-right: 0;
}

.hs-form form.hs-form-rtl ul {
  padding: 0;
}

.hs-form form.hs-form-rtl .legal-consent-container .hs-form-booleancheckbox-display input {
  width: auto;
  float: right;
}

.hs-form form.hs-form-rtl .legal-consent-container .hs-form-booleancheckbox-display > span {
  margin-left: 0;
}

.hs-form form.hs-form-rtl .hs-dependent-field {
  display: flex;
  flex: 0 1 100%;
  flex-wrap: wrap;
}

/* ============================================================================
   Email correction / validation
   ============================================================================ */
.hs-form .email-correction,
.hs-form .email-validation {
  padding-top: 0.25rem;
  font-family: inherit;
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--muted-foreground);
}

.hs-form .email-correction a,
.hs-form .email-validation a {
  cursor: pointer;
  color: var(--primary-blue);
}

@media (max-width: 400px), (min-device-width: 320px) and (max-device-width: 480px) {
  .hs-form .email-correction form .form-columns-2 .hs-form-field,
  .hs-form .email-correction form .form-columns-3 .hs-form-field,
  .hs-form .email-validation form .form-columns-2 .hs-form-field,
  .hs-form .email-validation form .form-columns-3 .hs-form-field {
    float: none;
    width: 100%;
  }

  .hs-form .email-correction form .form-columns-2 .hs-form-field .hs-input,
  .hs-form .email-correction form .form-columns-3 .hs-form-field .hs-input,
  .hs-form .email-validation form .form-columns-2 .hs-form-field .hs-input,
  .hs-form .email-validation form .form-columns-3 .hs-form-field .hs-input {
    width: 100%;
  }

  .hs-form .email-correction form .form-columns-2 .hs-form-field input[type="checkbox"],
  .hs-form .email-correction form .form-columns-2 .hs-form-field input[type="radio"],
  .hs-form .email-correction form .form-columns-3 .hs-form-field input[type="checkbox"],
  .hs-form .email-correction form .form-columns-3 .hs-form-field input[type="radio"],
  .hs-form .email-validation form .form-columns-2 .hs-form-field input[type="checkbox"],
  .hs-form .email-validation form .form-columns-2 .hs-form-field input[type="radio"],
  .hs-form .email-validation form .form-columns-3 .hs-form-field input[type="checkbox"],
  .hs-form .email-validation form .form-columns-3 .hs-form-field input[type="radio"] {
    width: 1.5rem;
  }
}

/* ============================================================================
   Appearance reset (preserved from HubSpot baseline)
   ============================================================================ */
.hs-form .hs-button,
.hs-form .hs-form-field input[type="text"],
.hs-form .hs-form-field input[type="email"],
.hs-form .hs-form-field input[type="phone"],
.hs-form .hs-form-field input[type="number"],
.hs-form .hs-form-field input[type="tel"],
.hs-form .hs-form-field input[type="date"],
.hs-form .hs-form-field textarea {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.hs-form .hs-default-font-element,
.hs-form .hs-main-font-element {
  font-family: inherit;
  line-height: normal;
}

/* ============================================================================
   Video form variant (used on dark overlay backgrounds)
   ============================================================================ */
.hs-form .hs-video-form label,
.hs-form .hs-video-form .hs-richtext {
  color: var(--primary-foreground) !important;
}

.hs-form .hs-video-form .hs-back-button {
  width: 20%;
  height: 2.25rem;
  margin-right: 0.625rem;
  color: var(--foreground);
  background-color: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.hs-form .hs-video-form .hs-button {
  width: 70%;
}

.hs-form .hs-video-form .hs-button span {
  font-size: 0.9375rem;
}

.hs-form .hs-video-form .legal-consent-container {
  max-height: 180px !important;
  overflow-y: auto !important;
}

.hs-form .hs-video-form .legal-consent-container::after {
  content: "";
  display: block;
  height: 100px;
  width: 100%;
}

.hs-form .hs-video-form .legal-consent-wrapper {
  position: relative;
}

.hs-form .hs-video-form .legal-consent-overlay {
  position: absolute;
  pointer-events: none;
  left: 0;
  bottom: 0;
  height: 100px;
  width: 100%;
  background: linear-gradient(to bottom, transparent 0%, var(--popover) 100%);
}
