/* The contact page: what happens next on the left, the form card on the right.
   Values come from tokens.css; shared parts (buttons, the direct lines, the lead) from styles.css.
   The form is driven by its own radio buttons through :has(), so both paths, and the
   partnership variant, work before contact.js loads and without it. */

/* ---------- The page: one navy section under the header ---------- */

.contact {
  padding-block: var(--space-7) var(--space-8);
}

.contact-grid {
  display: grid;
  gap: var(--space-7);
}

/* The title, then the form, then what happens next: on a phone the form comes before the
   small print. From 900px the title and the small print share the left column. */
.contact-copy,
.contact-aside {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
  align-content: start;
}

.contact-block {
  display: grid;
  gap: var(--space-3);
  padding-block-start: var(--space-5);
  border-top: var(--hair) solid var(--rule);
}

.contact-block h2 {
  font-size: var(--text-lg);
  font-weight: var(--heading-weight);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-heading);
}

.contact-block p {
  max-width: var(--measure);
  color: var(--fg-soft);
}

/* The three steps, numbered like the process on the home page. */
.contact-next ol {
  display: grid;
  gap: var(--space-3);
}

.contact-next li {
  display: grid;
  grid-template-columns: var(--space-6) minmax(0, 1fr);
  align-items: baseline;
  column-gap: var(--space-3);
}

.contact-next-num {
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: var(--tracking-mono);
}

/* The founding client note: a small panel with the brass bar on its top edge. */
.contact-founding {
  position: relative;
  max-width: var(--measure);
  padding: var(--space-5) var(--space-5) var(--space-4);
  border: var(--hair) solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--fg-soft);
  font-size: var(--text-sm);
}

.contact-founding::before {
  content: "";
  position: absolute;
  inset-block-start: calc(var(--hair) * -1);
  inset-inline-start: var(--space-5);
  inline-size: var(--space-7);
  block-size: calc(var(--space-1) + var(--hair-strong));
  background: var(--brass);
}

/* ---------- The form card: a light island on the navy ---------- */

/* It carries the name a pressed Book a call button borrows on the way here (site.js),
   so the button grows into the card. */
.contact-card {
  /* Field borders: darker than a rule, so an empty input still reads as one (3.7:1 on white). */
  --field-line: color-mix(in srgb, var(--ink-soft) 60%, var(--line));

  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--paper);
  view-transition-name: contact-card;
}

@media (min-width: 640px) {
  .contact-card {
    padding: var(--space-6);
  }
}

@media (min-width: 900px) {
  .contact {
    padding-block: var(--space-8) var(--space-9);
  }

  /* The first row is only as tall as the title, so the small print sits right under it
     however tall the form is. */
  .contact-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-rows: auto 1fr;
    gap: var(--space-5);
    align-items: start;
  }

  .contact-copy,
  .contact-aside {
    grid-column: 1 / span 5;
    padding-inline-end: var(--space-5);
  }

  .contact-card {
    grid-area: 1 / 6 / span 2 / -1;
  }
}

/* ---------- Form ---------- */

.form {
  display: grid;
  gap: var(--space-5);
}

/* The checked radio picks the path. */
.form:has(input[name="mode"][value="sure"]:checked) .only-unsure,
.form:has(input[name="mode"][value="unsure"]:checked) .only-sure {
  display: none;
}

/* A partnership has one path and no budget: the switch and the budget go, the message
   box stays whatever the switch last said, and its label and hint change their words. */
.form:has(input[name="topic"][value="partner"]:checked) .mode,
.form:has(input[name="topic"][value="partner"]:checked) .only-client,
.form:has(input[name="topic"][value="partner"]:checked) .only-unsure,
.form:has(input[name="topic"][value="partner"]:checked) .for-client {
  display: none;
}

.form:has(input[name="topic"][value="partner"]:checked) .only-sure:not(.only-client) {
  display: grid;
}

.for-partner {
  display: none;
}

.form:has(input[name="topic"][value="partner"]:checked) .for-partner {
  display: inline;
}

/* The honeypot: off screen for people, still in the form for bots. */
.hp {
  position: absolute;
  inline-size: var(--hair);
  block-size: var(--hair);
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.form-row {
  display: grid;
  gap: var(--space-5);
}

@media (min-width: 640px) {
  .form-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.mode,
.checks {
  min-width: 0;
  padding: 0;
  border: 0;
}

.field,
.mode,
.checks {
  display: grid;
  gap: var(--space-2);
  align-content: start;
}

.field label,
.mode legend,
.checks legend {
  padding: 0;
  font-size: var(--text-sm);
  font-weight: 600;
}

.mode legend,
.checks legend {
  margin-block-end: var(--space-2);
}

.field-optional {
  margin-inline-start: var(--space-1);
  color: var(--fg-soft);
  font-size: var(--text-xs);
  font-weight: 400;
}

/* The two paths through the form, as one switch. */
.mode-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: var(--hair) solid var(--field-line);
  border-radius: var(--radius-sm);
  background: var(--white);
}

.mode-option,
.chip {
  position: relative;
  display: block;
}

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

.mode-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-h);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: var(--leading-snug);
  text-align: center;
  transition:
    background-color var(--fast) var(--ease),
    color var(--fast) var(--ease);
}

