/* Provide one touch scrollbar and keep its touch area clear of page content. */
.jtc-page-scrollbar {
  display: none;
}

@media (max-width: 720px) {
  html.jtc-custom-scrollbar {
    scrollbar-width: none;
  }

  html.jtc-custom-scrollbar::-webkit-scrollbar {
    display: none;
  }

  /* Keep the 44px scrollbar touch area outside the content on subpages. */
  body.jtc-unified.jtc-page-scroll-inset {
    --jtc-content-inset: max(32px, calc(env(safe-area-inset-right) + 28px));
    margin-right: var(--jtc-content-inset);
  }

  body.jtc-unified.jtc-page-scroll-inset > .u-header {
    margin-right: calc(-1 * var(--jtc-content-inset));
  }

  .jtc-page-scroll-inset .to-top {
    right: max(56px, calc(env(safe-area-inset-right) + 52px));
  }

  .jtc-home main#top > :is(header, section) > :is(.wrap, .narrow, .hero-inner, .closing-copy),
  html.jtc-custom-scrollbar body:not(.jtc-page-scroll-inset) > .u-footer > .u-shell {
    width: auto;
    margin-left: var(--u-gutter);
    margin-right: max(52px, calc(env(safe-area-inset-right) + 48px));
  }

  .jtc-page-scrollbar:not([hidden]) {
    position: fixed;
    z-index: 20;
    top: max(90px, calc(env(safe-area-inset-top) + 78px));
    right: max(4px, env(safe-area-inset-right));
    bottom: max(16px, calc(env(safe-area-inset-bottom) + 8px));
    display: block;
    width: 44px;
    touch-action: none;
    user-select: none;
    cursor: ns-resize;
  }

  .jtc-page-scrollbar::before,
  .jtc-page-scroll-thumb {
    position: absolute;
    left: 50%;
    pointer-events: none;
  }

  .jtc-page-scrollbar::before {
    content: "";
    inset-block: 0;
    width: 4px;
    margin-left: -2px;
    border-radius: 4px;
    background: #c5b9a9;
  }

  .jtc-page-scroll-thumb {
    top: 0;
    width: 12px;
    height: 48px;
    margin-left: -6px;
    border-radius: 8px;
    background: var(--brand);
  }

  .jtc-page-scrollbar:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: -2px;
    border-radius: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.jtc-custom-scrollbar {
    scroll-behavior: auto;
  }
}

@media (forced-colors: active) {
  .jtc-page-scrollbar::before {
    forced-color-adjust: none;
    background: GrayText;
  }

  .jtc-page-scroll-thumb {
    forced-color-adjust: none;
    background: Highlight;
  }
}
