/* The Disciples — homepage.
 *
 * A Messages-style conversation played over the wordmark. The logo is fixed in
 * the middle of the viewport and the conversation scrolls across it.
 *
 * Loaded on top of styles.css, which owns the tokens and the wordmark layers.
 */

:root {
  --sf: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont,
        system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --size: clamp(22px, 3.1vw, 50px);
  --col: min(1150px, 100% - 2 * clamp(16px, 5vw, 64px));
  --muted: color-mix(in srgb, var(--tape) 45%, transparent);
  --field-line: color-mix(in srgb, var(--tape) 16%, transparent);
}

html { scroll-padding-top: env(safe-area-inset-top, 0px); }

body {
  font-family: var(--sf);
  padding-top: env(safe-area-inset-top, 0px);
}

/* ---------- the wordmark, behind everything ---------- */

.logo {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 0;
}

.logo h1 {
  margin: 0;
  width: clamp(126px, 27vw, 414px);
}

/* The frames are absolutely positioned over the type, so the stack needs the
   type's own aspect ratio to hold its height before the SVGs land. */
.wordmark__frames { aspect-ratio: 8644 / 2353.76; }
.wordmark__frames > svg { position: absolute; inset: 0; height: 100%; }

/* ---------- the conversation ---------- */

main {
  position: relative;
  z-index: 1;
  width: var(--col);
  margin: 0 auto;
  padding: clamp(40px, 12vh, 140px) 0 300px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* The column spans the page so bubbles can sit at either edge, but it must
     not swallow clicks meant for the logo behind it. */
  pointer-events: none;
}

main a,
main button,
main input,
main form { pointer-events: auto; }

.stamp {
  align-self: center;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}

.row { display: flex; flex-direction: column; }
.row.them { align-items: flex-start; }
.row.you { align-items: flex-end; }
.row.gap { margin-top: 22px; }

.bubble {
  --c: var(--speak-them);
  position: relative;
  max-width: min(72%, 16em);
  font-size: var(--size);
  line-height: 1.15;
  letter-spacing: -0.012em;
  padding: 0.42em 0.85em 0.48em;
  border-radius: 0.95em;
  background: var(--c);
  color: #000;
  overflow-wrap: break-word;
  animation: pop 0.42s cubic-bezier(0.2, 1.45, 0.45, 1) both;
}

.them .bubble { transform-origin: bottom left; }
.you .bubble { --c: var(--speak-you); transform-origin: bottom right; }

@keyframes pop {
  from { transform: scale(0.5) translateY(12px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* The tail is masked rather than drawn, so everything outside the curl stays
   transparent and the wordmark shows through it. */
.bubble.tail::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 0.95em;
  height: 1.03em;
  background: var(--c);
  -webkit-mask: var(--tail) no-repeat 0 0 / 100% 100%;
          mask: var(--tail) no-repeat 0 0 / 100% 100%;
}

:root {
  --tail: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 26'%3E%3Cpath d='M10 0 C10 13 8 21 0 26 C7 26 16 22.4 22 22.7 L24 22.8 L24 0 Z'/%3E%3C/svg%3E");
}

.them .bubble.tail::after { left: -0.4em; }
.you .bubble.tail::after { right: -0.4em; transform: scaleX(-1); }

.bubble a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.14em;
}

.bubble a:focus-visible,
.bubble button:focus-visible {
  outline: 3px solid #000;
  outline-offset: 3px;
  border-radius: 4px;
}

.bubble .btns { display: flex; flex-wrap: wrap; gap: 0.4em; }

.bubble .btns a,
.bubble .btns button,
.bubble form button {
  font: inherit;
  font-size: 0.62em;
  text-decoration: none;
  background: #000;
  color: #fff;
  border: 0;
  cursor: pointer;
  padding: 0.45em 0.9em;
  border-radius: 999px;
}

.bubble form { display: flex; gap: 0.35em; font-size: 0.62em; }
.bubble form button { font-size: 1em; }

.bubble form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.45em 0.9em;
  background: #fff;
  color: #000;
  outline: none;
}

.bubble form button:disabled { opacity: 0.45; cursor: default; }

/* The honeypot field in the signup form. Clipped to nothing rather than
   display:none, because it has to be in the layout for a form filler to find
   it, and a bot that checks whether a field is rendered is a bot that skips
   anything display:none. Nothing points at it: no label, no tab stop, no
   pointer. See mailingList() in chat.js for what filling it costs.

   Selector deliberately heavier than `.bubble form input` above, which
   otherwise wins on specificity and hands the decoy that rule's width,
   padding and border — a stray visible box beside the email field. */
.bubble form input.decoy {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  pointer-events: none;
}

.typing {
  display: inline-flex;
  gap: 0.32em;
  align-items: center;
  padding: 0.7em 0.85em;
  border-radius: 1.2em;
  background: var(--speak-them);
  animation: pop 0.3s cubic-bezier(0.2, 1.45, 0.45, 1) both;
  transform-origin: bottom left;
}

.typing i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #000;
  opacity: 0.3;
  animation: dot 1.1s infinite;
}

.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }

