/*
 * Folio, the form layer: the lead and order forms as a letterhead sheet,
 * with real field edges, inline validation, service tiles, the document drop
 * zone, consent, the Turnstile slot and the status line. Needs styles.css.
 */

.form-card {
  position: relative;
  background: var(--sheet);
  color: var(--ink);
  border-radius: var(--r-3);
  padding: 28px 22px 24px;
  box-shadow: var(--shadow-sheet);
}

/* A heavy ink rule across the top of the sheet, like a letterhead. */
.form-card::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 4px;
  background: var(--ink);
  border-radius: var(--r-3) var(--r-3) 0 0;
}

.form-card h2 {
  font-size: 1.625rem;
  line-height: 1.2;
  margin: 0 0 6px;
}

.form-card .hint {
  margin: 0 0 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
  color: var(--text-2);
  font-size: 1rem;
  line-height: 1.55;
}

.field {
  display: grid;
  gap: 6px;
  margin: 0 0 18px;
  min-width: 0;
}

.field label,
.choices legend {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.35;
}

.field input,
.field textarea {
  width: 100%;
  font: inherit;
  font-size: 1.125rem; /* never under 16px: no zoom on focus */
  line-height: 1.4;
  color: var(--ink);
  padding: 12px 14px;
  min-height: 52px;
  background: var(--field);
  border: 1px solid var(--field-edge);
  border-radius: var(--r-2);
  transition: border-color var(--dur-hover) ease;
}

.field input:focus-visible,
.field textarea:focus-visible {
  border-color: var(--ink);
  outline-offset: 2px;
  border-radius: var(--r-2);
}

@media (hover: hover) and (pointer: fine) {
  .field input:hover,
  .field textarea:hover {
    border-color: var(--text-2);
  }
}

/* Phone and mail read left to right, aligned with the Hebrew fields. */
.field input[type="tel"],
.field input[type="email"] {
  direction: ltr;
  text-align: var(--page-start);
}

.field textarea {
  min-height: 112px;
  resize: vertical;
}

/* Inline validation: once the person has touched a field, not before. A
   danger bar marks the field on the page's start side. */
.field
  :is(input:not([type="radio"], [type="file"]), textarea):is(
    :user-invalid,
    [aria-invalid="true"]
  ) {
  border-color: var(--danger);
  box-shadow: inset var(--page-start-inset) 0 0 var(--danger);
}

.error {
  color: var(--danger);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.4;
}

/* Empty, the live region leaves the layout but stays in the accessibility
   tree, so its first message is announced. */
.error:empty {
  position: absolute;
}

/* ---------- Service choice: stacked tiles, each label on one line -------- */
.choices {
  border: 0;
  padding: 0;
  margin: 0 0 20px;
  display: grid;
  gap: 8px;
}

.choices legend {
  padding: 0;
  margin-bottom: 8px;
}

.choice {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 56px;
  padding: 12px 14px;
  border: 1px solid var(--field-edge);
  border-radius: var(--r-2);
  background: var(--field);
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition:
    background-color var(--dur-hover) ease,
    border-color var(--dur-hover) ease,
    transform var(--dur-press) var(--ease-out);
}

.choice:active {
  transform: scale(0.98);
}

/* a Space press on the focused radio does not animate */
.choice:has(input:focus-visible):active {
  transform: none;
}

/* .field .choice: the tiles sit in a .field fieldset, whose text-input
   sizing must not reach the radios. */
.field .choice input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 22px;
  height: 22px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: var(--field);
  cursor: pointer;
}

/* The checked dot, drawn by the tile over the radio's ring so that only its
   scale and opacity change: 14px tile padding + (22px ring - 10px dot) / 2. */
.choice::after {
  content: "";
  position: absolute;
  inset-inline-start: 20px;
  top: calc(50% - 5px);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink);
  opacity: 0;
  transform: scale(0.4);
  pointer-events: none;
  transition:
    opacity var(--dur-press) var(--ease-out),
    transform var(--dur-press) var(--ease-out);
}

.choice:has(input:checked)::after {
  opacity: 1;
  transform: scale(1);
}

.choice:has(input:checked) {
  border-color: var(--ink);
  background: var(--gold-wash);
}

.choice:has(input[aria-invalid="true"]) {
  border-color: var(--danger);
}

