/* ============================================================
   Modern OTP (v11.0.214) — 6 boxes + 1 real input, gliding ring,
   shake/drain on error, green ripple on success.
   Sirf tab load hota hai jab admin setting otp_style = 'modern'.
   Scope: .aw-otp (host ko flow JS awco-otprow / awlp-otprow class
   bhi deta hai taaki existing verify code input padh sake).
   ============================================================ */
.aw-otp {
  --awotp-box: 48px;
  --awotp-box-h: 56px;
  --awotp-gap: 8px;
  --awotp-focus: #7b2d26;          /* Artwani maroon */
  --awotp-focus-glow: rgba(123, 45, 38, .16);
  --awotp-line: #d9d2cc;
  --awotp-filled: #8a7a70;
  --awotp-box-bg: #fdfcfa;
  --awotp-active-bg: #faf3f1;
  --awotp-err: #c0392b;
  --awotp-err-bg: #fdf0ee;
  --awotp-ok: #1e7e34;
  --awotp-ok-bg: #eaf7ee;
  --awotp-ok-line: #57a773;
  --awotp-ease: cubic-bezier(.22, .8, .3, 1);
  --awotp-spring: cubic-bezier(.34, 1.45, .44, 1);
  position: relative;
  display: block;
  margin: .8rem 0;
}
.aw-otp-boxes {
  position: relative;
  display: flex;
  justify-content: center;
  gap: var(--awotp-gap);
}
.aw-otp[data-state="error"] .aw-otp-boxes,
.aw-otp[data-shake="true"] .aw-otp-boxes { animation: awotp-shake .42s var(--awotp-ease); }

.aw-otp-box {
  position: relative;
  flex: 1 1 var(--awotp-box);
  max-width: 54px;
  min-width: 0;
  height: var(--awotp-box-h);
  display: grid;
  place-items: center;
  background: var(--awotp-box-bg);
  border: 1.5px solid var(--awotp-line);
  border-radius: 10px;
  transition: background-color .3s var(--awotp-ease), border-color .3s var(--awotp-ease);
}
.aw-otp-box[data-filled="true"] { border-color: var(--awotp-filled); }
.aw-otp[data-focus="true"] .aw-otp-box[data-active="true"] { background: var(--awotp-active-bg); }

.aw-otp-sep {
  flex: 0 0 10px;
  align-self: center;
  height: 2px;
  border-radius: 999px;
  background: #cbbfae;
}

.aw-otp-digit {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #2b211c;
  transition: color .3s var(--awotp-ease), opacity .3s var(--awotp-ease), transform .35s var(--awotp-ease);
}
.aw-otp-box--pop .aw-otp-digit { animation: awotp-digit-in .34s var(--awotp-spring); }

.aw-otp-caret {
  position: absolute;
  width: 2px;
  height: 1.5rem;
  border-radius: 999px;
  background: var(--awotp-focus);
  opacity: 0;
}
.aw-otp[data-focus="true"][data-state="idle"] .aw-otp-box[data-active="true"] .aw-otp-caret {
  animation: awotp-blink 1s steps(1) infinite;
}

.aw-otp-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--awotp-w, var(--awotp-box));
  height: var(--awotp-box-h);
  border: 2px solid var(--awotp-focus);
  border-radius: 10px;
  box-shadow: 0 0 0 4px var(--awotp-focus-glow);
  pointer-events: none;
  opacity: 0;
  transform: translateX(var(--awotp-x, 0px)) scale(.92);
  transition: transform .38s cubic-bezier(.3, 1.3, .4, 1), width .38s var(--awotp-ease),
    opacity .18s var(--awotp-ease), border-color .18s var(--awotp-ease);
  z-index: 3;
}
.aw-otp-ring[data-snap="true"] { transition: opacity .18s var(--awotp-ease), border-color .18s var(--awotp-ease); }
.aw-otp[data-focus="true"]:is([data-state="idle"], [data-state="verifying"]) .aw-otp-ring {
  opacity: 1;
  transform: translateX(var(--awotp-x, 0px)) scale(1);
}

/* Verifying — digits wave */
.aw-otp[data-state="verifying"] .aw-otp-box { border-color: var(--awotp-filled); }
.aw-otp[data-state="verifying"] .aw-otp-digit {
  animation: awotp-wave .9s var(--awotp-ease) infinite;
  animation-delay: calc(var(--i) * 70ms);
}

/* Error — red boxes, digits drain away */
.aw-otp[data-state="error"] .aw-otp-box { background: var(--awotp-err-bg); border-color: var(--awotp-err); }
.aw-otp[data-drain="true"] .aw-otp-digit {
  opacity: 0;
  transform: translateY(10px) scale(.8);
  transition-delay: calc(var(--i) * 40ms);
}

/* Success — green ripple, box by box */
.aw-otp[data-state="done"] .aw-otp-box {
  background: var(--awotp-ok-bg);
  border-color: var(--awotp-ok-line);
  transition-delay: calc(var(--i) * 60ms);
  animation: awotp-box-pop .45s var(--awotp-spring) calc(var(--i) * 60ms);
}
.aw-otp[data-state="done"] .aw-otp-digit { color: var(--awotp-ok); }

/* The one real input — invisible, covers the boxes (tap = focus).
   Specificity (0,2,0) classic .awco-otprow input (0,1,1) ko hara deti hai. */
.aw-otp .aw-otp-real {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  font-size: 16px; /* iOS zoom rokne ke liye */
  color: transparent;
  caret-color: transparent;
  background: transparent;
  border: 0;
  border-radius: 0;
  outline: none;
  opacity: .001;
  cursor: text;
  letter-spacing: -1em;
  -webkit-appearance: none;
  appearance: none;
}

@keyframes awotp-digit-in {
  0% { opacity: 0; transform: translateY(8px) scale(.6); }
  60% { opacity: 1; transform: translateY(-2px) scale(1.12); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes awotp-blink { 0% { opacity: 1; } 50% { opacity: 0; } }
@keyframes awotp-wave {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}
@keyframes awotp-shake {
  0% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
  100% { transform: translateX(0); }
}
@keyframes awotp-box-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@media (max-width: 400px) {
  .aw-otp { --awotp-box: 42px; --awotp-box-h: 52px; --awotp-gap: 6px; }
  .aw-otp-digit { font-size: 1.35rem; }
  .aw-otp-sep { flex-basis: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .aw-otp *, .aw-otp *::before, .aw-otp *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
