/* The stack of avatars viewing the doc that fans out into names: the header of a shared doc in Quire, a made up
   writing app, on white. A soft white card with a 1px edge and layered shadows; under the title a recessed well holds
   the stack of the people viewing, initials on gradients with a ring of their own colour. One accent for the app:
   indigo. */
:root {
  --page: #ffffff;            /* the page */
  --card: #fdfdfc;            /* the card */
  --well: #f4f3f0;            /* the recessed well under the stack */
  --ink: #18181c;             /* the words */
  --muted: #85848d;           /* the small words */
  --edge: rgba(24, 24, 40, 0.08); /* the 1px edges */
  --accent: #5b5cf0;          /* the app's one accent: indigo */
  --button: #17171b;          /* the Share button */
  --button-ink: #f7f7fa;      /* the words on the button */
  --chip: #ecebe7;            /* the +3 chip */
  --d: clamp(30px, 5.4vh, 38px); /* how big a face is */
}

* {
  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;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

/* ---------------------------------------------------------------- the card */
.doc {
  position: relative;
  width: min(470px, 94vw);
  padding: clamp(14px, 3.8vh, 22px) clamp(14px, 4.4vw, 22px) clamp(13px, 3.4vh, 19px);
  border-radius: 22px;
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(91, 92, 240, 0.045), transparent 60%),
    linear-gradient(180deg, #ffffff, var(--card));
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 1px rgba(20, 20, 40, 0.04),
    0 4px 10px -4px rgba(20, 20, 40, 0.08),
    0 22px 44px -18px rgba(30, 30, 70, 0.18),
    0 60px 90px -50px rgba(30, 30, 70, 0.22);
  opacity: 0;
}

/* a whisper of grain on the card */
.doc::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .55 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

.doc__head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.doc__icon {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #7c7dff, var(--accent) 55%, #4141c9);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.15),
    0 6px 14px -6px rgba(70, 70, 220, 0.6);
}

.doc__icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.doc__sheet {
  fill: rgba(255, 255, 255, 0.94);
}

.doc__fold {
  stroke: rgba(91, 92, 240, 0.55);
  stroke-width: 1.2;
  fill: rgba(220, 221, 255, 0.9);
}

.doc__lines {
  stroke: rgba(91, 92, 240, 0.55);
  stroke-width: 1.3;
}

.doc__titles {
  flex: 1;
  min-width: 0;
}

.doc__title {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.2;
  font-weight: 620;
  font-variation-settings: 'wdth' 104;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc__meta {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- Share */
.share {
  flex: none;
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
}

.share__body {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 13px 0 11px;
  border-radius: 999px;
  background: linear-gradient(180deg, #2a2a31, var(--button));
  color: var(--button-ink);
  font-size: 13px;
  font-weight: 560;
  font-variation-settings: 'wdth' 102;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 4px 10px -4px rgba(0, 0, 0, 0.45);
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1), box-shadow 0.3s ease;
}

.share svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

@media (hover: hover) {
  .share:hover .share__body {
    transform: translateY(-1px);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.2),
      0 0 0 1px rgba(0, 0, 0, 0.6),
      0 8px 16px -6px rgba(0, 0, 0, 0.45);
  }
}

.share:active .share__body {
  transform: translateY(0) scale(0.96);
  transition-duration: 0.08s;
}

.share:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---------------------------------------------------------------- the well and the stack */
.live {
  position: relative;
  margin-top: clamp(12px, 3vh, 18px);
  padding: 6px;
  border-radius: 15px;
  background: linear-gradient(180deg, #f1f0ec, var(--well));
  box-shadow:
    inset 0 1px 2px rgba(20, 20, 40, 0.06),
    inset 0 0 0 1px rgba(20, 20, 40, 0.045),
    0 1px 0 rgba(255, 255, 255, 0.95);
}

.stack {
  position: relative;
  display: block;
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0 0 0 3px;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  height: var(--d);
  width: var(--d);
  cursor: pointer;
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
}

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

/* one face: GSAP moves .av and grows its width; the pill inside carries the look */
.av {
  position: absolute;
  left: 0;
  top: 0;
  height: var(--d);
  width: var(--d);
  transform-origin: calc(var(--d) / 2) 50%;
  will-change: transform;
}

.av__pill {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  overflow: hidden;
  background: color-mix(in srgb, var(--c) 10%, #ffffff);
  box-shadow:
    0 0 0 2px var(--well),
    0 0 0 3.5px var(--c),
    0 3px 8px -3px color-mix(in srgb, var(--c) 55%, transparent);
  transition: transform 0.4s cubic-bezier(0.3, 1.7, 0.5, 1);
}

.av__face {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--d);
  height: var(--d);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(80% 60% at 30% 18%, rgba(255, 255, 255, 0.45), transparent 60%),
    linear-gradient(150deg, var(--g1), var(--g2));
  box-shadow:
    inset 0 -2px 4px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  color: #ffffff;
  font-size: calc(var(--d) * 0.36);
  font-weight: 660;
  font-variation-settings: 'wdth' 112;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.16);
}

.av__name {
  position: absolute;
  left: calc(var(--d) + 5px);
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 580;
  font-variation-settings: 'wdth' 100;
  white-space: nowrap;
  color: color-mix(in srgb, var(--c) 30%, var(--ink));
}

/* the ring that widens once when someone arrives */
.av__halo {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--d);
  height: var(--d);
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px var(--c);
  opacity: 0;
  pointer-events: none;
}

@media (hover: hover) {
  .stack.is-open .av:hover .av__pill {
    transform: translateY(-2px);
  }
}

/* the +3 chip with its rolling digits */
.more {
  position: absolute;
  left: 0;
  top: 0;
  height: var(--d);
  transform-origin: 50% 50%;
}

.more__pill {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--d);
  min-width: var(--d);
  padding: 0 8px 0 7px;
  border-radius: 999px;
  background: linear-gradient(180deg, #f3f2ef, var(--chip));
  box-shadow:
    0 0 0 2px var(--well),
    0 0 0 3px rgba(24, 24, 40, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  color: #55545c;
  font-size: calc(var(--d) * 0.34);
  font-weight: 640;
  font-variation-settings: 'wdth' 106;
}

.more__plus {
  margin-right: 0.5px;
}

/* rolling digits: one window per digit, a column 0 to 9 inside */
.roll {
  display: inline-flex;
  height: 1.1em;
  line-height: 1.1em;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
}

.roll__win {
  display: block;
  height: 1.1em;
  overflow: hidden;
}

.roll__col {
  display: flex;
  flex-direction: column;
}

.roll__col span {
  display: block;
  height: 1.1em;
  text-align: center;
}

/* ---------------------------------------------------------------- the line under the well */
.doc__foot {
  margin: clamp(10px, 2.4vh, 13px) 0 0 2px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  min-width: 0;
}

.live__count {
  position: absolute;
  right: 14px;
  top: 50%;
  margin-top: -0.65em;
  display: flex;
  align-items: center;
  gap: 5px;
  height: 1.3em;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
}

.live__count > .roll {
  color: var(--ink);
  font-weight: 620;
}

.doc__eye {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  margin-right: 1px;
}

.event {
  position: relative;
  display: inline-block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  height: 1.3em;
  line-height: 1.3em;
}

.event__text {
  display: inline-block;
}

.event__text b {
  font-weight: 600;
  color: var(--who, var(--ink));
}

@media (max-width: 420px) {
  .av__name {
    font-size: 11.5px;
  }
}
