/* ==========================================================================
   Sign-in screens. The first impression of the product, and the only place
   the brand is allowed to take the whole viewport.
   ========================================================================== */

.auth {
  position: relative;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto;
  padding: var(--sp-6) var(--page-pad);
  padding-top: max(var(--sp-6), env(safe-area-inset-top));
  background: var(--surface);
  overflow: hidden;
  isolation: isolate;
}

/* Two soft teal washes bled in from the corners, and a very faint grid over
   them. Radial gradients rather than an image: free, crisp at any density,
   and they recolour with the theme instead of needing a second asset. */
.auth::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(60rem 38rem at 12% -8%,
      color-mix(in oklab, var(--teal-400) 26%, transparent) 0%, transparent 62%),
    radial-gradient(48rem 34rem at 104% 108%,
      color-mix(in oklab, var(--orange-400) 15%, transparent) 0%, transparent 60%);
}

.auth::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(to right, color-mix(in oklab, var(--ink) 4%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in oklab, var(--ink) 4%, transparent) 1px, transparent 1px);
  background-size: 56px 56px;
  /* Fades out before it reaches the card, so the grid never competes with the
     thing the visitor is meant to be typing into. */
  mask-image: radial-gradient(70% 60% at 50% 45%, transparent 30%, #000 100%);
}

.auth__inner {
  inline-size: 100%;
  max-inline-size: 400px;
  margin-inline: auto;
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

/* -- the cover ------------------------------------------------------------ */

.auth__crest {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  text-align: center;
}

.auth__seal {
  inline-size: 84px;
  block-size: 84px;
  border-radius: var(--r-lg);
  /* White, for the reason given on .topbar__mark: the mark carries its own
     colour and needs a light ground to keep it. */
  background: #fff;
  display: grid;
  place-items: center;
  box-shadow: var(--e-3), inset 0 0 0 1px color-mix(in oklab, var(--navy-900) 8%, transparent);
  position: relative;
  animation: seal-in var(--dur-grand) var(--ease-spring) both;
}

@keyframes seal-in {
  from { opacity: 0; transform: scale(0.86) rotate(-4deg); }
  to { opacity: 1; transform: scale(1) rotate(0deg); }
}

.auth__seal-text {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
}

.auth__seal-year {
  font-size: 0.55rem;
  font-weight: 500;
  opacity: 0.85;
  margin-top: 2px;
  letter-spacing: 0.08em;
}

.auth__name {
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.auth__legal {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  max-inline-size: 30ch;
}

.auth__tagline {
  font-size: var(--text-sm);
  color: var(--brand);
  font-weight: 600;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-pill);
  background: color-mix(in oklab, var(--teal-400) 14%, transparent);
  border: 1px solid color-mix(in oklab, var(--teal-500) 26%, transparent);
}

/* -- the form card -------------------------------------------------------- */

.auth__card {
  background: color-mix(in oklab, var(--surface-raised) 92%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid color-mix(in oklab, var(--ink) 7%, transparent);
  border-radius: var(--r-xl);
  box-shadow: var(--e-3);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  animation: fade-up var(--dur-slow) var(--ease-out) 80ms both;
}

.auth__heading {
  font-size: var(--text-lg);
  font-weight: 600;
}

.auth__note {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.auth__error {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--danger-surface);
  color: var(--danger);
  font-size: var(--text-sm);
  font-weight: 500;
}

.auth__error svg { flex: none; margin-top: 1px; }

.auth__footer {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding-top: var(--sp-5);
}

.auth__footer .kasuti { max-inline-size: 200px; }

.auth__footer-text {
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

/* -- OTP entry ------------------------------------------------------------ */

.otp {
  position: relative;
}

.otp__cells {
  display: flex;
  gap: var(--sp-2);
  justify-content: center;
}

.otp__cell {
  flex: 1;
  max-inline-size: 54px;
  block-size: 60px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-raised);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}

.otp__cell.is-filled {
  border-color: var(--brand);
  background: var(--brand-tint);
}

.otp__cell.is-filled .otp__digit {
  animation: digit-pop var(--dur-fast) var(--ease-out);
}

@keyframes digit-pop {
  from { transform: scale(0.8); opacity: 0.4; }
  to { transform: scale(1); opacity: 1; }
}

.otp__cell.is-active {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--focus) 30%, transparent);
}

.otp.is-error .otp__cell {
  border-color: var(--danger);
}

/* The real input sits invisibly over the cells so the OS keyboard, paste and
   SMS autofill all work normally. */
.otp__input {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  opacity: 0;
  border: 0;
  padding: 0;
  font-size: 16px; /* stops iOS zooming on focus */
  letter-spacing: 3em;
  cursor: pointer;
}

/* -- countdown ring ------------------------------------------------------- */

