:root {
  color-scheme: light;

  --ground: #ffd02e;
  --ground-text: #5a4606;   /* secondary text on the yellow ground */
  --ink: #1c1326;
  --paper: #fffdf5;
  --paper-text: #645a6b;    /* secondary text on paper */
  --blue: #2438e8;
  --blue-deep: #1a2bc2;
  --error: #b8251a;

  --lift: 0 1px 0 rgb(120 80 0 / 0.12), 0 16px 28px -14px rgb(120 80 0 / 0.5);

  --display: "Gabarito", "Hanken Grotesk", system-ui, sans-serif;
  --body: "Hanken Grotesk", system-ui, sans-serif;

  --r-bubble: 1.5rem;
  --r-tail: 0.375rem;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
  scrollbar-color: var(--ink) var(--ground);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--blue);
}

::selection { background: var(--blue); color: var(--paper); }

h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
button, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.wrap {
  width: min(100% - 2rem, 60rem);
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 10;
  padding: 0.625rem 1rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
}
.skip-link:focus { top: 1rem; }

/* ---------- Header ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.25rem;
}

.wordmark {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.wordmark__bubble {
  display: inline-block;
  margin-inline: 0.2em;
  padding: 0.1em 0.5em 0.15em;
  border-radius: 0.8em 0.8em 0.8em 0.2em;
  background: var(--ink);
  color: var(--ground);
}

.top__link {
  font-weight: 600;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.25em;
}
.top__link:hover { text-decoration-color: var(--blue); }

/* ---------- Thread and bubbles ---------- */

.chat { padding-block: clamp(1.5rem, 6vw, 4.5rem) clamp(4rem, 10vw, 7rem); }

.thread {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
}

.msg { max-width: min(100%, 36rem); }
.msg--you { align-self: flex-end; }

.bubble {
  padding: 0.875rem 1.25rem;
  border-radius: var(--r-bubble) var(--r-bubble) var(--r-bubble) var(--r-tail);
  background: var(--paper);
  box-shadow: var(--lift);
  font-size: 1.0625rem;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.msg--you .bubble {
  border-radius: var(--r-bubble) var(--r-bubble) var(--r-tail) var(--r-bubble);
  background: var(--blue);
  color: var(--paper);
}

.msg:has(.bubble--hero) { max-width: 100%; }

.bubble--hero {
  padding: 0.22em 0.42em 0.3em;
  border-radius: 0.45em 0.45em 0.45em 0.1em;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(3rem, 13vw, 6rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  text-wrap: balance;
  transform: rotate(-1.5deg);
  transform-origin: 0 100%;
  margin-bottom: 0.5rem;
}

.bubble--lead {
  padding: 1.125rem 1.5rem;
  font-size: clamp(1.125rem, 2.4vw, 1.375rem);
  line-height: 1.4;
  text-wrap: pretty;
}

.bubble--error { color: var(--error); font-weight: 500; }

/* Messages added by the conversation pop in from their tail corner. */
.msg--in {
  animation: pop 420ms var(--ease-out) both;
  transform-origin: 0 100%;
}
.msg--you.msg--in { transform-origin: 100% 100%; }

@keyframes pop {
  from { opacity: 0; transform: translateY(0.5rem) scale(0.9); }
}

.typing {
  display: flex;
  gap: 0.375rem;
  padding: 1.125rem 1.25rem;
}
.typing i {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--ink);
  animation: dot 900ms ease-in-out infinite;
}
.typing i:nth-child(2) { animation-delay: 120ms; }
.typing i:nth-child(3) { animation-delay: 240ms; }

@keyframes dot {
  0%, 60%, 100% { transform: none; opacity: 0.35; }
  30% { transform: translateY(-0.3rem); opacity: 1; }
}

/* ---------- Composer ---------- */

.composer {
  margin-top: 1.5rem;
  padding: 1rem 1rem 0.75rem 1.5rem;
  border-radius: 1.75rem;
  background: var(--paper);
  box-shadow: var(--lift);
  transition: box-shadow 200ms var(--ease-out);
}
.composer:focus-within {
  box-shadow: 0 0 0 3px var(--ink), var(--lift);
}

.composer__label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--paper-text);
}

