/* ==========================================================================
   S · Contact: a form instead of a calendar. On About's thirds: who to write
   to in the first, sticky; the form in the other two. On a phone, one column.
   ========================================================================== */

.ct {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: var(--gap);
  align-items: start;
  padding: var(--page-top) var(--gutter) 0;
}

.ct-intro {
  position: sticky;
  top: var(--page-top);
  max-width: 400px;
  text-wrap: pretty;
}

.ct-intro h1 { font-size: var(--t-body); }
.ct-aside { margin-top: 28px; }

/* --- The form -------------------------------------------------------------------------- */

.ct-main { grid-column: 2 / -1; max-width: 720px; }

/* The label in black, the example inside the field a step lighter than the grey, so the two never
   read as the same thing. */
.ct-field label {
  display: block;
  margin-bottom: 12px;
}



.ct-field :is(input, textarea) {
  display: block;
  width: 100%;
  border: 0;
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  /* What people write is text, so it's at the text size, 18 everywhere (and over 16, so a phone
     doesn't zoom in on focus). */
  font-size: var(--t-body);
  letter-spacing: inherit;
  outline: none;
  transition: background-color 150ms ease-out, box-shadow 150ms ease-out;
}

.ct-field input {
  height: 52px;
  padding: 0 22px;
  border-radius: 999px;
}

.ct-field textarea {
  min-height: 188px;
  padding: 16px 22px;
  border-radius: var(--radius);
  line-height: var(--lh);
  resize: vertical;
}

/* Where the field grows with the text, it needs no handle. */
@supports (field-sizing: content) {
  .ct-field textarea { field-sizing: content; resize: none; }
}

/* Autofill keeps the grey instead of the browser's blue or yellow. */
.ct-field input:-webkit-autofill {
  -webkit-box-shadow: inset 0 0 0 100px var(--surface);
  -webkit-text-fill-color: var(--fg);
  caret-color: var(--fg);
}

.ct-field input:-webkit-autofill:focus { -webkit-box-shadow: inset 0 0 0 1.5px var(--fg), inset 0 0 0 100px var(--bg); }

/* An example inside each field, lighter than the labels: it's only there until you type. */
.ct-field :is(input, textarea)::placeholder { color: #8c8c8c; opacity: 1; }

@media (hover: hover) and (pointer: fine) {
  .ct-field :is(input, textarea):hover { background: var(--surface-hover); }
}

.ct-field :is(input, textarea):focus-visible,
.ct-field :is(input, textarea):focus { background: var(--bg); box-shadow: inset 0 0 0 1.5px var(--fg); }

/* An error keeps the grey, gets the ring and says what to do, right under the field. */
.ct-field [aria-invalid="true"] { box-shadow: inset 0 0 0 1.5px var(--fg); }

.ct-error { margin-top: 8px; font-size: var(--t-sm); }

/* Bots fill every field; people never see this one. */
.ct-trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* --- Send --------------------------------------------------------------------------------- */

.ct-send {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 32px;
}

/* As tall as the fields. "Send" and "Sending…" share one cell, so the width never changes. */
.ct-btn {
  display: inline-grid;
  place-items: center;
  height: 52px;
  padding: 0 26px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.8);
  color: #fff;
  font-size: var(--t-ui);
  transition: background-color 150ms ease-out, scale 150ms ease-out;
}

@media (hover: hover) and (pointer: fine) {
  .ct-btn:hover { background: rgb(0 0 0 / 0.92); }
}

.ct-btn:active { scale: 0.97; }
.ct-btn:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.ct-btn > span { grid-area: 1 / 1; }
.ct-btn > span + span,
.ct-btn[aria-disabled="true"] > span:first-child { visibility: hidden; }
.ct-btn[aria-disabled="true"] > span + span { visibility: visible; }
.ct-btn[aria-disabled="true"] { background: rgb(0 0 0 / 0.5); cursor: progress; }

