#contact {
  --ct-cg: var(--space-2);
  --ct-pad: clamp(10rem, 38vh, 24rem);
  --ct-btn-h: 3.5rem;
  --ct-settle: cubic-bezier(.16, 1, .3, 1);
  position: relative;
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr);
  column-gap: var(--ct-cg);
  padding: var(--ct-pad) var(--gutter) var(--space-6);
  background: var(--bg);
  color: var(--ink);
  overflow-x: clip;
}
#contact .ct-rail { grid-column: 1; grid-row: 1; align-self: stretch; }

/* No-JS thread: the whole height of the section, down the gutter */
#contact .ct-thread {
  position: absolute; left: 0; top: calc(-1 * var(--ct-pad));
  grid-column: 1; grid-row: 1 / -1;
  width: 100%;
  height: calc(100% + var(--ct-pad) + var(--space-6));
  overflow: visible; pointer-events: none;
}
#contact svg path { fill: none; stroke: var(--accent); stroke-width: var(--thread-w); stroke-linecap: round; stroke-linejoin: round; }

/* The photo is the large thing here; it runs off the right edge */
#contact .ct-photo {
  grid-column: 2; grid-row: 1;
  margin-right: calc(-1 * var(--gutter));
  aspect-ratio: 16 / 10;
  background: var(--surface);
  overflow: hidden;
}
#contact .ct-photo svg { display: block; width: 100%; height: 100%; }
#contact .ct-photo svg path { stroke: var(--ink); }
#contact .ct-photo .ct-ground { fill: var(--surface); }
#contact .ct-photo .ct-light { fill: var(--bg); opacity: .6; }
#contact .ct-photo .ct-table { fill: var(--accent-2); opacity: .14; }
#contact .ct-photo .ct-ink { fill: none; stroke: var(--ink); stroke-width: 1; opacity: .55; vector-effect: non-scaling-stroke; }
#contact .ct-photo .ct-grainlayer { opacity: .12; }
#contact .ct-caption {
  grid-column: 2; grid-row: 2;
  margin-top: var(--space-1);
  font-size: var(--t-small); font-style: italic; color: var(--muted);
}

/* Loud line, quiet letter */
#contact .ct-title {
  grid-column: 2; grid-row: 3;
  margin-top: var(--space-5);
  font-family: var(--font-display); font-style: normal; font-weight: 400;
  font-size: var(--t-title); line-height: var(--lh-title); letter-spacing: -0.01em;
  text-wrap: balance;
}
#contact .ct-letter {
  grid-column: 2; grid-row: 4;
  max-width: 44ch; margin-top: var(--space-3);
  font-size: var(--t-body); font-weight: 300; line-height: var(--lh-body);
  text-wrap: pretty;
}
#contact .ct-letter p + p { margin-top: var(--space-1); }

