/* Befora — Form element styles.
   Maps to the form-elements and form-patterns design artboards.
   Applied globally via form-element.html.twig and
   form-element-label.html.twig theme overrides. */

/* ── Field wrapper ───────────────────────────────────── */
.befora-form-field {
  margin-bottom: 20px;
}

/* Drupal fieldset wrappers (account, etc.) get the same rhythm */
.js-form-wrapper {
  margin-bottom: 20px;
}

.js-form-wrapper:last-child {
  margin-bottom: 0;
}

.befora-form-field:last-child {
  margin-bottom: 0;
}

/* ── Label ────────────────────────────────────────────── */
.befora-form-label {
  font-family: var(--bef-mono);
  font-size: var(--fs-12);
  font-weight: 500;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--bef-stone);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.befora-form-field--error .befora-form-label {
  color: var(--bef-ember-text);
}

.befora-form-label-optional {
  color: var(--bef-ash);
  font-size: var(--fs-11);
  letter-spacing: 0.16em;
}

/* Suppress Drupal's required asterisk */
.befora-form-label .form-required::after {
  content: none;
}

/* ── Input control shell ─────────────────────────────── */
.befora-form-control {
  display: flex;
  align-items: center;
  background: var(--bef-canvas-raised);
  border: 1px solid var(--bef-control-border);
  border-radius: var(--r-2);
  padding: 0 14px;
  min-height: 44px;
  gap: 8px;
  transition:
    border-color var(--dur-2) var(--ease-quiet),
    box-shadow var(--dur-2) var(--ease-quiet);
}

.befora-form-control:focus-within {
  border-color: var(--bef-ink);
  box-shadow: 0 0 0 3px var(--bef-ember-tint);
}

.befora-form-field--error .befora-form-control {
  border-color: var(--bef-ember); /* fill: border rule, not text — see designs/tokens/TOKENS.md */
  box-shadow: 0 0 0 3px var(--bef-ember-tint);
}

/* Disabled state */
.form-disabled .befora-form-control {
  border-style: dashed;
  border-color: var(--bef-hairline-strong);
  background: var(--bef-canvas-sunk);
}

/* ── Input element — text, email, password, number ──── */
.befora-form-control input[type="text"],
.befora-form-control input[type="email"],
.befora-form-control input[type="password"],
.befora-form-control input[type="number"],
.befora-form-control input[type="tel"],
.befora-form-control input[type="url"],
.befora-form-control input[type="search"],
.befora-form-control input[type="date"],
.befora-form-control input.form-text,
.befora-form-control input.form-email {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 12px 0;
  font-family: var(--bef-body);
  font-size: var(--fs-16);
  color: var(--bef-ink);
  min-width: 0;
  width: 100%;
  letter-spacing: 0.005em;
}

.befora-form-control input::placeholder {
  color: var(--bef-ash);
}

.form-disabled .befora-form-control input {
  color: var(--bef-ash);
}

/* ── Select ──────────────────────────────────────────── */
.befora-form-control select {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 12px 0;
  font-family: var(--bef-body);
  font-size: var(--fs-16);
  color: var(--bef-ink);
  min-width: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

/* ── Textarea ────────────────────────────────────────── */
.befora-form-control textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 12px 0;
  font-family: var(--bef-body);
  font-size: var(--fs-16);
  color: var(--bef-ink);
  line-height: 1.55;

  /* No native drag grip (#332). The browser draws the grip in the TEXTAREA's
     own bottom-right corner, which sits inside the shell's padding and radius,
     so it can never line up with the corner the maker sees. The form-design
     reference draws these textareas with `resize: none`
     (designs/components/form-elements.jsx). */
  resize: none;
  min-width: 0;
  width: 100%;
}

/* ── Checkbox + Radio — inline layout ────────────────── */
.befora-form-field--inline {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
}

.befora-form-field--inline .befora-form-label {
  font-family: var(--bef-body);
  font-size: var(--fs-15);
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  color: var(--bef-ink);
  margin-bottom: 0;
  cursor: pointer;
  line-height: 1.4;
}

