/* Two-step sign-in (web/js/ui/twostep.js): the code step of signing in, setting it up, the
   recovery codes, and the rule that requires it for everyone. Every class starts with
   `ts-`; the rest is borrowed as it is (.form, .check, .adm-box, .adm-secret, .adm-steps).
   The box around the sign-in screens is the shared sign-in look (.auth in app.css). */

/* One stage of setting up (scan, then the recovery codes). Focus is moved here by script
   when the stage changes, the way it is moved to a sheet when it opens. */
.ts-phase {
  display: grid;
  gap: 16px;
}

.ts-phase:focus {
  outline: none;
}

/* A numbered step here holds whole blocks (a QR code, a field), not a single line. The
   blocks sit in a box inside the list item, which has to stay a list item to keep its
   number. */
.ts-step {
  display: grid;
  gap: 12px;
  min-width: 0;
}

/* The QR code. A phone camera reads dark squares on a light ground, so these two do not
   follow the theme: the code is ink on paper in the dark theme too. They are values of
   their own for that reason, used nowhere else. The quiet zone (four light squares all
   round) is drawn inside the code itself; keep the width so it scans. */
.ts-qr {
  --ts-qr-ink: black;
  --ts-qr-paper: white;
  display: grid;
  justify-items: start;
}

.ts-qr__code {
  display: block;
  width: 100%;
  max-width: 232px;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
}

.ts-qr__paper {
  fill: var(--ts-qr-paper);
}

.ts-qr__ink {
  fill: var(--ts-qr-ink);
}

/* The key as text, in groups of four for typing it by hand. */
.ts-key,
.ts-codes__code {
  font-variant-numeric: tabular-nums;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0, "calt" 0, "dlig" 0;
}

.ts-key {
  font-size: 15px;
  line-height: 20px;
  word-spacing: 0.18em;
}

/* The ten recovery codes: two columns on a grey box, each code selected whole with a tap. */
.ts-codes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-box);
  background: var(--panel);
}

.ts-codes__code {
  font-weight: 600;
  white-space: nowrap;
  user-select: all;
}

@media (max-width: 339px) {
  .ts-codes {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* On or off, as a pill with a sentence beside it. */
.ts-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.ts-state__text {
  font-weight: 500;
}

/* The rule under the list of people: required for everyone, or not. A switch, with what it
   means in quiet text under it. On is the accent: it is something that can be done. */
.ts-rule {
  display: grid;
  gap: 4px;
  justify-items: start;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.ts-rule .switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.ts-rule .switch__track {
  position: relative;
  flex: none;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--control);
  transition: background-color 160ms;
}

.ts-rule .switch__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--bg);
  transition: transform 160ms;
}

.ts-rule .switch[aria-checked="true"] .switch__track {
  background: var(--accent);
}

.ts-rule .switch[aria-checked="true"] .switch__knob {
  background: var(--on-accent);
  transform: translateX(16px);
}

.ts-rule .switch:disabled {
  opacity: 0.5;
  cursor: default;
}

@media (prefers-reduced-motion: reduce) {
  .ts-rule .switch__track,
  .ts-rule .switch__knob {
    transition: none;
  }
}