/* The form: three plain lines on the paper, nothing boxed in */
#contact .ct-form {
  grid-column: 2; grid-row: 5;
  display: grid;
  gap: var(--space-3);
  max-width: 34rem;
  margin-top: var(--space-5);
  scroll-margin-top: var(--space-4);
}
#contact .ct-field { display: grid; gap: .35rem; }
#contact .ct-field label { font-size: .9375rem; font-weight: 400; color: var(--ink); }
#contact .ct-field label span { color: var(--muted); font-weight: 300; }
#contact .ct-field input,
#contact .ct-field textarea {
  width: 100%;
  min-height: 2.75rem;
  padding: .5rem 0;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 35%, transparent);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 300;
  font-size: 1.0625rem;
  line-height: 1.5;
  transition: border-color var(--dur-1) var(--ease-out);
}
#contact .ct-field textarea {
  resize: vertical;
  min-height: 7.5rem;
  padding: .75rem;
  border: 1px solid color-mix(in srgb, var(--ink) 25%, transparent);
  background: color-mix(in srgb, var(--surface) 40%, transparent);
}
#contact .ct-field input:focus-visible,
#contact .ct-field textarea:focus-visible { outline: none; border-color: var(--ink); box-shadow: 0 1px 0 var(--ink); }
#contact .ct-field input[aria-invalid="true"] { border-bottom-color: var(--accent); }
#contact .ct-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* The one action, with the thread tied around it */
#contact .ct-act { display: flex; align-items: flex-start; margin-top: var(--space-2); padding-left: .75rem; }
#contact .ct-tie { position: relative; display: inline-block; }
#contact .ct-wrap {
  position: absolute;
  left: calc(-1 * (var(--ct-cg) + .875rem)); top: -.75rem;
  width: calc(100% + var(--ct-cg) + .875rem + .75rem); height: calc(100% + 1.5rem);
  overflow: visible; pointer-events: none;
}
#contact .ct-btn {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center;
  min-height: var(--ct-btn-h); padding: 0 1.75rem;
  border: 0; border-radius: 0;
  background: var(--accent); color: var(--bg);
  font-family: var(--font-body); font-weight: 500; font-size: 1rem;
  cursor: pointer;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .35em;
  text-decoration-color: transparent;
  transition: text-decoration-color var(--dur-1) var(--ease-out), opacity var(--dur-1) var(--ease-out);
}
#contact .ct-btn:hover,
#contact .ct-btn:focus-visible { text-decoration-color: currentColor; }
#contact .ct-btn:focus-visible { outline-offset: .3rem; }
#contact .ct-btn[aria-busy="true"] { opacity: .7; cursor: progress; }

/* The last knot of the letter: on the thread, just left of the button */
#contact .ct-knot {
  position: absolute; z-index: 2;
  left: calc(-1.25rem - 10px); top: calc(50% - 1.25rem);
  width: 2.5rem; height: 2.5rem;
  overflow: visible; pointer-events: none;
}
#contact .ct-knot g { transform-origin: 0 0; transform: rotate(-28deg) scale(.85); }
#contact .ct-knot circle { fill: var(--accent); }
#contact .ct-knot[data-knot="waiting"] g { opacity: 0; transform: rotate(-8deg) scale(1.5); }

#contact .ct-status { min-height: 1.5em; font-size: 1rem; line-height: 1.55; }
#contact .ct-status[data-tone="ok"] { font-family: var(--font-display); font-style: italic; font-size: var(--step-1); }
#contact .ct-status[data-tone="error"] { color: var(--accent); }

#contact .ct-note {
  grid-column: 2; grid-row: 6;
  max-width: 44ch; margin-top: var(--space-4);
  font-size: var(--t-small); line-height: 1.6; color: var(--muted);
}
#contact .ct-note p + p { margin-top: var(--space-1); }
#contact .ct-note a { color: var(--ink); text-underline-offset: .3em; overflow-wrap: anywhere; }

@media (prefers-reduced-motion: no-preference) {
  #contact .ct-knot g { transition: transform 600ms var(--ct-settle), opacity 600ms var(--ct-settle); }
}

@media (min-width: 64rem) {
  /* The same twelve columns as every section: the thread in col 2, the letter from col 3 */
  #contact {
    --ct-cg: var(--cols-gap);
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }
  #contact .ct-rail, #contact .ct-thread { grid-column: 2; }
  #contact .ct-letter, #contact .ct-form, #contact .ct-note { grid-column: 3 / 8; }
  #contact .ct-title { grid-column: 3 / -1; }
  #contact .ct-photo { grid-column: 4 / -1; aspect-ratio: 21 / 9; }
  #contact .ct-caption { grid-column: 4 / -1; }
  #contact .ct-letter { max-width: 40ch; }
}

