/* The bank verification code with the falling digits: the confirm-transfer card of a banking app on pure black.
   The cells only draw, the real field is one input lying over them. Each cell carries a thin SVG outline the light
   runs along while the code is checked. The digits are an element for GSAP inside each cell. */
:root {
  --page: #000000;          /* the page */
  --card: #0f1013;          /* the body of the card */
  --card-low: #0a0b0d;      /* the card towards its foot */
  --edge: rgba(255, 255, 255, 0.075); /* the hairline edges */
  --cell: #15161a;          /* a cell */
  --cell-low: #101114;      /* a cell towards its foot */
  --ink: #f1f2f4;           /* the words and digits */
  --muted: #80838c;         /* the small words */
  --light: #9ff5cf;         /* the light running on the edges */
  --green: #2bd683;         /* the approved pill */
  --green-deep: #13a865;    /* the pill towards its foot */
  --red: #ff5d5d;           /* a wrong code */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

/* ---------------------------------------------------------------- the card */
.otp {
  --pad: clamp(18px, min(5.6vw, 4.6vh), 26px);
  position: relative;
  width: min(372px, calc(100vw - 28px));
  padding: var(--pad);
  border-radius: 24px;
  background: linear-gradient(180deg, var(--card), var(--card-low));
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 1px 2px rgba(0, 0, 0, 0.6),
    0 24px 60px -24px rgba(0, 0, 0, 0.9);
  isolation: isolate;
}

/* the hairline of light on the top edge */
.otp::before {
  content: '';
  position: absolute;
  inset: 0 18% auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  pointer-events: none;
}

/* the green breath behind the card when the code is right */
.otp__glow {
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -10%;
  height: 60%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(43, 214, 131, 0.28), transparent);
  filter: blur(18px);
  opacity: 0;
  z-index: -1;
  pointer-events: none;
}

.otp__head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.otp__mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(180deg, #1b1d22, #121317);
  box-shadow: inset 0 0 0 1px var(--edge), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.otp__mark svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.otp__words {
  min-width: 0;
}

.otp__title,
.otp__sub {
  margin: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.otp__title span,
.otp__sub span {
  display: inline-block;
}

.otp__title {
  font-size: 15.5px;
  font-weight: 600;
  font-stretch: 104%;
  letter-spacing: -0.01em;
}

.otp__sub {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- the field */
.otp__field {
  --h: clamp(42px, min(13.6vw, 11.5vh), 56px);
  position: relative;
  margin-top: clamp(16px, 4vh, 24px);
  height: var(--h);
}

.otp__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  font-size: 16px;
  color: transparent;
  background: transparent;
  caret-color: transparent;
  cursor: text;
  z-index: 3;
}

.otp__cells {
  position: absolute;
  inset: 0;
  display: flex;
  gap: clamp(5px, 1.8vw, 8px);
}

.otp__gap {
  flex: 0 0 clamp(2px, 1vw, 6px);
}

.cell {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  border-radius: 13px;
  background: linear-gradient(180deg, var(--cell), var(--cell-low));
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 1px 0 rgba(0, 0, 0, 0.7);
  transition: box-shadow 0.25s ease, background-color 0.25s ease;
}

.cell.is-active {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 4px rgba(255, 255, 255, 0.045);
}

.cell.is-error {
  box-shadow:
    inset 0 0 0 1px rgba(255, 93, 93, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 0 0 4px rgba(255, 93, 93, 0.09);
}

.cell.is-good {
  box-shadow:
    inset 0 0 0 1px rgba(43, 214, 131, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 0 4px rgba(43, 214, 131, 0.1);
}

/* the outline the light runs along */
.cell__edge {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  filter: drop-shadow(0 0 3px var(--light));
}

.cell__edge rect {
  fill: none;
  stroke: var(--light);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-dasharray: 16 84;
  stroke-dashoffset: 0;
  opacity: 0;
}

/* the reflection on the face of a cell */
.cell::after {
  content: '';
  position: absolute;
  inset: 1px 1px 50%;
  border-radius: 12px 12px 6px 6px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent);
  pointer-events: none;
}

.cell__digit {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(19px, min(6.2vw, 5.2vh), 25px);
  font-weight: 560;
  font-stretch: 96%;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--ink);
  opacity: 0;
}

.cell.is-error .cell__digit {
  color: #ffb3b3;
}

.cell__caret {
  position: absolute;
  left: 50%;
  top: 30%;
  bottom: 30%;
  width: 1.5px;
  margin-left: -0.75px;
  border-radius: 1px;
  background: var(--ink);
  opacity: 0;
}

.cell.is-active .cell__caret {
  animation: blink 1.05s steps(1) infinite;
}

@keyframes blink {
  0%, 55% { opacity: 1; }
  56%, 100% { opacity: 0; }
}

/* the approved pill */
.otp__done {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: min(100%, 236px);
  translate: -50% 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--green), var(--green-deep));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.18),
    0 10px 28px -10px rgba(43, 214, 131, 0.65);
  color: #04140b;
  font-size: 15px;
  font-weight: 640;
  font-stretch: 104%;
  letter-spacing: -0.01em;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 2;
}

