/* Book a demo: the modal every "Book a demo" link opens (demo.js).
   After Groundswell Studio's booking dialog, in the Ottawa night tokens: the
   pitch on the left (heading and one paragraph), the form on the
   right. A native <dialog> opened with showModal(), so focus stays inside,
   Escape closes it and the page behind is inert.

   Field borders: the design system's hairline (ink-700) is 1.3:1 on the
   canvas, under the 3:1 a field's edge needs, so fields take a mix of ink-400
   and ink-700 (3.3:1 on ink-950, 3.2:1 on ink-900). Focus is signal-500;
   errors are signal-400 text (6.7:1). */
.demo {
  --demo-pad: clamp(32px, 3.4vw, 48px);
  --field-border: color-mix(in srgb, var(--ink-400) 50%, var(--ink-700));
  width: min(100vw - 48px, 1000px);
  max-width: none;
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  border: var(--hairline);
  border-radius: var(--radius-sm);
  overflow: hidden;
  color: var(--ink-100);
  background-color: var(--ink-900);
  color-scheme: dark;
  font-family: var(--font-sans);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.32);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 150ms ease-in, transform 150ms ease-in, display 150ms allow-discrete, overlay 150ms allow-discrete;
}
.demo[open] {
  display: flex;
  opacity: 1;
  transform: none;
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out), display 180ms allow-discrete, overlay 180ms allow-discrete;
}
@starting-style { .demo[open] { opacity: 0; transform: translateY(8px); } }
.demo::backdrop {
  background-color: rgba(13, 13, 13, 0.8);
  opacity: 0;
  transition: opacity 150ms ease-in, display 150ms allow-discrete, overlay 150ms allow-discrete;
}
.demo[open]::backdrop { opacity: 1; }
@starting-style { .demo[open]::backdrop { opacity: 0; } }

html.demo-open { overflow: hidden; scrollbar-gutter: stable; }

.demo-sheet {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 9fr) minmax(0, 11fr);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* --- the pitch ------------------------------------------------------- */
.demo-pitch {
  display: flex;
  flex-direction: column;
  padding: var(--demo-pad);
  background-color: var(--ink-950);
}
.demo-title {
  margin: 0;
  max-width: 9em;
  font-size: clamp(32px, 3.2vw, 44px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.06;
  color: var(--white);
  text-wrap: balance;
}
.demo-text { margin: 20px 0 0; font-size: 17px; line-height: 1.55; color: var(--ink-400); }

/* The heading and the sent line take focus from the script so a screen
   reader starts there; they are not controls, so no ring (the site's
   [tabindex]:focus-visible rule would draw one). */
.demo .demo-title:focus-visible,
.demo .demo-ready:focus-visible { outline: none; }

/* --- close ------------------------------------------------------------- */
.demo-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-button);
  color: var(--ink-400);
  background: none;
  cursor: pointer;
  transition: color 150ms ease, background-color 150ms ease;
}
.demo-close:hover { color: var(--white); background-color: var(--ink-800); }
.demo-close svg { width: 20px; height: 20px; display: block; }

/* --- the form ---------------------------------------------------------- */
.demo-form,
.demo-done { padding: 72px var(--demo-pad) 40px; }
.demo-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 16px;
  align-content: start;
  margin: 0;
}
.demo-form[hidden],
.demo-done[hidden] { display: none; }
.demo-wide { grid-column: 1 / -1; }
.demo-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.demo-field > label,
.demo-field > legend {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  width: 100%;
  margin: 0 0 8px;
  padding: 0;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--white);
}
.demo-optional { font-size: 14px; font-weight: 400; color: var(--ink-400); }

.demo-field > input,
.demo-field > textarea {
  display: block;
  width: 100%;
  min-height: 46px;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius-button);
  font: 400 16px/1.5 var(--font-sans);
  color: var(--white);
  background-color: var(--ink-950);
  caret-color: var(--signal-500);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.demo-field > textarea { min-height: 104px; resize: vertical; }