.choice:has(input:focus-visible) {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.choice input:focus-visible {
  outline: none;
}

@media (hover: hover) and (pointer: fine) {
  .choice:hover {
    border-color: var(--ink);
  }
}

/* ---------- Document upload ----------------------------------------------
   The native input covers the drop zone and stays the control, so picking,
   dropping and the keyboard all work as before. */
.dropzone {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  align-items: start;
  padding: 18px 16px;
  border: 1px dashed var(--field-edge);
  border-radius: var(--r-2);
  background: var(--field);
  transition:
    background-color var(--dur-hover) ease,
    border-color var(--dur-hover) ease;
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
  border: 0;
  z-index: 1;
}

.dropzone-icon {
  grid-row: 1 / span 2;
  width: 40px;
  height: 40px;
  padding: 9px;
  border-radius: var(--r-2);
  background-color: var(--ink);
  color: var(--gold);
  -webkit-mask: none;
  mask: none;
  display: grid;
  place-items: center;
}

.dropzone-icon::before {
  content: "";
  width: 22px;
  height: 22px;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12'/%3E%3Cpath d='m17 8-5-5-5 5'/%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3C/svg%3E")
    center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12'/%3E%3Cpath d='m17 8-5-5-5 5'/%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.field-hint {
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text-2);
}

/* The Latin format list stays on one line where the zone has the room. */
@media (min-width: 360px) {
  .field-hint [dir="ltr"] {
    white-space: nowrap;
  }
}

.dropzone:has(input:focus-visible) {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.dropzone:has(input[aria-invalid="true"]) {
  border-color: var(--danger);
  border-style: solid;
}

@media (hover: hover) and (pointer: fine) {
  .dropzone:has(input:hover) {
    border-color: var(--ink);
    background: #fdfaf2;
  }
}

/* The chosen files: each name with its size, the size read left to right. */
.file-list {
  grid-column: 2;
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.file-list:empty {
  position: absolute;
}

.file-list li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  font-size: 0.9375rem;
  line-height: 1.45;
}

.file-list li::before {
  content: "";
  flex: none;
  align-self: center;
  width: 6px;
  height: 6px;
  background: var(--gold-rule);
}

.file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

/* Sizes line up in one column at the end of the list, like a ledger: the
   display face has tabular figures (Assistant has none). Isolated, not
   dir=ltr: "1.4MB" still reads left to right, and the logical margin stays on
   the page's end side so sizes form one column. */
.file-size {
  flex: none;
  unicode-bidi: isolate;
  margin-inline-start: auto;
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--text-2);
  white-space: nowrap;
}

/* ---------- Consent: a real 22px box, the sentence at reading size -------- */
.consent {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
  margin: 4px 0 6px;
  cursor: pointer;
}

.consent input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  border: 1.5px solid var(--ink);
  border-radius: var(--r-1);
  background: var(--field) center / 16px no-repeat;
  cursor: pointer;
  transition: background-color var(--dur-hover) ease;
}

.consent input:checked {
  background-color: var(--ink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e3c165' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}

.consent input[aria-invalid="true"] {
  border-color: var(--danger);
}

/* Honeypot: hidden from people, visible to naive bots */
.hp {
  position: absolute;
  inset-inline-start: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.privacy {
  margin: 10px 0 16px;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-2);
  max-width: 65ch;
}

/* Cloudflare's widget is its own ~300x65 iframe, placed at the start edge:
   reserve its slot, and outline it until the widget fills the container. */
.turnstile {
  position: relative;
  min-height: 72px;
  margin: 0 0 16px;
}

.turnstile:empty::before {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  width: min(300px, 100%);
  height: 65px;
  border: 1px dashed rgb(12 11 23 / 22%);
  border-radius: var(--r-2);
}

/* ---------- Status line ---------------------------------------------------- */
.form-status {
  margin: 0;
  font-weight: 700;
  line-height: 1.5;
}

.form-status:not(:empty) {
  margin-top: 16px;
  padding: 12px 14px;
  border-inline-start: 3px solid currentColor;
  background: rgb(163 38 26 / 6%);
}

.form-status[data-outcome="success"] {
  color: var(--success);
  background: rgb(31 107 58 / 7%);
}

.form-status:not([data-outcome="success"]) {
  color: var(--danger);
}

.form-status[data-outcome="sending"] {
  color: var(--text-2);
  background: rgb(12 11 23 / 4%);
}

/* ---------- Preferences and wider screens ---------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .choice:active {
    transform: none;
  }
  .choice::after {
    transform: none;
  }
}

@media (forced-colors: active) {
  /* The custom box loses its ink fill but keeps the gold tick image, which is
     unreadable on a light Canvas: hand the box back to the system. */
  .consent input,
  .consent input:checked {
    appearance: auto;
    -webkit-appearance: auto;
    background-image: none;
  }
  .choice::after {
    forced-color-adjust: none;
    background: CanvasText;
  }
  .choice:has(input:checked) {
    outline: 2px solid Highlight;
  }
}

@media (prefers-contrast: more) {
  .form-card {
    box-shadow: 0 0 0 1px var(--ink);
  }
}

@media (min-width: 720px) {
  .form-card {
    padding: 32px 32px 28px;
  }
}
