/*
 * Rutan för engångskoden vid inloggning — ren stil (Quiet Interface) med
 * kodrutorna från Rörelselabbet. Logiken ligger i kodrutor.js.
 */

#totp-dialog {
  width: min(92vw, 420px);
  border: 1px solid rgba(0, 0, 0, .09);
  border-radius: 16px;
  padding: 0;
  background: #fff;
  color: #202020;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .11);
  font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
}
#totp-dialog::backdrop { background: rgba(20, 20, 20, .32); }
#totp-dialog[open] { animation: kod-in 200ms cubic-bezier(.2, 0, 0, 1); }
@keyframes kod-in { from { opacity: 0; transform: translateY(4px); } }

#totp-dialog .totp-dialog-card { padding: 32px 28px 20px; text-align: center; }
#totp-dialog .totp-dialog-card h2 {
  font-family: inherit;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -.01em;
  margin: 0 0 6px;
  color: #202020;
}
#totp-dialog .totp-dialog-card p {
  font-size: 14px;
  line-height: 1.55;
  color: #666;
  margin: 0 0 24px;
}
/* Rubriken räcker — etiketten finns kvar för skärmläsare. */
#totp-dialog .totp-dialog-card label {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ── Kodrutorna ─────────────────────────────────────────────────────── */
.kodrutor { position: relative; display: flex; justify-content: center; margin: 0 auto; }
#totp-dialog .kodrutor input {
  position: absolute; inset: 0; z-index: 2;
  width: 100%; height: 100%; min-height: 0;
  margin: 0; padding: 0; border: 0; border-radius: 0;
  background: transparent; color: transparent; caret-color: transparent;
  font-size: 16px; letter-spacing: 0;
  opacity: 0; outline: none; cursor: text;
}
.kodrutor-rader { display: flex; gap: 8px; }
.kodruta {
  position: relative;
  display: grid; place-items: center;
  width: 46px; height: 54px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, .09);
  border-radius: 12px;
  background: #fff;
  font: 600 20px/1 Inter, -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
  color: #202020;
  transition: border-color 200ms cubic-bezier(.2, 0, 0, 1), box-shadow 200ms cubic-bezier(.2, 0, 0, 1);
}
.kodruta[data-fylld] { border-color: rgba(0, 0, 0, .18); }
.kodruta[data-aktiv] { border-color: #202020; box-shadow: 0 0 0 3px rgba(0, 0, 0, .05); }

/* Markören: mitt i en tom ruta, till höger om siffran i en fylld. */
.kodruta[data-aktiv]::after {
  content: '';
  position: absolute; top: 50%; left: 50%;
  width: 1px; height: 22px;
  background: #202020;
  transform: translate(-50%, -50%);
  animation: kod-blink 1s steps(1, end) infinite;
}
.kodruta[data-efter]::after { left: auto; right: 10px; transform: translateY(-50%); }
@keyframes kod-blink { 50% { opacity: 0; } }

.kodsiffra {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  animation: kod-upp 220ms cubic-bezier(.16, 1, .3, 1) both;
}
.kodsiffra.ut { animation: kod-ut 220ms cubic-bezier(.16, 1, .3, 1) both; }
@keyframes kod-upp { from { opacity: 0; transform: translateY(14px); filter: blur(4px); } }
@keyframes kod-ut { to { opacity: 0; transform: translateY(-14px); filter: blur(4px); } }

/* ── Fel, knappar, reservlänk ───────────────────────────────────────── */
#totp-dialog .auth-error { font-size: 13px; color: #c0362c; margin: 12px 0 0; }
#totp-dialog .auth-error:not(.visible) { display: none; }

#totp-dialog .privacy-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin: 24px 0 0;
}
#totp-dialog .privacy-action {
  height: 40px; margin: 0; padding: 0 16px;
  border: 1px solid rgba(0, 0, 0, .09);
  border-radius: 10px;
  background: #fff;
  color: #202020;
  font: 500 14px/1 Inter, -apple-system, sans-serif;
  cursor: pointer;
  transition: transform 140ms cubic-bezier(.23, 1, .32, 1), background-color 160ms ease, border-color 160ms ease;
}
#totp-dialog .privacy-action:hover { border-color: rgba(0, 0, 0, .18); background: #fafafa; }
#totp-dialog .privacy-action.primary { background: #2b2b2b; border-color: #2b2b2b; color: #fafafa; }
#totp-dialog .privacy-action.primary:hover { background: #1a1a1a; border-color: #1a1a1a; }
#totp-dialog .privacy-action:active { transform: scale(.97); }

#totp-dialog .totp-backup-link {
  display: block; width: 100%;
  margin: 12px 0 0; padding: 8px;
  border: 0; background: none;
  font: 500 13px/1.4 Inter, -apple-system, sans-serif;
  color: #8e8e8e;
  cursor: pointer;
  transition: color 160ms ease;
}
#totp-dialog .totp-backup-link:hover { color: #202020; }

@media (prefers-reduced-motion: reduce) {
  #totp-dialog[open], .kodsiffra, .kodsiffra.ut { animation-duration: 1ms; }
  .kodruta[data-aktiv]::after { animation: none; }
}
@media (max-width: 400px) {
  .kodruta { width: 40px; height: 48px; font-size: 18px; }
  .kodrutor-rader { gap: 6px; }
}
