/* The code block with the diff that applies line by line: a suggested change in a code review of Tessel, a made-up
   tool for developers, alone on black. The panel is a layer of soft shadows with a one pixel edge that catches the
   light on top; the code is a list of rows the script builds (number, sign, text), each with its own wash. */
:root {
  --page: #000000;          /* the page */
  --panel: #0e0f12;         /* the body of the panel */
  --panel-top: #14161a;     /* the top of the panel, a little lighter */
  --gutter: #0b0c0e;        /* the column of the line numbers */
  --edge: rgba(255, 255, 255, 0.075); /* the edge of the panel */
  --ink: #e8e9ec;           /* the words */
  --muted: #7d828c;         /* the small words and the numbers */
  --add: #3fb67a;           /* the added lines */
  --del: #f0646b;           /* the removed lines */
  --light: #b8ffd8;         /* the thread of light in the margin */
  --button: #eceef1;        /* the Apply button */
  --button-ink: #0b0c0e;    /* the words on it */
  /* the colours of the code */
  --c-key: #c792ea;         /* keywords: export, const, return */
  --c-fn: #82aaff;          /* functions */
  --c-type: #ffcb6b;        /* types */
  --c-str: #a5d6a7;         /* strings */
  --c-num: #f78c6c;         /* numbers */
  --c-prop: #b2ccd6;        /* properties */
  --c-punct: #6f7684;       /* brackets and signs */
  --c-text: #d7dae0;        /* names */
}

* {
  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: 12px;
  overflow: hidden;
}

/* ------------------------------------------------------------ the panel */
.sug {
  --fs: clamp(9.4px, min(2.75vw, 2.55vh), 13.5px);   /* the size of the code */
  --lh: 1.78em;                                     /* the height of one line of code */
  position: relative;
  width: min(94vw, 560px);
  border-radius: 16px;
  background: linear-gradient(180deg, var(--panel-top), var(--panel) 38%);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 1px 2px rgba(0, 0, 0, 0.6),
    0 12px 28px -10px rgba(0, 0, 0, 0.8),
    0 40px 80px -30px rgba(0, 0, 0, 0.9);
  opacity: 0;
}

/* a soft green bloom under the panel, lit once when the change lands */
.sug__glow {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -18px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--add) 45%, transparent), transparent);
  filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.sug__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: clamp(10px, 2.6vh, 15px) clamp(12px, 3.4vw, 18px) 0;
}

.sug__avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: #0b0c0e;
  background: linear-gradient(140deg, #f6d0a8, #e48f8f 55%, #a98be8);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35), 0 0 0 2px rgba(255, 255, 255, 0.04);
}

