/* Refer a friend, as modals: the referrer's "Give $50, get $50" panel
   (shared/_referral_modal), the friend's invite (shared/_referral_invite_modal)
   and the glowing gift beside the account menu.

   Unlayered on purpose: these extend the .smodal shell in application.css,
   which is unlayered, and a layered rule would lose to it whatever its
   specificity. */

/* ── The gift beside the menu ─────────────────────────────────────────── */

.refer-gift {
  position: relative;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-right: 6px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-white);
  color: var(--color-clay);
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.refer-gift::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  pointer-events: none;
  animation: refmGlow 2.4s ease-out infinite;
}

.refer-gift svg {
  width: 19px;
  height: 19px;
  transform-origin: 50% 85%;
  animation: refmWiggle 4.8s ease-in-out infinite;
}

.refer-gift:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.acct-menu .acct-refer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.acct-refer__tag {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--color-accent-bg);
  color: var(--color-clay);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

/* ── The modal shell: a photo half and a content half ─────────────────── */

.smodal.refm {
  width: min(820px, calc(100vw - 32px));
  min-height: 470px;
  flex-direction: row;
}

.smodal.refm.open {
  display: flex;
}

.refm-art {
  position: relative;
  flex: 0 0 38%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  overflow: hidden;
  background-color: var(--color-bg-dark);
  background-position: center;
  background-size: cover;
}

/* Darker toward the foot, so the wordmark and caption read on any photo. */
.refm-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(15, 25, 35, 0.42) 0%, rgba(15, 25, 35, 0.08) 30%, rgba(15, 25, 35, 0.12) 60%, rgba(15, 25, 35, 0.72) 100%);
}

.refm-art__logo {
  position: absolute;
  top: 26px;
  left: 28px;
  z-index: 1;
  width: auto;
  height: 13px;
  opacity: 0.92;
}

.refm-art__caption {
  position: absolute;
  right: 28px;
  bottom: 24px;
  left: 28px;
  z-index: 1;
  margin: 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.01em;
  text-align: center;
}

/* ── Stay credit, as gift cards ── */

.refm-cards {
  position: relative;
  z-index: 1;
  width: 224px;
  aspect-ratio: 1.586;
}

.refm-cards--2 {
  margin: 22px 0 0 22px;
}

.refm-card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 18px 15px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background:
    repeating-radial-gradient(circle at 112% 128%, rgba(219, 192, 138, 0.13) 0 1px, transparent 1.5px 10px),
    radial-gradient(130% 150% at 0% 0%, #2c3d52 0%, #1a2332 52%, #0f1923 100%);
  box-shadow:
    0 26px 50px -14px rgba(0, 0, 0, 0.6),
    0 2px 6px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  color: var(--color-white);
}

/* A soft sheen across the face. */
.refm-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.07) 48%, transparent 62%);
  pointer-events: none;
}

