/* The changes tree with the ticks that run down the folders: the source control panel of an invented editor on a black
   page. Every row of the tree is built by script.js from its list of files; the folders' children sit in a group with
   its own guide line, and a single pill under the rows follows the hand on a spring. */
:root {
  --page: #000000;          /* the page */
  --panel: #0e0f13;         /* the body of the panel */
  --panel-top: #16171d;     /* the top of the panel, where the light falls */
  --edge: rgba(255, 255, 255, 0.075); /* the edge of the panel */
  --ink: #ecedf2;           /* the words */
  --muted: #7d8193;         /* the small words */
  --faint: #4a4e5c;         /* the words of a row not ticked */
  --guide: rgba(255, 255, 255, 0.08); /* the guide lines */
  --accent: #8f8cff;        /* the ticks, the lit guide line, the button */
  --accent-2: #6a7bff;      /* the other end of the button's light */
  --add: #5fd39a;           /* lines added, files added */
  --del: #f07a86;           /* lines taken away */
  --mod: #e7b866;           /* files modified */
  --folder: #8b91a5;        /* the folders */
  --row: clamp(23px, 6.1vh, 31px); /* the height of a row */
}

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

/* ---------------------------------------------------------------- the panel */
.panel {
  position: relative;
  width: min(92vw, 404px);
  border-radius: 16px;
  background: linear-gradient(180deg, var(--panel-top), var(--panel) 34%);
  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 24px 48px -20px rgba(0, 0, 0, 0.9),
    0 40px 90px -40px color-mix(in srgb, var(--accent) 22%, transparent);
  opacity: 0;
}

/* a soft light behind the top edge, the colour of the ticks */
.panel__glow {
  position: absolute;
  left: 14%;
  right: 14%;
  top: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 70%, #ffffff), transparent);
  opacity: 0.55;
  pointer-events: none;
}

