:root {
  --bg: #f5f5f0;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --accent: #fffc00;
  --accent-text: #111;
  --border: #e2e2dc;
  --error: #c62828;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --card: #1d1d1d;
    --text: #f2f2f2;
    --muted: #a0a0a0;
    --border: #333;
    --error: #ff6b6b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--bg);
  color: var(--text);
  /* Avenir Next is the font Snapchat's app uses on iPhone; it's built into
     Apple devices, so it's used there. Everyone else gets Figtree, a free
     look-alike loaded from Google Fonts. */
  font-family: "Avenir Next", "Avenir", "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
}

h1 { font-weight: 800; letter-spacing: -0.01em; }
button { font-weight: 700; }
.name { font-weight: 700; }

.card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
}

h1 { margin: 0 0 6px; font-size: 1.6rem; }
.sub { margin: 0 0 24px; color: var(--muted); }

form { display: flex; gap: 8px; }

.field {
  flex: 1;
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 12px;
  background: var(--bg);
}
.field:focus-within { border-color: var(--text); }
.at { color: var(--muted); }

input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 12px 4px;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 0 20px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: 0.6; cursor: wait; }

.result { margin-top: 28px; }

.banner {
  height: 120px;
  margin: 0 -24px;
  background: var(--accent) center / cover no-repeat;
}
.banner.empty { background: var(--accent); }

.avatar-wrap {
  width: 148px;
  height: 148px;
  margin: -74px auto 0;
  padding: 4px;
  border-radius: 28px;
  background: var(--card);
}
.avatar-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 24px;
  background: var(--accent);
}
.result[data-type="profile"] .avatar-wrap,
.result[data-type="profile"] .avatar-wrap img { border-radius: 50%; }
.result[data-type="profile"] .avatar-wrap img { object-fit: cover; }