.otp__tick {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(4, 20, 11, 0.14);
}

.otp__tick svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: #04140b;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.otp__done-words {
  display: inline-block;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- the status line */
.otp__status {
  margin: 14px 0 0;
  height: 18px;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
  overflow: hidden;
}

.otp__status-in {
  display: inline-block;
  white-space: nowrap;
}

.otp__status b {
  font-weight: 560;
  color: #b8bbc3;
}

.otp__status .is-checking {
  background: linear-gradient(90deg, var(--muted) 0%, var(--muted) 35%, #eafff5 50%, var(--muted) 65%, var(--muted) 100%);
  background-size: 260% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shine 1.2s linear infinite;
}

@keyframes shine {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}

.otp__status .is-wrong {
  color: var(--red);
}

.otp__status .is-right {
  color: var(--green);
}

/* ---------------------------------------------------------------- the code from Messages */
.otp__suggest {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: clamp(12px, 3vh, 18px);
  padding: 9px 12px 9px 9px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #17181c, #121316);
  box-shadow: inset 0 0 0 1px var(--edge), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: box-shadow 0.2s ease;
}

.otp__suggest.is-waiting,
.otp__suggest.is-used {
  cursor: default;
}

.otp__suggest:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4), 0 0 0 3px rgba(159, 245, 207, 0.25);
}

@media (hover: hover) {
  .otp__suggest:not(.is-waiting):not(.is-used):hover {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  }
}

.otp__bubble {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(180deg, #1d1f24, #16171b);
  box-shadow: inset 0 0 0 1px var(--edge), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* the green face of the bubble, faded in when the message arrives */
.otp__bubble::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, #2fd47f, #17a862);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.otp__suggest:not(.is-waiting) .otp__bubble::before {
  opacity: 1;
}

.otp__bubble svg {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 17px;
  height: 17px;
  margin: -8.5px 0 0 -8.5px;
}

.otp__msg {
  fill: #fff;
  opacity: 0;
}

.otp__spin {
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  animation: spin 0.9s linear infinite;
}

.otp__spin circle {
  stroke: rgba(255, 255, 255, 0.12);
}

.otp__spin path {
  stroke: var(--muted);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .otp__spin { animation: none; }
}

.otp__from span {
  display: inline-block;
}

.otp__from {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.otp__code {
  flex: none;
  font-size: 14.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

.otp__code span {
  display: inline-block;
}

/* ---------------------------------------------------------------- the pretend pointer */
.pointer {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.pointer path {
  fill: #ffffff;
  stroke: #000000;
  stroke-width: 1.2;
  stroke-linejoin: round;
}

@media (max-width: 380px) {
  .otp__title { font-size: 14.5px; }
  .otp__mark { width: 34px; height: 34px; border-radius: 11px; }
}
