/* Custom scrollbar (lab/scrollbar.js), on the portfolio and the examples.
   The browser's bar is hidden once the custom one is in place (so without JavaScript the normal bar
   stays). A thin line on the right, a thumb, and (on the portfolio) a mark per section with its name
   on hover. Its colors and position can be set per page: the examples set them for light and dark,
   and start the bar below their own top bar (work/example.css). */
:root {
  --sb-top: 0px;
  --sb-z: 55;
  --sb-line: #1e1e21;
  --sb-thumb: #c7c7ca;
  --sb-thumb-strong: #ededee;
  --sb-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

.has-scrollbar {
  scrollbar-width: none;
}

.has-scrollbar::-webkit-scrollbar {
  display: none;
}

.scrollbar {
  position: fixed;
  top: var(--sb-top);
  right: 0;
  bottom: 0;
  z-index: var(--sb-z);
  width: 16px;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.4s var(--sb-ease);
}

/* the line */
.scrollbar::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  right: 7px;
  width: 1px;
  background: var(--sb-line);
}

.scrollbar:hover,
.scrollbar.is-active,
.scrollbar.is-dragging {
  opacity: 1;
}

.scrollbar-thumb {
  touch-action: none; /* a finger drag moves the thumb instead of panning the page */
  position: absolute;
  top: 0;
  right: 6px;
  width: 3px;
  border-radius: 2px;
  background: var(--sb-thumb);
  cursor: grab;
  will-change: transform;
  transition: width 0.25s var(--sb-ease), right 0.25s var(--sb-ease), background 0.25s var(--sb-ease);
}

.scrollbar:hover .scrollbar-thumb,
.scrollbar.is-dragging .scrollbar-thumb {
  right: 5px;
  width: 5px;
  background: var(--sb-thumb-strong);
}

.scrollbar.is-dragging .scrollbar-thumb {
  cursor: grabbing;
}

/* section marks: a short tick on the line; the name slides in beside it on hover */
.scrollbar-mark {
  display: block;
  position: absolute;
  right: 4px;
  width: 7px;
  height: 9px;
  margin-top: -4px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.scrollbar-mark::before {
  content: "";
  position: absolute;
  top: 4px;
  right: 0;
  width: 7px;
  height: 1px;
  background: var(--subtle);
  transition: background 0.25s var(--ease), width 0.25s var(--ease);
}

.scrollbar-mark::after {
  content: attr(data-label);
  position: absolute;
  top: 50%;
  right: 16px;
  padding: 3px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(17, 17, 19, 0.94);
  color: var(--text-soft);
  font-family: inherit;
  font-size: 0.72rem;
  white-space: nowrap;
  opacity: 0;
  transform: translate(4px, -50%);
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.35s var(--ease-out);
}

.scrollbar:hover .scrollbar-mark::before {
  background: var(--muted);
}

.scrollbar-mark:hover::before {
  width: 11px;
  background: var(--text);
}

.scrollbar-mark:hover::after {
  opacity: 1;
  transform: translate(0, -50%);
}

/* Hidden while the welcome animation covers the page */
.js.is-welcoming .scrollbar {
  visibility: hidden;
  opacity: 0;
}

/* Touch screens: no hover, so it only shows while the page moves */
@media (hover: none) {
  .scrollbar {
    opacity: 0;
  }

  .scrollbar.is-active,
  .scrollbar.is-dragging {
    opacity: 0.8;
  }
}

