/* Email gate + preview card styles. Loaded only on the home page. Matches
   the existing purple-on-cream palette used elsewhere on the site. */

/* ── Preview card (shown immediately after Analyse) ─────────────────────── */

.preview-card {
  max-width: 720px;
  margin: 24px auto 0;
  background: #FFFFFF;
  border: 1px solid #E4DAF3;
  border-radius: 14px;
  padding: 22px 24px 20px;
  box-shadow: 0 6px 24px rgba(91, 31, 138, 0.06);
  animation: fadeUp 320ms ease-out;
}

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

/* "Account found" badge above the identity block. Loud green tick on a
   light fill so the user instantly registers that we matched them. */
.preview-found {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #E8F8EE;
  border: 1px solid #BFE5CB;
  color: #207A3C;
  border-radius: 999px;
  padding: 6px 14px 6px 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 16px;
  animation: foundPop 480ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.preview-found-tick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: #2EA049;
  color: #FFFFFF;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}

@keyframes foundPop {
  0%   { opacity: 0; transform: scale(0.85); }
  60%  { opacity: 1; transform: scale(1.06); }
  100% { opacity: 1; transform: scale(1); }
}

.preview-card-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
  padding: 18px 20px;
  background: linear-gradient(135deg, #F8F4FC 0%, #FCFBFE 100%);
  border: 1px solid #EADFF6;
  border-radius: 12px;
}

.preview-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  background: #F4EFF9;
  border: 3px solid #FFFFFF;
  box-shadow: 0 0 0 2px #542C9E, 0 6px 16px rgba(91, 31, 138, 0.18);
  flex-shrink: 0;
}

.preview-id { line-height: 1.3; }

.preview-name {
  font-weight: 700;
  font-size: 22px;
  color: #2A1A4A;
  letter-spacing: -0.01em;
}

.preview-handle {
  font-size: 17px;
  color: #542C9E;
  font-weight: 600;
  margin-top: 2px;
}

.preview-followers {
  font-size: 13px;
  color: #7B5E9A;
  margin-top: 4px;
  font-weight: 500;
}

/* ── Loading skeleton (card shown the instant Analyse is clicked) ────────── */
/* Until /preview lands the identity head has no real data yet, so the avatar +
   the three identity lines render as shimmering placeholder bars (the four stat
   tiles spin in parallel, handled in JS). paintPreviewCard removes .preview-
   loading once the real name / avatar / followers arrive. */
