/* ==========================================================================
   Sign-in screens. The first impression of the product, and the only place
   the full khata cover is drawn.
   ========================================================================== */

.auth {
  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);
  /* A very faint ruled-paper texture: the khata's lines, almost subliminal.
     Two hairlines, not an image — free, and crisp at any density. */
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 31px,
    color-mix(in oklab, var(--ink) 4%, transparent) 31px,
    color-mix(in oklab, var(--ink) 4%, transparent) 32px
  );
}

.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: 76px;
  block-size: 76px;
  border-radius: var(--r-lg);
  background: var(--brand-strong);
  color: var(--brand-ink);
  display: grid;
  place-items: center;
  box-shadow: var(--e-3);
  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-xl);
  font-weight: 600;
  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: 500;
}

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

.auth__card {
  background: var(--surface-raised);
  border-radius: var(--r-lg);
  box-shadow: var(--e-2);
  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-sm);
  background: var(--surface-sunken);
  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;
}
