/* ==========================================================================
   Referral programme — the small surfaces outside the referral page:
   the sign-up offer banner (register.html), the wallet block on checkout.html
   and the "Refer & earn" card on the dashboard. Builds on styles.app.css
   tokens; public pages also define --primary-orange inline.
   ========================================================================== */

/* --- Sign-up offer banner (register.html) ---------------------------------- */

.xt-ref-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  margin: 0 0 1.5rem;
  padding: 1rem 1.15rem;
  background: rgba(255, 122, 0, 0.07);
  border: 1px solid rgba(255, 122, 0, 0.28);
  border-radius: 14px;
  text-align: left;
}
.xt-ref-banner[hidden] { display: none; }

.xt-ref-banner__icon {
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem;
  border-radius: 10px;
  background: rgba(255, 122, 0, 0.14);
  color: var(--primary-orange, var(--primary));
  font-size: 1.05rem;
}

.xt-ref-banner__body { min-width: 0; flex: 1; }

/* Names come from student profiles and can be one long unbroken word. */
.xt-ref-banner__title,
.xt-ref-banner__text,
.xt-wallet-pay__row dt,
.xt-wallet-pay__note,
.xt-wallet-pay__held,
.xt-refer-card__line { overflow-wrap: anywhere; }

.xt-ref-banner__title {
  margin: 0 0 0.3rem;
  color: #FFFFFF;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
}

.xt-ref-banner__text {
  margin: 0;
  color: #CBD5E1;
  font-size: 0.86rem;
  line-height: 1.55;
}

.xt-ref-banner__code {
  display: inline-flex; align-items: center; gap: 0.4rem;
  margin-top: 0.6rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.25);
  color: #E2E8F0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.xt-ref-banner__code strong {
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  letter-spacing: 0.12em;
  color: #FFFFFF;
}

.xt-ref-banner.is-linked {
  background: rgba(16, 185, 129, 0.07);
  border-color: rgba(16, 185, 129, 0.3);
}
.xt-ref-banner.is-linked .xt-ref-banner__icon {
  background: rgba(16, 185, 129, 0.14);
  color: #34D399;
}

@media (max-width: 480px) {
  .xt-ref-banner { padding: 0.9rem; gap: 0.75rem; }
  .xt-ref-banner__icon { width: 2.2rem; height: 2.2rem; font-size: 0.95rem; }
}

/* --- Checkout wallet block (checkout.html) --------------------------------- */

.xt-wallet-pay {
  margin: 0 0 1.25rem;
  padding: 1rem 1.15rem;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
}
.xt-wallet-pay[hidden] { display: none; }

.xt-wallet-pay__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
}

.xt-wallet-pay__eyebrow {
  display: flex; align-items: center; gap: 0.45rem;
  color: #94A3B8;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.xt-wallet-pay__eyebrow i { color: var(--primary-orange, var(--primary)); }

.xt-wallet-pay__balance {
  display: block;
  margin-top: 0.15rem;
  color: #FFFFFF;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.xt-wallet-pay__balance small {
  color: #94A3B8;
  font-size: 0.8rem;
  font-weight: 500;
  margin-left: 0.3rem;
}

/* A real checkbox under a switch skin: keyboard, label click and screen readers come free. */
.xt-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  cursor: pointer;
  color: #E2E8F0;
  font-size: 0.88rem;
  font-weight: 600;
  user-select: none;
}
.xt-switch input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
}
.xt-switch__track {
  position: relative;
  flex: none;
  width: 40px; height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  transition: background 0.15s ease-out, border-color 0.15s ease-out;
}
.xt-switch__track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #FFFFFF;
  transition: transform 0.15s ease-out;
}
.xt-switch input:checked + .xt-switch__track {
  background: var(--primary-orange, var(--primary));
  border-color: var(--primary-orange, var(--primary));
}
.xt-switch input:checked + .xt-switch__track::after { transform: translateX(18px); }
.xt-switch input:focus-visible + .xt-switch__track {
  outline: 2px solid var(--primary-orange, var(--primary));
  outline-offset: 2px;
}
.xt-switch input:disabled + .xt-switch__track { opacity: 0.5; }
.xt-switch input:disabled ~ span { opacity: 0.6; }

