/* The ground every tool stands on. Mobile first, because every one of these is
   opened on a phone by somebody who is in the middle of something else.
   
   What is here is what must not differ between tools: the palette, the touch
   floor, the safe-area padding, the focus ring, the dark-mode swap. A fix to
   any of those used to have to be made three times, and the copy that got
   missed was a bug nobody saw until somebody held that tool in their hand.

   What is NOT here is the accent. Each tool names its own --accent and
   --accent-pressed, in light and in dark, because that is the one thing that
   is genuinely its own. Everything below reads them.

   This file is copied into each tool's public/ by `npm run design`. Each tool
   has a test that fails if its copy has fallen behind this one. */

:root {
  --ink: #1b1b1f;
  --ink-soft: #55555f;
  --page: #fbfaf7;
  --card: #ffffff;
  --rule: #e2ded5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ece9e2;
    --ink-soft: #a6a29a;
    --page: #17171a;
    --card: #202024;
    --rule: #33333a;
  }
}

* {
  box-sizing: border-box;
}

html {
  /* A thumb should never pull the page out from under the form, and an
     over-scroll at the end of the questions should not reach the browser. */
  overscroll-behavior: contain;
}

body {
  margin: 0;
  /* No 300ms wait on a tap, and no grey OS flash — buttons paint their own
     pressed state below. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  background: var(--page);
  color: var(--ink);
  font:
    17px/1.55 ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}

#app {
  max-width: 34rem;
  margin: 0 auto;
  /* viewport-fit=cover hands us the whole screen, notch and home indicator
     included. These insets are what stops the first question and the button
     from sitting underneath them. */
  padding: calc(1.75rem + env(safe-area-inset-top))
    calc(1.25rem + env(safe-area-inset-right)) calc(4rem + env(safe-area-inset-bottom))
    calc(1.25rem + env(safe-area-inset-left));
}

h1 {
  /* 26px on a phone, 44px once there is room for it. */
  font-size: clamp(1.6rem, 1.15rem + 2vw, 2.75rem);
  line-height: 1.15;
  margin: 0 0 0.5rem;
}

h2 {
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 2rem 0 0.75rem;
}

.standfirst {
  color: var(--ink-soft);
  margin: 0 0 1.75rem;
}

#notice {
  background: var(--card);
  border-left: 3px solid var(--accent);
  padding: 0.75rem 0.9rem;
  margin: 0 0 1.5rem;
  border-radius: 0 6px 6px 0;
}

label {
  display: block;
  margin-bottom: 1.15rem;
  font-weight: 600;
}

label small {
  display: block;
  margin-top: 0.3rem;
  font-weight: 400;
  color: var(--ink-soft);
}

input,
select,
textarea,
button {
  /* 44px is the floor for a finger. A select sized only by its font lands at
     43, which is the kind of miss nobody sees without measuring. */
  min-height: 2.75rem;
}

@media (pointer: coarse) {
  input,
  select,
  button {
    min-height: 3rem;
  }
}

input,
select,
textarea {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.6rem 0.7rem;
  /* 17px inherited. Anything under 16 and iOS Safari zooms the whole page on
     focus, which on a long form is how somebody loses their place. */
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 6px;
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.8rem 1rem;
  font: inherit;
  font-weight: 600;
  color: var(--page);
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

button:active {
  background: var(--accent-pressed);
}

@media (hover: hover) and (pointer: fine) {
  button:hover {
    background: var(--accent-pressed);
  }
}
