/* Instagram-flavored gate. IG system font stack, IG palette. */

*,*::before,*::after { box-sizing: border-box; }
html,body { margin:0; padding:0; height:100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #fafafa;
  color: #262626;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

:root {
  --ig-text:      #262626;
  --ig-sub:       #8e8e8e;
  --ig-line:      #dbdbdb;
  --ig-bg:        #ffffff;
  --ig-blue:      #0095f6;
  --ig-blue-dark: #1877f2;
  --ig-red:       #ed4956;
  --radius:       12px;
}

/* ── SHELL ──────────────────────────────────────────────────── */
.ig-shell {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--ig-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (min-width: 480px) {
  body { padding: 24px 0; background: #e8eaed; }
  .ig-shell {
    height: min(880px, calc(100dvh - 48px));
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(0,0,0,.14), 0 0 0 1px rgba(0,0,0,.05);
  }
}

/* ── TOP BAR ────────────────────────────────────────────────── */
.ig-header {
  display: flex;
  align-items: center;
  padding: max(env(safe-area-inset-top), 12px) 16px 12px;
  border-bottom: 1px solid var(--ig-line);
  background: #fff;
  flex-shrink: 0;
}
.ig-wordmark {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--ig-text);
}

/* ── STAGE / SCREENS ────────────────────────────────────────── */
.ig-stage { position: relative; flex: 1; overflow: hidden; background: #fff; }
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; visibility: hidden;
  transform: translateY(6px);
  transition: opacity .28s ease, transform .28s ease, visibility 0s linear .28s;
}
.screen.is-active {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity .28s ease, transform .28s ease;
}
.screen--dark { background: #000; }
.ig-scroll {
  flex: 1; overflow-y: auto;
  padding: 28px 24px 32px;
  -webkit-overflow-scrolling: touch;
}

/* ── QR GATE ────────────────────────────────────────────────── */
.gate-hero { text-align: center; margin-bottom: 24px; }
.gate-logo { display: inline-flex; margin-bottom: 14px; }
.gate-title {
  margin: 0 0 8px;
  font-size: 22px; font-weight: 600;
  letter-spacing: -0.02em; color: var(--ig-text);
}
.gate-sub {
  margin: 0 auto;
  font-size: 14px; line-height: 1.5;
  color: var(--ig-sub); max-width: 300px;
}

.qr-card {
  background: #fff;
  border: 1px solid var(--ig-line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; flex-direction: column; align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.qr-img {
  display: block;
  width: 220px; height: 220px;
  image-rendering: pixelated;
  border-radius: 6px;
}
.qr-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: #15803d; font-weight: 500;
  background: #f0fdf4; border: 1px solid #dcfce7;
  border-radius: 999px; padding: 4px 10px;
}
.qr-tag .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #22c55e;
  animation: blink 1.6s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1;} 50%{opacity:.35;} }

.ig-btn {
  width: 100%; border: 0; cursor: pointer;
  background: var(--ig-blue); color: #fff;
  font-family: inherit; font-size: 15px; font-weight: 600; letter-spacing: -0.005em;
  padding: 13px 18px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s ease, transform .08s ease;
}
.ig-btn:hover  { background: var(--ig-blue-dark); }
.ig-btn:active { transform: scale(.985); }

.gate-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 22px 0 18px;
  color: var(--ig-sub); font-size: 12.5px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .08em;
}
.gate-divider::before, .gate-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--ig-line);
}

.store-row { display: flex; gap: 10px; margin-bottom: 22px; }
.store-pill {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 8px;
  border: 1px solid var(--ig-line); border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--ig-text);
  background: #fff; cursor: pointer;
  transition: background .15s ease;
  text-decoration: none;
}
.store-pill:hover { background: #fafafa; }

.legal {
  margin: 0; text-align: center;
  font-size: 12px; line-height: 1.5;
  color: var(--ig-sub);
}
.legal a { color: var(--ig-sub); text-decoration: none; font-weight: 500; }
.legal a:hover { text-decoration: underline; }

/* ── CAMERA ─────────────────────────────────────────────────── */
.cam-wrap { position: relative; flex: 1; overflow: hidden; background: #000; }
#camera { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.cam-scrim {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  pointer-events: none;
}
.cam-cutout {
  position: relative;
  width: min(74vw, 300px); height: min(74vw, 300px);
  border-radius: 16px;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.62);
}
.corner {
  position: absolute; width: 28px; height: 28px;
  border: 3px solid #fff; border-radius: 4px;
  filter: drop-shadow(0 0 6px rgba(255,255,255,.55));
}
.corner.tl { top: -2px; left: -2px; border-right: 0; border-bottom: 0; border-top-left-radius: 14px; }
.corner.tr { top: -2px; right: -2px; border-left: 0; border-bottom: 0; border-top-right-radius: 14px; }
.corner.bl { bottom: -2px; left: -2px; border-right: 0; border-top: 0; border-bottom-left-radius: 14px; }
.corner.br { bottom: -2px; right: -2px; border-left: 0; border-top: 0; border-bottom-right-radius: 14px; }

