/* The edited message with the version history: one message of the Juniper team chat on a white page. The bubble
   has the edges of its earlier versions peeking out under it; the history unfolds out of them. */
:root {
  --page: #ffffff;          /* the page */
  --card: #ffffff;          /* the chat panel */
  --card-low: #f8f8fa;      /* the bottom of the panel */
  --ink: #15161b;           /* the words */
  --muted: #80828e;         /* the small words */
  --line: rgba(21, 22, 27, 0.07); /* thin rules and edges */
  --bubble: #f1f1f5;        /* the bubble */
  --accent: #5b4cf0;        /* iris: edits, selection, the marker */
  --mark: rgba(91, 76, 240, 0.16); /* the marker behind changed words */
  --gone: #d6455b;          /* the words that were taken out */
  --av-a: #6d5cf5;          /* avatar, top */
  --av-b: #e0607a;          /* avatar, bottom */
}

* {
  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 panel */
.chat {
  position: relative;
  width: min(430px, 92vw);
  border-radius: 22px;
  background: linear-gradient(180deg, var(--card) 0%, var(--card) 55%, var(--card-low) 100%);
  box-shadow:
    0 0 0 1px rgba(21, 22, 27, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 1),
    0 1px 2px rgba(21, 22, 27, 0.04),
    0 10px 24px -10px rgba(21, 22, 27, 0.12),
    0 36px 70px -36px rgba(40, 30, 110, 0.28);
  opacity: 0;
  overflow: hidden;
}

/* a very light grain, so the white has a material */
.chat::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 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

.chat__head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: clamp(10px, 2.6vh, 14px) 18px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.chat__hash {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.chat__room {
  font-weight: 600;
  font-variation-settings: 'wdth' 104;
}

.chat__members {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

/* ---------------------------------------------------------------- the message */
.msg {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 11px;
  padding: clamp(12px, 3.2vh, 18px) 18px clamp(12px, 3vh, 18px) 16px;
}

.msg__avatar {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, var(--av-a), var(--av-b));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 0 0 1px rgba(0, 0, 0, 0.06), 0 4px 10px -4px rgba(91, 76, 240, 0.5);
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  font-variation-settings: 'wdth' 112;
  letter-spacing: 0.02em;
}

.msg__main {
  min-width: 0;
}

.msg__who {
  margin: 0 0 6px;
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 13px;
  line-height: 1.2;
}

.msg__name {
  font-weight: 620;
}

.msg__role,
.msg__time {
  color: var(--muted);
  font-size: 12px;
}

.msg__time {
  margin-left: auto;
}

/* the bubble and the edges of the versions under it */
.bubble-wrap {
  position: relative;
  padding-bottom: 10px;
}

.peek {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 5px;
  height: 24px;
  border-radius: 0 0 13px 13px;
  background: #ececf2;
  box-shadow: inset 0 0 0 1px rgba(21, 22, 27, 0.06), 0 3px 6px -3px rgba(21, 22, 27, 0.12);
}

.peek + .peek {
  left: 20px;
  right: 20px;
  bottom: 0;
  background: #f4f4f8;
}

.bubble {
  position: relative;
  z-index: 3;
  border-radius: 6px 16px 16px 16px;
  background: var(--bubble);
  box-shadow: inset 0 0 0 1px rgba(21, 22, 27, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 1px 2px rgba(21, 22, 27, 0.05);
  overflow: hidden;
}

.bubble__text {
  margin: 0;
  padding: 10px 14px 11px;
  font-size: clamp(14px, min(3.9vw, 3.6vh), 15px);
  line-height: 1.45;
}

/* a thin band of light that crosses the bubble when it is edited */
.bubble__glint {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 46%;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.85) 48%, rgba(91, 76, 240, 0.1) 54%, transparent 80%);
  transform: translateX(-120%);
}

/* every word is a span: the outer one carries the marker, the inner one rolls */
.w {
  display: inline-block;
  position: relative;
  border-radius: 4px;
  padding: 0 1px;
  margin: 0 -1px;
  background-image: linear-gradient(var(--mark), var(--mark));
  background-repeat: no-repeat;
  background-position: 0 50%;
  background-size: 0% 100%;
}

.w__in {
  display: inline-block;
}

/* ---------------------------------------------------------------- edited chip and count */
.msg__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  min-height: 28px;
}

.edited {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px 0 8px;
  border: 0;
  border-radius: 999px;
  background: rgba(91, 76, 240, 0.07);
  box-shadow: inset 0 0 0 1px rgba(91, 76, 240, 0.14);
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

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

.edited__pen,
.edited__caret {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.edited__caret {
  margin-left: 1px;
  opacity: 0.7;
}

.edited__word {
  font-weight: 600;
  font-variation-settings: 'wdth' 100;
  transition: font-variation-settings 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.edited__at {
  color: rgba(91, 76, 240, 0.72);
}

@media (hover: hover) {
  .edited:hover .edited__word {
    font-variation-settings: 'wdth' 112;
  }
  .edited:hover {
    background: rgba(91, 76, 240, 0.1);
  }
}

.msg__count {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* rolling digits: a drum one line tall with a column of twenty figures */
.roll {
  display: inline-flex;
  align-items: center;
  height: 1.2em;
  line-height: 1.2em;
}

.drum {
  display: inline-block;
  height: 1.2em;
  line-height: 1.2em;
  overflow: hidden;
  width: 0.62em;
  text-align: center;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 25%, #000 75%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 25%, #000 75%, transparent);
}

.drum__col {
  display: block;
}

.drum__col span {
  display: block;
  height: 1.2em;
}

.roll__ch {
  display: inline-block;
  height: 1.2em;
  line-height: 1.2em;
}

/* ---------------------------------------------------------------- the history */
.hist {
  height: 0;
  overflow: visible;
}

.hist__list {
  position: relative;
  display: grid;
  gap: 6px;
  padding-top: 12px;
}

.ver {
  position: relative;
  z-index: 0;
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 10px;
  width: 100%;
  padding: 9px 12px 10px;
  border: 0;
  border-radius: 13px;
  background: #f7f7fa;
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transform-origin: 50% 0;
}

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

.ver__when {
  display: grid;
  align-content: start;
  gap: 1px;
  font-size: 11.5px;
  line-height: 1.3;
}

.ver__time {
  font-weight: 600;
  transition: color 0.3s ease;
}

.ver__label {
  color: var(--muted);
}

.ver[aria-selected='true'] .ver__time {
  color: var(--accent);
}

.ver__text {
  font-size: 13px;
  line-height: 1.42;
  color: #3b3d47;
}

.ver__text .add {
  border-radius: 3px;
  padding: 0 2px;
  margin: 0 -1px;
  background: var(--mark);
  color: var(--ink);
}

.ver__text s {
  color: var(--gone);
  text-decoration-thickness: 1px;
  opacity: 0.85;
}

/* the frame of the chosen version: one element that springs from row to row */
.hist__sel {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 0;
  z-index: 2;
  border-radius: 13px;
  pointer-events: none;
  box-shadow: inset 0 0 0 1.5px var(--accent), 0 8px 20px -10px rgba(91, 76, 240, 0.55);
  opacity: 0;
}

.hist__note {
  margin: 9px 2px 0;
  font-size: 12px;
  color: var(--muted);
  min-height: 1.3em;
}

.hist__note b {
  color: var(--accent);
  font-weight: 600;
}

@media (max-height: 520px) {
  .chat__head {
    display: none;
  }
}