/* Purple ring when the user has a story up right now */
.avatar-wrap.has-story {
  background: conic-gradient(#9b5cff, #ff5ca8, #9b5cff);
}

.name {
  margin-top: 12px;
  font-weight: 600;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.verified {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1d9bf0;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.verified[hidden] { display: none; }
.handle { color: var(--muted); }

.details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 16px;
  margin: 24px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: left;
}
.details dt { color: var(--muted); white-space: nowrap; }
.details dd { margin: 0; min-height: 1.2em; overflow-wrap: anywhere; }
#f-bio { white-space: pre-line; }
.details a { color: inherit; }

/* ---- Blurred value with an animated "Show" button on top ---- */
.reveal {
  position: relative;
  display: inline-block;
  min-width: 90px;
  padding: 2px 8px;
  margin-left: -8px;
  border-radius: 8px;
}
.reveal-value {
  display: inline-block;
  transition: filter 0.45s ease, opacity 0.45s ease, transform 0.45s ease;
}
.reveal.empty .reveal-value { color: var(--muted); }

/* Hidden state: blurred text with a moving shimmer */
.reveal.hidden-value {
  background: linear-gradient(
    100deg,
    transparent 20%,
    rgba(255, 252, 0, 0.35) 50%,
    transparent 80%
  ) 0 0 / 200% 100%;
  animation: shimmer 1.8s linear infinite;
}
.reveal.hidden-value .reveal-value {
  filter: blur(7px);
  opacity: 0.8;
  user-select: none;
}

/* Revealed state: value pops into focus */
.reveal.revealed .reveal-value {
  animation: pop-in 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.reveal-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 2px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: 0 0 0 0 rgba(255, 220, 0, 0.7);
  animation: pulse 1.6s ease-out infinite;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.reveal-btn:hover { transform: translate(-50%, -50%) scale(1.08); }
.reveal-btn[hidden] { display: none; }

/* Button pops away when clicked */
.reveal.revealing .reveal-btn {
  animation: none;
  transform: translate(-50%, -50%) scale(0.4);
  opacity: 0;
  pointer-events: none;
}

/* ================= Popup card (layer 2) ================= */
.details dd:has(> .pop) { position: relative; }

.pop {
  position: absolute;
  top: calc(100% + 14px);
  left: -72px;
  z-index: 50;                       /* sits on top of everything below */
  width: min(300px, calc(100vw - 32px));
  padding: 18px 16px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.08);
  text-align: center;
  transform-origin: 110px -10px;     /* grows out of the arrow */
}
.pop[hidden] { display: none; }

/* Arrow pointing up at the Subscribers field */
.pop::before {
  content: "";
  position: absolute;
  top: -8px;
  left: var(--arrow-x, 102px);
  width: 16px;
  height: 16px;
  background: var(--card);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
}

.pop.opening { animation: pop-open 0.38s cubic-bezier(0.2, 1.5, 0.4, 1); }
.pop.closing { animation: pop-close 0.2s ease-in forwards; }

.pop-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
}
.pop-close:hover { background: var(--bg); color: var(--text); }

.pop-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.pop-body {
  position: relative;
  padding: 18px 8px;
  border-radius: 14px;
  overflow: hidden;
}
.pop-body.locked {
  background: linear-gradient(100deg, transparent 20%, rgba(255, 252, 0, 0.35) 50%, transparent 80%) 0 0 / 200% 100%,
              var(--bg);
  animation: shimmer 1.8s linear infinite;
}
.pop-body.locked .big-number,
.pop-body.locked .big-sub {
  filter: blur(11px);
  user-select: none;
}
.pop-body.locked .big-number { animation: bounce 0.9s ease-in-out infinite; }
.pop-body.unlocked { background: var(--bg); }

/* Second Show button, centred on the blur */
.pop-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 8px 26px;
  border-radius: 999px;
  font-size: 0.95rem;
  white-space: nowrap;
  animation: pulse 1.6s ease-out infinite;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.pop-btn:hover { transform: translate(-50%, -50%) scale(1.08); }
.pop-btn[hidden] { display: none; }
.pop-body.unlocking .pop-btn {
  animation: none;
  transform: translate(-50%, -50%) scale(0.4);
  opacity: 0;
}
.pop-body.unlocking .big-number,
.pop-body.unlocking .big-sub {
  transition: filter 0.3s ease;
  filter: blur(4px);
}

/* ================= The big stylish number ================= */
.big-number {
  display: inline-block;
  font-size: 2.2rem;
  white-space: nowrap;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(95deg, #ffb800 0%, #ff5c8a 50%, #9b5cff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.pop-body.unlocked .big-number { animation: number-in 0.5s cubic-bezier(0.2, 1.5, 0.4, 1); }
.big-number.landed { animation: number-land 0.45s ease; }
.big-number.big-empty {
  font-size: 1.8rem;
  background: none;
  color: var(--muted);
}
.big-sub {
  margin-top: 4px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

/* Clicking the card's Show: the blurred layer wobbles, blur stays */
.pop-body.locked.nudge {
  animation: shimmer 1.8s linear infinite, nudge 0.5s ease;
}
@keyframes nudge {
  0%, 100% { transform: translateX(0) scale(1); }
  20%      { transform: translateX(-6px) scale(1.02); }
  40%      { transform: translateX(5px); }
  60%      { transform: translateX(-3px); }
  80%      { transform: translateX(2px); }
}

/* Blurred areas are static: no shimmer, no bouncing behind the blur.
   (The Show buttons still pulse, and the card still wobbles on click.) */
.reveal.hidden-value,
.reveal.bouncing,
.pop-body.locked,
.pop-body.locked .big-number {
  animation: none;
  background-position: 0 0;
}
.reveal.hidden-value { background: none; }
.pop-body.locked { background: var(--bg); }
.pop-body.locked.nudge { animation: nudge 0.5s ease; }

@keyframes pop-open {
  from { opacity: 0; transform: scale(0.6) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes pop-close {
  to { opacity: 0; transform: scale(0.85) translateY(-6px); }
}
@keyframes number-in {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
@keyframes number-land {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* After "Show" is clicked: the blurred box stays static */
.reveal.bouncing {
  animation: none;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  30%      { transform: translateY(-6px) scale(1.04, 0.96); }
  50%      { transform: translateY(0) scale(0.97, 1.03); }
  70%      { transform: translateY(-2px) scale(1); }
}

@keyframes shimmer {
  from { background-position: 150% 0; }
  to   { background-position: -50% 0; }
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 220, 0, 0.7); }
  70%  { box-shadow: 0 0 0 10px rgba(255, 220, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 220, 0, 0); }
}
@keyframes pop-in {
  0%   { transform: scale(0.7); filter: blur(7px); opacity: 0; }
  100% { transform: scale(1);   filter: blur(0);   opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal.hidden-value,
  .reveal.bouncing,
  .pop, .pop-body, .pop-btn, .big-number,
  .reveal-btn,
  .reveal.revealed .reveal-value { animation: none; }
}

.msg { min-height: 1.2em; margin: 16px 0 0; }
.msg.error { color: var(--error); }
