/* Every sign-in page. One idea: a record running off the left edge, which turns when you press
   Sign in. Everything else stays quiet. Dark only, like the dashboard. */

:root {
  --auth-bg: #181a1b;
  --auth-vinyl: #0d0e0f;
  --auth-groove: #1b1e20;
  --auth-band: #131516;
  --auth-ink: #eef0f2;
  --auth-muted: #a0a6ab;
  --auth-line: #363b40;
  --auth-field: #212427;
  --auth-accent: #00b894;
  --auth-accent-ink: #04211a;
  --auth-danger: #ff9b8a;
}

body.auth-page {
  min-height: 100vh;
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 34rem);
  background: var(--auth-bg);
  color: var(--auth-ink);
  overflow-x: hidden;
}

/* ------------------------------------------------------------------ the record */
.auth-record {
  /* Large enough to run off the left, top and bottom, never so large it is cut by the form column. */
  --disc: min(max(150vh, 78vw), calc(1.4 * (100vw - 34rem) - 4rem));
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.auth-disc,
.auth-record::after {
  position: absolute;
  top: 50%;
  left: 30%;
  width: var(--disc);
  height: var(--disc);
  margin: calc(var(--disc) / -2) 0 0 calc(var(--disc) / -2);
  border-radius: 50%;
}

/* The bands between tracks and the smooth run-out around the label are what make this a record. */
.auth-disc {
  background:
    radial-gradient(circle closest-side, transparent 0 32%, var(--auth-band) 32% 37%, transparent 37% 51.6%,
      var(--auth-band) 51.6% 52.3%, transparent 52.3% 66%, var(--auth-band) 66% 66.7%, transparent 66.7% 81%,
      var(--auth-band) 81% 81.7%, transparent 81.7% 98%, var(--auth-band) 98%),
    repeating-radial-gradient(circle at center, var(--auth-vinyl) 0 2px, var(--auth-groove) 2px 3px);
  box-shadow: 0 0 0 1px #000, 0 2rem 6rem rgba(0, 0, 0, .55);
}

/* Light on a record stays put while the record turns. It falls on the vinyl, not the paper label. */
.auth-record::after {
  content: "";
  background: conic-gradient(from 35deg, transparent 0 6%, rgba(255, 255, 255, .1) 11%, transparent 17% 50%,
    transparent 56%, rgba(255, 255, 255, .07) 61%, transparent 67%);
  -webkit-mask-image: radial-gradient(circle closest-side, transparent 32.4%, #000 32.8%);
  mask-image: radial-gradient(circle closest-side, transparent 32.4%, #000 32.8%);
  pointer-events: none;
}

.auth-label {
  position: absolute;
  inset: 34%;
  width: 32%;
  height: 32%;
}

.auth-label-paper { fill: var(--auth-accent); }
.auth-label-hole { fill: var(--auth-bg); }
.auth-label-rule { fill: none; stroke: var(--auth-accent-ink); stroke-opacity: .35; stroke-width: .6; }
.auth-label-text {
  fill: var(--auth-accent-ink);
  font-family: "Archivo", sans-serif;
  font-size: 11px;
  font-weight: 700;
  font-stretch: 112%;
  letter-spacing: .03em;
  text-anchor: middle;
}

@keyframes auth-turn { to { transform: rotate(360deg); } }

/* 33 1/3 turns a minute. */
body.is-sending .auth-disc { animation: auth-turn 1.8s linear infinite; }

@media (prefers-reduced-motion: reduce) {
  body.is-sending .auth-disc { animation: none; }
}

/* ------------------------------------------------------------------ the column */
.auth-column {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.25rem;
  min-width: 0;
  max-width: 29rem;
  padding-block: 3rem;
  padding-inline: 1.5rem 3rem;
}

.auth-wordmark {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0 0 1.5rem;
  color: var(--auth-ink);
  font-size: 1.05rem;
  font-weight: 800;
  font-stretch: 125%;
  letter-spacing: -.01em;
}

.auth-title {
  margin: 0;
  color: var(--auth-ink);
  font-size: clamp(2.1rem, 4vw, 2.7rem);
  font-weight: 800;
  font-stretch: 112%;
  letter-spacing: -.02em;
  line-height: 1.05;
  text-wrap: balance;
}

.auth-lede {
  margin: -.5rem 0 0;
  color: var(--auth-muted);
  font-size: .98rem;
  line-height: 1.5;
}

.auth-lede strong { color: var(--auth-ink); font-weight: 600; }

/* ------------------------------------------------------------------ forms */
.auth-form { display: grid; gap: 1rem; }
.auth-field { display: grid; gap: .4rem; }

.auth-field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.auth-page .auth-field label,
.auth-page .auth-field .form-label {
  margin: 0;
  color: var(--auth-ink);
  font-size: .88rem;
  font-weight: 600;
}

.auth-page .form-control {
  min-height: 3rem;
  border: 1px solid var(--auth-line);
  border-radius: .4rem;
  background: var(--auth-field);
  color: var(--auth-ink);
  font-size: 1rem;
}

.auth-page .form-control::placeholder { color: #80868c; }

.auth-page .form-control:focus {
  border-color: var(--auth-accent);
  background: var(--auth-field);
  color: var(--auth-ink);
  box-shadow: 0 0 0 3px rgba(0, 184, 148, .28);
}

.auth-page .code-input {
  min-height: 3.6rem;
  font-size: 1.7rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: .32em;
  text-align: center;
}

.auth-page .code-input.is-recovery {
  font-size: 1.1rem;
  letter-spacing: .08em;
}

.auth-hint { margin: 0; color: var(--auth-muted); font-size: .85rem; }

.auth-steps {
  display: grid;
  gap: .5rem;
  margin: 0;
  padding-inline-start: 1.25rem;
  color: var(--auth-ink);
  font-size: .95rem;
  line-height: 1.45;
}

.auth-steps a {
  color: var(--auth-ink);
  text-underline-offset: 3px;
}

.auth-primary,
.auth-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  width: 100%;
  min-height: 3rem;
  border-radius: .4rem;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.auth-primary {
  border: 0;
  background: var(--auth-accent);
  color: var(--auth-accent-ink);
}

.auth-primary:hover { background: #12cfa9; color: var(--auth-accent-ink); }
.auth-primary:disabled { opacity: .65; cursor: progress; }

.auth-secondary {
  border: 1px solid var(--auth-line);
  background: transparent;
  color: var(--auth-ink);
}

.auth-secondary:hover { border-color: #5b6166; background: #212427; color: #fff; }

.auth-page a:focus-visible,
.auth-page button:focus-visible,
.auth-page summary:focus-visible {
  outline: 2px solid var(--auth-accent);
  outline-offset: 2px;
}

.auth-link {
  color: var(--auth-muted);
  font-size: .88rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-link:hover { color: var(--auth-ink); }

.auth-link-button {
  align-self: flex-start;
  justify-self: start;
  padding: 0;
  border: 0;
  background: none;
}

.auth-or {
  display: flex;
  align-items: center;
  gap: .75rem;
  color: var(--auth-muted);
  font-size: .85rem;
}

.auth-or::before, .auth-or::after { content: ""; flex: 1; border-bottom: 1px solid var(--auth-line); }

.auth-stack { display: grid; gap: .6rem; }

.auth-quiet {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.25rem;
  align-items: baseline;
}

.auth-quiet summary {
  color: var(--auth-muted);
  font-size: .88rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  list-style: none;
}

.auth-quiet summary::-webkit-details-marker { display: none; }
.auth-quiet details[open] { flex-basis: 100%; }
.auth-quiet details .input-group { margin-top: .6rem; }

.auth-page .btn-shopify {
  min-height: 3rem;
  border: 1px solid var(--auth-line);
  background: #2a2e31;
  color: var(--auth-ink);
  font-weight: 600;
}

/* ------------------------------------------------------------------ messages */
.auth-alert {
  margin: 0;
  padding: .7rem .9rem;
  border-left: 3px solid;
  background: var(--auth-field);
  font-size: .95rem;
  line-height: 1.45;
}

.auth-alert-error { border-color: var(--auth-danger); color: var(--auth-danger); }
.auth-alert-ok { border-color: var(--auth-accent); color: #7fe6cf; }
.auth-alert-warn { border-color: #f2c14e; color: #f2c14e; }

/* ------------------------------------------------------------------ authenticator setup */
.mfa-qr {
  display: block;
  width: 320px;
  max-width: 100%;
  height: auto;
  background: #fff;
  shape-rendering: crispEdges;
}

.setup-key, .recovery-codes {
  font-family: var(--bs-font-monospace);
}

.setup-key { margin: 0; letter-spacing: .06em; overflow-wrap: anywhere; }

.recovery-codes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .3rem 1rem;
  margin: 0;
  padding: .8rem 1rem;
  border: 1px solid var(--auth-line);
  font-size: .85rem;
  white-space: nowrap;
  list-style: none;
}

.auth-secondary.auth-phone-only { display: none; }

/* ------------------------------------------------------------------ small screens */
@media (max-width: 860px) {
  .auth-secondary.auth-phone-only { display: flex; }

  body.auth-page {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }

  .auth-record {
    --disc: 26rem;
    position: relative;
    height: 11rem;
  }

  .auth-disc,
  .auth-record::after {
    top: auto;
    bottom: .75rem;
    left: 50%;
    margin: 0 0 0 calc(var(--disc) / -2);
  }

  .auth-disc { box-shadow: 0 0 0 1px #000; }

  .auth-column {
    width: 100%;
    max-width: 30rem;
    margin-inline: auto;
    justify-content: flex-start;
    padding-block: 1.5rem 3rem;
    padding-inline: max(20px, env(safe-area-inset-left, 0px)) max(20px, env(safe-area-inset-right, 0px));
  }

  .auth-wordmark { margin-bottom: .5rem; }
}

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