/* =============================================================================
   bust.fun - AFFILIATE dashboard (EPIC 4). Synthwave styling for the multi-tier
   affiliate panel: share card + QR, per-tier commission cards, earnings/claim,
   campaign create + list, referred-friends list. Reuses the design system
   (.card, .subcard, .balgrid, table.data, .copybtn, .ref-* helpers) and pulls
   ALL colors from tokens.css so light/dark + reduced-motion are handled centrally.
   Loaded after styles.css; no new tokens, no CDN.
   ========================================================================== */

.affiliate { display: flex; flex-direction: column; gap: var(--sp-3); }

/* The page hero (headline + intro) is owned by the shell (index.html referrals panel). affiliate.js no longer
   renders its own headline — that was a duplicate hero. The share card below is this module's first surface. */

/* ---- share card: code + link fields beside the QR ---- */
.aff-share { display: flex; gap: var(--sp-4); flex-wrap: wrap; align-items: flex-start; }
/* HIERARCHY: this is the PRIMARY action of the page (the code + link users send
   to invite), so it is the dominant, elevated HERO — a violet brand left-edge
   (the referral surface's identity colour) + a real card lift raise it above the
   flatter commission / earnings / campaign sections stacked below it. */
.aff-share {
  border-left: 3px solid var(--violet);
  box-shadow: var(--shadow-2);
}
.aff-share-fields { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: var(--sp-3); }

/* ---- referral CODE = the focal point (the thing users copy/share) ---- */
.aff-code-field { gap: 8px; }
.aff-code-row {
  align-items: center; gap: var(--sp-3);
  padding: var(--sp-3); border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--violet);
  box-shadow: var(--neon-glow);
}
.aff-code-value {
  flex: 1 1 auto; min-width: 0;
  font-family: var(--font-display); font-weight: var(--fw-bold);
  font-size: var(--fs-xxl) !important; letter-spacing: .16em; line-height: 1.05;
  color: var(--violet); text-shadow: var(--neon-glow-text);
  background: none !important; border: none !important; padding: 0 !important;
  overflow-wrap: anywhere;
}
/* Primary (not ghost) copy affordance so the single most important action is unmissable. */
.aff-code-copy {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--touch); padding: 0 var(--sp-3);
  border-radius: var(--r-pill); border: 1px solid var(--violet);
  background: var(--violet); color: #fff;
  font-family: var(--font-display); font-size: var(--fs-sm); font-weight: var(--fw-semi);
  cursor: pointer;
  transition: transform var(--dur-1) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), filter var(--dur-1) var(--ease-out);
}
.aff-code-copy .icon { width: 16px; height: 16px; }
.aff-code-copy .copy-label { white-space: nowrap; }
.aff-code-copy:hover { box-shadow: var(--neon-glow); filter: brightness(1.08); }
.aff-code-copy:active { transform: translateY(1px); }
.aff-code-copy:focus-visible { outline: none; box-shadow: var(--ring); }
@media (prefers-reduced-motion: reduce) { .aff-code-copy { transition: none; } }
@media (max-width: 480px) { .aff-code-value { font-size: var(--fs-xl) !important; } }

