/* The Invite a friend button of a made-up money app's referral programme, alone on white. The pill is one element
   moved by GSAP (width, lift, press, gulp); its body, the grain, the light and the three contents (the button, the
   open panel with the link, the Link copied state) sit in a clipped layer inside it. The reward ticket lives in a
   slot behind the pill whose bottom edge is the middle of the pill, so it really comes out of the button. A GSAP
   element never has a transform in the CSS. */
:root {
  --page: #ffffff;            /* the page */
  --pill-top: #2c2a35;        /* the top of the pill's body */
  --pill-bottom: #111016;     /* the bottom of the pill's body */
  --ink: #f4f3f7;             /* the words on the pill */
  --muted: #9a98a6;           /* the small words and the host of the link */
  --accent: #5fe3a6;          /* the code, the check, the badge */
  --paper: #fffdf8;           /* the reward ticket */
  --paper-ink: #17161c;       /* the words on the ticket */
  --paper-muted: #8b8894;     /* the small words on the ticket */
  --money: #0f8d5a;           /* the amounts on the ticket */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--page);
  color: var(--ink);
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

/* the wrap holds the open pill and, above it, the room the ticket needs */
.wrap {
  position: relative;
  width: min(372px, calc(100vw - 32px));
  height: min(212px, 60vh);
  display: grid;
  place-items: end center;
  padding-bottom: 26px;
}

/* ---- the reward ticket ---- */
.slot {
  position: absolute;
  left: 50%;
  bottom: 56px;               /* the middle of the pill */
  width: min(330px, 100vw);
  transform: translateX(-50%);
  height: 172px;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.ticket {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 236px;
  height: 94px;
  margin-left: -118px;
  visibility: hidden;
  filter: drop-shadow(0 1px 1px rgba(23, 22, 28, 0.12)) drop-shadow(0 8px 14px rgba(23, 22, 28, 0.12)) drop-shadow(0 14px 16px rgba(23, 22, 28, 0.07));
}

.ticket__half {
  position: absolute;
  left: 0;
  right: 0;
  height: 47px;
  background: var(--paper);
}

/* the two notches on the perforation are cut out of both halves */
.ticket__bottom {
  bottom: 0;
  border-radius: 0 0 12px 12px;
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  align-items: center;
  padding: 0 14px;
  box-shadow: inset 0 -1px 0 rgba(23, 22, 28, 0.06);
  -webkit-mask: radial-gradient(circle 6.5px at 0 0, transparent 6px, #000 6.6px) left / 51% 100% no-repeat, radial-gradient(circle 6.5px at 100% 0, transparent 6px, #000 6.6px) right / 51% 100% no-repeat;
  mask: radial-gradient(circle 6.5px at 0 0, transparent 6px, #000 6.6px) left / 51% 100% no-repeat, radial-gradient(circle 6.5px at 100% 0, transparent 6px, #000 6.6px) right / 51% 100% no-repeat;
}
/* the shade the folding half throws on the lower half */
.ticket__bottom::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(23, 22, 28, 0.22), rgba(23, 22, 28, 0.04));
  opacity: var(--shade, 0);
  pointer-events: none;
}
.ticket__col {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
}
.ticket__col b {
  font-size: 19px;
  font-weight: 700;
  font-stretch: 112%;
  letter-spacing: -0.02em;
  color: var(--money);
  font-variant-numeric: tabular-nums;
}
.ticket__col i {
  font-style: normal;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--paper-muted);
}
.ticket__rule {
  width: 1px;
  height: 22px;
  background: rgba(23, 22, 28, 0.1);
}

.ticket__top {
  top: 0;
  border-radius: 12px 12px 0 0;
  -webkit-mask: radial-gradient(circle 6.5px at 0 100%, transparent 6px, #000 6.6px) left / 51% 100% no-repeat, radial-gradient(circle 6.5px at 100% 100%, transparent 6px, #000 6.6px) right / 51% 100% no-repeat;
  mask: radial-gradient(circle 6.5px at 0 100%, transparent 6px, #000 6.6px) left / 51% 100% no-repeat, radial-gradient(circle 6.5px at 100% 100%, transparent 6px, #000 6.6px) right / 51% 100% no-repeat;
  box-shadow: inset 0 1px 0 #ffffff;
}
/* the perforation, a dotted line drawn on the fold */
.ticket__top::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 1px;
  background: repeating-linear-gradient(90deg, rgba(23, 22, 28, 0.22) 0 3px, transparent 3px 6px);
}
.ticket__face {
  position: absolute;
  inset: 0;
  border-radius: inherit;
}
.ticket__front {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  background: linear-gradient(180deg, #ffffff, var(--paper));
}
.ticket__mark {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--money);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ticket__label {
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--paper-ink);
  letter-spacing: -0.005em;
}
.ticket__tag {
  white-space: nowrap;
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 600;
  font-stretch: 110%;
  color: var(--money);
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(15, 141, 90, 0.09);
  box-shadow: inset 0 0 0 1px rgba(15, 141, 90, 0.14);
}
/* the back of the folding half: the paper's inside, slightly darker, with a fine weave */
.ticket__back {
  opacity: 0;
  background: linear-gradient(0deg, #f1efe8, #e8e5dc);
}
.ticket__weave {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: repeating-linear-gradient(135deg, rgba(15, 141, 90, 0.07) 0 1px, transparent 1px 7px);
}
.ticket__shine {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.9) 48%, transparent 64%);
  background-size: 300% 100%;
  background-position: var(--tx, 120%) 0;
  mix-blend-mode: soft-light;
  pointer-events: none;
}

/* ---- the pill ---- */
.pill {
  position: relative;
  z-index: 1;
  height: 60px;
  width: 210px;
  border-radius: 30px;
  --mx: 50%;
  --ow: 340px;
}

/* the soft shadow the pill throws on the white floor */
.pill__floor {
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -12px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(17, 16, 22, 0.28), transparent);
  filter: blur(5px);
  pointer-events: none;
}

