/* The one WhatsApp OTP control (public/js/otp-field.js; Harshal, 4 Oct 2026; HANDOVER.md §4z73).
   Six boxes drawn over one input, which takes the typing, the paste and the phone's autofill; its
   own text, caret and focus are invisible, the boxes show the digits. The box the next digit goes
   into takes the accent border and a soft fill, with a blinking cursor while it is empty; focus is
   never a ring round the row or the box (interface-standards). Steady, not blinking, for anyone who
   asked for less motion.

   Colours come from the page, set on .otp by each stylesheet that uses it:
     --otp-line    a box's border          --otp-accent  the next box's border, cursor and fill
     --otp-ground  a box's background      --otp-ink     the digits
     --otp-bad     every box's border after a refused code (the input's aria-invalid)          */

.otp {
  position: relative;
  max-width: 360px;
}
.otp__boxes {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}
.otp__box {
  display: grid;
  place-items: center;
  height: 52px;
  border: 1px solid var(--otp-line, #828997);
  border-radius: 9px;
  background: var(--otp-ground, #ffffff);
  color: var(--otp-ink, #14213d);
  font-size: 24px;
  font-weight: 650;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.otp__box.is-active {
  border-color: var(--otp-accent, #14213d);
  background: color-mix(in srgb, var(--otp-accent, #14213d) 9%, var(--otp-ground, #ffffff));
}
.otp:has(.otp__input[aria-invalid='true']) .otp__box {
  border-color: var(--otp-bad, #a63d40);
}

@keyframes otp-caret {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}
.otp__box.is-active:empty::after {
  content: '';
  width: 2px;
  height: 26px;
  border-radius: 1px;
  background: var(--otp-accent, #14213d);
  animation: otp-caret 1s step-end infinite;
}
@media (prefers-reduced-motion: reduce) {
  .otp__box.is-active:empty::after {
    animation: none;
  }
}

/* The one input, over the six boxes so a tap anywhere on them focuses it. Every page's own field
   and focus rules are overridden here (some use !important): it never draws a border, fill, outline
   or ring of its own, or it would cover the boxes. 16 px text so a phone does not zoom. */
.otp .otp__input,
.otp .otp__input:focus,
.otp .otp__input:focus-visible,
.otp .otp__input[aria-invalid='true'] {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-width: none;
  margin: 0;
  padding: 0;
  border: 0 !important;
  border-radius: 9px;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  color: transparent;
  caret-color: transparent;
  font-size: 16px;
  letter-spacing: 0;
  opacity: 1;
}
.otp .otp__input::selection {
  background: transparent;
}
.otp:focus-within {
  outline: none !important;
  box-shadow: none !important;
}

@media (max-width: 360px) {
  .otp__boxes {
    gap: 6px;
  }
}
@media (forced-colors: active) {
  .otp__box {
    border-color: CanvasText;
  }
  .otp__box.is-active {
    border-color: Highlight;
  }
  .otp__box.is-active:empty::after {
    background: Highlight;
  }
}
