/* Back-to-top arrow + expandable category list, shared across designs.
   Each page maps --qn-* from its own palette in :root. */

.qn-sentinel {
  position: absolute;
  top: 0; left: 0;
  width: 1px; height: 90vh;
  pointer-events: none;
}

.qn {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 220ms cubic-bezier(0.16, 1, 0.3, 1), transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.qn.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.qn-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--qn-bg, oklch(18% 0.008 260 / 0.92));
  color: var(--qn-ink, oklch(90% 0.006 260));
  border: 1px solid var(--qn-rule, oklch(30% 0.008 260));
  cursor: pointer;
  padding: 0;
  transition: border-color 120ms cubic-bezier(0.16, 1, 0.3, 1);
}
.qn-btn:hover { border-color: var(--qn-accent, oklch(70% 0.13 45)); }
.qn-btn:active { transform: translateY(1px); }
.qn-btn:focus-visible {
  outline: 2px solid var(--qn-accent, oklch(70% 0.13 45));
  outline-offset: 2px;
}

.qn-list {
  display: grid;
  background: var(--qn-bg, oklch(18% 0.008 260 / 0.92));
  border: 1px solid var(--qn-rule, oklch(30% 0.008 260));
  min-width: 10rem;
}
/* the hidden attribute must beat the display rule above */
.qn-list[hidden] { display: none; }
.qn-item {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--qn-rule, oklch(30% 0.008 260));
  color: var(--qn-ink, oklch(90% 0.006 260));
  font: inherit;
  font-size: var(--qn-font-size, 0.875rem);
  text-align: right;
  text-decoration: none;
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}
.qn-item:last-child { border-bottom: 0; }
.qn-item:hover { color: var(--qn-accent, oklch(70% 0.13 45)); }
.qn-item:focus-visible {
  outline: 2px solid var(--qn-accent, oklch(70% 0.13 45));
  outline-offset: -2px;
}

/* variant flag: category list only where the page menu is not always visible */
@media (min-width: 60rem) {
  .qn--cats-mobile .qn-toggle,
  .qn--cats-mobile .qn-list { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .qn, .qn-btn { transition: none; }
}
