/* The bug form. Tokens are Mimir's (src/style.css, site/style.css), both
   themes, copied by hand: there's no shared source. */

@font-face {
  font-family: 'Schibsted Grotesk';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('fonts/SchibstedGrotesk-latin-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Schibsted Grotesk';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('fonts/SchibstedGrotesk-latinext-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg:          hsla(240, 20%, 97.5%, 1);
  --bg-raised:   hsla(0, 0%, 100%, 1);
  --ink:         hsla(227, 17%, 10%, 1);
  --ink-muted:   oklch(from var(--ink) 0.480 0.0032 286);
  --ink-faint:   oklch(from var(--ink) 0.700 0.0032 286);
  --accent:      hsla(210, 100%, 43%, 1);
  --accent-soft: hsla(210, 100%, 43%, 0.4);
  --on-accent:   hsla(0, 0%, 100%, 1);
  --hairline:    hsla(0, 0%, 0%, 0.12);
  --selection:   hsla(210, 100%, 44.5%, 0.16);
  --danger:      hsla(9, 67%, 51%, 1);
  /* The suggestion: clearly not the tester's own words, still easy to read. */
  --ghost:       var(--ink-muted);

  --sans: 'Schibsted Grotesk', ui-sans-serif, system-ui, sans-serif;

  --f--1: 0.889rem;
  --f-0:  1rem;
  --f-1:  1.125rem;
  --f-2:  1.266rem;
  --f-5:  1.802rem;

  --t-color: 80ms;
  --t-small: 120ms;
  --t-medium: 200ms;
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);

  --radius: 10px;
  --pad-y: 0.625rem;
  --pad-x: 0.875rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          hsla(240, 10%, 9%, 1);
    --bg-raised:   hsla(240, 9%, 12%, 1);
    --ink:         hsla(240, 4%, 88%, 1);
    --ink-muted:   oklch(from var(--ink) 0.680 0.0070 286);
    --ink-faint:   oklch(from var(--ink) 0.410 0.0065 286);
    --accent:      hsla(211, 100%, 64%, 1);
    --accent-soft: hsla(211, 100%, 64%, 0.4);
    --on-accent:   hsla(240, 10%, 9%, 1);
    --hairline:    hsla(0, 0%, 100%, 0.11);
    --selection:   hsla(211, 100%, 62.5%, 0.25);
    --danger:      hsla(10, 75%, 60%, 1);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: clip;
  background: var(--bg);
}

body {
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--f-0);
  font-weight: 300;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

::selection { background: var(--selection); }

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

main {
  max-width: 36rem;
  margin: 0 auto;
  padding:
    calc(3rem + env(safe-area-inset-top, 0px))
    max(1rem, env(safe-area-inset-right, 0px))
    calc(4rem + env(safe-area-inset-bottom, 0px))
    max(1rem, env(safe-area-inset-left, 0px));
}

h1 {
  font-size: var(--f-5);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.lede {
  margin-top: 0.5rem;
  font-size: var(--f-1);
  color: var(--ink-muted);
  text-wrap: pretty;
}

form { margin-top: 2.5rem; }

/* ---- text fields ----------------------------------------------------------- */

.field + .field,
.field + .choice,
.choice + .choice,
.choice + .field { margin-top: 1.25rem; }

label,
legend {
  display: block;
  font-weight: 500;
  margin-bottom: 0.375rem;
}

.optional { font-weight: 300; color: var(--ink-muted); }

/* A line of help between a label and its box. */
.hint {
  font-size: var(--f--1);
  color: var(--ink-muted);
  margin: -0.125rem 0 0.5rem;
  text-wrap: pretty;
}

/* The one follow-up question, shown only when the story has no steps. */
.followup { margin-top: 1.75rem; }

/* The textarea and its mirror share one grid cell. The mirror is in normal
   flow and sizes the cell; the textarea stretches to fill it. Everything
   that affects where a line wraps must be identical on both. */
.input {
  display: grid;
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  transition: border-color var(--t-color) var(--ease-standard), box-shadow var(--t-small) var(--ease-standard);
}

.input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input > textarea,
.input > .mirror,
.input > input {
  grid-area: 1 / 1;
  font: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  padding: var(--pad-y) var(--pad-x);
  border: 0;
  margin: 0;
  width: 100%;
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  tab-size: 4;
}

.input > textarea,
.input > input {
  color: var(--ink);
  caret-color: var(--accent);
  background: transparent;
  outline: none;
  appearance: none;
  border-radius: 0;
  resize: none;
  overflow: hidden;
  height: 100%;
  /* Above the mirror, so clicks and selection land on the real text. */
  position: relative;
}

.mirror {
  pointer-events: none;
  user-select: none;
}
.mirror .typed { color: transparent; }
.mirror .ghost { color: var(--ghost); }

.foot {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  /* Reserved, so a suggestion appearing never moves the page. */
  min-height: 1.75rem;
  margin-top: 0.25rem;
}

/* The suggestions switch: small, at the right end of the row under the
   story, while the accept button appears at the left end. Neither moves
   the other. */
.suggest-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0 auto;
  font-size: var(--f--1);
  font-weight: 400;
  color: var(--ink-muted);
  cursor: pointer;
}

.suggest-toggle input {
  appearance: none;
  flex: none;
  width: 1.75rem;
  height: 1rem;
  margin: 0;
  border-radius: 999px;
  background: var(--hairline);
  position: relative;
  cursor: pointer;
  transition: background-color var(--t-medium) var(--ease-standard);
}

.suggest-toggle input::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1rem - 4px);
  height: calc(1rem - 4px);
  border-radius: 50%;
  background: var(--bg-raised);
  box-shadow: 0 1px 2px hsla(0, 0%, 0%, 0.25);
  transition: transform var(--t-medium) var(--ease-standard);
}

