/* Good Work Digital. The inquiry form, alive.
   Loaded after the home page's styles.css and built only from its tokens. It adds what a drawn form does not have:
   a designed focus, a quiet mark when a field is right, the message beside a field that is wrong, the button while it sends,
   the note when sending failed, and the confirmation that takes the form's place in the same glass panel.
   Shared by the Start page and, later, the home page's form section. form.js is its other half.
   Movement is on transform and opacity only, 200 to 500 milliseconds, and all of it is off under reduced motion. */

/* The panel is the glass card. The form sits in it, and so does the confirmation. */
.panel { position: relative; }
.form__in { display: grid; gap: var(--s-16); }
.field-row__msg[hidden], .note[hidden], .done[hidden] { display: none; }

/* ---------- A field ---------- */
.field-row__box { position: relative; display: block; }
.field-row input, .field-row textarea { padding-right: var(--s-48); } /* room for the mark, kept always so nothing typed ever moves */
.field-row label { transition: color 0.14s ease; }
/* The text box: its lines are 24 apart and its words sit 12 inside its edge (11 of padding and the 1 of the edge), so at 96 tall
   it shows three whole lines, and each line more makes it 24 taller: 120, 144, and so on. Always a multiple of 8. */
.field-row textarea { line-height: 24px; padding-block: 11px; min-height: 96px; }
@supports (field-sizing: content) {
  /* it grows with what is written in it, up to ten lines, then scrolls */
  .field-row textarea { field-sizing: content; height: auto; max-height: 264px; }
}

/* Focus: the label and the edge take the accent, and the page's own ring sits 2 clear of the edge. Nothing changes size. */
.field-row:focus-within label { color: var(--accent-ink); }
.field-row input:focus-visible, .field-row textarea:focus-visible { box-shadow: inset 0 0 0 1px var(--focus); }

/* What the browser fills in for the visitor keeps the field white. */
.field-row input:-webkit-autofill, .field-row textarea:-webkit-autofill {
  -webkit-text-fill-color: var(--ink); caret-color: var(--ink);
  -webkit-box-shadow: inset 0 0 0 100px #fff; box-shadow: inset 0 0 0 100px #fff;
}

/* Right: one small tick at the end of the field. A shape, not only a colour. */
.field-row__ok {
  position: absolute; right: var(--s-16); top: 14px; width: 20px; height: 20px;
  color: var(--accent-ink); pointer-events: none;
  opacity: 0; transform: scale(0.6);
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.field-row--ok .field-row__ok { opacity: 1; transform: none; }

/* Wrong: the heavier red edge, the mark and the words are in styles.css. Here: the ring and the label follow, and the tick stands down. */
.field-row--wrong { --focus: var(--wrong); }
.field-row--wrong:focus-within label { color: var(--ink); }
.field-row--wrong input:-webkit-autofill, .field-row--wrong textarea:-webkit-autofill { -webkit-box-shadow: inset 0 0 0 1px var(--wrong), inset 0 0 0 100px #fff; box-shadow: inset 0 0 0 1px var(--wrong), inset 0 0 0 100px #fff; }
.field-row__msg { margin-top: var(--s-4); }

/* ---------- The end of the form: the note when sending failed, and the button ---------- */
.form__end { display: grid; gap: var(--s-24); justify-items: start; margin-top: var(--s-8); }
.form__end .btn { margin-top: 0; }
.form__end .note { justify-self: stretch; }
.note__say { display: grid; min-width: 0; }
.note__say p { text-wrap: pretty; }
/* the address on a line of its own, as it is beside the form: a full 44 to press, and the lines above it keep their even spacing */
.note__mail {
  display: inline-flex; align-items: center; justify-self: start; max-width: 100%; min-height: 44px; overflow-wrap: anywhere;
  color: var(--ink); font-weight: 600; text-decoration: underline; text-decoration-color: var(--edge); text-decoration-thickness: 1px; text-underline-offset: 5px;
  transition: color 0.14s ease, text-decoration-color 0.14s ease;
}
.note__mail:hover { color: var(--accent-ink); text-decoration-color: currentColor; }
.note { padding-bottom: var(--s-8); }

/* The button while it sends: pressed in, and it says so. It keeps the keyboard's place, so it is not switched off, only deaf. */
.btn__say { display: inline-flex; align-items: baseline; gap: var(--s-8); }
.btn__dots { display: inline-flex; align-items: baseline; gap: 4px; }
.btn__dots i { width: 4px; height: 4px; border-radius: 1px; background: currentColor; }
.btn--fill[aria-disabled="true"], .btn--fill[aria-disabled="true"]:hover, .btn--fill[aria-disabled="true"]:active {
  background: var(--accent-press); cursor: progress; transform: none;
  box-shadow: inset 0 1px 2px rgba(11, 13, 18, 0.28), 0 1px 1px rgba(11, 13, 18, 0.2);
}

/* ---------- Sent: the confirmation, in the same panel ---------- */
.done { display: grid; justify-items: start; align-content: center; gap: var(--s-16); }
.done__mark {
  position: relative; overflow: hidden; display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: var(--s-8);
  border-radius: var(--r-1); background: var(--accent); color: var(--accent-on); border: 1px solid var(--accent-edge);
  box-shadow: inset 0 1px 0 var(--accent-lit), 0 1px 2px rgba(11, 13, 18, 0.18), 0 10px 20px -10px rgba(11, 13, 18, 0.45);
}
.done__mark svg { width: 32px; height: 32px; }
.done__h:focus { outline: none; } /* it takes the focus only so a screen reader starts here; it is not a control */
.done .lead { color: var(--text); }
.done__acts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-8) var(--s-24); margin-top: var(--s-8); }
.done__acts .btn { margin-top: 0; min-width: 0; }
.done__acts .link { font-size: 16px; } /* the size of the button's words, so the two share a baseline */