/* Sending: the cone after the word rocks on its base. */
.ct-btn > span + span { display: inline-flex; align-items: center; gap: 8px; }

.ct-btn .cone {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: var(--hand-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
  transform-origin: 50% 92%;
}

.ct-btn[aria-disabled="true"] .cone { animation: cone-rock 900ms ease-in-out infinite; }

@keyframes cone-rock {
  0%, 100% { transform: rotate(-7deg); }
  50% { transform: rotate(7deg); }
}

.ct-keys { font-size: var(--t-sm); }

@media not ((hover: hover) and (pointer: fine)) {
  .ct-keys { display: none; }
}

.ct-failed { margin-top: 20px; }

/* --- Sent ------------------------------------------------------------------------------- */

.ct-done { outline: none; }
.ct-done:not([hidden]) { animation: ct-in 240ms var(--expo-out); }

@keyframes ct-in {
  from { opacity: 0; translate: 0 4px; }
}
/* Sent: one line, then a pill back to the site. */
.ct-done h2 { font-size: var(--t-body); text-wrap: pretty; }

/* The fist bump after the thanks, at the size of the line. */
.ct-icon svg {
  display: inline-block;
  width: 22px;
  height: 22px;
  margin-left: 6px;
  vertical-align: -5px;
  fill: none;
  stroke: currentColor;
  stroke-width: var(--hand-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ct-done:not([hidden]) .fist g { animation-delay: 160ms; animation-fill-mode: backwards; }

/* --- The three steps ---------------------------------------------------------------------
   Who's writing, what they're making, the budget. All three sit in one cell, so the box takes the
   tallest one's size and doesn't jump between them; only the current one shows. A dot per step
   says where you are: black once done, a bar where you are, grey still to come. One rhythm inside: 24 between the question and each field, 8
   between a label and its field, and the buttons pinned to the foot, Back then the black one on the
   right. */

.ak-form { position: relative; }

.ak-dots {
  display: flex;
  gap: 6px;
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}

.ak-dots li {
  width: 6px;
  height: 6px;
  border-radius: 3px;
  /* Still to come: the ink, faint, so it reads by day and by night. */
  background: color-mix(in srgb, var(--fg) 16%, transparent);
  transition: background-color 240ms var(--expo-out), width 320ms var(--expo-out);
}

/* Done: a black dot. Where you are: the dot stretches into a bar. */
.ak-dots li.is-on { background: var(--fg); }
.ak-dots li.is-here { width: 24px; }

.ak-steps { display: grid; }

.ak-step {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* The others keep their room but don't show or take the keyboard. */
.ak-step[hidden] { display: flex; visibility: hidden; }
.ak-step:not([hidden]) { animation: ak-in 260ms var(--expo-out); }
.ak-step.is-back:not([hidden]) { animation-name: ak-in-back; }

@keyframes ak-in { from { opacity: 0; translate: 12px 0; } }
@keyframes ak-in-back { from { opacity: 0; translate: -12px 0; } }

.ak-title { font-size: var(--t-body); }

.ak-step .ct-field { margin-top: 24px; }

/* The step's question is the title, in black; the fields under it are labelled in the grey. */
.ak-step .ct-field > label,
.ak-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
}

.ak-step .ct-field textarea { min-height: 112px; }

.ak-nav {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 32px;
}

/* Back: words only, in the grey, next to the black one. */
.ak-back {
  height: 52px;
  padding: 0 18px;
  border-radius: 999px;
  color: var(--muted);
  font-size: var(--t-ui);
  transition: color 150ms ease-out, background-color 150ms ease-out;
}

@media (hover: hover) and (pointer: fine) {
  .ak-back:hover { color: var(--fg); background: var(--surface); }
}

.ak-back:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

/* --- What they need: pills, as many as they like --------------------------------------------
   As the Work filters: grey, black once picked. Plain checkboxes underneath. */

.ak-pills { display: flex; flex-wrap: wrap; gap: 8px; }

.ak-pills .ak-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 44px;
  margin: 0;
  padding: 0 20px;
  border-radius: 999px;
  background: var(--surface);
  font-size: var(--t-ui);
  cursor: pointer;
  transition: background-color 150ms ease-out, color 150ms ease-out, scale 150ms ease-out;
}

.ak-pill input,
.ak-row input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }

.ak-pill:has(:checked) { background: var(--fg); color: var(--bg); }
.ak-pill:active { scale: 0.97; }
.ak-pill:has(:focus-visible) { outline: 2px solid var(--fg); outline-offset: 2px; }

@media (hover: hover) and (pointer: fine) {
  .ak-pill:not(:has(:checked)):hover { background: var(--surface-hover); }
}

/* --- When and the budget: rows, pick one -------------------------------------------------------
   Between hairlines, as the home's lists. The rows are grey, the one picked black with its ring
   filled. Plain radios underneath. */

.ak-rows__options { border-bottom: 1px solid var(--line); }

.ak-rows .ak-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  margin: 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  transition: color 150ms ease-out;
}

