/* ============================================================
   ATSF Referral System — Main Styles
   Mobile-first. Warm. South Dakota proud.
   ============================================================ */

/* ── Custom Properties ─────────────────────────────────────── */
:root {
  --bg:           #FDFAF5;
  --surface:      #FFFFFF;
  --surface-warm: #FBF7F0;
  --border:       #E5D5BC;

  --primary:      #C94B0C;   /* burnt orange – SD sunset */
  --primary-dark: #A33C09;
  --primary-glow: rgba(201, 75, 12, 0.12);
  --secondary:    #1C3A5C;   /* deep navy – SD night sky */
  --accent:       #E8A020;   /* amber – wheat fields */
  --success:      #2A6B2A;   /* prairie green */
  --success-bg:   #EDF7ED;

  --text:         #1A1209;   /* warm near-black */
  --text-muted:   #5C4A2A;   /* warm brown */
  --text-faint:   #8B7355;   /* warm gray-brown */

  --radius-sm:    6px;
  --radius:       12px;
  --radius-lg:    20px;

  --shadow-sm:    0 1px 3px rgba(0,0,0,0.08);
  --shadow:       0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.14);

  --transition:   0.2s ease;
  --font-serif:   Georgia, 'Times New Roman', serif;
  --font-sans:    -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100dvh;
}
img { display: block; max-width: 100%; }
a { color: var(--primary); }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input { font-family: inherit; }

/* ── Page structure ─────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

/* ── Loading screen ─────────────────────────────────────────── */
#loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  gap: 20px;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Site header ─────────────────────────────────────────────── */
.site-header {
  text-align: center;
  padding: 28px 20px 20px;
}
.site-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.logo-mark {
  width: 44px; height: 44px;
  background: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: bold;
  flex-shrink: 0;
}
.logo-text {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: normal;
  color: var(--text);
  text-align: left;
  line-height: 1.2;
}
.logo-text span {
  display: block;
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-sans);
  letter-spacing: 0.5px;
}

/* ── Layout container ─────────────────────────────────────────── */
.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

/* ── Error state ─────────────────────────────────────────────── */
.error-page {
  text-align: center;
  padding: 60px 20px;
}
.error-icon { font-size: 48px; margin-bottom: 20px; }
.error-page h2 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: normal;
  color: var(--text);
  margin-bottom: 12px;
}
.error-page p {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.7;
  max-width: 360px;
  margin: 0 auto 24px;
}
.btn-secondary {
  display: inline-block;
  padding: 12px 24px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text);
  font-size: 15px;
  text-decoration: none;
  transition: border-color var(--transition), background var(--transition);
}
.btn-secondary:hover { border-color: var(--primary); background: var(--primary-glow); }

/* ═══════════════════════════════════════════════════════════════
   AMBASSADOR PAGE
   ═══════════════════════════════════════════════════════════════ */

/* ── Hero ─────────────────────────────────────────────────────── */
.ambassador-hero {
  text-align: center;
  padding: 8px 0 28px;
}
.ambassador-badge {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 100px;
  margin-bottom: 16px;
}
.ambassador-hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(24px, 6vw, 34px);
  font-weight: normal;
  color: var(--text);
  line-height: 1.25;
  margin-bottom: 12px;
}
.ambassador-hero p {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.65;
  max-width: 420px;
  margin: 0 auto;
}

/* ── Link card ────────────────────────────────────────────────── */
.link-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.link-card-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 10px;
}
.link-display {
  font-size: 14px;
  color: var(--secondary);
  background: var(--surface-warm);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  word-break: break-all;
  margin-bottom: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  line-height: 1.5;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px 20px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary.copied {
  background: var(--success);
  animation: pop 0.3s ease;
}
@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.btn-share {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px 20px;
  background: var(--secondary);
  color: #fff;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  transition: background var(--transition), transform var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-share:hover { background: #162f4e; }
.btn-share:active { transform: scale(0.98); }

.btn-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
}

/* ── Pre-written copy ────────────────────────────────────────── */
.share-copy-section {
  margin-bottom: 28px;
}
.share-copy-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 12px;
}
.share-copy-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.share-copy-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.share-copy-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.share-copy-card-type {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.5px;
}
.share-copy-card-text {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}
.copy-snippet-btn {
  font-size: 12px;
  color: var(--text-faint);
  padding: 4px 10px;
  border-radius: 100px;
  border: 1px solid var(--border);
  transition: all var(--transition);
  flex-shrink: 0;
}
.copy-snippet-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-glow); }
.copy-snippet-btn.copied { color: var(--success); border-color: var(--success); background: var(--success-bg); }

/* ── Stats card ──────────────────────────────────────────────── */
.stats-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 20px;
}
.stats-number {
  font-family: var(--font-serif);
  font-size: 48px;
  color: var(--primary);
  line-height: 1;
  min-width: 64px;
  text-align: center;
  flex-shrink: 0;
}
.stats-label {
  font-size: 16px;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 4px;
}
.stats-microcopy {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Milestone progress ──────────────────────────────────────── */
.milestone-section {
  margin-bottom: 28px;
}
.section-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: normal;
  color: var(--text);
  margin-bottom: 16px;
}
.milestone-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.milestone-tiers {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.milestone-tier {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  align-items: start;
  opacity: 0.45;
  transition: opacity var(--transition);
}
.milestone-tier.reached { opacity: 1; }
.milestone-tier.current { opacity: 1; }
.milestone-tier-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface-warm);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}
.milestone-tier.reached .milestone-tier-icon {
  background: var(--primary);
  border-color: var(--primary);
}
.milestone-tier.current .milestone-tier-icon {
  background: var(--accent);
  border-color: var(--accent);
  animation: pulse 2s ease infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232, 160, 32, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(232, 160, 32, 0); }
}
.milestone-tier-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 2px;
}
.milestone-tier.reached .milestone-tier-label { color: var(--primary); }
.milestone-tier-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.milestone-tier-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}
.milestone-tier-count {
  font-size: 12px;
  color: var(--text-faint);
}