/* ---- one-tap SHARE buttons (native share + X / Telegram / WhatsApp intents, prefilled message) ---- */
.aff-share-btns { flex: 1 1 320px; min-width: 0; display: flex; flex-wrap: wrap; gap: var(--sp-2); align-content: flex-start; }
.aff-share-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--touch); padding: 0 var(--sp-3);
  border-radius: var(--r-pill); border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--fg);
  font-family: var(--font-display); font-size: var(--fs-sm); font-weight: var(--fw-semi);
  cursor: pointer;
  transition: transform var(--dur-1) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), border-color var(--dur-1) var(--ease-out);
}
.aff-share-btn .icon { width: 16px; height: 16px; }
.aff-share-btn:hover { box-shadow: var(--neon-glow); }
.aff-share-btn:active { transform: translateY(1px); }
.aff-share-btn:focus-visible { outline: none; box-shadow: var(--ring); }
/* Per-target accent so the brands read at a glance (no brand glyphs in our icon set). */
.aff-share-native   { border-color: var(--violet); color: var(--violet); }
.aff-share-x        { border-color: var(--fg-dim); }
.aff-share-telegram { border-color: #229ED9; color: #4cc2f0; }
.aff-share-whatsapp { border-color: #25D366; color: #3ddc7f; }
@media (prefers-reduced-motion: reduce) { .aff-share-btn { transition: none; } }
.aff-qr {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  padding: 10px; border-radius: var(--r-md);
  background: #fff; /* QR must be high-contrast to scan; a white quiet zone is correct regardless of theme */
  border: 1px solid var(--line-2); box-shadow: var(--neon-glow);
}
.aff-qr.hidden { display: none; }
.aff-qr svg { display: block; width: 168px; height: 168px; }
#affCode { letter-spacing: .12em; font-size: var(--fs-lg); color: var(--brand-ink, var(--fg)); }

/* ---- tier breakdown: a COMPACT 3-up grid (reuses .balgrid tokens) — one card per tier, Tier 1 first ---- */
.aff-tiergrid { margin: var(--sp-3) 0; }
/* .aff-tier-cell inherits the .balgrid > div surface/padding; we only add the tier-specific interior.
   min-width: 0 lets a long "earned" money string wrap instead of forcing grid overflow (chat-dock safe). */
.aff-tier-cell { gap: 2px; min-width: 0; }
.aff-tier-cell.primary { border-color: var(--violet); background: rgba(124, 77, 255, 0.08); }
/* .aff-tier-cell scope raises specificity above `.balgrid b` (which would otherwise force --fs-xxl). */
.aff-tier-cell .aff-tier-rate { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: var(--fw-bold); color: var(--violet); text-shadow: var(--neon-glow-text); line-height: 1.05; }
.aff-tier-cell .unit { font-size: var(--fs-xs); color: var(--muted); }
.aff-tier-stats { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.aff-tier-stats > span { display: inline-flex; align-items: baseline; gap: 3px; }
.aff-tier-stats b { font-family: var(--font-display); font-size: var(--fs-md); font-variant-numeric: tabular-nums; }
.aff-tier-stats .unit { font-size: var(--fs-xs); color: var(--muted); }
@media (max-width: 620px) { .aff-tiergrid { grid-template-columns: 1fr; } }

/* ---- earnings stats (reuse .balgrid) with a neon claimable highlight ---- */
.aff-stats { grid-template-columns: repeat(3, 1fr); margin-top: var(--sp-2); }
/* Claimable is affirmative GREEN only when there's a positive balance; a $0 value is muted so it never reads
   as "money available" at a glance (green = you can claim now). Toggled by affiliate.js #affClaimable.is-zero. */
#affClaimable { color: var(--win); }
#affClaimable.is-zero { color: var(--muted); }
@media (max-width: 620px) { .aff-stats { grid-template-columns: 1fr; } }

/* ---- campaign create row ---- */
.aff-campaign-row { display: flex; gap: var(--sp-2); align-items: stretch; flex-wrap: wrap; margin: var(--sp-2) 0; }
.aff-campaign-row input {
  flex: 1 1 220px; min-width: 0; padding: 10px 12px; border-radius: var(--r-md);
  background: var(--bg-1); border: 1px solid var(--line-2); color: var(--fg); font-size: var(--fs-md);
}
.aff-campaign-row input:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
.aff-campaign-row button { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; }
.aff-campaign-row button .icon { width: 16px; height: 16px; }

/* ---- campaign + referred tables: a code cell with an inline copy button ---- */
.aff-camp-code { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.aff-camp-code code {
  font-family: var(--font-mono); letter-spacing: .08em;
  padding: 4px 8px; border-radius: var(--r-sm); background: var(--bg-1); border: 1px solid var(--line-2); color: var(--fg);
}
.aff-camp-code .copybtn .icon { width: 14px; height: 14px; }

/* Reuse the existing claim-button pulse (defined in styles.css as .ref-claim-row .ready) for #affClaimBtn. */
#affClaimBtn { display: inline-flex; align-items: center; gap: 8px; }
#affClaimBtn .icon { width: 18px; height: 18px; }
/* When there is nothing to claim the button is a genuinely NEUTRAL/inactive
   control — not a dimmed green CTA. A 50%-opacity green gradient still reads as
   "claim available"; the green fill is reserved for the actionable (.ready)
   state so colour carries meaning (green = you can claim now). */
#affClaimBtn[disabled] {
  opacity: 1;
  cursor: not-allowed;
  filter: none;
  box-shadow: none;
  background: var(--surface-3);
  background-image: none;
  color: var(--muted);
  border: 1px solid var(--line-2);
}
#affClaimBtn.ready { animation: refClaimPulse 2.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { #affClaimBtn.ready { animation: none; } }

/* The "nothing to claim yet" affordance shown beside the disabled claim button (makes the disabled state
   read as intentional rather than broken). */
.aff-claim-hint { margin: var(--sp-2) 0 0; font-size: var(--fs-sm); }
.aff-claim-hint.hidden { display: none; }

/* Designed empty states for the two tables (referred friends / campaigns): a centered block with an icon, a
   plain-language line and an in-place CTA that JUMPS to the relevant control — instead of a bare muted
   sentence under empty table headers (weak new-user motivation). Same id + `hidden` toggle as before, so the
   show/hide logic in renderReferred/renderCampaigns is unchanged. */
.aff-empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--sp-2); padding: var(--sp-5) var(--sp-4);
  border: 1px dashed var(--line-2); border-radius: var(--r-md); background: var(--surface-2);
}
.aff-empty.hidden { display: none; }
.aff-empty-ic { display: inline-flex; color: var(--violet); }
.aff-empty-ic svg { width: 28px; height: 28px; }
.aff-empty-title { margin: 0; font-weight: var(--fw-semi); font-size: var(--fs-md); color: var(--fg); }
.aff-empty-sub { margin: 0; max-width: 44ch; font-size: var(--fs-sm); line-height: 1.5; }
.aff-empty-cta { margin-top: var(--sp-1); }