.ak-row::after {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px currentColor;
  transition: box-shadow 200ms var(--expo-out);
}

.ak-row:has(:checked) { color: var(--fg); }
.ak-row:has(:checked)::after { box-shadow: inset 0 0 0 5px currentColor; }
.ak-row:has(:focus-visible) span { text-decoration: underline; text-underline-offset: 4px; }

@media (hover: hover) and (pointer: fine) {
  .ak-row:hover { color: var(--fg); }
}

.ak-step .ct-error { margin-top: 8px; }



/* --- Over the page ---------------------------------------------------------------------------
   A white card in the middle, the page blurred behind it like under the buttons. On a phone it sits
   at the foot of the screen, where the thumb is. */

.ak {
  width: min(440px, calc(100vw - 24px));
  max-width: none;
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  overflow: auto;
  overscroll-behavior: contain;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.04), 0 24px 64px -16px rgb(0 0 0 / 0.18);
}

.ak::backdrop {
  background: rgb(255 255 255 / 0.4);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

[data-sky] .ak::backdrop { background: var(--wash, rgb(255 255 255 / 0.12)); }

.ak[open] { animation: ak-open 320ms var(--expo-out); }
.ak[open]::backdrop { animation: ak-fade 320ms var(--expo-out); }
.ak.is-closing { animation: ak-shut 180ms ease-in forwards; }
.ak.is-closing::backdrop { animation: ak-fade 180ms ease-in reverse forwards; }

@keyframes ak-open { from { opacity: 0; scale: 0.96; translate: 0 8px; } }
@keyframes ak-shut { to { opacity: 0; scale: 0.98; } }
@keyframes ak-fade { from { opacity: 0; } }

html:has(.ak[open]) { overflow: hidden; }

.ak-card { position: relative; padding: 24px; }

.ak-close {
  position: absolute;
  top: 24px;
  right: 24px;
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--surface);
  font-size: var(--t-ui);
  transition: background-color 150ms ease-out, scale 150ms ease-out;
  z-index: 1;
}

@media (hover: hover) and (pointer: fine) {
  .ak-close:hover { background: var(--surface-hover); }
}

.ak-close:active { scale: 0.96; }
.ak-close:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

/* The bars sit level with Close. */
.ak .ak-dots { height: 32px; align-items: center; margin-bottom: 12px; }

/* Over the page it's compact: everything a step smaller and closer than on /contact. */
.ak .ak-step .ct-field { margin-top: 16px; }
.ak .ak-step .ct-field > label,
.ak .ak-label { margin-bottom: 6px; }
.ak .ct-field input:not([type="radio"], [type="checkbox"]) { height: 46px; padding-left: 18px; }
.ak .ak-step .ct-field textarea { min-height: 84px; padding: 11px 18px; }
.ak .ak-nav { padding-top: 24px; }
.ak .ct-btn,
.ak .ak-back { height: 46px; }
.ak .ct-btn { padding: 0 22px; }