/* Progress bar between tiers */
.milestone-progress-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.milestone-progress-bar-outer {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
}
.milestone-progress-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 100px;
  width: 0;
  transition: width 1s cubic-bezier(0.16, 1, 0.3, 1);
}
.milestone-progress-text {
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
}

/* Hall of fame banner */
.hall-of-fame {
  background: linear-gradient(135deg, #1C3A5C, #2A5280);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  color: #fff;
  margin-bottom: 16px;
}
.hall-of-fame h3 {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: normal;
  margin-bottom: 8px;
}
.hall-of-fame p {
  font-size: 14px;
  opacity: 0.85;
  line-height: 1.6;
}

/* ── Leaderboard ─────────────────────────────────────────────── */
.leaderboard-section {
  margin-bottom: 28px;
}
.leaderboard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.leaderboard-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.leaderboard-row:last-child { border-bottom: none; }
.leaderboard-row.is-you {
  background: var(--primary-glow);
  border-left: 3px solid var(--primary);
}
.leaderboard-rank {
  font-size: 13px;
  color: var(--text-faint);
  font-weight: 600;
  text-align: center;
}
.leaderboard-rank.top3 { font-size: 16px; }
.leaderboard-name {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}
.leaderboard-name small {
  display: block;
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 400;
}
.leaderboard-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
}
.leaderboard-stat span { font-size: 16px; }
.leaderboard-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-faint);
  font-size: 14px;
}

/* ── My position (outside top 10) ───────────────────────────── */
.my-position {
  margin-top: 12px;
  background: var(--primary-glow);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
}
.my-position-label { color: var(--text-muted); }
.my-position-rank { font-weight: 700; color: var(--primary); }

/* ── Realtime pulse indicator ────────────────────────────────── */
.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.live-dot {
  width: 7px; height: 7px;
  background: var(--success);
  border-radius: 50%;
  animation: live-pulse 2s ease infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ═══════════════════════════════════════════════════════════════
   SIGNUP PAGE
   ═══════════════════════════════════════════════════════════════ */

.signup-hero {
  text-align: center;
  padding: 8px 0 28px;
}
.social-proof-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.social-proof-avatars {
  display: flex;
}
.social-proof-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid #fff;
  margin-right: -8px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}
.social-proof-avatar:nth-child(2) { background: var(--secondary); }
.social-proof-avatar:nth-child(3) { background: var(--accent); color: var(--text); }

.signup-hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(22px, 6vw, 32px);
  font-weight: normal;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 12px;
}
.signup-hero p {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.7;
  max-width: 420px;
  margin: 0 auto;
}

/* ── What is ATSF ─────────────────────────────────────────────── */
.atsf-about {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.atsf-about-item {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}
.atsf-about-item:last-child { margin-bottom: 0; }
.atsf-about-icon {
  font-size: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}
.atsf-about-text {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}
.atsf-about-text strong { color: var(--text); }

/* ── Signup form ─────────────────────────────────────────────── */
.signup-form-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.form-group {
  margin-bottom: 14px;
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-input {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;  /* 16px prevents iOS zoom */
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-input::placeholder { color: var(--text-faint); }

.btn-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px 20px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 700;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}
.btn-submit:hover { background: var(--primary-dark); box-shadow: var(--shadow); }
.btn-submit:active { transform: scale(0.98); }
.btn-submit:disabled { opacity: 0.65; cursor: not-allowed; transform: none; }
.btn-submit.loading .btn-text { opacity: 0; }
.btn-submit.loading::after {
  content: '';
  position: absolute;
  width: 22px; height: 22px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Form result messages ────────────────────────────────────── */
.form-result {
  display: none;
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 12px;
  text-align: center;
}
.form-result.success {
  display: block;
  background: var(--success-bg);
  border: 1px solid var(--success);
  color: var(--success);
}
.form-result.error {
  display: block;
  background: #FEF2F0;
  border: 1px solid #F4A090;
  color: #8B2500;
}
.form-result.info {
  display: block;
  background: var(--surface-warm);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.form-result-icon { font-size: 32px; margin-bottom: 10px; }
.form-result h3 { font-size: 17px; margin-bottom: 6px; }
.form-result p { font-size: 14px; line-height: 1.6; }

.fine-print {
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 14px;
  line-height: 1.5;
}

/* ── Exit intent overlay ─────────────────────────────────────── */
#exit-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 18, 9, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
  padding: 20px;
  animation: fade-in 0.2s ease;
}
#exit-overlay.visible { display: flex; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.exit-card {
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-sm);
  padding: 28px 24px 32px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slide-up {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.exit-card h3 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: normal;
  margin-bottom: 10px;
}
.exit-card p {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.6;
}
.exit-close {
  position: absolute;
  top: 12px; right: 14px;
  font-size: 22px;
  color: var(--text-faint);
  cursor: pointer;
}
#exit-overlay .exit-card { position: relative; }

/* ── Footer ──────────────────────────────────────────────────── */
.page-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  padding: 0 20px 40px;
  line-height: 1.6;
}
.page-footer a { color: var(--text-faint); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (min-width: 480px) {
  .btn-row { flex-direction: row; }
  .btn-primary, .btn-share { width: auto; flex: 1; }
  .stats-card { padding: 24px 28px; }
  .link-card { padding: 24px; }
}

@media (min-width: 600px) {
  .site-header { padding: 36px 20px 24px; }
  .ambassador-hero h1 { font-size: 34px; }
}

/* ── Reduced motion ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
