/* The controls of the sign-in pages: the labels, the fields and their focus
   and error states, the boxes for an error, a warning and a success, and the
   buttons. The pages on login_base.html load this before main.css. The Tip Jar
   home page (payments/tip_jar/home.html) is a variant of those pages, and it
   loads this too, so a control looks and behaves the same on all of them. The
   colors and the focus ring are the ones of pinecast-ts. Put no layout here:
   a page has its own, and it may change the size of a control (the button of
   the Tip Jar home page is smaller). */

form label {
  display: block;
  margin-bottom: 20px;
}
form label > span,
form legend {
  color: #090909;
  font-family: "Monument Grotesk Bold", "ABC Monument Grotesk Bold", sans-serif;
  font-size: 18px;
  line-height: 18px;
  display: block;
  padding-bottom: 8px;
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="tel"],
input[type="password"],
input[type="datetime-local"],
textarea {
  background: #fff;
  /* The box shadow draws the edge, and forced colors mode (Windows high
     contrast) removes box shadows. It shows a transparent border in the color
     of the theme, so the field keeps an edge there. In normal mode nothing
     changes: the pages are border-box, the white fills the border, and the
     padding is 1px less, so the text stays 16px in. */
  border: 1px solid transparent;
  border-radius: 10px;
  box-shadow: 0 0 0 1px #888;
  color: #090909;
  font-size: 16px;
  height: 40px;
  padding: 0 15px;
  transition: box-shadow 0.2s, opacity 0.2s;
  width: 100%;
}
textarea {
  height: 64px;
}
input[type="password"] {
  letter-spacing: 4px;
}

/* The focus ring of the controls of the dashboard (`focusRing` in pinecast-ts,
   packages/styles/src/focusRing.ts): a 2px outline in the `focusRing` token,
   2px outside the control, that fades in. A color change is not motion, so it
   runs under `prefers-reduced-motion` too. It is an outline and not a box
   shadow, so forced colors mode keeps it. A text field shows it on every focus,
   as it does in the dashboard. */
@keyframes focus-ring-fade-in {
  from {
    outline-color: transparent;
  }
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input[type="datetime-local"]:focus,
textarea:focus {
  animation: focus-ring-fade-in 0.2s ease-out;
  outline: 2px solid #090909;
  outline-offset: 2px;
}

/* A field that an error is about, as in the dashboard (`$invalid` in
   `TextInputWrapper`): the edge is `borderRedAccent`, and the ring is
   `borderRedLight`, the red that clears 3:1 on the page. */
input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  box-shadow: 0 0 0 1px #f05569;
}
input[aria-invalid="true"]:focus,
textarea[aria-invalid="true"]:focus {
  outline-color: #a3132d;
}
input[type="text"]::placeholder,
input[type="text"]::-webkit-placeholder,
input[type="email"]::placeholder,
input[type="email"]::-webkit-placeholder,
input[type="url"]::placeholder,
input[type="url"]::-webkit-placeholder,
input[type="number"]::placeholder,
input[type="number"]::-webkit-placeholder,
input[type="password"]::placeholder,
input[type="password"]::-webkit-placeholder,
input[type="datetime-local"]::placeholder,
input[type="datetime-local"]::-webkit-placeholder,
textarea::placeholder,
textarea::-webkit-placeholder {
  /* The placeholder color of the fields of pinecast-ts, 5.7:1 on the white
     field. #888 was 3.54:1 (WCAG 1.4.3). */
  color: #546a74;
}

form label > small {
  color: #616669;
  display: block;
  margin-top: 4px;
}

.error,
.warning,
.success {
  border-radius: 10px;
  font-size: 16px;
  margin: 10px 0 20px;
  padding: 16px;
}
/* The colors of the negative Callout in pinecast-ts (badgeRedText on
   badgeRedBackground), 4.86:1. White on the red these pages had was 3.74:1.
   Its border is 1px in the color of the text, as the Callout's is.
   The dark mode block at the end has the Callout's dark pair: #ff809e on
   #6b261f. */
