/* ═══════════════ Passkey ceremony overlay (.tc-pk-*) ═════════════════════
   Ported from _reference/passkey-ux-kit/client/passkey-ux.css. The kit's
   `--pk-*` token NAMES are kept (they are scoped to .tc-pk-overlay and leak
   nowhere) but their VALUES map onto TC tokens from src/css/system/tokens.css,
   so the overlay follows the app theme instead of the device theme.

   Shared by the classic pages (admin login, portal) and the admin SPA — the
   SPA imports this same file from admin-spa/src/lib/passkey-ceremony.js. */
.tc-pk-overlay {
  --pk-surface: var(--surface-card);
  --pk-border: var(--border-default);
  --pk-heading: var(--text-heading);
  --pk-dim: var(--text-muted);
  --pk-accent: var(--accent);
  --pk-accent-glow: var(--accent-glow);
  --pk-accent-muted: color-mix(in srgb, var(--accent) 10%, transparent);
  --pk-hover: var(--surface-card-hover);
  --pk-success: var(--status-success);
  --pk-success-muted: color-mix(in srgb, var(--status-success) 14%, transparent);
  --pk-danger: var(--tc-danger-light);

  position: fixed;
  inset: 0;
  /* SPA defines --z-toast (2700, above modal 1200 / popover 2000); the classic
     pages do not, so the fallback clears portal.css's 9999 ceiling. */
  z-index: var(--z-toast, 10000);
  display: grid;
  place-items: center;
  background: rgba(4, 6, 10, 0.6);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
/* The --pk-* tokens above already flip with the theme; only the backdrop is a
   literal that needs a light-mode counterpart. */
[data-theme='light'] .tc-pk-overlay,
.light-mode .tc-pk-overlay {
  background: rgba(15, 23, 42, 0.4);
}
.tc-pk-overlay.tc-pk-open {
  opacity: 1;
}
.tc-pk-card {
  width: 300px;
  padding: 34px 28px 26px;
  text-align: center;
  background: var(--pk-surface);
  border: 1px solid var(--pk-border);
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
  transform: translateY(14px) scale(0.96);
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.tc-pk-open .tc-pk-card {
  transform: none;
}
.tc-pk-orb {
  position: relative;
  width: 84px;
  height: 84px;
  margin: 0 auto 18px;
}
.tc-pk-orb-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--pk-accent-glow);
  opacity: 0;
}
.tc-pk-open .tc-pk-orb-ring {
  animation: tc-pk-pulse 1.6s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}
.tc-pk-orb-ring:nth-child(2) {
  animation-delay: 0.45s !important;
}
@keyframes tc-pk-pulse {
  0% {
    transform: scale(0.75);
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}
.tc-pk-orb-core {
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--pk-accent-muted);
  color: var(--pk-accent);
  transition:
    background 0.3s,
    color 0.3s;
}
.tc-pk-success .tc-pk-orb-core {
  background: var(--pk-success-muted);
  color: var(--pk-success);
}
.tc-pk-success .tc-pk-orb-ring {
  animation: none;
  opacity: 0;
}
.tc-pk-check {
  stroke-dasharray: 26;
  stroke-dashoffset: 26;
}
.tc-pk-success .tc-pk-check {
  animation: tc-pk-draw 0.45s cubic-bezier(0.22, 1, 0.36, 1) 0.1s forwards;
}
@keyframes tc-pk-draw {
  to {
    stroke-dashoffset: 0;
  }
}
.tc-pk-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 650;
  color: var(--pk-heading);
}
.tc-pk-sub {
  margin: 0 0 20px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--pk-dim);
}
.tc-pk-cancel {
  background: none;
  border: 0;
  color: var(--pk-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 8px;
}
.tc-pk-cancel:hover {
  color: var(--pk-heading);
  background: var(--pk-hover);
}

/* ---- Post-login enrollment offer (one card, morphs into the ceremony) ----
   Stages via data-pk-stage on .tc-pk-card: 'offer' → 'ceremony' → 'done'.
   Offer rings breathe; leaving offer hands back to the base .tc-pk-open radar
   pulse. Icons stack in the orb core and crossfade between stages. */
.tc-pk-orb-core > svg {
  grid-area: 1 / 1;
}
.tc-pk-icon-face,
.tc-pk-icon-key {
  transition:
    opacity 0.3s,
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.tc-pk-card[data-pk-stage='offer'] .tc-pk-icon-key,
.tc-pk-card[data-pk-stage='done'] .tc-pk-icon-key,
.tc-pk-card[data-pk-stage='ceremony'] .tc-pk-icon-face,
.tc-pk-card[data-pk-stage='done'] .tc-pk-icon-face {
  opacity: 0;
  transform: scale(0.55);
}
.tc-pk-card[data-pk-stage='offer'] .tc-pk-orb-ring {
  animation: tc-pk-breathe 3.4s ease-in-out infinite;
}
.tc-pk-card[data-pk-stage='offer'] .tc-pk-orb-ring:nth-child(2) {
  animation-delay: 1.7s !important;
}
@keyframes tc-pk-breathe {
  0%,
  100% {
    transform: scale(0.82);
    opacity: 0.3;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.75;
  }
}
.tc-pk-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tc-pk-primary {
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--pk-accent);
  color: #fff;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 22px var(--pk-accent-glow);
  transition:
    transform 0.2s,
    filter 0.2s;
}
.tc-pk-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}
.tc-pk-primary:active {
  transform: none;
}
.tc-pk-error {
  margin: -10px 0 14px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--pk-danger);
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .tc-pk-overlay,
  .tc-pk-card {
    transition-duration: 0.01ms;
  }
  .tc-pk-open .tc-pk-orb-ring {
    animation: none;
    opacity: 0.5;
  }
  .tc-pk-card[data-pk-stage='offer'] .tc-pk-orb-ring {
    animation: none;
    opacity: 0.5;
  }
  .tc-pk-success .tc-pk-check {
    animation-duration: 0.01ms;
  }
  .tc-pk-icon-face,
  .tc-pk-icon-key,
  .tc-pk-primary {
    transition-duration: 0.01ms;
  }
}

/* ---- Forced colors (Windows High Contrast) ---- */
@media (forced-colors: active) {
  .tc-pk-primary,
  .tc-pk-cancel {
    border: 1px solid ButtonText;
  }
}
