/* ==========================================================================
   CONTACT FORM — ramy.photos
   --------------------------------------------------------------------------
   Styling only. The markup, the field names, the honeypot, the token and the
   backend contract in templates/contact.php are untouched, which is why this
   is CSS and not a template fork.

   Two names matter and are easy to confuse:
     input[name="mail"]   the real address field, visible
     input[name="email"]  the HONEYPOT, wrapped in <p style="display:none!
                          important">. ContactRequest.php:140 rejects the
                          submission unless it is present AND empty, so nothing
                          here may give that <p> a display value. No rule below
                          targets it; the grid rules address the two fields by
                          name so the honeypot is never selected.

   Every selector is prefixed `body main form.form-background` so it outranks
   _base.css and mode-dark.css regardless of where this sheet is loaded.
   ========================================================================== */

/* ---- surface: no card. The page ground shows through. ------------------- */

body main form.form-background {
  max-width: 720px;
  margin: 0 auto;
  padding: 0;
  background: none;
  border: 0;
}

/* ---- layout ------------------------------------------------------------ */

body main form.form-background fieldset {
  display: grid;
  grid-template-columns: 1fr;      /* single column is the baseline */
  gap: 22px;
}

body main form.form-background fieldset > p { margin: 0; }

/* The template has a bare <br> before the submit paragraph. As a grid item it
   would open an empty row. */
body main form.form-background fieldset > br { display: none; }

/* Name and Email share a row only where :has() can identify them by field
   name. Without :has() every row stays full width and the form is simply
   vertical — the same form, just stacked. */
@supports selector(:has(*)) {
  @media (min-width: 641px) {
    body main form.form-background fieldset {
      grid-template-columns: 1fr 1fr;
      column-gap: 28px;
    }
    body main form.form-background fieldset > p { grid-column: 1 / -1; }
    body main form.form-background fieldset > p:has(input[name="name"]) { grid-column: 1 / 2; }
    body main form.form-background fieldset > p:has(input[name="mail"]) { grid-column: 2 / 3; }
  }
}

/* ---- labels ------------------------------------------------------------ */

body main form.form-background fieldset p > label:not(.optionlabel) {
  display: block;
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: rgba(255, 255, 255, .72);
}

/* ---- fields ------------------------------------------------------------ */

body main form.form-background fieldset input[type="text"],
body main form.form-background fieldset input[type="email"],
body main form.form-background fieldset textarea {
  width: 100%;
  background: #121212;                       /* a step up from the page ground */
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: 4px;
  color: rgba(255, 255, 255, .92);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  padding: 14px 16px;
  transition: border-color .18s ease, box-shadow .18s ease;
}

body main form.form-background fieldset input[type="text"],
body main form.form-background fieldset input[type="email"] { height: 50px; }

body main form.form-background fieldset textarea {
  display: block;
  height: 190px;
  resize: vertical;
}

body main form.form-background fieldset ::placeholder {
  color: rgba(255, 255, 255, .28);
  opacity: 1;
}

/* Focus: a brighter edge and a whisper of a halo. The browser default ring is
   removed only because this replaces it — :focus-visible gets the stronger of
   the two treatments so keyboard users are never left guessing. */
body main form.form-background fieldset input:focus,
body main form.form-background fieldset textarea:focus {
  outline: none;
  border-color: rgba(255, 255, 255, .34);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .05);
}

body main form.form-background fieldset input:focus-visible,
body main form.form-background fieldset textarea:focus-visible {
  border-color: rgba(255, 255, 255, .5);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .09);
}

/* ---- privacy consent --------------------------------------------------- */

/* A real <input type="checkbox">, restyled rather than replaced, so it keeps
   its semantics, its keyboard behaviour and its required validation. */
body main form.form-background fieldset input[type="checkbox"] {
  width: 19px;
  height: 19px;
  min-width: 19px;
  padding: 0;
  margin: 0;
  background: none;
  border: 0;
  border-radius: 3px;
  accent-color: #c9c9c9;
  vertical-align: middle;   /* only used by the no-:has() fallback below */
  cursor: pointer;
}

body main form.form-background fieldset label.optionlabel {
  margin-left: 10px;        /* flex gap replaces this where :has() is available */
  font-size: 14px;
  line-height: 1.5;
  color: rgba(255, 255, 255, .72);
  cursor: pointer;
}

/* Flexbox centres the box against the text exactly, instead of the
   vertical-align approximation that left it a pixel high. Gated on :has()
   like the two-column rule; without it the row falls back to the inline
   layout above, which is what shipped and works. */
@supports selector(:has(*)) {
  body main form.form-background fieldset > p:has(> input[type="checkbox"]) {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  body main form.form-background fieldset > p:has(> input[type="checkbox"]) label.optionlabel {
    margin-left: 0;
  }
}

body main form.form-background fieldset label.optionlabel a {
  color: rgba(255, 255, 255, .82);
  text-underline-offset: 3px;
}

body main form.form-background fieldset label.optionlabel a:hover { color: #fff; }

/* ---- submit ------------------------------------------------------------ */

body main form.form-background fieldset .button-primary {
  height: 48px;
  padding: 0 34px;
  background: #ededed;
  border: 1px solid #ededed;
  border-radius: 4px;
  color: #0b0b0b;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, transform .1s ease;
}

body main form.form-background fieldset .button-primary:hover {
  background: #fff;
  border-color: #fff;
}

body main form.form-background fieldset .button-primary:active { transform: translateY(1px); }

body main form.form-background fieldset .button-primary:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}

body main form.form-background fieldset .button-primary:focus-visible {
  outline: 2px solid rgba(255, 255, 255, .75);
  outline-offset: 2px;
}

/* ---- validation messages ----------------------------------------------- */

body main form.form-background fieldset .error-message,
body main form.form-background fieldset .bouncer-message {
  display: block;
  margin-top: 8px;
  font-size: 12.5px;
  line-height: 1.4;
  color: #e08b78;
}

body main form.form-background fieldset input.error,
body main form.form-background fieldset textarea.error {
  border-color: rgba(224, 139, 120, .55);
}