.preview-card.preview-loading .preview-avatar {
  display: block;
  background: linear-gradient(100deg, #F1EAFA 30%, #E7DBF6 50%, #F1EAFA 70%);
  background-size: 200% 100%;
  animation: previewShimmer 1.2s ease-in-out infinite;
}

.preview-card.preview-loading .preview-name,
.preview-card.preview-loading .preview-handle,
.preview-card.preview-loading .preview-followers {
  color: transparent;
  border-radius: 6px;
  background: linear-gradient(100deg, #F1EAFA 30%, #E7DBF6 50%, #F1EAFA 70%);
  background-size: 200% 100%;
  animation: previewShimmer 1.2s ease-in-out infinite;
}

.preview-card.preview-loading .preview-name      { width: 180px; height: 18px; }
.preview-card.preview-loading .preview-handle    { width: 120px; height: 15px; margin-top: 8px; }
.preview-card.preview-loading .preview-followers { width: 90px;  height: 12px; margin-top: 8px; }

@keyframes previewShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.preview-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.preview-stat {
  background: linear-gradient(180deg, #FFFFFF 0%, #F8F4FC 100%);
  border: 1px solid #EADFF6;
  border-radius: 12px;
  padding: 18px 12px;
  text-align: center;
  opacity: 0;
  transform: translateY(10px) scale(0.96);
  transition: opacity 360ms ease-out, transform 420ms cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 8px rgba(91, 31, 138, 0.04);
}

.preview-stat.stat-revealed {
  opacity: 1;
  transform: translateY(0) scale(1);
  box-shadow: 0 4px 14px rgba(91, 31, 138, 0.10);
}

/* While the count-up is running - or a locked tile is rolling its scramble -
   pulse the border + a tiny dot so the box reads as actively gathering data
   instead of a static UI animation. */
.preview-stat.stat-counting,
.preview-stat.stat-rolling {
  border-color: #542C9E;
  box-shadow: 0 0 0 3px rgba(91, 31, 138, 0.10), 0 4px 14px rgba(91, 31, 138, 0.14);
  position: relative;
}

.preview-stat.stat-counting::after,
.preview-stat.stat-rolling::after {
  content: '';
  position: absolute;
  top: 10px;
  right: 10px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2EA049;
  box-shadow: 0 0 0 0 rgba(46, 160, 73, 0.7);
  animation: liveDot 1.1s ease-out infinite;
}

@keyframes liveDot {
  0%   { box-shadow: 0 0 0 0 rgba(46, 160, 73, 0.7); }
  70%  { box-shadow: 0 0 0 10px rgba(46, 160, 73, 0); }
  100% { box-shadow: 0 0 0 0 rgba(46, 160, 73, 0); }
}

.preview-stat .stat-num {
  font-weight: 700;
  font-size: 28px;
  color: #542C9E;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* Rolling tile: a reel-performance stat we can't know until the post-sign-in
   analysis runs. Rather than a fabricated value, the number scrambles
   continuously (see email-gate.js:startRoll) to read as "populating your
   numbers". Dim + a hair of blur so it never looks like a settled, real figure;
   the churning digits cannot be mistaken for - or contradict - the report. */
.preview-stat.stat-rolling .stat-num {
  opacity: 0.5;
  filter: blur(0.4px);
}

.preview-stat .stat-lbl {
  font-size: 11px;
  color: #7B5E9A;
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.preview-progress {
  margin-top: 14px;
  font-size: 13px;
  color: #7B5E9A;
  text-align: center;
  font-style: italic;
  min-height: 18px;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

.preview-timestamp {
  margin-top: 6px;
  font-size: 11px;
  color: #B2A4C6;
  text-align: center;
}

/* ── Building state (while /analyze runs after sign-in) ─────────────────── */
/* The pre-sign-in #preview-progress line is a passive whisper; once the real
   analysis is in flight this prominent panel takes over so the 20 to 40s cold
   run always reads as actively working, never as a crashed page. */
.preview-building {
  margin-top: 16px;
  padding: 16px 18px 14px;
  background: linear-gradient(135deg, #F8F4FC 0%, #FCFBFE 100%);
  border: 1px solid #E4DAF3;
  border-radius: 12px;
  animation: fadeUp 320ms ease-out;
}

/* Indeterminate bar: a slice slides across continuously. /analyze gives no
   real percentage, so a moving (not filling) bar signals "working" honestly. */
.preview-building-bar {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: #ECE3F7;
  overflow: hidden;
}

.preview-building-fill {
  position: absolute;
  top: 0;
  left: -42%;
  height: 100%;
  width: 40%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7E3FD0, #542C9E);
  animation: buildSlide 1.5s ease-in-out infinite;
}

@keyframes buildSlide {
  0%   { left: -42%; }
  100% { left: 102%; }
}

.preview-building-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}

.preview-building-spin {
  width: 16px;
  height: 16px;
  border: 2px solid #DAC9F0;
  border-top-color: #542C9E;
  border-radius: 50%;
  flex-shrink: 0;
  animation: buildSpin 0.7s linear infinite;
}

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

.preview-building-step {
  font-size: 14px;
  font-weight: 600;
  color: #542C9E;
}

.preview-building-note {
  margin-top: 10px;
  font-size: 12px;
  color: #7B5E9A;
  text-align: center;
  line-height: 1.4;
}

/* "While we build it, here is what is inside" - a short tour of the sections the
   report will hold, shown during the wait so the build never reads as a dead
   pause. The full guided spotlight tour runs on the report once it lands. */
.preview-building-tut {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #E4DAF3;
  text-align: left;
}

.preview-building-tut-head {
  font-size: 12px;
  font-weight: 600;
  color: #542C9E;
  margin-bottom: 8px;
}

.preview-building-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.preview-building-list li {
  position: relative;
  padding-left: 20px;
  margin-bottom: 6px;
  font-size: 12.5px;
  line-height: 1.45;
  color: #5A4A6E;
}

.preview-building-list li::before {
  content: "\2713";
  position: absolute;
  left: 0;
  top: 0;
  color: #7E3FD0;
  font-weight: 700;
}

@media (max-width: 540px) {
  .preview-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ── Wow popup (small floating insight) ─────────────────────────────────── */

.wow-popup {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  max-width: 480px;
  width: calc(100% - 32px);
  animation: dropIn 360ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dropIn {
  from { opacity: 0; transform: translate(-50%, -20px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.wow-popup-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #542C9E 0%, #7B3FB0 100%);
  color: #FFFFFF;
  padding: 14px 18px;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(91, 31, 138, 0.28);
  position: relative;
}

.wow-popup-flash {
  font-size: 22px;
  flex-shrink: 0;
}

.wow-popup-text {
  font-size: 14px;
  line-height: 1.4;
  font-weight: 500;
  flex: 1;
}

.wow-popup-close {
  background: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.wow-popup-close:hover { background: rgba(255, 255, 255, 0.28); }

/* ── Email gate modal ───────────────────────────────────────────────────── */

.email-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.email-gate-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 14, 50, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 220ms ease-out;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.email-gate-panel {
  position: relative;
  background: #FFFFFF;
  border-radius: 16px;
  padding: 28px 26px 22px;
  max-width: 440px;
  width: 100%;
  /* min-width:0 stops a fixed-width child (the Google iframe) from stretching
     this flex item wider than the viewport on a phone. */
  min-width: 0;
  box-shadow: 0 24px 60px rgba(30, 14, 50, 0.32);
  animation: panelIn 320ms cubic-bezier(0.34, 1.4, 0.64, 1);
}

@keyframes panelIn {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.email-gate-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  border: none;
  color: #9B8AB0;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 8px;
  transition: color .15s, background .15s;
}
.email-gate-close:hover { color: #542C9E; background: #F4EFF9; }

.email-gate-title {
  font-size: 19px;
  font-weight: 600;
  color: #2A1A4A;
  margin-bottom: 6px;
  text-align: center;
}

.email-gate-sub {
  font-size: 13px;
  color: #7B5E9A;
  margin-bottom: 18px;
  text-align: center;
  line-height: 1.5;
}

.email-gate-sub span {
  font-weight: 600;
  color: #542C9E;
}

.email-gate-google {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
  min-height: 44px;
  /* Safety net: if the Google button is ever sized wider than the card, clip it
     to the card width instead of letting it hang over the panel edges. */
  max-width: 100%;
  overflow: hidden;
}

.email-gate-or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 14px;
  font-size: 11px;
  color: #B2A4C6;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.email-gate-or::before,
.email-gate-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #EADFF6;
}

.email-gate-form {
  display: flex;
  gap: 8px;
}

.email-gate-form input[type="email"],
.email-gate-form input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  font-size: 14px;
  border: 1px solid #E4DAF3;
  border-radius: 10px;
  font-family: inherit;
  color: #2A1A4A;
  background: #FCFBFE;
  outline: none;
  transition: border-color 160ms;
}

.email-gate-form input[type="email"]:focus,
.email-gate-form input[type="text"]:focus {
  border-color: #542C9E;
  background: #FFFFFF;
}

/* The 6-digit code reads as a code: big, spaced, centered. */
#otp-input {
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.4em;
  font-variant-numeric: tabular-nums;
}

.email-gate-form button {
  background: #542C9E;
  color: #FFFFFF;
  border: none;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  transition: background 160ms;
  white-space: nowrap;
}

.email-gate-form button:hover { background: #4A1872; }
.email-gate-form button:disabled { background: #B2A4C6; cursor: not-allowed; }

/* On narrow phones the inline input + "Send code" button can't both fit on one
   row, so stack them: full-width field with the button beneath it. */
@media (max-width: 420px) {
  .email-gate-form { flex-direction: column; align-items: stretch; }
  .email-gate-form button { width: 100%; }
}

.email-gate-error {
  margin-top: 10px;
  font-size: 12px;
  color: #C12A2A;
  min-height: 16px;
  text-align: center;
}

.email-gate-foot {
  margin-top: 14px;
  font-size: 10px;
  line-height: 1.5;
  color: #9B8AB0;
  text-align: center;
}
.email-gate-foot a {
  color: #7B5E9A;
  text-decoration: underline;
}
.email-gate-foot a:hover { color: #542C9E; }

/* ── OTP (one-time code) step ───────────────────────────────────────────── */
.email-gate-otp-sent {
  font-size: 13px;
  color: #7B5E9A;
  text-align: center;
  line-height: 1.5;
  margin-bottom: 14px;
}

.email-gate-otp-sent span {
  font-weight: 600;
  color: #542C9E;
}

.email-gate-otp-actions {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 12px;
}

.email-gate-link {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 12px;
  color: #7B5E9A;
  cursor: pointer;
  text-decoration: underline;
}

.email-gate-link:hover { color: #542C9E; }
.email-gate-link:disabled { color: #C3B6D6; cursor: not-allowed; text-decoration: none; }

/* ── Lock the body when the gate is open ────────────────────────────────── */
body.gate-open { overflow: hidden; }