.demo-field > input:hover,
.demo-field > textarea:hover { border-color: var(--ink-400); }
.demo-field > input:focus,
.demo-field > textarea:focus {
  outline: none;
  border-color: var(--signal-500);
  box-shadow: 0 0 0 1px var(--signal-500);
}
.demo-field > input:-webkit-autofill {
  -webkit-text-fill-color: var(--white);
  -webkit-box-shadow: inset 0 0 0 99px var(--ink-950);
}
.demo-field > input[aria-invalid="true"] { border-color: var(--signal-400); }
.demo-err { margin: 6px 0 0; font-size: 14px; line-height: 1.4; color: var(--signal-400); }
.demo-err[hidden] { display: none; }

/* "I'm from": a radio group drawn as a segmented control. */
.demo-opts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius-button);
  background-color: var(--ink-950);
}
.demo-opt {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 15px;
  line-height: 1.2;
  text-align: center;
  color: var(--ink-200);
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}
.demo-opt:hover { color: var(--white); background-color: var(--ink-800); }
.demo-opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.demo-opt:has(:checked) { font-weight: 600; color: var(--ink-950); background-color: var(--ink-100); }
.demo-opts:has(:focus-visible) { border-color: var(--signal-500); box-shadow: 0 0 0 1px var(--signal-500); }

.demo-foot { margin-top: 4px; }
.demo-status { margin: 0 0 12px; font-size: 15px; line-height: 1.5; color: var(--signal-400); }
.demo-status:empty { display: none; }
.demo-status a { color: var(--signal-400); text-underline-offset: 3px; }
.demo-send { width: 100%; border: 0; cursor: pointer; }
.demo-send:disabled { cursor: progress; background-color: var(--signal-700); }

/* --- sent -------------------------------------------------------------- */
.demo-done { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 28px; }
.demo-ready {
  margin: 0;
  font-size: clamp(24px, 2.1vw, 30px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--white);
  text-wrap: balance;
}
.demo-again {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius-button);
  font: 600 15px/1 var(--font-sans);
  color: var(--white);
  background: none;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease;
}
.demo-again:hover { border-color: var(--ink-400); background-color: var(--ink-800); }

/* --- tablet: one column, the pitch above the form ---------------------- */
@media (max-width: 859px) {
  .demo { --demo-pad: 40px; width: min(100vw - 32px, 600px); }
  .demo-sheet { display: block; }
  .demo-pitch { display: block; padding-bottom: 0; background: none; }
  .demo-title { max-width: none; padding-right: 48px; }
  .demo-form { padding-top: 28px; }
  .demo-sheet:has(.demo-form[hidden]) .demo-pitch { display: none; }
}

/* --- phone: a full-screen sheet; the pitch is the heading, one line and
   a small founder row; the button stays in reach while the fields scroll */
@media (max-width: 599px) {
  .demo {
    --demo-pad: 16px;
    width: 100vw;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
  }
  .demo-pitch { padding-top: 20px; }
  .demo-title { font-size: 28px; }
  .demo-text { margin-top: 10px; font-size: 16px; line-height: 1.5; }
  .demo-text-more { display: none; }
  .demo-sheet { scroll-padding-bottom: 100px; }
  .demo-form { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 24px var(--demo-pad) 0; }
  .demo-field > textarea { min-height: 88px; }
  .demo-opts { grid-template-columns: minmax(0, 1fr); }
  .demo-opt { justify-items: start; padding-inline: 12px; text-align: left; }
  .demo-foot {
    position: sticky;
    bottom: 0;
    margin: 0 calc(var(--demo-pad) * -1);
    padding: 12px var(--demo-pad) calc(12px + env(safe-area-inset-bottom));
    background-color: var(--ink-900);
    border-top: var(--hairline);
  }
  .demo-done { padding-block: 72px 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .demo, .demo[open], .demo::backdrop, .demo[open]::backdrop { transition: none; transform: none; }
}