/* Checkbox custom appearance */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 3px;
  border: 1.5px solid var(--bef-control-border);
  background: var(--bef-canvas-raised);
  cursor: pointer;
  position: relative;
  margin: 1px 0 0;
  transition:
    background var(--dur-2) var(--ease-quiet),
    border-color var(--dur-2) var(--ease-quiet);
}

input[type="checkbox"]:checked {
  background: var(--bef-ember);
  border-color: var(--bef-ember); /* fill: border rule, not text — see designs/tokens/TOKENS.md */
}

input[type="checkbox"]:checked::after {
  content: '';
  display: block;
  position: absolute;
  top: 2px;
  left: 5px;
  width: 5px;
  height: 9px;
  border: 1.5px solid var(--bef-canvas-raised);
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--bef-ember);
  outline-offset: 2px;
}

input[type="checkbox"]:disabled {
  background: var(--bef-canvas-sunk);
  border-style: dashed;
  border-color: var(--bef-hairline-strong);
  cursor: default;
}

/* Touch target (issue #401): the design (form-elements.jsx §10) authors this
   as a square 16-18px box with a 1.5px border — do not inflate it to 44px,
   that would break the design. Below 768px, extend the tap area with a
   transparent ::before sized to --touch-min and centred on the input via
   negative inset, instead of the padding + background-clip:content-box
   technique: this box is `box-sizing: border-box` (global reset), so
   width/height IS the visible outer edge the border draws at — adding
   padding would force the border itself to expand to the padding edge (or,
   with background-clip:content-box, leave the fill and border mismatched)
   and would also require re-deriving the `::after` tick's `top`/`left`
   offsets, which are hand-tuned to the 18px box. A `::before` overlay
   leaves the drawn box, its border, and the checked-state tick completely
   untouched while still giving taps a 44x44 target (the input already has
   `position: relative` above, which the pseudo-element needs as its
   containing block). */
@media (width <= 768px) {
  /* Scoped to .befora-auth-checkbox — the /login and /signup checkboxes #401
     names — NOT every checkbox. A blanket 44x44 overlay overlaps vertically
     adjacent options wherever checkboxes stack closer than 44px apart (the
     settings completion list sits at a ~27px row pitch), and the later
     sibling's pseudo-element wins hit-testing, so a tap near one row's bottom
     edge would toggle the next row. Radios are excluded for the same reason:
     they are, by definition, a stacked list. */
  .befora-auth-checkbox input[type="checkbox"]::before {
    content: '';
    position: absolute;

    /* Sized explicitly and centred with a transform rather than a negative
       `inset`: an absolutely positioned pseudo-element resolves `inset`
       against its containing block's PADDING box, which is 15px inside this
       18px border-box input, so a -13px inset yields a 41x41 overlay, not the
       44x44 the minimum needs. Stating the size outright is also immune to
       the box ever changing size. */
    width: var(--touch-min);
    height: var(--touch-min);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
}

/* Radio custom appearance */
input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 999px;
  border: 1.5px solid var(--bef-control-border);
  background: var(--bef-canvas-raised);
  cursor: pointer;
  position: relative;
  margin: 1px 0 0;
  transition:
    border-color var(--dur-2) var(--ease-quiet);
}

input[type="radio"]:checked {
  border-color: var(--bef-ember); /* fill: border rule, not text — see designs/tokens/TOKENS.md */
}

input[type="radio"]:checked::after {
  content: '';
  display: block;
  position: absolute;
  top: 3px;
  left: 3px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--bef-ember);
}

input[type="radio"]:focus-visible {
  outline: 2px solid var(--bef-ember);
  outline-offset: 2px;
}

/* ── Hint / helper text ──────────────────────────────── */
.befora-form-hint {
  font-family: var(--bef-body);
  font-size: var(--fs-13);
  color: var(--bef-stone);
  margin-top: 6px;
  line-height: 1.45;
}