.error {
  background: #ff92a1;
  border: 1px solid currentcolor;
  color: #7e0b49;
}
.warning {
  background: #ff6f17;
  color: #fff;
}
.success {
  background: #85b192;
  color: #090909;
}
.error strong,
.warning strong,
.success strong {
  display: block;
  font-family: "Monument Grotesk Bold", "ABC Monument Grotesk Bold", sans-serif;
}

/* The edge is a box shadow, which forced colors mode removes. The media query
   at the end of this file gives the button a border there.

   A button is 48px high: 12px, a line of 24px and 12px. A label that is too
   long for one line (a translation, on a narrow page) takes a second line, and
   the button grows by it. With a fixed height, the second line fell out of the
   button, as white text on the page (WCAG 1.4.10). */
.btn {
  align-items: center;
  background: #fff;
  border: 0;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15), 0 3px 4px rgba(0, 0, 0, 0.05),
    0 0 0 0.5px rgba(0, 0, 0, 0.15), 0 0 0 transparent inset;
  color: #000;
  cursor: pointer;
  display: inline-flex;
  font-family: "Monument Grotesk Bold", "ABC Monument Grotesk Bold", sans-serif;
  font-size: 16px;
  line-height: 24px;
  min-height: 48px;
  opacity: 1;
  padding: 12px 32px;
  position: relative;
  text-align: center;
  text-decoration: none;
  transition: background-color 0.2s, box-shadow 0.2s, color 0.2s, opacity 0.2s;
  user-select: none;
}
/* Waiting: the script of `click_guard.html` sets `aria-disabled` for a moment
   after the page is shown. The button is dimmer and the pointer says "wait",
   and a screen reader hears the state. Nothing moves: it is not `disabled`,
   which would take it out of the tab order. */
.btn.is-disabled,
.btn[aria-disabled="true"] {
  cursor: progress;
  opacity: 0.5;
}
.btn:hover {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15), 0 3px 5px rgba(0, 0, 0, 0.15),
    0 0 0 0.5px rgba(0, 0, 0, 0.15), 0 0 0 transparent inset;
  text-decoration: none;
}
/* Pressed, as the Button of the dashboard is: a 2px edge inside, in
   `borderBlueNormal`, and 1px down. */
.btn:active {
  box-shadow: 0 0 0 rgba(0, 0, 0, 0.05), inset 0 0 0 2px #c7ecfa;
  transform: translateY(1px);
}
/* On the keyboard's focus only, as in the dashboard. The ring meets the page,
   and not the fill of the button, so it is the same for both buttons. */
.btn:focus-visible {
  animation: focus-ring-fade-in 0.2s ease-out;
  outline: 2px solid #090909;
  outline-offset: 2px;
}

.btn.is-primary {
  background-color: #090909;
  color: #fff;
}

/* Dark mode, for a system that is set to it. It is a media query and nothing
   else: no script, no setting of the account and no choice that the browser
   keeps (the dashboard keeps its own, and a server page cannot read it). Each
   color is a token of `designColorsDark` in pinecast-ts
   (packages/styles/src/colors.ts), and the control is the control of the
   dashboard in that mode: the field fill is `contentBackground`, the edge of a
   field is `inputBorder` (the same in both modes, so its rule is not here), the
   focus ring is `focusRing`, and the pairs of a box are the dark pairs of the
   Callout (`badge*Text` on `badge*Background`).
   It changes colors only: a rule here has no size, no spacing and no font, so
   the layout, the zoom and the reflow are the ones of light mode.
   `color-scheme` makes the browser draw what it owns (the scrollbar, the
   autofill color, the reveal button of a password field, a button that has no
   class) for dark mode.
   The query leaves out forced colors mode (Windows high contrast). There the
   system picks the colors, and a color that the browser does not force (the
   fill of an SVG) would show against them. The rules for that mode, below, are
   as they were.
   These rules go after the rules of light mode that they override, as they
   have the same specificity. accounts/tests/test_sign_in_dark_mode.py lists
   the tokens and checks the contrast of each pair. */