.countdown {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.countdown__ring {
  inline-size: 22px;
  block-size: 22px;
  flex: none;
  transform: rotate(-90deg);
}

.countdown__track {
  fill: none;
  stroke: var(--line);
  stroke-width: 3;
}

.countdown__progress {
  fill: none;
  stroke: var(--ink-muted);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke var(--dur-base) var(--ease-out);
}

/* The numeric time is always beside the ring: the ring alone never carries
   the information. */
.countdown__time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.countdown.is-warning .countdown__progress { stroke: var(--warning); }
.countdown.is-warning .countdown__time { color: var(--warning); }
.countdown.is-urgent .countdown__progress { stroke: var(--danger); }
.countdown.is-urgent .countdown__time { color: var(--danger); }

.countdown.is-urgent {
  animation: countdown-blink 1s steps(1, end) infinite;
}

@keyframes countdown-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.55; }
}

@media (prefers-reduced-motion: reduce) {
  /* Colour still escalates; only the blink is dropped. */
  .countdown.is-urgent { animation: none; }
}

.countdown.is-expired .countdown__progress { stroke: var(--danger); }

/* -- the demo code panel -------------------------------------------------- */

.demo-code {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--warning-surface);
  color: var(--warning);
  border: 1px dashed color-mix(in oklab, var(--warning) 45%, transparent);
}

.demo-code__label {
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.3;
}

.demo-code__value {
  margin-inline-start: auto;
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* -- role hints on the demo login ----------------------------------------- */

.demo-accounts {
  display: grid;
  gap: var(--sp-1);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  border: 1px dashed var(--line-strong);
  font-size: var(--text-xs);
}

.demo-accounts__title {
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: var(--sp-1);
}

.demo-accounts__row {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  min-height: 30px;
}

.demo-accounts__user {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--ink);
  min-inline-size: 8ch;
}

.demo-accounts__role {
  color: var(--ink-muted);
  flex: 1;
}

.demo-accounts__fill {
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xs);
  padding: 2px 8px;
  font-size: var(--text-xs);
  color: var(--brand);
  min-height: 28px;
}

/* --------------------------------------------------------------------------
   The daily way in: a roster of names, then a four-digit PIN.

   Sized for a thumb on a phone held one-handed in a busy hall — the keypad
   keys are deliberately larger than the design system's usual tap target,
   because this is the single most-repeated interaction in the product.
   -------------------------------------------------------------------------- */

.roster {
  list-style: none;
  margin: var(--sp-4) 0 var(--sp-3);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.roster__person {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-block-size: 64px;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}

.roster__person:active { transform: scale(0.985); }
.roster__person:hover  { border-color: var(--brand); }

.roster__avatar {
  flex: none;
  inline-size: 42px;
  block-size: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  background: var(--brand-strong);
  color: var(--brand-ink);
  font-weight: 700;
  font-size: var(--text-lg);
}

.roster__avatar--lg { inline-size: 54px; block-size: 54px; font-size: var(--text-2xl); }

.roster__who   { display: flex; flex-direction: column; min-inline-size: 0; }
.roster__name  { font-weight: 600; }
.roster__role  { font-size: var(--text-sm); color: var(--ink-muted); }

.roster__code {
  margin-inline-start: auto;
  padding: 2px var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--surface-sunken);
  color: var(--ink-muted);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
}

/* -- the PIN pad ---------------------------------------------------------- */

.unlock__who {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.unlock__name { font-weight: 600; font-size: var(--text-lg); }
.unlock__role { font-size: var(--text-sm); color: var(--ink-muted); }

.pin__dots {
  display: flex;
  justify-content: center;
  gap: var(--sp-3);
  margin: var(--sp-5) 0;
}

.pin__dot {
  inline-size: 14px;
  block-size: 14px;
  border-radius: var(--r-pill);
  border: 2px solid var(--line-strong);
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}

.pin__dot.is-filled {
  background: var(--brand);
  border-color: var(--brand);
  transform: scale(1.15);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
}

.keypad__key {
  min-block-size: 62px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-2xl);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}

.keypad__key:active {
  background: var(--surface-sunken);
  transform: scale(0.96);
}

.keypad__key--muted { color: var(--ink-muted); font-size: var(--text-xl); }

.input--pin {
  font-size: var(--text-2xl);
  letter-spacing: 0.5em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* The staff code, shown when it is set and again on every screen after, because
   every bill written carries it into a 103-year-old co-operative's books. */
.identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-3);
  margin-block: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  border-inline-start: 3px solid var(--brand);
}

.identity__label { font-size: var(--text-xs); color: var(--ink-muted); }
.identity__code  { font-size: var(--text-2xl); font-weight: 700; letter-spacing: 0.08em; }
.identity__note  { font-size: var(--text-xs); color: var(--ink-muted); }

@media (prefers-reduced-motion: reduce) {
  .roster__person, .keypad__key, .pin__dot { transition: none; }
  .roster__person:active, .keypad__key:active { transform: none; }
}


/* Shown on the demo roster when the one-time code is *not* revealed on screen,
   so nobody picks an account and discovers at the next step that they cannot
   finish signing in. */
.demo-accounts__note {
  color: var(--warning);
  font-weight: 600;
  padding-block: var(--sp-1);
}