@keyframes dot {
  0%, 60%, 100% { opacity: 0.25; transform: none; }
  30% { opacity: 0.8; transform: translateY(-3px); }
}

.receipt { font-size: 12px; color: var(--muted); margin: 5px 4px 0 0; }

/* ---------- the bar ---------- */

.bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 2;
  padding: 18px clamp(16px, 5vw, 64px)
           calc(18px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--ground) 78%, transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 720px;
}

.pills button {
  font: inherit;
  font-size: clamp(14px, 1.3vw, 17px);
  color: #000;
  background: var(--speak-you);
  border: 0;
  border-radius: 999px;
  padding: 0.55em 1em;
  cursor: pointer;
  animation: pop 0.35s cubic-bezier(0.2, 1.45, 0.45, 1) both;
  transition: transform 0.15s;
}

.pills button:hover { transform: translateY(-2px); }
.pills button:focus-visible { outline: 3px solid var(--tape); outline-offset: 3px; }

.field {
  position: relative;
  width: min(600px, 100%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ground);
  border: 1px solid var(--field-line);
  border-radius: 999px;
  padding: 5px 5px 5px 20px;
}

.field:focus-within { border-color: var(--tape); }

.field input {
  flex: 1;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 17px;
  color: var(--tape);
  caret-color: var(--tape);
  padding: 9px 0;
}

/* During playback the real field is inert and a fake layer is typed into, so
   the caret and the text can be animated. */
.field input[readonly] { color: transparent; }

.ghost {
  position: absolute;
  left: 20px; right: 56px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
  display: flex;
  align-items: center;
  color: var(--tape);
}

.caret {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  background: var(--tape);
  margin-left: 1px;
  animation: caret 1.05s steps(1) infinite;
}

@keyframes caret { 50% { opacity: 0; } }

.field.live:focus-within .ghost,
.field.has-text .ghost { display: none; }

.send {
  flex: none;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background: var(--tape);
  color: var(--ground);
  display: grid;
  place-items: center;
  transition: opacity 0.15s, transform 0.15s;
}

.send:disabled { opacity: 0.18; cursor: default; }
.send:not(:disabled):active { transform: scale(0.9); }
.send:focus-visible { outline: 3px solid var(--speak-you); outline-offset: 3px; }
.send svg { width: 17px; height: 17px; }

/* Only ever one of the two showing. The stop square fills its own viewBox, so
   its size is set here rather than by a rect inside the icon. */
.send__stop { display: none; width: 11px; height: 11px; }
.send.is-stop .send__arrow { display: none; }
.send.is-stop .send__stop { display: block; }

/* ---------- the two links ---------- */

/* Small, underlined, in the same place the tape labels were. Nothing but
   text: no block, no angle, nothing competing with the bubbles above. */

.links {
  display: flex;
  gap: 22px;
}

.links a,
.links button {
  font: inherit;
  font-size: 13px;
  line-height: 1.3;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 2px 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.28em;
  transition: color 160ms ease-out;
}

.links a:hover,
.links button:hover,
.links a:focus-visible,
.links button:focus-visible { color: var(--tape); }

.links a:focus-visible,
.links button:focus-visible { outline: 2px solid var(--tape); outline-offset: 4px; }

/* ---------- the copy, as it sits in the HTML ---------- */

/* Everything the conversation says is written into index.html and read from
   there by chat.js, which then removes the block. This is what a crawler sees
   and what is left when there is no script, so it is laid out to be read.

   The .js class is set by an inline script in <head>, before the body paints,
   so with a script running this never flashes up. Without one, nothing hides
   it. */

.js .source,
.js .wordmark__still { display: none; }

.wordmark__still { display: block; width: 100%; height: auto; }

.source {
  position: relative;
  z-index: 1;
  width: var(--col);
  margin: 0 auto;
  /* Clears the fixed wordmark, which sits in the middle of the viewport. */
  padding: 56vh 0 96px;
  font-size: clamp(18px, 2.2vw, 28px);
  line-height: 1.3;
}

.source h2 {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 52px 0 18px;
}

.source h3 {
  font-size: inherit;
  font-weight: 400;
  margin: 0 0 10px;
}

.source ol,
.source ul { list-style: none; margin: 0; padding: 0; }

.source li,
.source p,
.source h3 {
  display: block;
  max-width: 16em;
  width: fit-content;
  margin-bottom: 10px;
  padding: 0.42em 0.85em 0.48em;
  border-radius: 0.95em;
  background: var(--speak-them);
  color: #000;
}

/* The visitor's side of the opening, and the questions they ask. */
.source li[data-side="v"],
.source li[data-side="hesitate"],
.source h3 {
  background: var(--speak-you);
  margin-left: auto;
  text-align: right;
}

.source section { margin-bottom: 26px; }

.source a { color: inherit; text-decoration: underline; }

/* Trigger words are matching data, not something to read. */
.source [data-on] { position: relative; }

@media (max-width: 640px) {
  .bubble { max-width: 86%; }
  main { padding-bottom: 330px; }
}

@media (prefers-reduced-motion: reduce) {
  .bubble, .typing, .pills button { animation: none; }
  .caret { animation: none; }
  .pills button:hover { transform: none; }
}
