/* The Gift article button with the ribbon that wraps the link. A dark pill on warm paper: the body (.gift__body) is
   moved only by GSAP, its children only by CSS or GSAP. Inside one rounded clip sit the light under the pointer, the
   coral thread of the loading, the rest face, the satin ribbon (revealed with a clip-path) and the fold at its
   leading edge. */
:root {
  --page: #efebe4;            /* the paper around the button */
  --light: #fffaf2;           /* the soft light on the paper */
  --ink: #171411;             /* the button */
  --ink-2: #2b2621;           /* the top of the button */
  --text: #f6f1ea;            /* the words on the button */
  --muted: rgba(246, 241, 234, 0.62); /* the small words */
  --coral: #f2603a;           /* the ribbon */
  --coral-hi: #ff9466;        /* the light side of the ribbon */
  --coral-lo: #d4441f;        /* the shaded side of the ribbon */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--text);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* the paper: a soft light from the top left, a faint warm one from below, and grain */
.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
  isolation: isolate;
}

.stage::before,
.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.stage::before {
  background:
    radial-gradient(60% 55% at 30% 22%, var(--light), transparent 70%),
    radial-gradient(45% 40% at 72% 88%, color-mix(in srgb, var(--coral) 9%, transparent), transparent 70%),
    radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(60, 40, 20, 0.08));
}

.stage::after {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.25 0 0 0 0 0.18 0 0 0 0 0.1 0 0 0 0.16 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
  opacity: 0.8;
}

.gift {
  position: relative;
  display: grid;
  place-items: center;
}

/* the soft shadow on the paper, which turns coral while the ribbon is on */
.gift__floor {
  position: absolute;
  left: 50%;
  top: 100%;
  width: 92%;
  height: 34px;
  margin: -16px 0 0 -46%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(40, 24, 10, 0.34), rgba(40, 24, 10, 0.1) 60%, transparent);
  filter: blur(10px);
  pointer-events: none;
}

.gift__floor::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--coral) 70%, transparent), transparent);
  opacity: var(--warm, 0);
}

.gift__btn {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
}

.gift__btn:focus-visible {
  outline: 2px solid var(--coral);
  outline-offset: 5px;
}

.gift__body {
  --mx: 50%;
  --my: 50%;
  position: relative;
  display: block;
  width: min(84vw, 300px);
  height: 60px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--ink-2), var(--ink) 58%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    inset 0 -2px 6px rgba(0, 0, 0, 0.35),
    0 1px 1px rgba(30, 18, 8, 0.3),
    0 6px 14px -6px rgba(30, 18, 8, 0.4),
    0 22px 40px -22px rgba(30, 18, 8, 0.55);
}

.gift__clip {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  isolation: isolate;
}

/* the light under the pointer */
.gift__shine {
  position: absolute;
  inset: 0;
  background: radial-gradient(110px 70px at var(--mx) var(--my), rgba(255, 240, 225, 0.16), rgba(255, 240, 225, 0.04) 50%, transparent 72%);
  opacity: 0;
  pointer-events: none;
}

/* the coral thread that runs along the bottom while the link is made */
.gift__thread {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 9px;
  height: 1.5px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--coral-lo), var(--coral-hi));
  box-shadow: 0 0 8px color-mix(in srgb, var(--coral) 70%, transparent);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

.gift__face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 0 20px;
  text-align: left;
}

.gift__icon {
  flex: none;
  width: 22px;
  height: 22px;
}

.gift__icon svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.gift__box {
  fill: rgba(255, 255, 255, 0.06);
  stroke: var(--text);
  stroke-width: 1.5;
}

.gift__ribbon {
  fill: none;
  stroke: var(--coral-hi);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gift__labels {
  flex: 1;
  display: grid;
  min-width: 0;
  text-align: left;
}

.gift__label {
  grid-area: 1 / 1;
  font-size: 16px;
  font-weight: 560;
  font-variation-settings: 'wdth' 102;
  letter-spacing: 0.003em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Wrapping link shimmers: a light band slides through the letters (GSAP moves background-position) */
.gift__label--busy {
  background: linear-gradient(90deg, var(--text) 0%, var(--text) 38%, #ffffff 46%, var(--coral-hi) 50%, #ffffff 54%, var(--text) 62%, var(--text) 100%);
  background-size: 260% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.gift__label--empty {
  color: var(--muted);
}

.gift__chip {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 62px;
  height: 32px;
  padding: 0 11px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 1px 2px rgba(0, 0, 0, 0.4);
  font-size: 12px;
  font-weight: 560;
  font-variation-settings: 'wdth' 94;
  color: var(--muted);
  white-space: nowrap;
}

/* the counter: a column of digits behind a one line window */
.gift__roll {
  position: relative;
  display: block;
  height: 16px;
  overflow: hidden;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.gift__digits {
  display: block;
}

.gift__digits span {
  display: block;
  height: 16px;
  line-height: 16px;
  text-align: center;
}

/* the satin ribbon: coral, lighter at the top, two stitched edges, a sheen that slides slowly */
.gift__ribbonface {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--coral-hi) 0%, var(--coral) 46%, var(--coral-lo) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), inset 0 -1px 0 rgba(90, 20, 0, 0.25), inset 0 -8px 14px -8px rgba(110, 30, 0, 0.4);
  clip-path: inset(0 100% 0 0);
  color: #ffffff;
}

.gift__satin {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(104deg, transparent 20%, rgba(255, 255, 255, 0.07) 34%, rgba(255, 255, 255, 0.3) 44%, rgba(255, 255, 255, 0.07) 54%, transparent 68%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 3px);
  background-size: 300% 100%, auto;
  background-position: 100% 0, 0 0;
}

.gift__stitch {
  position: absolute;
  left: 20px;
  right: 20px;
  height: 1px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.55) 0 4px, transparent 4px 8px);
  opacity: 0.7;
}

.gift__stitch--t {
  top: 6px;
}

.gift__stitch--b {
  bottom: 6px;
  opacity: 0.45;
}

.gift__face--done {
  padding: 0 10px 0 19px;
  gap: 9px;
}

.gift__icon--link {
  width: 20px;
  height: 20px;
}

.gift__icon--link path {
  fill: none;
  stroke: #ffffff;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.gift__link {
  flex: 1;
  min-width: 0;
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  text-shadow: 0 1px 0 rgba(120, 30, 0, 0.25);
}

.gift__copied {
  flex: none;
  display: flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 12px 0 9px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0.12));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 2px 4px -1px rgba(110, 30, 0, 0.35);
  font-size: 12px;
  font-weight: 600;
  font-variation-settings: 'wdth' 96;
}

.gift__copied svg {
  width: 14px;
  height: 14px;
  overflow: visible;
}

.gift__check {
  fill: none;
  stroke: #ffffff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

/* the fold at the leading edge of the ribbon: a shaded roll with a bright lip */
.gift__fold {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 24px;
  margin-left: -14px;
  background: linear-gradient(90deg, transparent 0%, color-mix(in srgb, var(--coral) 60%, transparent) 22%, var(--coral-hi) 44%, #ffd9c4 54%, var(--coral-lo) 62%, rgba(20, 8, 0, 0.42) 68%, rgba(20, 8, 0, 0.12) 84%, transparent 100%);
  opacity: 0;
  pointer-events: none;
}

/* before the script runs, only the rest state shows */
.gift__label + .gift__label {
  opacity: 0;
}

@media (hover: hover) {
  .gift__btn:hover .gift__chip {
    color: var(--text);
  }
}