.composer__input {
  display: block;
  width: 100%;
  min-height: 3.5rem;
  max-height: 14rem;
  padding: 0.25rem 0 0;
  border: 0;
  background: none;
  resize: none;
  font-size: clamp(1.125rem, 2.4vw, 1.375rem);
  line-height: 1.4;
}
.composer__input:focus { outline: none; }
.composer__input::placeholder { color: var(--paper-text); opacity: 1; }

.composer__bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

.meter {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-right: auto;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--paper-text);
  font-variant-numeric: tabular-nums;
}
.meter__track { display: flex; gap: 0.25rem; }
.meter__track i {
  width: 1.25rem;
  height: 0.5rem;
  border-radius: 999px;
  background: #e6e0d3;
  transition: background-color 300ms var(--ease-out), transform 300ms var(--ease-out);
}
.meter__track i.is-on { background: var(--blue); transform: scaleY(1.25); }

.composer__skip {
  padding: 0.5rem 0.25rem;
  border: 0;
  background: none;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.25em;
}
.composer__skip:hover { color: var(--blue); }

.composer__send {
  display: grid;
  place-items: center;
  flex: none;
  width: 3rem;
  height: 3rem;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  color: var(--paper);
  transition: background-color 150ms, transform 150ms var(--ease-out);
}
.composer__send:hover { background: var(--blue-deep); }
.composer__send:active { transform: scale(0.94); }

.composer[aria-busy="true"] .composer__send,
.composer[aria-busy="true"] .composer__skip {
  opacity: 0.45;
  pointer-events: none;
}

/* ---------- Starters ---------- */

.starters { margin-top: 1.5rem; }
.starters__label {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ground-text);
}
.starters__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.625rem;
}

.chip {
  padding: 0.5rem 0.875rem;
  border: 2px solid var(--ink);
  border-radius: 1.375rem;
  background: none;
  font-size: 0.9375rem;
  font-weight: 500;
  text-align: left;
  transition: background-color 150ms, color 150ms, transform 150ms var(--ease-out);
}
.chip:hover { background: var(--ink); color: var(--ground); }
.chip:active { transform: scale(0.97); }

/* ---------- After submit ---------- */

.after {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-top: 1.5rem;
}
.after__note,
.noscript {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ground-text);
}
.noscript { margin-top: 1rem; }

.btn {
  display: inline-block;
  padding: 0.875rem 1.5rem;
  border: 0;
  border-radius: 999px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.0625rem;
  text-decoration: none;
  transition: transform 150ms var(--ease-out), background-color 150ms;
}
.btn:active { transform: scale(0.97); }
.btn--ink { background: var(--ink); color: var(--ground); }
.btn--ink:hover { background: #33243f; }
.btn--paper { background: var(--paper); color: var(--ink); }
.btn--paper:hover { background: var(--ground); }

[hidden] { display: none !important; }

/* ---------- Before you ask ---------- */

.faq { padding-bottom: clamp(4rem, 10vw, 7rem); }

.faq__title {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.25rem, 7vw, 4rem);
  line-height: 1;
  letter-spacing: -0.03em;
  margin-bottom: 2rem;
}

.thread--static { gap: 0.625rem; }
.thread--static .msg--you:not(:first-child) { margin-top: 1.75rem; }
.thread--static .bubble {
  font-size: clamp(1.0625rem, 2vw, 1.25rem);
  line-height: 1.45;
}
.thread--static h3.bubble { font-weight: 600; }

/* ---------- Close ---------- */

.close {
  background: var(--blue);
  color: var(--paper);
}
.close ::selection { background: var(--ground); color: var(--ink); }
.close :focus-visible { outline-color: var(--paper); }

.close__inner { padding-block: clamp(4rem, 10vw, 7rem) 2rem; }

.close__line {
  max-width: 14ch;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.5rem, 9vw, 5.5rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
  text-wrap: balance;
  margin-bottom: 2rem;
}