/* ── Error text ──────────────────────────────────────── */
.befora-form-error {
  font-family: var(--bef-body);
  font-size: var(--fs-13);
  color: var(--bef-ember-text);
  margin-top: 6px;
  line-height: 1.45;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Submit actions ──────────────────────────────────── */
.form-actions {
  margin-top: var(--s-4);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-actions input[type="submit"],
.form-actions button[type="submit"] {
  font-family: var(--bef-body);
  font-size: var(--fs-16);
  font-weight: 500;
  letter-spacing: 0.005em;
  padding: 14px 24px;
  border-radius: var(--r-2);
  border: 1px solid var(--bef-ember);
  background: var(--bef-ember);
  color: var(--bef-canvas-raised);
  cursor: pointer;
  transition:
    background var(--dur-2) var(--ease-quiet),
    border-color var(--dur-2) var(--ease-quiet);
}

.form-actions input[type="submit"]:hover,
.form-actions button[type="submit"]:hover {
  background: var(--bef-ember-deep);
  border-color: var(--bef-ember-deep);
}

/* Drupal wraps form-item inside form-control — strip default margin */
.befora-form-control .form-item,
.befora-form-control .js-form-item {
  flex: 1;
  margin: 0;
  min-width: 0;
}

/* ── Status messages ─────────────────────────────────── */
.befora-message {
  border-radius: var(--r-2);
  padding: 12px 14px;
  margin-bottom: var(--s-4);
}

.befora-message--error {
  background: var(--bef-ember-tint);
  border-left: 2px solid var(--bef-ember);
}

.befora-message--warning {
  background: var(--bef-honey-tint);
  border-left: 2px solid var(--bef-honey);
}

.befora-message--status {
  background: var(--bef-posted-tint);
  border-left: 2px solid var(--bef-posted);
}

.befora-message-inner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.befora-message--error .befora-message-icon {
  color: var(--bef-ember-text);
}

.befora-message--warning .befora-message-icon {
  color: var(--bef-honey);
}

.befora-message--status .befora-message-icon {
  color: var(--bef-posted);
}

.befora-message-icon {
  flex-shrink: 0;
  margin-top: 1px;
}

.befora-message-body {
  font-family: var(--bef-body);
  font-size: var(--fs-14);
  color: var(--bef-ink);
  line-height: 1.5;
}

.befora-message-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── Password reveal toggle (external button) ────────── */
.befora-password-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.befora-password-row > :first-child {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.befora-password-toggle {
  flex: 0 0 auto;
  min-width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bef-canvas-raised);
  border: 1px solid var(--bef-control-border);
  border-radius: var(--r-2);
  color: var(--bef-stone);
  cursor: pointer;
  padding: 0 12px;
  transition:
    border-color var(--dur-2) var(--ease-quiet),
    color var(--dur-2) var(--ease-quiet);
}

.befora-password-toggle:hover {
  border-color: var(--bef-ink);
  color: var(--bef-ink);
}

.befora-password-toggle:focus-visible {
  outline: 2px solid var(--bef-ember);
  outline-offset: 2px;
}

/* ── Radio cards ─────────────────────────────────────── */

/* Grid layout (horizontal, e.g. stage picker) */
.befora-radio-cards--grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* Stack layout (vertical, e.g. visibility picker) */
.befora-radio-cards--stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Remove default radios wrapper margin */
.befora-radio-cards--grid .befora-form-field,
.befora-radio-cards--stack .befora-form-field {
  margin-bottom: 0;
}

/* Each radio option becomes a card */
.befora-radio-cards--grid .befora-form-field--inline,
.befora-radio-cards--stack .befora-form-field--inline {
  margin-bottom: 0;
}

.befora-radio-card {
  padding: 14px 16px;
  background: var(--bef-canvas-raised);
  border: 1px solid var(--bef-control-border);
  border-radius: var(--r-2);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition:
    border-color var(--dur-2) var(--ease-quiet),
    background var(--dur-2) var(--ease-quiet),
    box-shadow var(--dur-2) var(--ease-quiet);
}

.befora-radio-card:hover {
  border-color: var(--bef-ink);
}

.befora-radio-card.is-selected {
  border-color: var(--bef-ember); /* fill: border rule, not text — see designs/tokens/TOKENS.md */
  box-shadow: 0 0 0 3px var(--bef-ember-tint);
}

/* Hide native radio input */
.befora-radio-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Card header: custom radio dot + label */
.befora-radio-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Custom radio dot */
.befora-radio-dot {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid var(--bef-control-border);
  background: var(--bef-canvas-raised);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color var(--dur-2) var(--ease-quiet);
}

.is-selected .befora-radio-dot {
  border-color: var(--bef-ember); /* fill: border rule, not text — see designs/tokens/TOKENS.md */
}

.befora-radio-dot-inner {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--bef-ember);
  display: none;
}

.is-selected .befora-radio-dot-inner {
  display: block;
}

/* Card label */
.befora-radio-card-label {
  font-family: var(--bef-body);
  font-size: var(--fs-15);
  color: var(--bef-ink);
  font-weight: 400;
}

.is-selected .befora-radio-card-label {
  color: var(--bef-ember-text);
  font-weight: 500;
}

/* Card description */
.befora-radio-card-desc {
  font-family: var(--bef-body);
  font-size: var(--fs-13);
  color: var(--bef-stone);
  line-height: 1.4;
  padding-left: 24px;
}

/* Stack variant with icon */
.befora-radio-card--with-icon {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 14px;
  align-items: center;
  flex-direction: row;
}

.befora-radio-card--with-icon .befora-radio-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--bef-canvas-sunk);
  color: var(--bef-graphite);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    background var(--dur-2) var(--ease-quiet),
    color var(--dur-2) var(--ease-quiet);
}

