/* The cite this article button with the reference that writes itself: the Cite this essay button at the end of a
   post on a personal blog, warm porcelain on a soft light page. The button is one box moved by GSAP (.ct__body) with
   absolute layers inside; the paper slip lives in a slot that ends at the button's middle line, so it can rise out of
   the button and sink back into it. */
:root {
  --page: #f3efe8;          /* the page */
  --page-light: #fbf9f5;    /* the light on the page, from above */
  --porcelain: #fdfcf9;     /* the top of the button */
  --porcelain-low: #f1ece4; /* the bottom of the button */
  --paper: #fffefb;         /* the slip */
  --ink: #1d1e24;           /* the words and the disc */
  --muted: #858079;         /* the small words */
  --accent: #3a56e0;        /* the blue of the beam, the check and the highlight */
  --bone: #ebe6de;          /* the grey placeholders */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  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 page: a soft light from above and a very fine grain */
.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
  background:
    radial-gradient(120% 70% at 50% 0%, var(--page-light), transparent 70%),
    radial-gradient(60% 40% at 50% 62%, rgba(255, 255, 255, 0.55), transparent 70%),
    var(--page);
}

.stage::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.32;
  mix-blend-mode: multiply;
  background-image: 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.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.4 0 0 0 0 0.34 0 0 0 0.16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* the frame: the button in the middle, with room above for the slip and the same room below, so it stays centred */
.ct {
  --room: min(150px, 34vh);
  position: relative;
  width: min(86vw, 340px);
  padding: var(--room) 0;
}

/* the slot ends at the button's middle line and clips the slip: it comes out of the button, not from behind it */
.ct__slot {
  position: absolute;
  left: -32px;
  right: -32px;
  top: 0;
  bottom: calc(var(--room) + 30px);
  overflow: hidden;
  pointer-events: none;
}

/* the slip: paper with stacked soft shadows and a lit top edge */
.ct__slip {
  position: absolute;
  left: 40px;
  right: 40px;
  bottom: 39px;
  display: grid;
  gap: 7px;
  padding: 12px 15px 13px;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, var(--paper) 40%, #fbf8f2);
  box-shadow:
    inset 0 1px 0 #ffffff,
    0 0 0 1px rgba(60, 45, 25, 0.07),
    0 1px 1px rgba(60, 45, 25, 0.05),
    0 4px 10px -4px rgba(60, 45, 25, 0.1),
    0 16px 30px -14px rgba(60, 45, 25, 0.18);
  overflow: hidden;
  will-change: transform;
}

/* a light that slides down the slip when the reference is copied */
.ct__slip-sheen {
  position: absolute;
  inset: -40% -10%;
  background: linear-gradient(170deg, transparent 38%, rgba(255, 255, 255, 0.9) 50%, transparent 62%);
  opacity: 0;
  pointer-events: none;
}

.ct__slip-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ct__style {
  font-size: 10.5px;
  font-weight: 600;
  font-variation-settings: 'wdth' 104;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 3px 7px;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(60, 45, 25, 0.1);
}

.ct__copied {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 560;
  font-variation-settings: 'wdth' 100;
  color: var(--accent);
  opacity: 0;
}

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

.ct__copied path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

/* the reference, in a book face: five pieces, each with a grey placeholder over it while it is formatted */
.ct__ref {
  position: relative;
  font-family: 'Newsreader Variable', Georgia, serif;
  font-size: 14px;
  line-height: 1.5;
  font-variation-settings: 'opsz' 14;
  color: var(--ink);
  text-wrap: pretty;
}

.ct__tk {
  position: relative;
  display: inline-block;
}

.ct__tk--url {
  color: color-mix(in srgb, var(--ink) 62%, var(--page));
}

.ct__w {
  position: relative;
  display: inline-block;
}

.ct__w em {
  font-style: italic;
}

.ct__bone {
  position: absolute;
  left: 0;
  right: 0;
  top: 22%;
  bottom: 18%;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--bone) 0%, var(--bone) 35%, #f7f4ee 50%, var(--bone) 65%, var(--bone) 100%);
  background-size: 300% 100%;
  background-position: 100% 0;
}

/* the soft blue highlight behind the title when it is copied (a wash, grown from the left by GSAP) */
.ct__mark {
  position: absolute;
  left: -2px;
  right: -2px;
  top: 20%;
  bottom: 8%;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

/* the shadow of the button on the page */
.ct__floor {
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: calc(var(--room) - 14px);
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(70, 50, 25, 0.16), transparent);
  filter: blur(4px);
  pointer-events: none;
}