.close__meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: clamp(4rem, 10vw, 7rem);
  font-size: 0.9375rem;
  font-weight: 500;
  color: #dfe3ff;
}

/* ---------- Small screens ---------- */

@media (max-width: 40rem) {
  .composer { padding: 0.875rem 0.75rem 0.625rem 1.125rem; border-radius: 1.5rem; }
  .composer__bar { gap: 0.75rem; }
  .meter__label { display: none; }
  .msg { max-width: 92%; }
  .top__link { font-size: 0.9375rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .msg--in, .typing i { animation: none; }
  .typing i { opacity: 0.7; }
  * { transition-duration: 0.01ms !important; }
}

/* ---------- Motion ----------
   Everything here sits behind no-preference, so reduced-motion visitors get
   the finished page with no hidden states. `.intro` is set inline in <head>
   and removed by script.js once the opening has played; `.reveal-ready` is
   set by script.js, so nothing stays hidden if the script fails to load. */

.words .w {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  padding: 0 0.05em 0.14em;
  margin: 0 -0.05em -0.14em;
}
.words .w > span { display: inline-block; }

.composer__send { overflow: hidden; }
.composer__send svg { transition: transform 200ms var(--ease-out); }
.composer__send:hover svg { transform: translateY(-2px); }

.close { border-radius: clamp(1.5rem, 5vw, 3rem) clamp(1.5rem, 5vw, 3rem) 0 0; }

@media (prefers-reduced-motion: no-preference) {
  :root { --ease-pop: cubic-bezier(0.34, 1.4, 0.64, 1); }

  .msg--in { animation-timing-function: var(--ease-pop); }

  /* Opening: the conversation arrives one message at a time. */
  .intro .top { animation: fade 600ms ease-out backwards; }
  .intro .bubble--hero { animation: hero-pop 750ms var(--ease-pop) 120ms backwards; }
  .intro .bubble--hero .w > span {
    animation: rise 800ms var(--ease-out) backwards;
    animation-delay: calc(260ms + var(--i) * 90ms);
  }
  .intro .msg--lead {
    transform-origin: 0 100%;
    animation: pop 520ms var(--ease-pop) 800ms backwards;
  }
  .intro .composer { animation: lift-in 700ms var(--ease-out) 1000ms backwards; }
  .intro .starters__label { animation: fade 500ms ease-out 1250ms backwards; }
  .intro .starters__list li {
    animation: lift-in 500ms var(--ease-out) backwards;
    animation-delay: calc(1300ms + var(--n, 0) * 70ms);
  }
  .starters__list li:nth-child(2) { --n: 1; }
  .starters__list li:nth-child(3) { --n: 2; }

  /* Scroll: the Q&A plays out as an exchange, headlines rise word by word. */
  .reveal-ready .msg[data-reveal]:not(.is-in),
  .reveal-ready .btn[data-reveal]:not(.is-in) { opacity: 0; }
  .reveal-ready .words[data-reveal]:not(.is-in) .w > span { transform: translateY(115%); }

  .msg[data-reveal].is-in {
    transform-origin: 0 100%;
    animation: pop 520ms var(--ease-pop) 220ms backwards;
  }
  .msg--you[data-reveal].is-in { transform-origin: 100% 100%; animation-delay: 0ms; }
  .btn[data-reveal].is-in { animation: lift-in 600ms var(--ease-out) 450ms backwards; }
  .words[data-reveal].is-in .w > span {
    animation: rise 800ms var(--ease-out) backwards;
    animation-delay: calc(var(--i) * 55ms);
  }

  .composer__send.is-sending svg { animation: launch 450ms var(--ease-out); }
}

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(115%); } }
@keyframes lift-in { from { opacity: 0; transform: translateY(1.25rem); } }
@keyframes hero-pop { from { opacity: 0; transform: rotate(5deg) scale(0.55); } }
@keyframes launch {
  45% { transform: translateY(-160%); }
  46% { transform: translateY(160%); }
}
