/* The form written as a sentence: the enquiry form of a design studio, on a white page. The sentence is set in
   Fraunces, light; every blank is a real field with a hairline under it, and the only colour is the blue of a blank
   that needs a word, and of the line that signs the sentence once it is sent. */
:root {
  --page: #ffffff;          /* the page */
  --ink: #141414;           /* the sentence and what you write in it */
  --muted: #9a968e;         /* the words waiting in an empty blank, and the line under the sentence */
  --hair: #cfccc5;          /* the line under an empty blank */
  --accent: #2448ff;        /* a blank that needs a word, and the line that signs the sent sentence */
  --send: #141414;          /* the button */
  --send-ink: #ffffff;      /* the button's words */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 40px 16px;
}

.frase {
  position: relative;
  width: min(640px, 100%);
  margin: 0;
}

.frase__eyebrow {
  margin: 0 0 18px;
  font-size: 13px;
  font-weight: 560;
  font-stretch: 112%;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--muted);
}

/* ---------------------------------------------------------------- the sentence */
.frase__text {
  position: relative;
  margin: 0;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: 32px;
  font-weight: 300;
  font-optical-sizing: auto;
  font-variation-settings: 'SOFT' 50, 'WONK' 0;
  line-height: 1.62;
  letter-spacing: -0.005em;
  color: var(--ink);
}

/* every word is a token that the script can move on its spring without touching the layout */
.tok {
  display: inline-block;
  white-space: nowrap;
  will-change: transform;
}

/* ---------------------------------------------------------------- a blank */
.blank {
  position: relative;
  display: inline-block;
  vertical-align: baseline;
  --line: var(--hair);
  --line-w: 1px;
}

.blank.is-filled {
  --line: var(--ink);
}

.blank.is-focus {
  --line: var(--ink);
  --line-w: 1.5px;
}

.blank.is-wrong {
  --line: var(--accent);
  --line-w: 1.5px;
}

.blank__input {
  display: inline-block;
  width: 7ch;
  height: 1.3em;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  caret-color: var(--accent);
  font: inherit;
  font-weight: var(--wg, 400);
  font-variation-settings: 'SOFT' 100, 'WONK' 0;
  line-height: inherit;
  letter-spacing: inherit;
  vertical-align: baseline;
  -webkit-tap-highlight-color: transparent;
}

.blank__input::placeholder {
  color: var(--muted);
  font-style: italic;
  font-weight: 300;
  opacity: 1;
}

.blank.is-wrong .blank__input::placeholder {
  color: var(--accent);
}

.blank__input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 60px var(--page) inset;
}

/* the hidden twin that measures what is written (or the words waiting in the blank) */
.blank__mirror {
  position: absolute;
  left: 0;
  top: 0;
  visibility: hidden;
  white-space: pre;
  font-weight: var(--wg, 400);
  font-variation-settings: 'SOFT' 100, 'WONK' 0;
  pointer-events: none;
}

.blank__mirror.is-empty {
  font-style: italic;
  font-weight: 300;
}

/* the line under the blank */
.blank__line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.12em;
  height: var(--line-w);
  background: var(--line);
  transform-origin: 50% 50%;
  transition: background-color 0.25s ease, height 0.2s ease;
  pointer-events: none;
}

/* the caret of the library's preview, which writes without taking the focus */
.blank__caret {
  position: absolute;
  left: 0;
  top: 0.28em;
  width: 1.5px;
  height: 0.95em;
  background: var(--accent);
  opacity: 0;
  pointer-events: none;
}

.blank__caret.is-on {
  animation: blink 1.06s steps(1) infinite;
}

@keyframes blink {
  0%,
  50% {
    opacity: 1;
  }

  50.01%,
  100% {
    opacity: 0;
  }
}

/* a choice: a real select over the words it shows */
.blank__select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  font-size: 16px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.blank__face {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: calc(0.18em * var(--chev, 1));
  overflow: hidden;
  vertical-align: baseline;
  pointer-events: none;
  padding-bottom: 0.08em;
  margin-bottom: -0.08em;
}

.face__word {
  display: inline-block;
  font-weight: var(--wg, 400);
  font-variation-settings: 'SOFT' 100, 'WONK' 0;
  white-space: pre;
}

.face__word.is-going {
  position: absolute;
  left: 0;
  top: 0;
}

.face__chev {
  width: calc(0.38em * var(--chev, 1));
  height: 0.38em;
  flex: none;
  align-self: center;
  margin-top: 0.12em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.4s cubic-bezier(0.3, 1.7, 0.45, 1);
}

@media (hover: hover) and (pointer: fine) {
  .blank--choice:hover .face__chev {
    transform: translateY(0.06em);
  }

  .blank--choice:hover {
    --line: var(--ink);
  }
}

.blank__select:focus-visible ~ .blank__line {
  height: 1.5px;
  background: var(--ink);
}

.blank__select:focus-visible ~ .blank__face {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ---------------------------------------------------------------- the line that signs the sentence */
.frase__rule {
  display: block;
  height: 1.5px;
  margin-top: 22px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

/* ---------------------------------------------------------------- the button and the line beside it */
.frase__foot {
  position: relative;
  display: flex;
  align-items: center;
  gap: 22px;
  min-height: 48px;
  margin-top: 18px;
}

.send {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  height: 48px;
  margin: 0;
  padding: 0 26px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--send-ink);
  font: 560 16px/1 'Mona Sans Variable', system-ui, sans-serif;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}

/* the elastic pill: the colour swells under the pointer while the words widen */
.send__bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--send);
  transition: inset 0.6s cubic-bezier(0.3, 1.7, 0.45, 1), transform 0.16s ease-out;
}

.send__label {
  display: block;
  font-stretch: 100%;
  white-space: nowrap;
  transition: font-stretch 0.6s cubic-bezier(0.3, 1.7, 0.45, 1);
}

@media (hover: hover) and (pointer: fine) {
  .send:not([aria-disabled='true']):hover .send__bg {
    inset: -2px -5px;
  }

  .send:not([aria-disabled='true']):hover .send__label {
    font-stretch: 118%;
  }
}

.send:not([aria-disabled='true']):active .send__bg,
.send.is-pressed .send__bg {
  transform: scale(0.95);
}

.send[aria-disabled='true'] {
  cursor: default;
}

.send:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.frase__note {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 22px;
  font-size: 15px;
  font-weight: 400;
  line-height: 22px;
  color: var(--muted);
}

.note__line {
  display: block;
}

.note__line.is-going {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  pointer-events: none;
}

.note__line.is-wrong {
  color: var(--ink);
}

.note__line.is-sent {
  color: var(--ink);
}

/* the blanks named in the line: buttons that take you to them, and widen under the pointer (never underlined) */
.note__go,
.note__edit {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  font-stretch: 100%;
  cursor: pointer;
  transition: font-stretch 0.5s cubic-bezier(0.3, 1.7, 0.45, 1);
  -webkit-tap-highlight-color: transparent;
}

.note__edit {
  color: var(--ink);
}

@media (hover: hover) and (pointer: fine) {
  .note__go:hover,
  .note__edit:hover {
    font-stretch: 120%;
  }

  .note__edit:hover {
    color: var(--accent);
  }
}

.note__go:focus-visible,
.note__edit:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

.frase.is-sent .send {
  pointer-events: none;
}

/* for screen readers only */
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 520px) {
  .frase__text {
    font-size: 25px;
    line-height: 1.6;
  }

  .frase__foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  .frase__note {
    flex: none;
    width: 100%;
  }
}
