/* ==========================================================================
   09-OTP-MODAL.CSS — Al Aliyah Supermarket implementation kit
   Status: PENDING REVIEW.

   The generic `.aly-modal` scaffold lives here because the OTP sign-in
   popup is this kit's primary/reference modal, but the scaffold itself is
   reusable for any dialog (address-edit, confirm-remove, etc.) — see
   js/otp-modal.js for the paired behaviour (focus trap, Escape, etc.).
   ========================================================================== */

.aly-modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgb(32 22 8 / 0.5);
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-base) var(--ease-standard), visibility var(--duration-base);
}

.aly-modal-backdrop--open {
  opacity: 1;
  visibility: visible;
}

.aly-modal {
  z-index: var(--z-modal);
  background-color: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg); /* a genuinely floating layer — drop shadow is correct here, still warm-tinted */
  max-inline-size: 420px;
  inline-size: 100%;
  max-block-size: min(90vh, 640px);
  overflow-y: auto;
  transform: translateY(12px) scale(0.98);
  transition: transform var(--duration-slow) var(--ease-decel);
}

.aly-modal-backdrop--open .aly-modal {
  transform: translateY(0) scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .aly-modal,
  .aly-modal-backdrop {
    transition: none;
  }
}

.aly-modal__header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-6) var(--space-4);
  text-align: center;
}

.aly-modal__logo {
  block-size: 40px; /* OTP popup header minimum per brand foundation doc */
  inline-size: auto;
}

.aly-modal__title {
  font-family: var(--font-sans); /* UI chrome, not brand-display */
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--color-text);
}

.aly-modal__subtitle {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  max-inline-size: 32ch;
}

.aly-modal__close {
  position: absolute;
  inset-block-start: var(--space-3);
  inset-inline-end: var(--space-3);
}

.aly-modal__body {
  padding: 0 var(--space-6) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.aly-modal__footer {
  padding: 0 var(--space-6) var(--space-6);
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   OTP flow steps — phone entry then 6-digit code. Both steps live in the
   DOM together; js/otp-modal.js toggles [data-step] on the container.
   -------------------------------------------------------------------------- */
.aly-otp-flow[data-step="phone"] .aly-otp-flow__step--code,
.aly-otp-flow[data-step="code"] .aly-otp-flow__step--phone {
  display: none;
}

.aly-otp-flow__step {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.aly-otp-flow__change-number {
  align-self: center;
  font-size: var(--fs-sm);
  color: var(--gold-text-on-white);
  background: none;
  border: 0;
  padding: var(--space-1);
  min-block-size: var(--touch-target-min);
}

.aly-otp-flow__change-number:hover {
  text-decoration: underline;
}

/* ---- aria-live announcement region for errors + resend timer ---- */
.aly-otp-flow__live {
  min-block-size: 1.25em; /* reserve space so layout doesn't jump when a message appears */
}

/* ---- Error state banners, one per failure mode named in the brief ---- */
.aly-otp-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
}

.aly-otp-alert--invalid-code,
.aly-otp-alert--expired {
  background-color: var(--color-error-bg);
  color: var(--color-error-strong);
}

.aly-otp-alert--too-many-attempts,
.aly-otp-alert--rate-limited {
  background-color: var(--color-warning-bg);
  color: var(--color-warning-text);
}

.aly-otp-alert--network {
  background-color: var(--color-surface-sunk);
  color: var(--color-text-body);
}

.aly-otp-alert__icon {
  flex: none;
  inline-size: 1.1rem;
  block-size: 1.1rem;
  margin-block-start: 0.1em;
}

.aly-otp-alert__retry {
  margin-inline-start: auto;
  flex: none;
}

/* ---- Loading state on the whole flow while a request is in-flight ---- */
.aly-otp-flow[aria-busy="true"] {
  position: relative;
}

.aly-otp-flow[aria-busy="true"] .aly-otp-flow__step {
  opacity: 0.6;
  pointer-events: none;
}
