/* =====================================================================
   Cadence - affiliate portal (affiliates.html)

   Loaded AFTER styles.css, which supplies every design token (--bg, --text,
   --muted, --accent, --border, --radius*, --shadow*, --ease), the .btn system,
   the nav, and the footer. Nothing here redefines a token - this file only
   adds the .aff-* block.

   Dark is the default; light is handled with the same [data-theme="light"]
   override pattern styles.css uses. Mobile-first: the base rules are the
   phone layout, and the @media blocks at the bottom widen it.

   Modelled on the .refgate__* block (styles.css ~1785-1951) so the sign-up
   form on this page and the one in the hero feel like the same product.
   ===================================================================== */

/* [hidden] must beat the display rules below, exactly as the refgate block
   has to beat .btn / .hero__cta. Without this, every panel renders at once. */
.aff-boot[hidden],
.aff-step[hidden],
.aff-msg[hidden],
.aff-panel__body[hidden],
.aff-funnel[hidden],
.aff-empty[hidden],
.aff-retry[hidden],
.aff-panel__empty[hidden],
#affSignedOut[hidden],
#affDashboard[hidden],
#affBankFields[hidden],
#affUpiFields[hidden] { display: none; }

/* ---------- Boot ---------- */
.aff-boot { padding: clamp(64px, 18vh, 160px) 0; text-align: center; }
.aff-boot__text { color: var(--muted); font-size: .95rem; }

/* =====================================================================
   SIGNED OUT
   ===================================================================== */
.aff-hero {
  position: relative;
  padding: clamp(36px, 7vw, 76px) 0 clamp(24px, 4vw, 40px);
}
.aff-hero__inner { max-width: 720px; }
.aff-hero__title {
  font-size: clamp(2rem, 7vw, 3.4rem);
  letter-spacing: -.03em;
  margin-bottom: 18px;
}
.aff-hero__sub {
  color: var(--muted);
  font-size: clamp(1rem, 2.4vw, 1.14rem);
  line-height: 1.65;
  margin-bottom: 26px;
  max-width: 60ch;
}
.aff-hero__note {
  margin-top: 14px;
  font-size: .87rem;
  color: var(--muted);
}

/* ---------- Rates ---------- */
.aff-rates {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: clamp(24px, 4vw, 36px);
}
.aff-rate {
  padding: 22px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
[data-theme="light"] .aff-rate { background: var(--surface); }

/* The 50% tier is the one people came to read. Mark it without shouting. */
.aff-rate--lead {
  background: var(--green-tint);
  border-color: var(--green-line);
}
.aff-rate__when {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.aff-rate__pct {
  font-size: clamp(2.2rem, 6vw, 2.8rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.03em;
  color: var(--accent-ink);
  margin-bottom: 12px;
}
.aff-rate__eg {
  color: var(--muted);
  font-size: .89rem;
  line-height: 1.6;
}

/* ---------- The constraints ---------- */
.aff-example {
  padding: clamp(20px, 3vw, 28px);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  max-width: 640px;
}
[data-theme="light"] .aff-example { background: var(--surface); }
.aff-example h3 { font-size: 1.2rem; margin-bottom: 8px; letter-spacing: -.02em; }
.aff-example__lead {
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.6;
  margin-bottom: 18px;
}
.aff-example__rows { list-style: none; margin: 0 0 16px; padding: 0; }
.aff-example__rows li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: .93rem;
}
.aff-example__rows li span { color: var(--muted); }
.aff-example__rows li strong {
  font-family: 'Geist Mono', 'SF Mono', 'Fira Code', monospace;
  font-weight: 500;
  white-space: nowrap;
}
.aff-example__total {
  border-bottom: 0 !important;
  padding-top: 14px !important;
  font-weight: 700;
}
.aff-example__total span { color: var(--text) !important; font-weight: 600; }
.aff-example__total strong { color: var(--accent-ink); font-size: 1.15rem; font-weight: 700; }
.aff-example__fine {
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.65;
}

/* ---------- Earnings calculator ---------- */
.aff-calc {
  padding: clamp(22px, 3.4vw, 30px);
  margin-bottom: clamp(24px, 4vw, 36px);
  border-radius: var(--radius-lg);
  background: var(--green-tint);
  border: 1px solid var(--green-line);
  box-shadow: var(--shadow-sm);
}
[data-theme="light"] .aff-calc { background: var(--green-tint); }
.aff-calc__title {
  font-size: 1.2rem;
  letter-spacing: -.02em;
  margin-bottom: 6px;
}
.aff-calc__sub {
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.6;
  margin-bottom: 22px;
}
.aff-calc__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 22px;
}
.aff-calc__field { flex: 1; min-width: 160px; }
.aff-calc__label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.aff-calc__stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
}
[data-theme="light"] .aff-calc__stepper { background: var(--bg); }
.aff-calc__btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 0;
  background: none;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent-ink);
  cursor: pointer;
  transition: background .15s var(--ease);
}
.aff-calc__btn:hover { background: rgba(56, 161, 105, .12); }
.aff-calc__btn:active { background: rgba(56, 161, 105, .22); }
.aff-calc__input {
  flex: 1;
  min-width: 0;
  height: 44px;
  border: 0;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: none;
  font-family: 'Geist Mono', 'SF Mono', 'Fira Code', monospace;
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
  color: var(--text);
  -moz-appearance: textfield;
  appearance: textfield;
}
.aff-calc__input::-webkit-inner-spin-button,
.aff-calc__input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.aff-calc__input:focus { outline: none; }
.aff-calc__select {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  font-family: inherit;
  font-size: .95rem;
  color: var(--text);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='7' viewBox='0 0 12 7' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%239CA3AF' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
[data-theme="light"] .aff-calc__select { background-color: var(--bg); }
.aff-calc__select:focus { outline: none; border-color: var(--accent); }

.aff-calc__results {
  border-top: 1px solid var(--green-line);
  padding-top: 18px;
}
.aff-calc__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(56, 161, 105, .12);
}
.aff-calc__row:last-child { border-bottom: 0; }
.aff-calc__month {
  font-size: .9rem;
  color: var(--muted);
}
.aff-calc__amount {
  font-family: 'Geist Mono', 'SF Mono', 'Fira Code', monospace;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.aff-calc__row--total {
  border-bottom: 0;
  padding-top: 14px;
  margin-top: 4px;
  border-top: 1px solid var(--green-line);
}
.aff-calc__row--total .aff-calc__month {
  color: var(--text);
  font-weight: 600;
}
.aff-calc__row--total .aff-calc__amount {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent-ink);
}

