/* ============================================================================
   RESB forms.

   Loaded after abridge.css (see `stylesheets` in config.toml), so these win.
   Kept separate from resb.css (colour), resb-layout.css (measure) and
   resb-fonts.css (typography).

   Forms post natively to our own /api/contact Worker. Abridge styles form
   controls but gives them `border: 0` and a Paper background, which is nearly
   invisible against the Document page colour; these rules give the fields a
   visible edge.
   ============================================================================ */

.resb-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  margin: 1.5rem 0;
  width: 60%;
}

/* 60% of a phone screen leaves the fields unusably narrow. */
@media (max-width: 40rem) {
  .resb-form {
    width: 100%;
  }
}

/* Markdown-adjacent: each field is a <p>, so the theme's paragraph margins
   would fight the flex gap. */
.resb-form .resb-field,
.resb-form p {
  margin: 0;
}

.resb-form label {
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.resb-optional {
  font-weight: 400;
  color: var(--color-slate);
  font-size: 0.875em;
}

.resb-form input[type="text"],
.resb-form input[type="email"],
.resb-form input[type="tel"],
.resb-form input[type="url"],
.resb-form textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  background: var(--color-paper);
  border: 1px solid var(--color-slate);
  border-radius: 0.25rem;
  color: var(--color-record-ink);
}

.resb-form input:focus-visible,
.resb-form textarea:focus-visible {
  outline: 2px solid var(--color-board-blue);
  outline-offset: 1px;
  border-color: var(--color-board-blue);
}

/* Triad Rose, the palette's action colour — the same object as a.resb-button in
   resb.css. Submitting is the call to action on a form page, so it takes Rose.
   The ALTCHA checkbox below stays Board Blue: it is a control state, not an
   action, and Rose is for calls to action only. */
.resb-form button[type="submit"] {
  align-self: flex-start;
  padding: 0.55rem 1.4rem;
  background: var(--color-triad-rose);
  color: var(--color-paper);
  border: 2px solid var(--color-triad-rose);
  border-radius: 0.25rem;
  font-weight: 600;
  cursor: pointer;
}

.resb-form button[type="submit"]:hover,
.resb-form button[type="submit"]:focus-visible {
  background: var(--color-triad-rose-deep);
  border-color: var(--color-triad-rose-deep);
  opacity: 1;                       /* abridge fades buttons to .75 on hover */
}

/* Pressed. Must follow :hover — same specificity, so source order decides. */
.resb-form button[type="submit"]:active {
  background: var(--color-triad-rose-press);
  border-color: var(--color-triad-rose-press);
  opacity: 1;
}

/* ALTCHA widget. Self-hosted from /js/altcha.min.js — no third-party request,
   no cookies, no tracking, so the CSP can stay 'self'.

   The widget injects its stylesheet into document.head rather than a shadow
   root, so its internals are reachable with ordinary CSS. Its own structure is:

     .altcha            flex column, bordered box, max-width 260px
       .altcha-main     flex row — .altcha-checkbox + .altcha-label
       .altcha-footer   "Protected by ALTCHA"

   Left alone that stacks into three rows and uses the raw browser checkbox,
   which sits oddly beside the rest of the form. */

/* Selectors are scoped to .resb-form and target ALTCHA's own class names
   directly, rather than hanging off the .resb-captcha class we set on the
   host element — that anchor proved unreliable once the widget renders. Two
   class levels (0,2,0) also outrank the widget's own single-class rules,
   which matters because it injects its stylesheet at runtime, after ours. */

.resb-form altcha-widget {
  display: block;
  --altcha-color-border: var(--color-slate);
  --altcha-color-base: var(--color-paper);
  --altcha-color-text: var(--color-record-ink);
  --altcha-border-radius: 0.25rem;
}

/* One line: the widget defaults to a column, stacking checkbox, label and
   footer into three rows. */
.resb-form .altcha {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  max-width: none;
  width: fit-content;
  padding-right: 0.7rem;
  /* Set explicitly rather than through --altcha-* custom properties, so the
     box does not depend on the widget's own theming plumbing. */
  border: 1px solid var(--color-slate);
  border-radius: 0.25rem;
  background: var(--color-paper);
}

/* The checkbox and logo must not shrink. In a nowrap row they are the only
   items without a min-content floor, so they collapse to a sliver while the
   text holds its width. */
.resb-form .altcha-checkbox,
.resb-form .altcha-logo {
  flex: 0 0 auto;
}

.resb-form .altcha-checkbox {
  width: 20px;
  height: 20px;
}

.resb-form .altcha-main {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
}

/* The form's own labels are 600 with a bottom margin; this one sits inline. */
.resb-form .altcha-label {
  flex-grow: 0;
  font-weight: 400;
  margin: 0;
  white-space: nowrap;
}

.resb-form .altcha-footer {
  padding: 0;
  font-size: 0.7rem;
  white-space: nowrap;
}

/* Custom checkbox. Board Blue, NOT the submit button's Rose — this is a
   control state rather than a call to action, and Rose is for CTAs only.
   appearance:none removes the platform control so the box can be drawn here;
   the tick is an inline SVG (data: is permitted by img-src in _headers). */
.resb-form .altcha-checkbox input {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  min-width: 20px;
  margin: 0;
  padding: 0;
  border: 2px solid var(--color-slate);
  border-radius: 0.25rem;
  background-color: var(--color-paper);
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.resb-form .altcha-checkbox input:hover {
  border-color: var(--color-board-blue);
}

.resb-form .altcha-checkbox input:checked {
  background-color: var(--color-board-blue);
  border-color: var(--color-board-blue);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23FAFAFA' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8.5l3.5 3.5L13 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 13px 13px;
}

.resb-form .altcha-checkbox input:focus-visible {
  outline: 2px solid var(--color-board-blue);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .resb-form .altcha-checkbox input {
    transition: none;
  }
}

/* Spam honeypot. Bots fill every field they find in the DOM; people never see
   this one. Hidden with display:none rather than a visually-hidden pattern —
   a screen reader should not be asked to skip a decoy field. */
.resb-honeypot {
  display: none;
}
