/*
 * R4 in-place sign-in modal — EXPLORE-SIGNUP task 6c (spec §5/§6/§7).
 * Token-only (design-system var()s) — passes the CSS token lint gate. The card
 * itself reuses .auth__* from auth.css; this file adds only the overlay, the
 * bottom-sheet responsive treatment, the code field, and the success tick.
 */

.r4-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  /* Token-based scrim: solid-charcoal fallback, then a translucent mix for
     evergreen browsers (no hardcoded colour — CSS token gate). */
  background: var(--color-charcoal);
  background: color-mix(in srgb, var(--color-charcoal) 55%, transparent);
  overflow-y: auto;
}

.r4-modal[hidden] { display: none; }

.r4-modal__card {
  position: relative;
  z-index: var(--z-modal);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.r4-modal__close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-4);
  width: 40px;
  height: 40px;
  line-height: 1;
  font-size: var(--font-size-2xl);
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--border-radius-full);
}

.r4-modal__close:hover { color: var(--color-text-primary); }
.r4-modal__close:focus-visible { outline: 2px solid var(--color-accent-blue); outline-offset: 2px; }

.r4-modal__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.r4-modal__fallback { margin-top: var(--space-3); }

/* Single input, styled to read as a 6-digit code entry (spec §5 — one input
   keeps paste + OS autofill robust; the cells are presentational). */
.r4-modal__code {
  text-align: center;
  letter-spacing: 0.6em;
  padding-left: 0.6em; /* balance the trailing letter-spacing so digits centre */
  font-size: var(--font-size-xl);
  font-variant-numeric: tabular-nums;
}

.r4-modal__success {
  text-align: center;
  padding: var(--space-6) 0;
}

.r4-modal__tick {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-2xl);
  color: var(--color-accent-green-dark);
  background: var(--color-accent-green-tint);
  border-radius: var(--border-radius-full);
}

/* Bottom-sheet on small screens (spec §5): full-width, pinned to the bottom,
   rounded top corners, safe-area inset — keeps the field above the keyboard. */
@media (max-width: 640px) {
  .r4-modal {
    align-items: flex-end;
    padding: 0;
  }
  .r4-modal__card {
    max-width: 100%;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
    max-height: 92vh;
    overflow-y: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .r4-modal, .r4-modal__card, .r4-modal__tick { transition: none; animation: none; }
}