.scan-line {
  position: absolute; left: 8%; right: 8%; height: 2px;
  background: linear-gradient(90deg, transparent, #fff, transparent);
  border-radius: 2px; top: 12%;
  animation: scan 1.8s ease-in-out infinite;
}
@keyframes scan {
  0%   { top: 12%; opacity: .3; }
  50%  { top: 84%; opacity: 1;  }
  100% { top: 12%; opacity: .3; }
}

.cam-close {
  position: absolute; top: max(env(safe-area-inset-top), 16px); left: 16px;
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(0,0,0,.4); backdrop-filter: blur(8px);
  border: 0; color: #fff; cursor: pointer;
  display: grid; place-items: center;
}
.cam-close:hover { background: rgba(0,0,0,.55); }

.cam-foot {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0 24px max(env(safe-area-inset-bottom), 32px);
  text-align: center; color: #fff;
}
.cam-foot h2 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.cam-foot p  { margin: 0 0 14px; font-size: 13px; opacity: .78; line-height: 1.5; }

.cam-dots { display: inline-flex; gap: 6px; }
.cam-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255,255,255,.35);
  animation: pulse 1.2s ease-in-out infinite;
}
.cam-dots span:nth-child(2) { animation-delay: .2s; }
.cam-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes pulse {
  0%,80%,100% { background: rgba(255,255,255,.3); transform: scale(.85); }
  40%         { background: #fff; transform: scale(1); }
}

/* ── PROCESSING / ERROR ─────────────────────────────────────── */
.center-stack {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 32px; text-align: center;
}
.center-stack h2 { margin: 20px 0 6px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.center-stack p  { margin: 0; font-size: 14px; line-height: 1.55; }
.muted { color: var(--ig-sub); }
.center { text-align: center; }
.small { font-size: 12.5px; }

.ig-spinner { width: 56px; height: 56px; }
.ig-spinner svg { width: 100%; height: 100%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.err-badge {
  width: 72px; height: 72px; border-radius: 50%;
  background: #fef2f2; border: 1px solid #fee2e2;
  display: grid; place-items: center;
}

/* ── SUCCESS ────────────────────────────────────────────────── */
.profile-card { text-align: center; margin: 30px 0 26px; }
.profile-ring {
  width: 104px; height: 104px; border-radius: 50%;
  padding: 3px;
  background: conic-gradient(from 200deg, #fdf497, #fd5949, #d6249f, #285AEB, #fdf497);
  display: inline-grid; place-items: center;
  margin-bottom: 14px;
  animation: ring 4s linear infinite;
}
@keyframes ring {
  to { transform: rotate(360deg); }
}
.profile-inner {
  width: 100%; height: 100%; border-radius: 50%;
  background: #fff; border: 3px solid #fff;
  display: grid; place-items: center;
  transform: rotate(0deg);
  animation: ring-counter 4s linear infinite;
}
@keyframes ring-counter {
  to { transform: rotate(-360deg); }
}
.profile-handle { margin: 0 0 4px; font-size: 16px; font-weight: 600; color: var(--ig-text); }
.profile-sub { margin: 0; font-size: 13px; color: var(--ig-sub); }

.progress-bar {
  height: 4px; border-radius: 2px;
  background: #efefef; overflow: hidden;
  margin: 8px 0 14px;
}
.progress-fill {
  height: 100%; width: 30%;
  background: var(--ig-blue); border-radius: 2px;
  animation: fill 2.4s ease-in-out infinite;
}
@keyframes fill {
  0%   { width: 8%; margin-left: 0; }
  50%  { width: 60%; margin-left: 20%; }
  100% { width: 8%; margin-left: 92%; }
}

/* ── FOOTER ─────────────────────────────────────────────────── */
.ig-footer {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 16px max(env(safe-area-inset-bottom), 12px);
  font-size: 12px; color: var(--ig-sub);
  border-top: 1px solid var(--ig-line);
  background: #fff;
  flex-shrink: 0;
}