/* ForgeIEC contact form (layouts/shortcodes/contact-form.html).

   Uses the design tokens of the site stylesheet (assets/css/forge.css,
   section 1) directly, so the form follows the light/dark theme and the
   theme toggle like every other component. Tokens read here:

     --surface        form background
     --surface-2      input background
     --text, --muted, --heading
     --border, --border-strong
     --brand          required marks, checkbox, counter warning
     --link           links
     --focus          focus ring
     --good, --good-bg  success message
     --bad, --bad-bg    errors
     --radius, --radius-sm, --font-sans, --shadow

   The submit button carries the site classes "btn btn-primary".
   All rules are scoped to .contact-form-wrap so nothing leaks into the
   rest of the site. */

.contact-form-wrap {
  max-width: 100%;
  margin: 1.5rem 0 2rem;
  text-align: start;
  color: var(--text);
  font-family: var(--font-sans);
}

.contact-form-wrap *,
.contact-form-wrap *::before,
.contact-form-wrap *::after { box-sizing: border-box; }

.contact-form-wrap a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }

.contact-form {
  display: grid;
  gap: 1.25rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.contact-form[hidden] { display: none; }

.cf-row-2 { display: grid; gap: 1.25rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .cf-row-2 { grid-template-columns: 1fr; } }

.cf-field { display: grid; gap: 0.4rem; min-width: 0; }

.cf-field > label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--heading);
}

.cf-req { color: var(--brand); font-weight: 700; }

.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form select,
.contact-form textarea {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.6rem 0.8rem;
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.contact-form textarea { resize: vertical; min-height: 10rem; }
.contact-form select { cursor: pointer; }

.contact-form input:hover,
.contact-form select:hover,
.contact-form textarea:hover { border-color: var(--muted); }

.contact-form input:focus-visible,
.contact-form select:focus-visible,
.contact-form textarea:focus-visible,
.contact-form button:focus-visible,
.contact-form-wrap a:focus-visible,
.cf-status:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.contact-form [aria-invalid="true"] { border-color: var(--bad); }

.cf-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
}
.cf-count { font-variant-numeric: tabular-nums; }
.cf-count-warn { color: var(--brand); }

.cf-err {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--bad);
}
.cf-err[hidden] { display: none; }

/* Consent checkbox: box left, text right. */
.cf-check {
  grid-template-columns: auto 1fr;
  align-items: start;
  column-gap: 0.75rem;
}
.cf-check input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  margin: 0.2rem 0 0;
  accent-color: var(--brand);
  cursor: pointer;
}
.cf-check > label {
  font-weight: 400;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text);
  cursor: pointer;
}
.cf-check .cf-err { grid-column: 2; }

/* Honeypot: off-screen for sighted users, aria-hidden for screen readers,
   tabindex -1 for keyboard users. Not display:none, which some bots skip. */
.cf-hp {
  position: absolute !important;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.contact-form { position: relative; }

.cf-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.cf-submit:disabled { opacity: 0.65; cursor: progress; transform: none; }
.cf-legend { font-size: 0.85rem; color: var(--muted); }

.cf-status:empty { display: none; }
.cf-status {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-inline-start-width: 4px;
  font-size: 0.95rem;
  line-height: 1.5;
}
.cf-status-ok { border-color: var(--good); background: var(--good-bg); }
.cf-status-error { border-color: var(--bad); background: var(--bad-bg); }

.contact-noscript {
  padding: 1rem 1.2rem;
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--brand);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

@media (prefers-reduced-motion: reduce) {
  .contact-form-wrap * { transition: none !important; }
}
