/* Theme tokens follow the organization's landing page (landing-pages repo):
   neutral page background per theme, primary color as the accent. */
:root {
  --brand: #5f2580;
  --accent: #9a7ab0;

  --bg: #fafafa;
  --text: #212529;
  --muted: rgba(33, 37, 41, .62);
  --surface: #ffffff;
  --glass: rgba(255, 255, 255, .5);
  --glass-border: rgba(255, 255, 255, .7);
  --glass-shine: rgba(255, 255, 255, .55);
  --glass-shadow: 0 12px 32px rgba(0, 0, 0, .18), inset 0 1px 0 rgba(255, 255, 255, .5);
  --track: rgba(0, 0, 0, .08);
  --blob-opacity: .55;
  --radius: 28px;
  color-scheme: only light;
}

:root[data-theme="dark"] {
  --bg: #121212;
  --text: #dee2e6;
  --muted: rgba(222, 226, 230, .6);
  --surface: #1c1c1e;
  --glass: rgba(30, 30, 30, .5);
  --glass-border: rgba(255, 255, 255, .15);
  --glass-shine: rgba(255, 255, 255, .12);
  --glass-shadow: 0 12px 32px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .06);
  --track: rgba(255, 255, 255, .12);
  --blob-opacity: .6;
  color-scheme: only dark;
}

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

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 16px calc(max(20px, env(safe-area-inset-bottom)) + 56px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  transition: background-color .4s ease, color .4s ease;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Soft glows in the organization's colors behind the card */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(40px);
  opacity: var(--blob-opacity);
  transition: background-color .6s ease;
  animation: drift 18s ease-in-out infinite alternate;
}

.b1 { background: var(--brand); top: -30vmax; left: -22vmax; }
.b2 { background: var(--accent); bottom: -32vmax; right: -26vmax; animation-duration: 22s; animation-delay: -6s; }
.b3 { background: var(--brand); opacity: calc(var(--blob-opacity) * .6); bottom: -34vmax; left: 8vmax; width: 40vmax; height: 40vmax; animation-duration: 26s; animation-delay: -12s; }

/* Passes behind the card so the glass has something to refract */
.b4 {
  background: var(--brand);
  width: min(70vw, 360px);
  height: min(70vw, 360px);
  top: calc(50% - min(35vw, 180px) - 120px);
  left: calc(50% - min(35vw, 180px) + 60px);
  filter: blur(24px);
  animation: orbit 14s ease-in-out infinite alternate;
}

@keyframes orbit {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(-140px, 220px, 0) scale(.85); }
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(8vmax, 6vmax, 0) scale(1.15); }
}

/* Card — same "liquid glass" material as the landing page */
.card {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 40px 28px 32px;
  text-align: center;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  animation: rise .7s cubic-bezier(.2, .8, .2, 1) both;
}

/* Light catching the top edge of the glass */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(160deg, var(--glass-shine), transparent 38%);
  pointer-events: none;
}

.card > * { position: relative; }

/* Browsers without backdrop-filter get the landing page's opaque glass */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass: rgba(255, 255, 255, .95); }
  :root[data-theme="dark"] { --glass: rgba(30, 30, 30, .95); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

/* Pulsing ring while the page is working */
.logo-wrap {
  position: relative;
  width: 104px;
  margin: 0 auto;
}

.logo-wrap::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 36px;
  border: 2px solid var(--brand);
  opacity: 0;
}

[data-state="loading"] .logo-wrap::before,
[data-state="redirecting"] .logo-wrap::before {
  animation: pulse 1.8s ease-out infinite;
}

@keyframes pulse {
  0%   { opacity: .6; transform: scale(.94); }
  100% { opacity: 0;  transform: scale(1.18); }
}

.logo {
  position: relative;
  width: 104px;
  height: 104px;
  margin: 0 auto 24px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--track);
  border-radius: 28px;
  box-shadow: 0 10px 24px -10px rgba(0, 0, 0, .3);
  overflow: hidden;
}

.logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 10px;
}

.logo img.fill {
  object-fit: cover;
  padding: 0;
}

.logo-initial {
  font-size: 44px;
  font-weight: 700;
  color: var(--brand);
}

h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

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

.skeleton {
  display: block;
  width: 60%;
  height: 1.2em;
  margin-left: auto;
  margin-right: auto;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--track) 0%, transparent 50%, var(--track) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  from { background-position: 100% 0; }
  to   { background-position: -100% 0; }
}

/* Status */
.status {
  margin: 28px 0 0;
  min-height: 48px;
}

.status-text {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
}

.progress {
  height: 4px;
  margin: 0 auto 14px;
  max-width: 180px;
  border-radius: 4px;
  background: var(--track);
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: inherit;
  background: var(--brand);
  animation: indeterminate 1.2s ease-in-out infinite;
}

[data-state="redirecting"] .progress span {
  width: 100%;
  animation: fill var(--redirect-ms, 1800ms) linear both;
  transform-origin: left;
}

[data-state="ready"] .progress,
[data-state="error"] .progress { display: none; }

[data-state="ready"] .status,
[data-state="error"] .status { min-height: 0; }

@keyframes indeterminate {
  from { transform: translateX(-100%); }
  to   { transform: translateX(250%); }
}

@keyframes fill {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* Store buttons — black like the official badges, in both themes */
.stores {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

.stores[hidden], .store[hidden] { display: none; }

.store {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  min-height: 60px;
  color: #ffffff;
  background: #000000;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 16px;
  text-decoration: none;
  text-align: left;
  transition: transform .15s ease, box-shadow .15s ease;
  animation: rise .5s cubic-bezier(.2, .8, .2, 1) both;
}

.store + .store { animation-delay: .08s; }

.store:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -10px rgba(0, 0, 0, .6); }
.store:active { transform: scale(.98); }
.store:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }

.store svg { flex: none; width: 28px; height: 28px; fill: currentColor; }

.store small {
  display: block;
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: .02em;
  opacity: .8;
}

.store strong {
  display: block;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.01em;
}

.store .arrow { margin-left: auto; opacity: .5; font-size: 20px; }

.hint {
  margin: 20px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* BEMP mark fixed at the bottom of the page, framed by two fading hairlines.
   The logo is white, the light theme shows it in black like the landing page */
.brand-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(20px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  pointer-events: none;
}

.brand-footer::before,
.brand-footer::after {
  content: "";
  width: 32px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--text));
  opacity: .25;
}

.brand-footer::after { transform: scaleX(-1); }

.brand-footer a {
  display: flex;
  padding: 4px;
  border-radius: 6px;
  pointer-events: auto;
}

.brand-footer img {
  height: 18px;
  width: auto;
  opacity: .45;
  transition: opacity .2s ease;
}

:root:not([data-theme="dark"]) .brand-footer img { filter: brightness(0); }

.brand-footer a:hover img { opacity: .85; }
.brand-footer a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition: none !important;
  }
}
