/* ==================================================
   CATALYST PHONE MODAL — Shared phone auth modal
   Used on: sign-in, checkout, any page with phone auth
   Extracted from v2-checkout.css so it loads everywhere
   the phone auth JS is enqueued.
   ================================================== */

/* ── Overlay ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  animation: modalFadeIn 0.2s ease;
}
.modal-overlay.is-open {
  display: flex;
}

/* ── Modal Card ── */
.modal {
  background: var(--white);
  border-radius: 20px;
  width: 90%;
  max-width: 380px;
  padding: 32px 28px;
  position: relative;
  box-shadow: 0 24px 80px rgba(0,0,0,0.15);
  animation: modalFadeUp 0.3s ease;
}

.modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--surface-warm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 16px;
  z-index: 1;
}
.modal__close:hover {
  background: transparent;
  color: var(--catalyst-orange);
  border-color: var(--catalyst-orange);
  transform: rotate(90deg);
}
.modal__close:active {
  background: var(--catalyst-orange);
  color: var(--white);
}
.modal__close {
  border: 1.5px solid var(--border-solid);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Header — compact: text left, icon right ── */
.modal__header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.modal__header-text {
  flex: 1;
}
.modal__header-text .modal__title {
  margin-bottom: 4px;
}
.modal__header-text .modal__desc {
  margin-bottom: 0;
}

/* ── Icon ── */
.modal__icon {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.modal__icon--google {
  background: #f1f3f4;
}
.modal__icon--phone {
  background: var(--catalyst-orange-light);
}
.modal__icon svg {
  width: 22px;
  height: 22px;
}

/* ── Typography ── */
.modal__title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
  line-height: 1.2;
}

.modal__desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

/* ── Inputs ── */
.modal__input {
  width: 100%;
  padding: 14px 16px;
  font-family: var(--font);
  font-size: var(--input-font-size);
  border: 1.5px solid var(--border-solid);
  border-radius: 12px;
  outline: none;
  background: var(--white);
  box-sizing: border-box;
}
.modal__input:focus {
  border-color: var(--carbon);
}
.modal__input--phone {
  font-family: var(--font-mono);
  font-size: 18px;
  letter-spacing: 0.04em;
  text-align: center;
  transition: border-color 0.2s;
}
.modal__input--phone.has-value {
  border-color: var(--carbon);
}

/* ── Buttons ── */
.modal__btn {
  width: 100%;
  padding: 14px;
  border-radius: 100px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 14px;
  transition: all 0.2s;
}
.modal__btn--google {
  background: var(--carbon);
  color: var(--white);
  border: 1.5px solid var(--carbon);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.modal__btn--google:hover {
  background: transparent;
  color: var(--catalyst-orange);
  border-color: var(--catalyst-orange);
}
.modal__btn--phone {
  background: var(--carbon);
  color: var(--white);
  border: 1.5px solid var(--carbon);
}
.modal__btn--phone:hover {
  background: transparent;
  color: var(--catalyst-orange);
  border-color: var(--catalyst-orange);
}

/* ── Divider ── */
.modal__divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
}
.modal__divider::before,
.modal__divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-solid);
}
.modal__divider span {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ── Footer ── */
.modal__footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 16px;
}
.modal__footer a {
  color: var(--catalyst-teal);
  text-decoration: none;
}

/* ── Phone Keypad ── */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
}
.keypad__key {
  height: 52px;
  border-radius: 12px;
  border: 1px solid var(--border-solid);
  background: var(--white);
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  transition: all 0.15s;
}
.keypad__key:hover {
  background: var(--surface-warm);
}
.keypad__key:active {
  background: var(--border-solid);
  transform: scale(0.95);
}
.keypad__key.is-pressed {
  animation: keypadPop 0.2s ease;
}
.keypad__key--wide {
  grid-column: span 1;
}
.keypad__key--del {
  font-size: 14px;
  color: var(--white);
  background: var(--carbon);
  border-color: var(--carbon);
}
.keypad__key--del:hover {
  background: transparent;
  color: var(--catalyst-orange);
  border-color: var(--catalyst-orange);
}
.keypad__key--del:active {
  background: var(--catalyst-orange);
  color: var(--white);
  border-color: var(--catalyst-orange);
  transform: scale(0.95);
}
.keypad__key--empty {
  border-color: transparent;
  background: transparent;
  cursor: default;
}
.keypad__key--empty:hover {
  background: transparent;
}
.keypad__letters {
  display: block;
  font-size: 8px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: -2px;
}

/* ── Verification Code Input ── */
.phone-code-digit {
  width: 48px;
  height: 52px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  border: 1.5px solid var(--border-solid);
  border-radius: 12px;
  outline: none;
  background: var(--white);
  transition: border-color 0.2s;
}
.phone-code-digit:focus {
  border-color: var(--carbon);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}
.phone-code-digit.is-filled {
  border-color: var(--carbon);
  animation: digitPop 0.15s ease;
}

/* ── Code area container ── */
#phone-code-area {
  display: none;
  text-align: center;
}
#phone-code-area .phone-code-digit {
  margin: 0 4px;
}

/* ── Error message ── */
#phone-code-error {
  display: none;
  color: var(--error, #d32f2f);
  font-size: 13px;
  margin-top: 8px;
  text-align: center;
}
#phone-code-area.has-error .phone-code-digit {
  border-color: var(--error, #d32f2f);
  animation: shake 0.4s ease;
}

/* ── Success flash ── */
#phone-code-area.is-verified .phone-code-digit {
  border-color: #2e7d32;
  background: rgba(46,125,50,0.05);
  transition: all 0.3s ease;
}
.modal__btn.is-loading {
  pointer-events: none;
  opacity: 0.7;
}
.modal__btn.is-success {
  background: #2e7d32 !important;
  border-color: #2e7d32 !important;
  color: var(--white) !important;
  pointer-events: none;
}

/* ── Resend timer ── */
#resend-timer {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 12px;
}
#resend-link {
  font-size: 12px;
  color: var(--catalyst-teal);
  text-decoration: none;
  cursor: pointer;
}

/* ── Animations ── */
@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modalFadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes keypadPop {
  0%   { background: var(--border-solid); }
  100% { background: var(--white); }
}
@keyframes digitPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-4px); }
  40%      { transform: translateX(4px); }
  60%      { transform: translateX(-3px); }
  80%      { transform: translateX(2px); }
}

/* ── Mobile ── */
@media screen and (max-width: 768px) {
  .modal__input,
  .phone-code-digit {
    font-size: var(--input-font-size) !important;
  }

  .modal {
    padding: 28px 24px;
    border-radius: 16px;
  }
}