.refm-card--clay {
  background:
    repeating-radial-gradient(circle at 112% 128%, rgba(255, 236, 214, 0.14) 0 1px, transparent 1.5px 10px),
    radial-gradient(130% 150% at 0% 0%, #c46a42 0%, #a8512c 50%, #7d3a1e 100%);
}

/* The back card peeks out, tilted, above and to the left of the front one:
   a plain edge, its face hidden so no half-covered mark shows. */
.refm-cards--2 .refm-card:first-child {
  transform: translate(-20px, -18px) rotate(-6deg);
}

.refm-cards--2 .refm-card:first-child > * {
  visibility: hidden;
}

.refm-card__row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.refm-card__row--end {
  align-items: flex-end;
}

.refm-card__mark svg {
  display: block;
  width: 30px;
  height: auto;
  color: var(--color-accent-light);
}

.refm-card--clay .refm-card__mark svg {
  color: #ffe6cf;
}

.refm-card__kind,
.refm-card__label {
  color: rgba(255, 255, 255, 0.72);
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.refm-card__label {
  padding-bottom: 5px;
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: 0.12em;
}

.refm-card__amount {
  color: var(--color-accent-light);
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.02em;
}

.refm-card--clay .refm-card__amount {
  color: #fff1e4;
}

/* Cards settle in as the modal opens. */
.smodal.refm.open .refm-cards {
  animation: refmRise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.refm-body {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 46px 40px 32px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.refm-body turbo-frame {
  display: block;
}

/* ── Type and controls ────────────────────────────────────────────────── */

.refm-eyebrow {
  margin: 0 0 10px;
  color: var(--color-clay);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.refm-title {
  margin: 0 0 12px;
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.05rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.refm-lede {
  margin: 0 0 22px;
  color: var(--color-text-secondary);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.refm-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  background: var(--color-primary);
  color: var(--color-white);
  font: 600 0.9375rem/1 var(--font-sans);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.refm-cta:hover {
  background: var(--color-primary-hover);
}

.refm-cta:active {
  transform: scale(0.98);
}

.refm-body > turbo-frame > .refm-cta,
.refm-body > turbo-frame > button.refm-cta {
  align-self: flex-start;
}

.refm-link,
.refm-form {
  display: flex;
  gap: 8px;
}

.refm-link {
  margin-bottom: 14px;
}

/* "Or send an invite by email": second to the link, so its button is quiet. */
.refm-invite {
  margin: 0 0 18px;
}

.refm-invite__label {
  display: block;
  margin: 0 0 8px;
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
}

.refm-cta--quiet {
  border: 1px solid var(--color-border);
  background: var(--color-white);
  color: var(--color-text);
}

.refm-cta--quiet:hover {
  border-color: var(--color-text-tertiary);
  background: var(--color-bg-muted);
}

.refm-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #eef6f0;
  color: #24583b;
  font-size: 0.8125rem;
  line-height: 1.45;
}

.refm-link input,
.refm-input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  color: var(--color-text);
}

.refm-link input {
  background: var(--color-bg-muted);
  font: 500 0.8125rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-overflow: ellipsis;
}

.refm-input {
  background: var(--color-white);
  font: 400 1rem/1 var(--font-sans);
}

.refm-input:focus,
.refm-link input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.refm-error {
  margin: 8px 0 0;
  color: #b42318;
  font-size: 0.8125rem;
}

.refm-fine,
.refm-note {
  margin: 16px 0 0;
  color: var(--color-text-tertiary);
  font-size: 0.75rem;
  line-height: 1.5;
}

.refm-note {
  margin: 0 0 14px;
  font-size: 0.8125rem;
}

.refm-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* The whole of the tracking: two chips. */
.refm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}

.refm-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--color-accent-bg);
  color: var(--color-text);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
}

.refm-chip svg {
  width: 15px;
  height: 15px;
  color: var(--color-clay);
}

.refm-codes {
  margin: -8px 0 22px;
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.refm-codes code {
  padding: 2px 7px;
  border: 1px dashed rgba(168, 81, 44, 0.5);
  border-radius: 6px;
  color: var(--color-text);
  font: 700 0.8125rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.05em;
}

.refm-h {
  margin: 0 0 10px;
  color: var(--color-text);
  font: 700 0.9375rem/1.3 var(--font-sans);
}

.refm-steps {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.refm-steps li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  line-height: 1.45;
}

.refm-steps svg {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  color: var(--color-text);
}

.refm-terms summary {
  width: max-content;
  color: var(--color-text);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.refm-terms p {
  margin: 8px 0 0;
  color: var(--color-text-tertiary);
  font-size: 0.75rem;
  line-height: 1.5;
}

/* ── The friend's "it's on its way" moment ────────────────────────────── */

.refm-badge {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 16px;
  border-radius: 50%;
  background: var(--color-accent-bg);
  color: var(--color-clay);
  animation: refmPop 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.4) both;
}

.refm-badge svg {
  width: 26px;
  height: 26px;
}

.refm-confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.refm-confetti i {
  position: absolute;
  top: -16px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  opacity: 0;
  animation: refmConfetti 1.7s cubic-bezier(0.2, 0.6, 0.4, 1) forwards;
}

.refm-confetti i:nth-child(4n + 1) { background: var(--color-clay); }
.refm-confetti i:nth-child(4n + 2) { background: var(--color-accent); }
.refm-confetti i:nth-child(4n + 3) { background: var(--color-sand); }
.refm-confetti i:nth-child(4n + 4) { background: var(--color-primary); width: 6px; height: 10px; }

.refm-confetti i:nth-child(1)  { left: 6%;  animation-delay: 0.00s; }
.refm-confetti i:nth-child(2)  { left: 13%; animation-delay: 0.12s; }
.refm-confetti i:nth-child(3)  { left: 20%; animation-delay: 0.05s; }
.refm-confetti i:nth-child(4)  { left: 27%; animation-delay: 0.20s; }
.refm-confetti i:nth-child(5)  { left: 34%; animation-delay: 0.08s; }
.refm-confetti i:nth-child(6)  { left: 41%; animation-delay: 0.26s; }
.refm-confetti i:nth-child(7)  { left: 48%; animation-delay: 0.02s; }
.refm-confetti i:nth-child(8)  { left: 55%; animation-delay: 0.16s; }
.refm-confetti i:nth-child(9)  { left: 62%; animation-delay: 0.10s; }
.refm-confetti i:nth-child(10) { left: 69%; animation-delay: 0.24s; }
.refm-confetti i:nth-child(11) { left: 76%; animation-delay: 0.04s; }
.refm-confetti i:nth-child(12) { left: 83%; animation-delay: 0.18s; }
.refm-confetti i:nth-child(13) { left: 89%; animation-delay: 0.09s; }
.refm-confetti i:nth-child(14) { left: 95%; animation-delay: 0.22s; }
.refm-confetti i:nth-child(odd) { --refm-drift: 26px; }
.refm-confetti i:nth-child(even) { --refm-drift: -22px; }

/* ── Motion ───────────────────────────────────────────────────────────── */

@keyframes refmGlow {
  0%   { box-shadow: 0 0 0 0 rgba(168, 81, 44, 0.55), 0 0 14px 1px rgba(196, 162, 101, 0.55); }
  70%  { box-shadow: 0 0 0 11px rgba(168, 81, 44, 0), 0 0 14px 1px rgba(196, 162, 101, 0.3); }
  100% { box-shadow: 0 0 0 0 rgba(168, 81, 44, 0), 0 0 14px 1px rgba(196, 162, 101, 0.55); }
}

@keyframes refmWiggle {
  0%, 84%, 100% { transform: rotate(0); }
  88% { transform: rotate(-14deg); }
  92% { transform: rotate(11deg); }
  96% { transform: rotate(-6deg); }
}

@keyframes refmRise {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

@keyframes refmPop {
  from { opacity: 0; transform: scale(0.4); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes refmConfetti {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  100% { opacity: 0; transform: translate(var(--refm-drift, 0), 460px) rotate(560deg); }
}

@media (prefers-reduced-motion: reduce) {
  .refer-gift::before,
  .refer-gift svg,
  .smodal.refm.open .refm-cards,
  .refm-badge {
    animation: none;
  }

  .refer-gift::before {
    box-shadow: 0 0 0 3px rgba(168, 81, 44, 0.25);
  }

  .refm-confetti {
    display: none;
  }
}

/* ── Phones: the photo becomes a banner above the content ─────────────── */

@media (max-width: 720px) {
  .smodal.refm {
    flex-direction: column;
    min-height: 0;
  }

  .refm-art {
    flex: 0 0 196px;
    padding: 20px;
  }

  .refm-art__logo {
    top: 18px;
    left: 20px;
    height: 11px;
  }

  .refm-art__caption {
    display: none;
  }

  .refm-cards {
    width: 176px;
    margin-top: 14px;
  }

  .refm-cards--2 {
    margin: 30px 0 0 16px;
  }

  .refm-cards--2 .refm-card:first-child {
    transform: translate(-15px, -13px) rotate(-6deg);
  }

  .refm-card {
    padding: 12px 14px 11px;
    border-radius: 11px;
  }

  .refm-card__mark svg {
    width: 24px;
  }

  .refm-card__amount {
    font-size: 32px;
  }

  .refm-body {
    justify-content: flex-start;
    padding: 26px 22px 24px;
  }

  .refm-form {
    flex-wrap: wrap;
  }

  .refm-form .refm-cta {
    width: 100%;
  }
}

/* "Claim" for a signed-in friend is a button_to form. */
.refm-claim { margin: 0; }
