/*
 * ng-totop.css - Site-wide "scroll to top" button.
 *
 * Markup is printed once per page in wp_footer (wp-content/mu-plugins/nomadgear-assets.php):
 *   <button type="button" id="ng-totop" class="ng-totop" aria-label="Scroll to top">...</button>
 *
 * Styled in the Port of Entry system (nomadgear/port-of-entry.css): square
 * corners, 2px solid var(--ink) border, var(--card) fill, mono glyph size,
 * same ink-fill hover as .btn-ink. The focus ring uses var(--green), matching
 * the site's existing green focus convention (#search:focus, .news-form
 * input:focus both border-color:var(--green) on keyboard/pointer focus).
 *
 * ng-totop.js toggles .is-visible after the reader scrolls roughly one
 * viewport down, and hides again near the top. Also force-hidden while the
 * mobile menu sheet is open (body.menu-open, port-of-entry.css) since that
 * opaque sheet already covers this corner.
 */

.ng-totop {
  position: fixed;
  right: var(--pad, 20px);
  bottom: var(--pad, 20px);
  z-index: 900; /* below .site-head (980) and .menu-overlay (950); paper grain (2000) is pointer-events:none */
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card, #FBFAF7);
  color: var(--ink, #1A1A17);
  border: 2px solid var(--ink, #1A1A17);
  border-radius: 0;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition:
    opacity .25s ease,
    transform .25s ease,
    visibility 0s linear .25s,
    background-color .25s ease,
    color .25s ease;
}

.ng-totop.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition:
    opacity .25s ease,
    transform .25s ease,
    visibility 0s linear 0s,
    background-color .25s ease,
    color .25s ease;
}

.ng-totop:hover {
  background: var(--ink, #1A1A17);
  color: var(--card, #FBFAF7);
}

.ng-totop:active {
  transform: scale(.92);
}

.ng-totop:focus-visible {
  outline: 2px solid var(--green, #2E7D5B);
  outline-offset: 3px;
}

.ng-totop svg {
  width: 20px;
  height: 20px;
  display: block;
  pointer-events: none;
}

/* The mobile menu sheet (port-of-entry.css .menu-overlay) already owns this
   corner while open; keep the button out of the tab order too, not just
   visually covered. */
body.menu-open .ng-totop {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

@media (max-width: 640px) {
  .ng-totop {
    width: 42px;
    height: 42px;
    right: 16px;
    bottom: 16px;
  }

  .ng-totop svg {
    width: 18px;
    height: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ng-totop {
    transition: opacity .01ms linear, visibility 0s linear;
    transform: none;
  }

  .ng-totop.is-visible {
    transition: opacity .01ms linear, visibility 0s linear;
  }
}