@media (max-width: 400px) {
  .aff-calc__controls { flex-direction: column; gap: 12px; }
  .aff-calc__field { min-width: 100%; }
}

/* ---------- The constraints ---------- */
.aff-rules {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.aff-rule {
  padding: 20px 22px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}
[data-theme="light"] .aff-rule { background: var(--surface); }
.aff-rule h3 {
  font-size: 1.02rem;
  margin-bottom: 8px;
  letter-spacing: -.02em;
  padding-left: 26px;
  position: relative;
}
/* A neutral marker, not a green tick. These are caveats, not features. */
.aff-rule h3::before {
  content: "";
  position: absolute;
  left: 0;
  top: .45em;
  width: 12px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.aff-rule p { color: var(--muted); font-size: .91rem; line-height: 1.65; }

/* =====================================================================
   Sign-up card + form  (mirrors .refgate)
   ===================================================================== */
.aff-card {
  padding: clamp(22px, 3.4vw, 30px);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--green-line);
  box-shadow: var(--shadow);
}
[data-theme="light"] .aff-card {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.aff-card__eyebrow {
  display: inline-block;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin-bottom: 8px;
}
.aff-card__title { font-size: 1.5rem; letter-spacing: -.02em; margin-bottom: 10px; }
.aff-card__lead {
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.6;
  margin-bottom: 22px;
}

.aff-step { display: block; }
.aff-label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
/* Labels that follow a field need air above them. */
.aff-input + .aff-label,
.aff-rail + .aff-label,
div + .aff-label { margin-top: 16px; }
.aff-opt { color: var(--muted); font-weight: 500; }
.aff-echo { color: var(--accent-ink); overflow-wrap: anywhere; }

.aff-input {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  padding: 13px 14px;
  margin-bottom: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
[data-theme="light"] .aff-input { background: var(--bg); }
.aff-input::placeholder { color: var(--muted); opacity: .7; }
.aff-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 133, 90, .18);
}
.aff-input--upper { text-transform: uppercase; }
.aff-input--upper::placeholder { text-transform: none; }
.aff-input--otp {
  font-family: 'Geist Mono', 'SF Mono', 'Fira Code', monospace;
  font-size: 1.35rem;
  letter-spacing: .35em;
  text-align: center;
  padding-left: 8px;
  padding-right: 8px;
}
.aff-input--otp::placeholder { letter-spacing: .35em; }

.aff-step .btn--block { margin-top: 16px; margin-bottom: 12px; }
.aff-step .btn[disabled],
.aff-panel .btn[disabled] { opacity: .6; pointer-events: none; }

.aff-fine {
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.55;
}
.aff-row { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.aff-link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  color: var(--accent-ink);
  cursor: pointer;
}
.aff-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.aff-link[disabled] { opacity: .6; cursor: default; text-decoration: none; }

/* ---------- Messages (error / info / success) ----------
   Error is the default state: the loud one should be the one you get by
   accident, not the one you have to remember to ask for. */
.aff-msg {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: .85rem;
  line-height: 1.55;
  color: #E2B4B4;
  background: rgba(197, 48, 48, .10);
  border: 1px solid rgba(197, 48, 48, .28);
}
[data-theme="light"] .aff-msg { color: #9B2C2C; background: #FDF0F0; border-color: #F0C9C9; }
.aff-msg.is-info,
.aff-msg.is-ok {
  color: var(--accent-ink);
  background: var(--green-tint);
  border-color: var(--green-line);
}
.aff-retry { margin-top: 12px; }

/* =====================================================================
   DASHBOARD
   ===================================================================== */
.aff-dash { padding-top: clamp(28px, 5vw, 56px); }
.aff-dash__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: clamp(20px, 3vw, 30px);
}
.aff-dash__title { font-size: clamp(1.8rem, 5vw, 2.4rem); margin-bottom: 6px; }
.aff-dash__who {
  color: var(--muted);
  font-size: .88rem;
  overflow-wrap: anywhere;
}
.aff-dash__foot {
  margin-top: 24px;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.6;
  text-align: center;
}

/* ---------- Panel ---------- */
.aff-panel {
  padding: clamp(20px, 3vw, 26px);
  margin-bottom: 16px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
[data-theme="light"] .aff-panel { background: var(--surface); }
.aff-panel__title {
  font-size: 1.15rem;
  letter-spacing: -.02em;
  margin-bottom: 16px;
}
.aff-panel__intro {
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.6;
  margin-bottom: 18px;
}
.aff-panel__empty {
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.6;
  margin-bottom: 14px;
}

/* ---------- Referral link ---------- */
.aff-linkbox {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  margin-bottom: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--green-line);
}
[data-theme="light"] .aff-linkbox { background: var(--green-tint); }
.aff-linkbox__url {
  font-family: 'Geist Mono', 'SF Mono', 'Fira Code', monospace;
  font-size: .88rem;
  color: var(--text);
  overflow-wrap: anywhere;
  line-height: 1.5;
}
.aff-linkbox__actions { display: flex; gap: 8px; }
.aff-linkbox__actions .btn { flex: 1; }

/* ---------- Balance ---------- */
.aff-balance__main {
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.aff-balance__label {
  display: block;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.aff-balance__value {
  display: block;
  font-size: clamp(2.2rem, 8vw, 3rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -.03em;
  color: var(--accent-ink);
  margin-bottom: 8px;
}
.aff-balance__hint {
  display: block;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.55;
}
.aff-balance__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.aff-stat__label {
  display: block;
  font-size: .78rem;
  color: var(--muted);
  margin-bottom: 4px;
  line-height: 1.4;
}
.aff-stat__value {
  display: block;
  font-family: 'Geist Mono', 'SF Mono', 'Fira Code', monospace;
  font-size: 1.02rem;
  font-weight: 500;
  color: var(--text);
}

/* ---------- Funnel ---------- */
.aff-funnel {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.aff-funnel__step {
  padding: 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  text-align: center;
}
[data-theme="light"] .aff-funnel__step { background: var(--surface-2); }
.aff-funnel__step--end {
  background: var(--green-tint);
  border-color: var(--green-line);
}
.aff-funnel__num {
  display: block;
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.02em;
}
.aff-funnel__step--end .aff-funnel__num { color: var(--accent-ink); }
.aff-funnel__label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-top: 4px;
}
.aff-funnel__sub {
  display: block;
  font-size: .76rem;
  color: var(--muted);
  margin-top: 2px;
  min-height: 1em;
}
.aff-funnel__arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4px 0;
  color: var(--muted);
}
.aff-funnel__arrow svg { width: 16px; height: 16px; transform: rotate(90deg); }
.aff-funnel__rate {
  font-family: 'Geist Mono', 'SF Mono', 'Fira Code', monospace;
  font-size: .8rem;
  color: var(--accent-ink);
}

/* ---------- Honest empty state ---------- */
.aff-empty {
  padding: 22px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: rgba(255, 255, 255, 0.02);
}
[data-theme="light"] .aff-empty { background: var(--surface-2); }
.aff-empty h3 { font-size: 1.05rem; margin-bottom: 10px; letter-spacing: -.02em; }
.aff-empty p { color: var(--muted); font-size: .9rem; line-height: 1.65; }
.aff-empty ul { margin: 12px 0; padding-left: 20px; }
.aff-empty li {
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.65;
  margin-bottom: 6px;
}
.aff-empty li strong { color: var(--text); }
.aff-empty__fine { font-size: .82rem !important; opacity: .85; margin-top: 12px; }

/* ---------- Payout rail switch ---------- */
.aff-rail {
  display: flex;
  gap: 6px;
  padding: 4px;
  margin-bottom: 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}
[data-theme="light"] .aff-rail { background: var(--surface-2); }
.aff-rail__btn {
  flex: 1;
  padding: 9px 12px;
  border: 0;
  border-radius: 9px;
  background: none;
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.aff-rail__btn:hover { color: var(--text); }
.aff-rail__btn.is-on {
  color: #fff;
  background: var(--accent);
}

/* ---------- Withdrawal history ---------- */
.aff-history { list-style: none; margin: 0; padding: 0; }
.aff-hrow {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.aff-hrow:last-child { border-bottom: 0; padding-bottom: 0; }
.aff-hrow:first-child { padding-top: 0; }
.aff-hrow__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.aff-hrow__amount {
  font-family: 'Geist Mono', 'SF Mono', 'Fira Code', monospace;
  font-size: 1.15rem;
  font-weight: 700;
}
.aff-hrow__badge {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  color: var(--muted);
}
.aff-hrow__badge--requested,
.aff-hrow__badge--processing {
  color: var(--accent-ink);
  background: var(--green-tint);
  border-color: var(--green-line);
}
.aff-hrow__badge--paid {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.aff-hrow__badge--rejected {
  color: #E2B4B4;
  background: rgba(197, 48, 48, .10);
  border-color: rgba(197, 48, 48, .28);
}
[data-theme="light"] .aff-hrow__badge--rejected {
  color: #9B2C2C; background: #FDF0F0; border-color: #F0C9C9;
}
.aff-hrow__meta {
  color: var(--muted);
  font-size: .83rem;
  line-height: 1.5;
}
.aff-hrow__hint {
  color: var(--muted);
  font-size: .83rem;
  line-height: 1.5;
  margin-top: 4px;
}
.aff-hrow__reason {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: .83rem;
  line-height: 1.5;
  color: #E2B4B4;
  background: rgba(197, 48, 48, .10);
  border: 1px solid rgba(197, 48, 48, .28);
}
[data-theme="light"] .aff-hrow__reason {
  color: #9B2C2C; background: #FDF0F0; border-color: #F0C9C9;
}
.aff-hrow__cancel { margin-top: 12px; }
.aff-hrow__warn {
  margin-top: 8px;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.55;
}

/* =====================================================================
   RESPONSIVE - base above is the phone; these widen it.
   ===================================================================== */
@media (min-width: 620px) {
  .aff-rates { grid-template-columns: repeat(2, 1fr); }
  .aff-rules { grid-template-columns: repeat(2, 1fr); }
  .aff-balance__grid { grid-template-columns: repeat(4, 1fr); }
  .aff-linkbox {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .aff-linkbox__actions { flex: 0 0 auto; }
  .aff-linkbox__actions .btn { flex: 0 0 auto; }

  /* Horizontal funnel once there's room for three columns + two arrows. */
  .aff-funnel { flex-direction: row; align-items: stretch; }
  .aff-funnel__step { flex: 1; display: flex; flex-direction: column; justify-content: center; }
  .aff-funnel__arrow { flex-direction: column; padding: 0 4px; }
  .aff-funnel__arrow svg { transform: none; }
}

@media (min-width: 900px) {
  .aff-rates { grid-template-columns: repeat(3, 1fr); }
  .aff-rules { grid-template-columns: repeat(3, 1fr); }
}

/* The theme sweep overlay is created by script.js, which this page doesn't
   load. Nothing to do here - the toggle just swaps data-theme, and every
   colour above is a token, so both themes follow automatically. */

@media (prefers-reduced-motion: reduce) {
  .aff-rail__btn,
  .aff-input { transition: none; }
}