.ct__btn {
  position: relative;
  display: block;
  width: 100%;
  height: 60px;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.ct__btn:focus-visible .ct__edge {
  box-shadow:
    inset 0 1px 0 #ffffff,
    inset 0 -1px 0 rgba(70, 50, 25, 0.1),
    0 0 0 2px var(--page),
    0 0 0 4px color-mix(in srgb, var(--accent) 70%, transparent);
}

.ct__body {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  overflow: hidden;
  isolation: isolate;
  box-shadow:
    0 0 0 1px rgba(60, 45, 25, 0.09),
    0 1px 1px rgba(60, 45, 25, 0.06),
    0 3px 6px -2px rgba(60, 45, 25, 0.08),
    0 12px 24px -10px rgba(60, 45, 25, 0.18),
    0 26px 44px -22px rgba(40, 50, 120, 0.2);
}

.ct__body > span {
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.ct__fill {
  background: linear-gradient(180deg, var(--porcelain) 0%, #faf8f3 46%, var(--porcelain-low) 100%);
}

/* the light under the pointer */
.ct__shine {
  background:
    radial-gradient(120px 70px at var(--mx, 30%) var(--my, 50%), rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 70%),
    radial-gradient(160px 90px at var(--mx, 30%) var(--my, 50%), color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%);
  opacity: 0;
}

/* the beam that runs round the border while the reference is formatted (GSAP moves --a) */
.ct__beam {
  padding: 2px;
  background: conic-gradient(from calc(var(--a, 0) * 1deg), transparent 0deg, transparent 230deg, color-mix(in srgb, var(--accent) 30%, transparent) 290deg, var(--accent) 340deg, #ffffff 352deg, transparent 360deg);
  -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 exclude, linear-gradient(#000 0 0);
  opacity: 0;
}

/* the same beam, blurred, as a soft glow inside the border */
.ct__beam::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: inherit;
  filter: blur(5px);
  opacity: 0.9;
}

/* the reflection that crosses the porcelain when the reference is copied */
.ct__sweep {
  overflow: hidden;
}

.ct__sweep-band {
  position: absolute;
  top: -30%;
  left: 0;
  width: 30%;
  height: 160%;
  background: linear-gradient(100deg, transparent 0%, rgba(255, 255, 255, 0.2) 30%, rgba(255, 255, 255, 0.95) 50%, rgba(255, 255, 255, 0.2) 70%, transparent 100%);
}

/* the edges: a lit hairline at the top, a darker one at the bottom, a glaze on the upper half */
.ct__edge {
  z-index: 3;
  box-shadow:
    inset 0 1px 0 #ffffff,
    inset 0 -1px 0 rgba(70, 50, 25, 0.1),
    inset 0 -10px 16px -12px rgba(70, 50, 25, 0.14);
  pointer-events: none;
}

.ct__edge::after {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  top: 1px;
  height: 46%;
  border-radius: 999px 999px 40% 40%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0));
  opacity: 0.6;
}

.ct__row {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 10px 0 9px;
  gap: 12px;
}

/* the disc: ink with two quote marks at rest, blue with a check when the reference is copied */
.ct__disc {
  position: relative;
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
}

.ct__disc > * {
  grid-area: 1 / 1;
  position: relative;
}

.ct__plate {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 14%, rgba(255, 255, 255, 0.22), transparent 58%),
    linear-gradient(180deg, #2c2e37, var(--ink) 60%, #121318);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 1px 2px rgba(20, 20, 30, 0.3),
    0 4px 10px -3px rgba(20, 20, 30, 0.35);
}

.ct__plate--done {
  background:
    radial-gradient(circle at 50% 12%, rgba(255, 255, 255, 0.4), transparent 58%),
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 80%, white), var(--accent) 55%, color-mix(in srgb, var(--accent) 80%, black));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -1px 0 rgba(0, 0, 30, 0.25),
    0 1px 2px rgba(20, 30, 90, 0.25),
    0 6px 14px -4px color-mix(in srgb, var(--accent) 60%, transparent);
  opacity: 0;
}

.ct__quotes {
  width: 27px;
  height: 27px;
  overflow: visible;
}

.ct__quotes path {
  fill: #f6f3ec;
}

.ct__check {
  width: 22px;
  height: 22px;
  overflow: visible;
}

.ct__check path {
  fill: none;
  stroke: #ffffff;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

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

.ct__state {
  grid-area: 1 / 1;
  display: grid;
  gap: 2px;
  min-width: 0;
}

.ct__state + .ct__state {
  opacity: 0;
}

.ct__title {
  font-size: 15.5px;
  font-weight: 590;
  font-variation-settings: 'wdth' 102;
  letter-spacing: -0.003em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Formatting shimmers: a blue band runs through the letters (GSAP moves background-position) */
.ct__title--busy {
  background: linear-gradient(90deg, var(--ink) 0%, var(--ink) 38%, color-mix(in srgb, var(--accent) 60%, white) 47%, var(--accent) 50%, color-mix(in srgb, var(--accent) 60%, white) 53%, var(--ink) 62%, var(--ink) 100%);
  background-size: 260% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.ct__sub {
  font-size: 11.5px;
  font-weight: 460;
  font-variation-settings: 'wdth' 96;
  letter-spacing: 0.01em;
  line-height: 1.2;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* the chip: the style at rest, a small meter while formatting, Copied at the end */
.ct__chip {
  flex: none;
  display: grid;
  place-items: center;
  width: 62px;
  height: 30px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #f4f0e9);
  box-shadow:
    inset 0 0 0 1px rgba(60, 45, 25, 0.1),
    inset 0 1px 0 #ffffff,
    0 1px 2px rgba(60, 45, 25, 0.08);
  overflow: hidden;
}

.ct__chip-face {
  grid-area: 1 / 1;
  font-size: 11.5px;
  font-weight: 600;
  font-variation-settings: 'wdth' 104;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.ct__chip-face + .ct__chip-face {
  opacity: 0;
}

.ct__chip-face--ok {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  letter-spacing: 0.01em;
  color: var(--accent);
}

.ct__board {
  width: 15px;
  height: 15px;
  overflow: visible;
}

.ct__board rect,
.ct__board path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ct__board [data-board] {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.ct__meter {
  display: block;
  position: relative;
  width: 34px;
  height: 4px;
  border-radius: 4px;
  background: var(--bone);
  overflow: hidden;
}

.ct__meter-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 70%, white), var(--accent));
  transform-origin: 0 50%;
  transform: scaleX(0);
}

@media (hover: hover) {
  .ct__btn:hover .ct__fill {
    background: linear-gradient(180deg, #ffffff 0%, #fbf9f5 46%, #f3eee6 100%);
  }
}
