:root {
  --color-bg: #f5f6f8;
  --color-card: #ffffff;
  --color-navy: #1a2340;
  --color-navy-light: #2d3a5c;
  --color-green: #03178c;
  --color-green-light: #e8ebf7;
  --color-border: #e2e8f0;
  --color-text-muted: #6b7280;
  --color-error: #dc2626;
  --radius: 16px;
  --shadow: 0 4px 24px rgba(26, 35, 64, 0.08);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] { display: none !important; }

html, body {
  height: 100%;
}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-navy);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
  line-height: 1.6;
}

.container {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 36px;
  width: 100%;
  max-width: 460px;
  text-align: center;
}

/* Logo */
.logo-area {
  margin-bottom: 32px;
}

.wordmark img {
  width: 150px;
  height: auto;
}

/* Divider */
.divider {
  height: 1px;
  background: var(--color-border);
  margin: 0 -36px 32px;
}

/* Headings */
h1 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 26px;
  font-weight: 400;
  color: var(--color-navy);
  margin-bottom: 10px;
  line-height: 1.3;
}

.subtitle {
  font-size: 15px;
  color: var(--color-text-muted);
  margin-bottom: 28px;
}

/* Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: var(--color-text-muted);
  font-size: 15px;
}

/* QR Container */
.qr-wrapper {
  display: inline-block;
  padding: 16px;
  border: 2px solid var(--color-border);
  border-radius: 12px;
  margin-bottom: 16px;
  animation: pulse-ring 2s ease-in-out infinite;
  background: #fff;
}

@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(3, 23, 140, 0.35); }
  50%  { box-shadow: 0 0 0 8px rgba(3, 23, 140, 0); }
  100% { box-shadow: 0 0 0 0 rgba(3, 23, 140, 0); }
}

#qr-container {
  width: 240px;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#qr-container img,
#qr-container canvas {
  border-radius: 4px;
}

.bankid-label {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.bankid-label::before,
.bankid-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* Deep link button */
.btn-deeplink {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border: 2px solid var(--color-green);
  border-radius: 8px;
  background: transparent;
  color: var(--color-green);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}

.btn-deeplink:hover {
  background: var(--color-green);
  color: #fff;
}

.btn-deeplink:focus-visible {
  outline: 3px solid var(--color-green);
  outline-offset: 2px;
}

/* Verifying state */
.verifying-content {
  padding: 12px 0;
}

.verifying-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}

/* Verified state */
.verified-content {
  padding: 8px 0;
}

.checkmark-svg {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
}

.checkmark-circle {
  stroke: var(--color-green);
  stroke-width: 2;
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  stroke-miterlimit: 10;
  animation: stroke-circle 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark-check {
  stroke: var(--color-green);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: stroke-check 0.4s cubic-bezier(0.65, 0, 0.45, 1) 0.5s forwards;
}

@keyframes stroke-circle {
  100% { stroke-dashoffset: 0; }
}

@keyframes stroke-check {
  100% { stroke-dashoffset: 0; }
}

.verified-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 24px;
  font-weight: 400;
  color: var(--color-green);
  margin-bottom: 24px;
}

.identity-card {
  background: var(--color-green-light);
  border: 1px solid #c3e0c1;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  text-align: left;
}

.identity-card .label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.identity-card .value {
  font-size: 17px;
  font-weight: 500;
  color: var(--color-navy);
  margin-bottom: 14px;
}

.identity-card .value:last-of-type {
  margin-bottom: 0;
}

.verified-message {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.verified-timestamp {
  font-size: 12px;
  color: #9ca3af;
}

.redirect-countdown {
  margin-top: 20px;
  display: flex;
  justify-content: center;
}

.countdown-ring {
  position: relative;
  width: 72px;
  height: 72px;
}

.countdown-svg {
  width: 72px;
  height: 72px;
  transform: rotate(-90deg);
}

.countdown-track {
  stroke: var(--color-green-light);
  stroke-width: 2;
}

.countdown-progress {
  stroke: var(--color-green);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 157;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.9s linear;
}

.countdown-number {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 600;
  color: var(--color-green);
}

/* Error state */
.error-icon {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
}

.error-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-navy);
  margin-bottom: 8px;
}

.error-message {
  font-size: 15px;
  color: var(--color-text-muted);
  margin-bottom: 24px;
}

.btn-restart {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--color-navy);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-restart:hover {
  background: var(--color-navy-light);
}

.btn-restart:focus-visible {
  outline: 3px solid var(--color-navy);
  outline-offset: 2px;
}

/* State visibility */
.state {
  display: none;
}

.state.active {
  display: block;
}

/* Footer */
.footer {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
  font-size: 12px;
  color: #9ca3af;
}

/* Fade transition */
.state {
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
  .container {
    padding: 28px 20px;
  }
  .divider {
    margin: 0 -20px 28px;
  }
}