/* the halo of the copy: it swells once from the edge */
.pill__halo {
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  box-shadow: 0 0 0 1px rgba(95, 227, 166, 0.6), 0 0 22px 2px rgba(95, 227, 166, 0.35);
  opacity: 0;
  pointer-events: none;
}

.pill__clip {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  background: linear-gradient(180deg, var(--pill-top), var(--pill-bottom));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -1px 0 rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(17, 16, 22, 0.9),
    0 1px 2px rgba(17, 16, 22, 0.28),
    0 6px 14px -4px rgba(17, 16, 22, 0.3),
    0 20px 40px -16px rgba(17, 16, 22, 0.42),
    0 28px 54px -26px rgba(15, 141, 90, 0.35);
  isolation: isolate;
}

.pill__grain {
  position: absolute;
  inset: 0;
  opacity: 0.08;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='120' height='120' filter='url(%23n)'/></svg>");
  pointer-events: none;
}

.pill__sheen {
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: 0;
  width: 130px;
  background: linear-gradient(100deg, rgba(190, 255, 225, 0) 10%, rgba(190, 255, 225, 0.07) 38%, rgba(255, 255, 255, 0.16) 50%, rgba(190, 255, 225, 0.07) 62%, rgba(190, 255, 225, 0) 90%);
  filter: blur(3px);
  opacity: 0;
  pointer-events: none;
}

/* the 1px edge that takes the light where the pointer is */
.pill__edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: radial-gradient(150px 70px at var(--mx) 0%, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.12) 60%, rgba(255, 255, 255, 0.04));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  opacity: 0.45;
  transition: opacity 0.35s ease;
  pointer-events: none;
}
.pill.is-hot .pill__edge { opacity: 1; }