.mode-option + .mode-option span {
  border-inline-start: var(--hair) solid var(--field-line);
}

.mode-option input:checked + span {
  background: var(--navy);
  color: var(--white);
  font-weight: 600;
}

/* The inputs are invisible, so the ring goes on what the visitor sees instead. */
.mode-options:has(:focus-visible),
.chip input:focus-visible + span {
  outline: var(--focus-w) solid var(--focus);
  outline-offset: var(--hair-strong);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip span {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-h-sm);
  padding: var(--space-2) var(--space-4);
  border: var(--hair) solid var(--field-line);
  border-radius: var(--radius-pill);
  background: var(--white);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  transition:
    background-color var(--fast) var(--ease),
    border-color var(--fast) var(--ease),
    box-shadow var(--fast) var(--ease);
}

.chip:hover span {
  border-color: var(--ink);
}

.chip input:checked + span {
  border-color: var(--teal);
  background: var(--teal-tint);
  box-shadow: inset 0 0 0 var(--hair) var(--teal);
  font-weight: 500;
}

.field input,
.field select,
.field textarea {
  inline-size: 100%;
  min-height: var(--control-h);
  padding: var(--space-3);
  border: var(--hair) solid var(--field-line);
  border-radius: var(--radius-sm);
  background-color: var(--white);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-snug);
  transition:
    border-color var(--fast) var(--ease),
    box-shadow var(--fast) var(--ease);
}

.field textarea {
  min-height: calc(var(--control-h) * 3);
  line-height: var(--leading-body);
  resize: vertical;
}

/* A drawn caret, so the select matches the inputs on every platform. */
.field select {
  appearance: none;
  padding-inline-end: var(--space-7);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position:
    right calc(var(--space-4) + var(--space-1) + var(--hair)) center,
    right var(--space-4) center;
  background-size: calc(var(--space-1) + var(--hair)) calc(var(--space-1) + var(--hair));
  background-repeat: no-repeat;
  cursor: pointer;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: var(--ink);
}

.field [aria-invalid="true"] {
  border-color: var(--error);
  box-shadow: inset 0 0 0 var(--hair) var(--error);
}

.field-hint {
  color: var(--fg-soft);
  font-size: var(--text-sm);
}

/* Under the button: what happens to what is sent, with the policy one press away. */
.form-privacy {
  color: var(--fg-soft);
  font-size: var(--text-sm);
}

.field-error {
  color: var(--error);
  font-size: var(--text-sm);
  font-weight: 500;
}

.form-summary {
  padding: var(--space-4);
  border: var(--hair) solid var(--error);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--error);
  font-size: var(--text-sm);
  font-weight: 500;
}

.form-summary ul {
  display: grid;
  gap: var(--space-1);
  margin-block-start: var(--space-2);
}

.form-summary a {
  color: var(--error);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}

/* ---------- A plan attached from the founders page ---------- */

/* What is attached and Remove share the first line; the plan itself opens under them. */
.plan {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0 var(--space-4);
  padding: var(--space-2) var(--space-4);
  border: var(--hair) solid var(--teal);
  border-radius: var(--radius-md);
  background: var(--teal-tint);
  font-size: var(--text-sm);
}

.plan details {
  grid-column: 1 / -1;
}

.plan summary {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-h-sm);
  color: var(--link);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: var(--hair);
  text-underline-offset: var(--space-1);
  list-style: none;
  cursor: pointer;
}

.plan summary::-webkit-details-marker {
  display: none;
}

.plan summary:hover {
  color: var(--link-hover);
}

.plan pre {
  max-block-size: calc(var(--space-10) * 2);
  margin: 0 0 var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: var(--leading-body);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow-y: auto;
}

.plan .link-button {
  min-height: var(--control-h-sm);
}

/* ---------- After sending ---------- */

.form-done {
  display: grid;
  gap: var(--space-4);
  justify-items: start;
  padding-block: var(--space-5);
}

.form-done h2,
.form-status h2 {
  font-size: var(--text-xl);
}

/* Focus lands on these so screen readers announce them; they are not controls, so no ring. */
.form-done h2:focus-visible,
.form-status:focus-visible {
  outline: 0;
}

.form-done p,
.form-status p {
  max-width: var(--measure);
  color: var(--fg-soft);
}

.form-done .link-button {
  min-height: var(--control-h-sm);
}

/* After a form post without JavaScript, the Worker sends the visitor back to #sent or #not-sent. */
.form-status {
  display: none;
}

.form-status:target {
  display: grid;
  gap: var(--space-3);
  justify-items: start;
}

.form-status--sent:target {
  padding-block: var(--space-5);
}

.form-status--sent a {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-h-sm);
  font-weight: 500;
}

.contact-card:has(#sent:target) .form {
  display: none;
}

.form-status--failed:target {
  gap: var(--space-2);
  margin-block-end: var(--space-5);
  padding: var(--space-4);
  border: var(--hair) solid var(--error);
  border-radius: var(--radius-sm);
  background: var(--white);
}

.form-status--failed h2 {
  color: var(--error);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  font-stretch: 100%;
  letter-spacing: 0;
}

.form-status--failed p {
  color: var(--ink);
  font-size: var(--text-sm);
}