.xt-wallet-pay__breakdown {
  margin: 0.85rem 0 0;
  padding: 0.75rem 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: grid;
  gap: 0.4rem;
}
.xt-wallet-pay__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.9rem;
}
.xt-wallet-pay__row dt { color: #CBD5E1; margin: 0; min-width: 0; }
.xt-wallet-pay__row dd {
  margin: 0;
  color: #FFFFFF;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.xt-wallet-pay__row.is-credit dd { color: #34D399; }
.xt-wallet-pay__row.is-total {
  margin-top: 0.2rem;
  padding-top: 0.55rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  font-size: 1rem;
}
.xt-wallet-pay__row.is-total dt { color: #FFFFFF; font-weight: 700; }
.xt-wallet-pay__row.is-total dd { font-weight: 800; font-size: 1.05rem; }
.xt-wallet-pay__row.is-covered dd { color: #34D399; }

.xt-wallet-pay__note,
.xt-wallet-pay__held {
  margin: 0.7rem 0 0;
  color: #94A3B8;
  font-size: 0.82rem;
  line-height: 1.5;
}
.xt-wallet-pay__held {
  display: flex; gap: 0.5rem; align-items: flex-start;
  color: #FBBF24;
}
.xt-wallet-pay__held[hidden],
.xt-wallet-pay__note[hidden] { display: none; }
.xt-wallet-pay__note.is-error { color: #FCA5A5; }

/* --- Dashboard "Refer & earn" card ---------------------------------------- */

.xt-refer-card[hidden] { display: none !important; }

.xt-refer-card__wallet {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.xt-refer-card__label {
  color: var(--xt-ink-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.xt-refer-card__balance {
  color: var(--xt-ink);
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.xt-refer-card__balance.is-loading {
  display: inline-block;
  width: 5.5rem; height: 1.6rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

.xt-refer-card__offer {
  margin: 0.75rem 0 0;
  color: var(--xt-ink-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}
.xt-refer-card__offer strong { color: var(--xt-ink); }

.xt-refer-card__meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.9rem 0 0;
  color: var(--xt-ink-muted);
  font-size: 0.82rem;
}
.xt-refer-card__slots {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.xt-refer-card__slots span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: inherit;
}
.xt-refer-card__used { white-space: nowrap; }

.xt-refer-card__line {
  margin: 0.65rem 0 0;
  color: var(--xt-ink-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}
.xt-refer-card__line i { margin-right: 0.35rem; }
.xt-refer-card__line.is-warning { color: var(--xt-warning); }
.xt-refer-card__line.is-success { color: var(--xt-success); }
.xt-refer-card__line.is-error { color: #ff8a80; }

.xt-refer-card__go {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  min-height: 44px;
  padding: 0 1rem;
  border-radius: var(--xt-radius-sm);
  border: 1px solid rgba(240, 126, 19, 0.4);
  background: rgba(240, 126, 19, 0.1);
  color: var(--primary);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background 0.15s ease-out, border-color 0.15s ease-out;
}
.xt-refer-card__go:hover { background: rgba(240, 126, 19, 0.18); border-color: var(--primary); }
.xt-refer-card__go:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .xt-switch__track, .xt-switch__track::after, .xt-refer-card__go { transition: none; }
}

.xt-ref-banner.is-invalid {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.12);
}
.xt-ref-banner.is-invalid .xt-ref-banner__icon {
  background: rgba(255, 255, 255, 0.06);
  color: #94A3B8;
}

.xt-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Component display rules above would otherwise beat the hidden attribute. */
.xt-ref-banner [hidden],
.xt-wallet-pay [hidden],
.xt-refer-card [hidden] { display: none !important; }