/* ---- the closed button ---- */
.invite {
  position: absolute;
  inset: 0;
  border: 0;
  border-radius: inherit;
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  display: grid;
  place-items: center;
  outline: none;
}
.invite:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.pill.is-open .invite { pointer-events: none; }
.invite__in {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
}
.gift {
  width: 19px;
  height: 19px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.invite__word {
  font-size: 15.5px;
  font-weight: 560;
  letter-spacing: -0.005em;
  font-stretch: 100%;
  transition: font-stretch 0.45s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.pill.is-hot .invite__word { font-stretch: 108%; }
.invite__badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  font-stretch: 110%;
  color: #0b2a1d;
  background: linear-gradient(180deg, #8ff0c3, var(--accent));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 2px 6px -2px rgba(95, 227, 166, 0.55);
  font-variant-numeric: tabular-nums;
}

/* ---- the open panel ---- */
.panel {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: var(--ow);
  margin-left: calc(var(--ow) / -2);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 0 12px;
  visibility: hidden;
}
.pill.is-open .panel { visibility: visible; }

.avatar {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: rgba(95, 227, 166, 0.12);
  box-shadow: inset 0 0 0 1px rgba(95, 227, 166, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.avatar svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.link {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 3px;
}
.link__line {
  position: relative;
  display: flex;
  align-items: center;
  height: 22px;
  font-size: 14.5px;
  font-weight: 520;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.link__host { color: var(--muted); }
.code {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 22px;
  margin-left: 2px;
  padding: 0 6px;
  border-radius: 6px;
  color: var(--ink);
  font-weight: 650;
  font-stretch: 108%;
  letter-spacing: 0.02em;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  font-variant-numeric: tabular-nums;
}
.code.is-empty { display: none; }
.code__sel {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(95, 227, 166, 0.26), rgba(95, 227, 166, 0.36));
  box-shadow: inset 0 0 0 1px rgba(95, 227, 166, 0.45);
}
.code__text { position: relative; }
.code__glint {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  --gx: -60%;
  pointer-events: none;
}
.code__glint::after {
  content: "";
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: var(--gx);
  width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.75), transparent);
  transform: skewX(-18deg);
  mix-blend-mode: overlay;
}
.code__ghost {
  position: absolute;
  left: 6px;
  top: 0;
  line-height: 22px;
  color: var(--accent);
  opacity: 0;
  pointer-events: none;
}
.caret {
  width: 1.6px;
  height: 15px;
  margin-left: 2px;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0;
}
.link__sub {
  display: block;
  height: 15px;
  overflow: hidden;
  font-size: 11.5px;
  line-height: 15px;
  font-weight: 500;
  color: var(--muted);
}
.link__subin { display: inline-block; }

.copy {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #111016;
  cursor: pointer;
  background: linear-gradient(180deg, #ffffff, #e4e3ea);
  box-shadow: inset 0 1px 0 #ffffff, inset 0 -1px 0 rgba(0, 0, 0, 0.14), 0 2px 6px -2px rgba(0, 0, 0, 0.6);
  outline: none;
}
.copy:focus-visible { box-shadow: 0 0 0 2px var(--pill-bottom), 0 0 0 4px var(--accent); }
.copy__ic {
  width: 18px;
  height: 18px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.copy__check { stroke-width: 2; }

/* ---- Link copied ---- */
.done {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  white-space: nowrap;
  visibility: hidden;
  pointer-events: none;
}
.done__ic {
  width: 22px;
  height: 22px;
  overflow: visible;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.done__ic circle { stroke: rgba(95, 227, 166, 0.45); }
.done__word {
  font-size: 15.5px;
  font-weight: 560;
  letter-spacing: -0.005em;
}

/* ---- the drawn pointer of the autopilot ---- */
.ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  pointer-events: none;
  fill: #111016;
  stroke: #ffffff;
  stroke-width: 1.4;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  opacity: 0;
  visibility: hidden;
  z-index: 5;
}

@media (max-width: 380px) {
  .avatar { width: 32px; height: 32px; }
  .copy { width: 36px; height: 36px; }
  .link__line { font-size: 13.5px; }
  .panel { gap: 8px; padding: 0 9px 0 10px; }
  .ticket { width: 224px; margin-left: -112px; }
}