/* ---- Writing feel: warm paper, faint ruled lines, a soft glow when you write ---- */
#contact .ct-form { position: relative; }
#contact .ct-field { position: relative; }
#contact .ct-field textarea {
  --ct-rule: 1.75rem;
  padding: .75rem .875rem;
  line-height: var(--ct-rule);
  border-color: color-mix(in srgb, var(--ink) 18%, transparent);
  background-color: color-mix(in srgb, #fbf6ea 70%, var(--bg));
  background-image: linear-gradient(to bottom, transparent calc(var(--ct-rule) - 1px), color-mix(in srgb, var(--accent-2) 22%, transparent) calc(var(--ct-rule) - 1px));
  background-size: 100% var(--ct-rule);
  background-attachment: local;
  background-origin: content-box;
  background-clip: padding-box;
  transition: border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out);
}
#contact .ct-field textarea:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--ink) 20%);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent), 0 0 28px color-mix(in srgb, var(--accent) 14%, transparent);
}
#contact .ct-count {
  position: absolute; right: 1.75rem; bottom: .55rem;
  font-size: .8125rem; color: var(--muted); font-style: italic;
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-2) var(--ease-out);
}
#contact .ct-count.is-on { opacity: .85; }

/* ---- The send ritual ---- */
#contact .ct-stage[hidden], #contact .ct-thanks[hidden] { display: none; }
#contact .ct-stage {
  position: absolute; inset: 0; z-index: 3;
  display: grid; place-items: center;
  pointer-events: none; overflow: visible;
}
#contact .ct-stage > * { grid-area: 1 / 1; }
#contact .ct-env { position: relative; width: min(15rem, 70%); aspect-ratio: 3 / 2; will-change: transform, opacity; }
#contact .ct-env svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
#contact .ct-env-paper { fill: color-mix(in srgb, #fbf6ea 85%, var(--bg)); stroke: color-mix(in srgb, var(--ink) 25%, transparent); stroke-width: 1; }
#contact .ct-env-fold { stroke: color-mix(in srgb, var(--ink) 28%, transparent); stroke-width: 1; }
#contact .ct-env-thread { stroke: #9e3b2e; stroke-width: var(--thread-w); }
#contact .ct-env-text {
  position: absolute; inset: 16% 12%; overflow: hidden;
  font-family: var(--font-display); font-style: italic; font-size: .8125rem; line-height: 1.35; color: var(--ink);
}
#contact .ct-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: color-mix(in srgb, #e8c9a0 80%, #fff); box-shadow: 0 0 10px 2px color-mix(in srgb, #e8c9a0 60%, transparent);
  opacity: 0; will-change: transform, opacity;
}
#contact .ct-dot:nth-of-type(1) { margin: -60px 0 0 -90px; }
#contact .ct-dot:nth-of-type(2) { margin: 20px 0 0 -120px; }
#contact .ct-dot:nth-of-type(3) { margin: -90px 0 0 40px; }
#contact .ct-dot:nth-of-type(4) { margin: 50px 0 0 100px; }
#contact .ct-dot:nth-of-type(5) { margin: -10px 0 0 130px; }
#contact .ct-dot:nth-of-type(6) { margin: 70px 0 0 -30px; }

#contact .ct-thanks {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: var(--space-3);
}
#contact .ct-thanks:focus { outline: none; }
#contact .ct-thanks-text { font-family: var(--font-display); font-style: italic; font-size: var(--step-2); line-height: 1.25; max-width: 24ch; text-wrap: balance; }
#contact .ct-again {
  min-height: 2.75rem; padding: 0 .1rem;
  border: 0; border-bottom: 1px solid currentColor; background: none; color: var(--ink);
  font: inherit; font-size: 1rem; cursor: pointer;
  transition: color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out);
}
#contact .ct-again:hover { color: var(--accent); }
#contact .ct-again:focus-visible { outline: 2px solid var(--accent); outline-offset: .3rem; }

/* The acknowledgement is carried by the thanks block; the live region still speaks it */
#contact .ct-form:has(.ct-thanks:not([hidden])) .ct-status {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  #contact .ct-field textarea, #contact .ct-count { transition-duration: var(--dur-2); }
}

/* the hands reach up to the top edge: keep the fingertips in the wide crop */
#contact .ct-photo img { object-position: 50% 0; }