.panel__glow::after {
  content: '';
  position: absolute;
  left: 10%;
  right: 10%;
  top: 0;
  height: 40px;
  background: radial-gradient(60% 100% at 50% 0%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%);
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: clamp(36px, 10vh, 46px);
  padding: 0 14px 0 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.panel__title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.panel__mark {
  width: 15px;
  height: 15px;
  flex: none;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.3;
  stroke-linecap: round;
}

.panel__name {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  font-variation-settings: 'wdth' 104;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.panel__branch {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.panel__branch-name {
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: 10.5px;
  color: var(--muted);
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel__count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  color: var(--page);
  background: var(--ink);
}

/* ---------------------------------------------------------------- the numbers that roll */
.roll {
  display: inline-grid;
  overflow: hidden;
  vertical-align: top;
}

.roll > span {
  grid-area: 1 / 1;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- the tree */
.tree {
  position: relative;
  padding: 6px 6px 8px;
}

.tree__pill {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 0;
  height: var(--row);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.04));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  opacity: 0;
  pointer-events: none;
  transform-origin: 50% 50%;
}

.tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree__root {
  position: relative;
}

.item {
  position: relative;
}

.row {
  --depth: 0;
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--row);
  padding: 0 10px 0 calc(8px + var(--depth) * 14px);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.row__chev {
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.row__chev svg {
  width: 10px;
  height: 10px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.row__chev:focus-visible,
.box:focus-visible {
  outline: 1.5px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.row__spacer {
  width: 14px;
  flex: none;
}

/* the three state tick box */
.box {
  position: relative;
  display: block;
  width: 14px;
  height: 14px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  box-shadow: inset 0 0 0 1.25px rgba(255, 255, 255, 0.2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
  .box:hover {
    box-shadow: inset 0 0 0 1.25px rgba(255, 255, 255, 0.38);
  }
}

.box__fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 80%, #ffffff), var(--accent));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 1px 3px color-mix(in srgb, var(--accent) 45%, transparent);
  transform: scale(0);
}

.box__ring {
  position: absolute;
  inset: -3px;
  border-radius: 6px;
  box-shadow: 0 0 0 1.5px var(--accent);
  opacity: 0;
  pointer-events: none;
}

.box svg {
  position: absolute;
  inset: 0;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: #0b0b12;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.box__tick,
.box__dash {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.row__icon {
  width: 15px;
  height: 15px;
  flex: none;
  overflow: visible;
}

.row__name {
  min-width: 0;
  flex: 1 1 auto;
  font-size: 12.5px;
  font-weight: 480;
  font-variation-settings: 'wdth' 100;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.3s ease;
}

.item.is-folder > .row .row__name {
  font-weight: 560;
}

.item.is-on > .row .row__name {
  color: var(--ink);
}

.item.is-part > .row .row__name {
  color: color-mix(in srgb, var(--ink) 72%, var(--faint));
}

.row__diff {
  display: flex;
  gap: 5px;
  flex: none;
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  opacity: 0.55;
  transition: opacity 0.3s ease;
}

.item.is-on > .row .row__diff {
  opacity: 1;
}

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

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

.row__badge {
  width: 12px;
  flex: none;
  text-align: right;
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 700;
}

.row__badge.is-m {
  color: var(--mod);
}

.row__badge.is-a {
  color: var(--add);
}

/* the folder: its back and its lid, the lid leans back when the folder is open */
.row__icon .f-back {
  fill: color-mix(in srgb, var(--folder) 26%, transparent);
  stroke: var(--folder);
  stroke-width: 1.1;
  stroke-linejoin: round;
}

.row__icon .f-lid {
  fill: color-mix(in srgb, var(--folder) 40%, var(--panel));
  stroke: var(--folder);
  stroke-width: 1.1;
  stroke-linejoin: round;
  transform-box: fill-box;
  transform-origin: 50% 100%;
}

.row__icon .p-page {
  fill: rgba(255, 255, 255, 0.03);
  stroke: #9aa0b4;
  stroke-width: 1.05;
  stroke-linejoin: round;
}

.row__icon .p-fold {
  fill: none;
  stroke: #9aa0b4;
  stroke-width: 1.05;
  stroke-linejoin: round;
}

.row__icon .p-mark {
  fill: none;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.row__icon .p-tag {
  stroke: none;
}

/* the group of a folder's children and its guide line */
.group {
  position: relative;
  overflow: hidden;
}

.group.is-shut {
  display: none;
}

.guide,
.guide__lit {
  position: absolute;
  top: 1px;
  bottom: 5px;
  width: 1px;
  transform-origin: 50% 0%;
  pointer-events: none;
}

.guide {
  background: var(--guide);
}

.guide__lit {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 30%, transparent), var(--accent) 40%, color-mix(in srgb, var(--accent) 60%, #ffffff));
  box-shadow: 0 0 6px color-mix(in srgb, var(--accent) 60%, transparent);
  transform: scaleY(0);
  opacity: 0;
}

/* ---------------------------------------------------------------- the foot: the message and the button */
.panel__foot {
  display: grid;
  gap: clamp(6px, 1.8vh, 8px);
  padding: clamp(8px, 2.4vh, 12px) 12px clamp(10px, 2.8vh, 14px);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.msg {
  position: relative;
  display: flex;
  align-items: center;
  height: clamp(28px, 7.6vh, 34px);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  transition: box-shadow 0.25s ease;
}

.msg:focus-within {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 70%, transparent), 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.msg__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 0 10px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  outline: none;
}

.msg__keys {
  display: flex;
  gap: 2px;
  margin-right: 8px;
  flex: none;
}

.msg__keys svg {
  width: 16px;
  height: 16px;
  padding: 2px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.commit {
  position: relative;
  display: block;
  width: 100%;
  height: clamp(32px, 8.6vh, 38px);
  padding: 0;
  border: 0;
  border-radius: 10px;
  color: #ffffff;
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #ffffff), var(--accent-2));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2),
    0 6px 18px -8px color-mix(in srgb, var(--accent) 80%, transparent);
  -webkit-tap-highlight-color: transparent;
  transition: filter 0.35s ease;
}

.commit.is-empty {
  filter: grayscale(1) brightness(0.45);
  cursor: default;
}

.commit.is-done {
  filter: none;
  cursor: default;
  background: linear-gradient(180deg, color-mix(in srgb, var(--add) 70%, #ffffff), color-mix(in srgb, var(--add) 80%, #0b3b26));
  color: #062616;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -1px 0 rgba(0, 0, 0, 0.15),
    0 6px 18px -8px color-mix(in srgb, var(--add) 80%, transparent);
}

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

/* a sheen that crosses the button on hover */
.commit::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -40%;
  width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  transform: translateX(-100%);
  pointer-events: none;
}

@media (hover: hover) {
  .commit:not(.is-empty):hover::before {
    transform: translateX(380%);
    transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  }
}

.commit__run {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 34%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #ffffff, transparent);
  opacity: 0;
  pointer-events: none;
}

.commit__face {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 14px;
}

.commit__label {
  font-size: 13px;
  font-weight: 620;
  font-variation-settings: 'wdth' 104;
}

.commit__label svg {
  width: 13px;
  height: 13px;
  margin-right: 6px;
  vertical-align: -2px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.commit__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  font-weight: 520;
  color: rgba(255, 255, 255, 0.82);
  font-variant-numeric: tabular-nums;
}

.commit__diff {
  display: flex;
  gap: 5px;
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
}

.commit__diff .is-add {
  color: #b8f5d4;
}

.commit__diff .is-del {
  color: #ffc4ca;
}

/* ---------------------------------------------------------------- the pilot's hand */
.hand {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  margin: -3px 0 0 -5px;
  fill: #f4f4f7;
  stroke: #0b0b10;
  stroke-width: 1.3;
  stroke-linejoin: round;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.5));
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}

@media (max-width: 380px) {
  .panel__branch-name {
    max-width: 104px;
  }
}