.suggest-toggle input:checked { background: var(--accent); }
.suggest-toggle input:checked::after { transform: translateX(0.75rem); }
.suggest-toggle input:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }

.accept {
  font: inherit;
  font-size: var(--f--1);
  color: var(--ink-muted);
  background: none;
  border: 0;
  border-radius: 999px;
  padding: 0.125rem 0.625rem;
  cursor: pointer;
  transition: background-color var(--t-color) var(--ease-standard), color var(--t-color) var(--ease-standard);
}
.accept:hover { background: var(--hairline); color: var(--ink); }
.accept[hidden] { display: none; }

kbd {
  font: inherit;
  font-weight: 500;
  padding: 0 0.3125rem;
  border: 1px solid var(--hairline);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--ink);
}

/* No Tab key to speak of: the button is the way in. */
.accept .touch { display: none; }
@media (hover: none) and (pointer: coarse) {
  .accept .keys { display: none; }
  .accept .touch { display: inline; color: var(--ink); font-weight: 500; }
  .accept { padding: 0.25rem 0.75rem; background: var(--hairline); }
}

/* ---- choices --------------------------------------------------------------- */

fieldset { border: 0; min-width: 0; }

.segments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.segments label {
  margin: 0;
  font-weight: 400;
  cursor: pointer;
}

.segments input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segments span {
  display: inline-block;
  padding: 0.375rem 0.875rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--bg-raised);
  transition: background-color var(--t-color) var(--ease-standard), border-color var(--t-color) var(--ease-standard), color var(--t-color) var(--ease-standard);
}

.segments label:hover span { border-color: var(--ink-faint); }
.segments input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--bg); font-weight: 500; }
.segments input:focus-visible + span { outline: 2px solid var(--accent-soft); outline-offset: 2px; }

.field:has(#contact) { margin-top: 1.75rem; }

/* The honeypot: out of sight, out of the tab order, out of the a11y tree. */
.trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

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

.send {
  margin-top: 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

button#send,
button#again {
  font: inherit;
  font-weight: 500;
  color: var(--on-accent);
  background: var(--accent);
  border: 0;
  border-radius: 999px;
  padding: 0.625rem 1.375rem;
  cursor: pointer;
  transition: filter var(--t-color) var(--ease-standard), transform var(--t-small) var(--ease-standard);
}
button#send:hover,
button#again:hover { filter: brightness(1.08); }
button#send:active,
button#again:active { transform: scale(0.98); }
button#send:disabled { opacity: 0.6; cursor: default; }

/* Next to Send once the follow-up is asked: same size, so skipping the
   question never looks like the wrong choice. */
button#send-as-is {
  font: inherit;
  font-weight: 500;
  color: var(--ink);
  background: none;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: calc(0.625rem - 1px) calc(1.375rem - 1px);
  cursor: pointer;
  transition: border-color var(--t-color) var(--ease-standard), transform var(--t-small) var(--ease-standard);
}
button#send-as-is:hover { border-color: var(--ink-faint); }
button#send-as-is:active { transform: scale(0.98); }
button#send-as-is:disabled { opacity: 0.6; cursor: default; }
button#send-as-is:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 3px; }
button#send:focus-visible,
button#again:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 3px; }

.status {
  font-size: var(--f--1);
  color: var(--ink-muted);
}

.done { margin-top: 2.5rem; outline: none; }
.done h2 { font-size: var(--f-2); font-weight: 600; }
.done button { margin-top: 1.5rem; }

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}