@media (prefers-color-scheme: dark) and (forced-colors: none) {
  :root {
    color-scheme: dark;
  }

  form label > span,
  form legend {
    color: #fff; /* contentText */
  }

  input[type="text"],
  input[type="email"],
  input[type="url"],
  input[type="number"],
  input[type="tel"],
  input[type="password"],
  input[type="datetime-local"],
  textarea {
    background: #26262a; /* contentBackground */
    color: #fff; /* contentText */
  }

  input[type="text"]:focus,
  input[type="email"]:focus,
  input[type="url"]:focus,
  input[type="number"]:focus,
  input[type="password"]:focus,
  input[type="datetime-local"]:focus,
  textarea:focus {
    outline-color: #fff; /* focusRing */
  }

  input[aria-invalid="true"],
  textarea[aria-invalid="true"] {
    box-shadow: 0 0 0 1px #ff5c72; /* borderRedAccent */
  }
  input[aria-invalid="true"]:focus,
  textarea[aria-invalid="true"]:focus {
    outline-color: #ff8a9b; /* borderRedLight */
  }

  input[type="text"]::placeholder,
  input[type="text"]::-webkit-placeholder,
  input[type="email"]::placeholder,
  input[type="email"]::-webkit-placeholder,
  input[type="url"]::placeholder,
  input[type="url"]::-webkit-placeholder,
  input[type="number"]::placeholder,
  input[type="number"]::-webkit-placeholder,
  input[type="password"]::placeholder,
  input[type="password"]::-webkit-placeholder,
  input[type="datetime-local"]::placeholder,
  input[type="datetime-local"]::-webkit-placeholder,
  textarea::placeholder,
  textarea::-webkit-placeholder {
    color: #949494; /* contentTextMuted */
  }

  form label > small {
    color: #949494; /* contentTextMuted */
  }

  .error {
    background: #6b261f; /* badgeRedBackground */
    color: #ff809e; /* badgeRedText */
  }
  .warning {
    background: #675a03; /* badgeYellowBackground */
    color: #ffe266; /* badgeYellowText */
  }
  .success {
    background: #095a1b; /* badgeGreenBackground */
    color: #79ff97; /* badgeGreenText */
  }

  /* The edge of a button is a box shadow. The hairline of light mode is
     black at 15%, which the page swallows, so the edge is `borderGrayNormal`.
     The primary button keeps no edge, as in the dashboard: its fill is the
     edge. */
  .btn {
    background: #26262a; /* contentBackground */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15), 0 0 0 1px #69778c; /* borderGrayNormal */
    color: #fff; /* contentText */
  }
  .btn:hover {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15), inset 0 0 0 2px #28408c; /* borderBlueLight */
  }
  .btn:active {
    box-shadow: 0 0 0 rgba(0, 0, 0, 0.05), inset 0 0 0 2px #4b6884; /* borderBlueNormal */
  }
  .btn:focus-visible {
    outline-color: #fff; /* focusRing */
  }

  .btn.is-primary {
    background-color: #0066ff; /* accentBlue */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    color: #fff; /* accentBlueText */
  }
  .btn.is-primary:hover {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15), inset 0 0 0 2px #888; /* inputBorder */
  }
  .btn.is-primary:active {
    box-shadow: 0 0 0 rgba(0, 0, 0, 0.05), inset 0 0 0 2px #4b6884; /* borderBlueNormal */
  }
  /* A primary button's ring is its fill, as in the dashboard (the `accent`
     tone of `focusRing`). It meets the page, across the gap. */
  .btn.is-primary:focus-visible {
    outline-color: #0066ff; /* accentBlue */
  }
}

/* Forced colors mode (Windows high contrast) removes box shadows, and with them
   the edge of a button. A border here draws it in the color of the theme. It is
   not a transparent border in the base rule, as the fields have. The padding
   gives up the 1px that the border takes on each side, so that a button is as
   high here as everywhere else. */
@media (forced-colors: active) {
  .btn {
    border: 1px solid ButtonText;
    padding: 11px 31px;
  }
}
