/* Doqmah · the project-request form (/request and /en/request).
 *
 * Loaded after style.css (tokens, font, reset, .btn) and legal.css (the .doc page frame).
 * Logical properties throughout, so the Arabic (rtl) and English (ltr) pages share one file.
 * No inline <style> or style="" on these pages: the CSP allows exactly one inline style hash,
 * and it belongs to 404.html.
 *
 * Without JavaScript the Worker answers a submit with a 303 to #sent or #error, and :target
 * below shows the matching panel. With JavaScript, request.js toggles .is-shown instead.
 */

.req__lede {
  margin-block-start: 14px;
  max-inline-size: 58ch;
  color: var(--graphite);
  font-size: clamp(1.0625rem, 2.6vw, 1.1875rem);
}

/* ---- form frame -------------------------------------------------------- */

.req__form {
  margin-block-start: clamp(24px, 4vw, 36px);
  max-inline-size: 720px;
  display: grid;
  gap: clamp(22px, 3.5vw, 28px);
  padding: clamp(18px, 4vw, 32px);
  background: var(--porcelain);
  border: 1px solid var(--stone);
  border-radius: 18px;
  box-shadow: 0 1px 1px rgb(var(--sh) / .08), 0 18px 40px -28px rgb(var(--sh) / .45);
}

.req__field,
.req__group {
  display: grid;
  gap: 8px;
  align-content: start;
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.req__group > legend { margin-block-end: 10px; }   /* room for the chips' focus ring */

.req__label,
.req__group > legend {
  padding: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
}

.req__opt {
  color: var(--graphite);
  font-weight: 400;
  font-size: 0.875rem;
  margin-inline-start: 6px;
}

.req__hint {
  color: var(--graphite);
  font-size: 0.875rem;
  line-height: 1.6;
}

.req__pair {
  display: grid;
  align-items: start;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: clamp(18px, 3vw, 22px);
}

/* ---- text inputs ------------------------------------------------------- */

.req__input {
  inline-size: 100%;
  min-block-size: 50px;
  padding: 11px 14px;
  font: 400 1.0625rem/1.5 var(--font);
  color: var(--ink);
  background: #FFFFFF;
  border: 1px solid #8C8579;       /* 3.5:1 against Porcelain, 3.6:1 against white (WCAG 1.4.11) */
  border-radius: 12px;
  transition: border-color .15s, box-shadow .15s;
}

.req__input:hover { border-color: var(--graphite); }

.req__input:focus-visible {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgb(21 19 15 / .14);
}

.req__input::placeholder { color: #6F685D; opacity: 1; }   /* 5.5:1 on white */

textarea.req__input {
  min-block-size: 150px;
  resize: vertical;
}

/* numbers and addresses read left to right on the Arabic page, but keep the label side */
.req__input[dir="ltr"] { text-align: start; }
[dir="rtl"] .req__input[dir="ltr"] { text-align: right; }
[dir="rtl"] .req__input[dir="ltr"]::placeholder { text-align: right; }

select.req__input {
  appearance: none;
  padding-inline-end: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%234A453E' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 16px center;
  cursor: pointer;
}

[dir="ltr"] select.req__input { background-position: right 16px center; }

/* a field the visitor has already left wrong */
.req__input.is-bad,
.req__input:user-invalid {
  border-color: var(--red-deep);
  box-shadow: 0 0 0 3px rgb(196 50 12 / .12);
}

/* ---- chip radios (project type, contact method) ------------------------ */

.req__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.req__chip {
  position: relative;
  display: inline-flex;
}

.req__chip input {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.req__chip span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-block-size: 46px;
  padding-inline: 18px;
  font-size: 1rem;
  font-weight: 500;
  background: #FFFFFF;
  border: 1px solid #8C8579;
  border-radius: 999px;
  transition: background-color .15s, border-color .15s, color .15s;
}

.req__chip span::before {
  content: "";
  inline-size: 14px;
  block-size: 14px;
  flex: none;
  border: 1.5px solid #8C8579;
  border-radius: 50%;
  background: #FFFFFF;
}

.req__chip:hover span { border-color: var(--graphite); }

.req__chip input:checked + span {
  color: #FFFFFF;
  background: var(--ink);
  border-color: var(--ink);
}

.req__chip input:checked + span::before {
  border-color: #FFFFFF;
  background: var(--lamp);
  box-shadow: inset 0 0 0 2px var(--ink);
}

.req__chip input:focus-visible + span {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

/* ---- the trap for bots: present for scripts, invisible and unreachable for people ---------- */

.req__hp {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- send ---------------------------------------------------------------- */

.req__send {
  display: grid;
  gap: 14px;
  justify-items: start;
  padding-block-start: 6px;
  border-block-start: 1px solid var(--stone);
}

.req__note {
  color: var(--graphite);
  font-size: 0.875rem;
  padding-block-start: 16px;
}

.req__note a,
.req__alt a,
.req__state a:not(.btn) {
  color: var(--red-text);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.req__submit[disabled] {
  cursor: progress;
  opacity: .7;
}

.req__alt {
  max-inline-size: 720px;
  margin-block-start: 18px;
  color: var(--graphite);
  font-size: 0.9375rem;
}

/* ---- after sending ------------------------------------------------------ */

.req__state {
  display: none;
  max-inline-size: 720px;
  margin-block-start: clamp(24px, 4vw, 36px);
  padding: clamp(20px, 4vw, 32px);
  border-radius: 18px;
  border: 1px solid var(--stone);
  background: var(--porcelain);
}

.req__state h2 {
  font-size: clamp(1.25rem, 3.4vw, 1.5rem);
  font-weight: 600;
  line-height: 1.35;
}

.req__state p { margin-block-start: 10px; }
.req__state .btn { margin-block-start: 18px; }

.req__state--ok { border-inline-start: 4px solid var(--lamp); }
.req__state--err { border-inline-start: 4px solid var(--red-deep); background: #FBF1EC; }

.req__state:target,
.req__state.is-shown { display: block; }

/* once request.js has sent the form, only .is-shown counts (a #error left in the address bar
   from a no-JS attempt must not show beside a later success) */
.req.is-live .req__state:target:not(.is-shown) { display: none; }

.req__state:focus { outline: none; }

/* sent without JavaScript: hide the form behind the thank-you panel */
#sent:target ~ .req__form,
#sent:target ~ .req__alt,
.req.is-sent .req__form,
.req.is-sent .req__alt { display: none; }

@media (forced-colors: active) {
  .req__chip input:checked + span { forced-color-adjust: none; background: Highlight; color: HighlightText; }
}