/* What was sent: the form's own fields, now plain lines under one rule each. */
/* The values stand on a column line of the page's own grid: the labels take four of the twelve columns on a phone, two on a tablet,
   and one of the panel's six on a computer. --c is the width of one column, worked out from the panel's own width. */
.receipt { justify-self: stretch; min-width: 0; margin-top: var(--s-8); --k: 4; --c: calc((100% + 2 * var(--inset) - 11 * var(--gutter)) / 12); }
@media (min-width: 600px) { .receipt { --k: 2; } }
.receipt__h { padding-bottom: var(--s-8); color: var(--ink); font-weight: 600; font-size: var(--small); line-height: var(--small-lh); }
.receipt__rows > div { display: grid; grid-template-columns: calc(var(--k) * var(--c) + (var(--k) - 1) * var(--gutter)) minmax(0, 1fr); column-gap: var(--gutter); align-items: baseline; padding-block: var(--s-12); box-shadow: inset 0 1px 0 var(--rule); }
.receipt__rows > div:last-child { box-shadow: inset 0 1px 0 var(--rule), inset 0 -1px 0 var(--rule); }
.receipt__rows > div[hidden] { display: none; }
.receipt dt { color: var(--muted); font-size: var(--small); line-height: var(--small-lh); }
.receipt dd { color: var(--ink); line-height: 24px; overflow-wrap: anywhere; }
.receipt [data-from="message"] dd { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }

/* Once sent, the line under the heading has been said in the panel, so it leaves. */
.start.is-sent .start__say .lead { display: none; }

/* Stacked (under 1200): the form leaves and the panel is as tall as the confirmation. */
@media (max-width: 1199px) {
  .panel.is-sent .form__in { display: none; }
}
/* Side by side (1200 up): the panel keeps the height the form gave it, so the footer stays exactly where it was.
   The confirmation fills it from the top, and the two ways on stand at its foot. */
@media (min-width: 1200px) {
  .panel.is-sent .form__in { visibility: hidden; }
  .panel.is-sent .done { position: absolute; inset: var(--inset); grid-template-rows: auto auto auto 1fr auto; align-content: stretch; }
  .done { gap: var(--s-24); }
  .done__mark { width: 64px; height: 64px; margin-bottom: 0; }
  .done__mark svg { width: 36px; height: 36px; }
  .receipt { margin-top: 0; align-self: start; --k: 1; --c: calc((100% + 2 * var(--inset) - 5 * var(--gutter)) / 6); }
  .done__acts { margin-top: 0; }
}

/* ---------- Movement ---------- */
@media (prefers-reduced-motion: no-preference) {
  /* a message arrives from just above its place */
  .field-row__msg, .form__end .note { animation: form-in 0.24s cubic-bezier(0.2, 0.7, 0.2, 1) backwards; }
  @keyframes form-in { from { opacity: 0; transform: translateY(-6px); } }
  /* Sending: three small squares, the name mark's own full stop, arrive one after another and stay. Nothing loops. */
  .btn__dots i { animation: form-dot 0.2s ease backwards; }
  .btn__dots i:nth-child(1) { animation-delay: 0.16s; }
  .btn__dots i:nth-child(2) { animation-delay: 0.3s; }
  .btn__dots i:nth-child(3) { animation-delay: 0.44s; }
  @keyframes form-dot { from { opacity: 0; transform: translateY(3px); } }
  /* Sent: the mark arrives, the tick is drawn across it (a cover the colour of the mark slides off it), then the words rise one by one. */
  .done__mark { animation: done-mark 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) backwards; }
  .done__mark::after { content: ""; position: absolute; inset: 0; background: var(--accent); transform: translateX(102%); animation: done-draw 0.4s cubic-bezier(0.45, 0, 0.2, 1) 0.24s backwards; }
  .done > :not(.done__mark) { animation: done-rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) backwards; }
  .done > :nth-child(2) { animation-delay: 0.34s; }
  .done > :nth-child(3) { animation-delay: 0.42s; }
  .done > :nth-child(4) { animation-delay: 0.5s; }
  .done > :nth-child(5) { animation-delay: 0.58s; }
  @keyframes done-mark { from { opacity: 0; transform: scale(0.72); } }
  @keyframes done-draw { from { transform: none; } }
  @keyframes done-rise { from { opacity: 0; transform: translateY(10px); } }
}