.befora-radio-card--with-icon.is-selected .befora-radio-card-icon {
  background: var(--bef-ember-tint);
  color: var(--bef-ember-text);
}

.befora-radio-card--with-icon .befora-radio-card-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.befora-radio-card--with-icon .befora-radio-card-desc {
  padding-left: 0;
}

/* Focus visible on the card via keyboard */
.befora-radio-card:focus-within {
  outline: 2px solid var(--bef-ember);
  outline-offset: 2px;
}

/* Locked visibility card (#317): a paid-plan upgrade prompt, not a radio.
   Kept OFF the .befora-radio-card class so project-create.js never wires it
   as selectable — a locked mode can never reach the hidden input. */
.befora-radio-card--locked {
  background: var(--bef-canvas-sunk);
  border: 1px solid var(--bef-hairline);
  border-radius: var(--r-2);
  overflow: hidden;
}

.befora-radio-card-locked-head {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
}

.befora-radio-card-lockdot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--bef-stone);
}

.befora-radio-card--locked .befora-radio-card-icon {
  background: var(--bef-canvas-raised);
  color: var(--bef-stone);
  border: 1px solid var(--bef-hairline);
}

.befora-radio-card-labelrow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.befora-radio-card--locked .befora-radio-card-label {
  color: var(--bef-graphite);
  font-weight: 500;
}

/* The locked card lays its label and sub-copy out in the same grid cell, the
   way `--with-icon` does, but carries neither class — so it kept the 24px
   radio-dot indent and its sub-copy sat right of its label (#510). The
   artboard draws all three cards flush. */
.befora-radio-card--locked .befora-radio-card-desc {
  padding-left: 0;
}

.befora-radio-card-plancue {
  font-size: var(--fs-11);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bef-honey-deep);
  background: var(--bef-honey-tint);
  padding: 2px 7px;
  border-radius: var(--r-1);
  white-space: nowrap;
}

.befora-radio-card-upsell {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--bef-hairline);
}

.befora-radio-card-upsell-line {
  flex: 1;
  font-size: var(--fs-13);
  color: var(--bef-graphite);
  line-height: 1.45;
}

.befora-radio-card-seeplans {
  flex-shrink: 0;
  gap: 4px;
  color: var(--bef-ember-text);
}

/* Form hint below radio groups */
.befora-radio-cards-hint {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 10px;
  font-family: var(--bef-body);
  font-size: var(--fs-13);
  color: var(--bef-stone);
  line-height: 1.4;
}

.befora-radio-cards-hint svg {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--bef-stone);
}

@media (width <= 720px) {
  .befora-radio-cards--grid {
    grid-template-columns: 1fr;
  }
}