.sug__who {
  margin: 0;
  min-width: 0;
  font-size: clamp(12px, 3.3vw, 13.5px);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sug__who b {
  font-weight: 600;
  color: var(--ink);
  font-variation-settings: 'wdth' 104;
}

/* the count of added and removed lines: two small rolls */
.sug__count {
  margin-left: auto;
  flex: none;
  display: flex;
  gap: 8px;
  padding: 4px 9px;
  border-radius: 999px;
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  transition: color 0.4s ease;
}

.sug__plus,
.sug__minus {
  display: inline-flex;
  align-items: center;
  transition: color 0.45s ease;
}

.sug__plus {
  color: var(--add);
}

.sug__minus {
  color: var(--del);
}

.sug__minus svg {
  width: 0.62em;
  height: 0.62em;
  margin-right: 1px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.is-applied .sug__plus,
.is-applied .sug__minus {
  color: var(--muted);
}

/* a number that rolls: the old figure leaves upwards, the new one comes in from below */
.roll {
  position: relative;
  display: inline-block;
  height: 1.2em;
  line-height: 1.2em;
  overflow: hidden;
  vertical-align: bottom;
}

.roll > span {
  display: block;
}

.roll > span + span {
  position: absolute;
  inset: 0 auto auto 0;
}

.sug__file {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: clamp(8px, 2vh, 12px) 0 0;
  padding: 0 clamp(12px, 3.4vw, 18px) clamp(8px, 2vh, 11px);
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: clamp(10.5px, 2.9vw, 12px);
  color: var(--ink);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sug__file-icon {
  flex: none;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.2;
  stroke-linejoin: round;
}

.sug__path span {
  color: var(--muted);
}

.sug__state {
  margin-left: auto;
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 550;
  letter-spacing: 0.01em;
  color: var(--muted);
  transition: color 0.45s ease;
}

.is-applied .sug__state {
  color: var(--add);
}

/* ------------------------------------------------------------ the code */
.code {
  --num: 4.4ch;     /* the column of the numbers */
  --sign: 2.4ch;    /* the column of the signs */
  position: relative;
  padding: 6px 0;
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: var(--fs);
  font-weight: 420;
  background: linear-gradient(90deg, var(--gutter) var(--num), transparent var(--num));
}

/* the thin line between the numbers and the code, and the thread of light that runs down it */
.code__thread {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--num);
  width: 1px;
  background: rgba(255, 255, 255, 0.055);
  clip-path: inset(0 -12px);
  pointer-events: none;
  z-index: 3;
}

.code__beam {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 120px;
  background: linear-gradient(180deg, transparent, var(--light) 70%, #ffffff 88%, transparent);
  box-shadow: 0 0 8px 1px color-mix(in srgb, var(--light) 50%, transparent);
  opacity: 0;
  visibility: hidden;
}

.code__rows {
  position: relative;
}

.row {
  --o: 1;
  position: relative;
  height: calc(var(--lh) * var(--o));
  overflow: hidden;
  perspective: 300px;
}

.row__in {
  position: relative;
  display: grid;
  grid-template-columns: var(--num) var(--sign) 1fr;
  align-items: center;
  height: var(--lh);
  transform-origin: 50% 0;
}

/* the wash of a changed line: a layer of its own, so GSAP can fade it without touching the row */
.row__wash {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.row--del .row__wash,
.row--add .row__wash {
  opacity: 1;
}

.row--del .row__wash {
  background: linear-gradient(90deg, color-mix(in srgb, var(--del) 22%, transparent) var(--num), color-mix(in srgb, var(--del) 10%, transparent) var(--num));
  box-shadow: inset 2px 0 0 color-mix(in srgb, var(--del) 80%, transparent);
}

.row--add .row__wash {
  background: linear-gradient(90deg, color-mix(in srgb, var(--add) 22%, transparent) var(--num), color-mix(in srgb, var(--add) 10%, transparent) var(--num));
  box-shadow: inset 2px 0 0 color-mix(in srgb, var(--add) 80%, transparent);
}

/* the light that crosses an added line as it loses its colour */
.row__sweep {
  position: absolute;
  inset: 0 auto 0 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(184, 255, 216, 0.13), transparent);
  opacity: 0;
  pointer-events: none;
}

.row__num {
  position: relative;
  text-align: right;
  padding-right: 1.1ch;
  color: color-mix(in srgb, var(--muted) 80%, transparent);
  font-variant-numeric: tabular-nums;
}

.row__num .roll {
  height: var(--lh);
  line-height: var(--lh);
  min-width: 2ch;
  text-align: right;
}

.row__sign {
  position: relative;
  display: grid;
  place-items: center;
  height: 100%;
}

.row__sign svg {
  width: 0.72em;
  height: 0.72em;
  fill: none;
  stroke-width: 1.4;
  stroke-linecap: round;
}

.row--del .row__sign svg {
  stroke: var(--del);
}

.row--add .row__sign svg {
  stroke: var(--add);
}

.row__code {
  position: relative;
  justify-self: start;
  white-space: pre;
  color: var(--c-text);
}

/* the thin strike through a removed line, as long as its text */
.row--del .row__code {
  opacity: 0.62;
}

.row__strike {
  position: absolute;
  left: -0.2ch;
  right: -0.2ch;
  top: 52%;
  height: 1px;
  background: color-mix(in srgb, var(--del) 75%, transparent);
  transform-origin: 0 50%;
  pointer-events: none;
}

.row--add .row__num {
  color: color-mix(in srgb, var(--add) 70%, var(--muted));
  transition: color 0.7s ease;
}

.row--add.is-merged .row__num {
  color: color-mix(in srgb, var(--muted) 80%, transparent);
}

@media (hover: hover) {
  .row:hover .row__in {
    background: rgba(255, 255, 255, 0.022);
  }
}

/* syntax colours, written by the script as small spans */
.k { color: var(--c-key); }
.f { color: var(--c-fn); }
.t { color: var(--c-type); }
.s { color: var(--c-str); }
.n { color: var(--c-num); }
.p { color: var(--c-punct); }
.pr { color: var(--c-prop); }
.cm { color: #5c6370; font-style: italic; }

/* ------------------------------------------------------------ the buttons */
.sug__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: clamp(9px, 2.2vh, 13px) clamp(12px, 3.4vw, 18px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  font-variation-settings: 'wdth' 100;
  transition: font-variation-settings 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.4s ease, color 0.4s ease, box-shadow 0.4s ease;
}

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

.btn__icon {
  width: 14px;
  height: 14px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.btn--ghost {
  gap: 6px;
  background: transparent;
  color: var(--muted);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09);
  opacity: 0;
  visibility: hidden;
}

.btn--main {
  background: var(--button);
  color: var(--button-ink);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 6px 18px -8px rgba(236, 238, 241, 0.45);
}

.btn__face {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  z-index: 1;
}

/* the tick sits at no width until the change is applied, then opens and draws itself */
.btn__tick {
  width: 0;
  margin-right: -6px;
  stroke: var(--add);
}

.btn__tick path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.btn__words {
  position: relative;
  display: inline-block;
  height: 1.3em;
  line-height: 1.3em;
  overflow: hidden;
}

.btn__words > span {
  display: block;
  white-space: nowrap;
}

.btn__words > span + span {
  position: absolute;
  inset: 0 auto auto 0;
}

.btn__shine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 46%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.85), transparent);
  opacity: 0;
  visibility: hidden;
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.btn--main.is-done {
  background: color-mix(in srgb, var(--add) 12%, transparent);
  color: var(--add);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--add) 38%, transparent), 0 6px 18px -10px color-mix(in srgb, var(--add) 60%, transparent);
  cursor: default;
}

@media (hover: hover) {
  .btn--main:not(.is-done):hover {
    font-variation-settings: 'wdth' 112;
    background: #ffffff;
  }

  .btn--ghost:hover {
    font-variation-settings: 'wdth' 112;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.05);
  }
}

@media (max-width: 420px) {
  .sug__who span {
    display: none;
  }

  .btn {
    height: 32px;
    padding: 0 12px;
    font-size: 12.5px;
  }
}