.ak-sr,
.ct .ak-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Sent: the fist bump where the bars were, the thanks in black and who I'll write to in the grey,
   both balanced, and one button at the foot where Send was. It keeps the steps' height (focus.js),
   and Close goes: the button below does the same. */
.ak-done:not([hidden]) { display: flex; flex-direction: column; }
.ak-done__icon { display: flex; align-items: center; height: 32px; margin-bottom: 12px; }

.ak-done__icon svg {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: currentColor;
  stroke-width: var(--hand-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ak-done h2,
.ak-done p { max-width: 28em; text-wrap: balance; }
.ak-done:not([hidden]) .fist g { animation-delay: 160ms; animation-fill-mode: backwards; }
.ak-card:has(.ak-done:not([hidden])) .ak-close { display: none; }

/* On /contact the thanks sits in the page, its button right under the words. */
.ct .ak-done .ak-nav { justify-content: flex-start; padding-top: 28px; }

@media (max-width: 600px) {
  .ak {
    width: calc(100vw - 16px);
    margin: auto auto 8px;
  }
  .ak-card { padding: 20px; }
  .ak-close { top: 20px; right: 20px; }
  @keyframes ak-open { from { translate: 0 24px; opacity: 0; } }
}

/* --- 404: alone in the middle of the screen ----------------------------------------------- */

.nf {
  display: grid;
  place-content: center;
  justify-items: center;
  min-height: 100svh;
  padding: var(--gutter);
  text-align: center;
}

.nf .ufo {
  width: 32px;
  height: 32px;
  margin-bottom: 20px;
  overflow: visible; /* the hull's ends sit on the box's edges, and the dome rises past it as it floats */
  fill: none;
  stroke: currentColor;
  stroke-width: var(--hand-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nf .ct-btn { margin-top: 28px; }
.ct-back { margin-top: 28px; }

.page-s:has(.ct) { --foot-gap: clamp(160px, 22vh, 260px); }

@media (prefers-reduced-motion: reduce) {
  .ct-field :is(input, textarea),
  .ct-btn { transition: none; }
  .ct-btn .cone { animation: none !important; }
  .ct-done:not([hidden]),
  .ak-step:not([hidden]),
  .ak[open], .ak[open]::backdrop, .ak.is-closing, .ak.is-closing::backdrop { animation: none; }
  .ak-dots li, .ak-back, .ak-close, .ak-pill, .ak-row, .ak-row::after { transition: none; }
}

/* --- Phone ----------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .ct { grid-template-columns: minmax(0, 1fr); }
  .ct-intro { position: static; max-width: none; }
  .ct-main { grid-column: 1; margin-top: 40px; }

  /* Sent, on a phone: nothing else on the screen, just the line and the pill, in the middle of it. */
  .ct[data-sent] { display: flex; align-items: center; justify-content: center; text-align: center; }
  .ct[data-sent] .ct-intro { display: none; }
  .ct[data-sent] .ct-main { margin: 0; max-width: 22em; }
  .ct[data-sent] .ct-done h2 { text-wrap: balance; }
  .ct[data-sent] :is(.ak-done__icon, .ak-done .ak-nav) { justify-content: center; }
  .ct[data-sent] .ak-done :is(h2, p) { margin-inline: auto; }
  /* The whole space down to the footer is the thanks', so it sits in the middle of the screen. */
  .page-s:has(.ct[data-sent]) { --foot-gap: var(--gap); }
}

/* --- /firma: the email signature, to copy ---------------------------------------------- */

.sg-box {
  padding: 32px;
  border-radius: var(--radius);
  outline: 1px solid var(--line);
}

.sg-steps { margin: 32px 0 0; padding-left: 20px; color: var(--muted); }
.sg-steps li + li { margin-top: 12px; }
.sg-steps strong { font-weight: inherit; color: var(--fg); }
