/* ==========================================================================
   Back Pill - sticky escape hatch for deep-view pages (report / reader / games)
   Uses Brand_Guide v2.0 tokens. See Brand/02_Colors/css_variables.css.
   ========================================================================== */

.wt-back-pill {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: var(--z-sticky, 300);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px 8px 10px;
  border-radius: var(--radius-full, 9999px);
  background: var(--wt-surface, #221C26);
  color: var(--wt-text, #F0EAE0);
  font-family: var(--font-body, 'Inter', system-ui, sans-serif);
  font-size: 13px;
  font-weight: var(--weight-medium, 500);
  line-height: 1;
  text-decoration: none;
  border: 1px solid var(--wt-border, rgba(255, 255, 255, 0.06));
  box-shadow: var(--elevation-2, 0 2px 4px rgba(0, 0, 0, 0.22));
  opacity: 0.55;
  transform: translateY(0);
  transition:
    opacity var(--duration-base, 200ms) var(--ease-standard, ease),
    transform var(--duration-base, 200ms) var(--ease-standard, ease),
    background var(--duration-fast, 120ms) var(--ease-standard, ease),
    border-color var(--duration-fast, 120ms) var(--ease-standard, ease);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.wt-back-pill:hover,
.wt-back-pill:focus-visible {
  opacity: 1;
  background: var(--wt-canvas, #1A1520);
  border-color: var(--wt-border-hover, rgba(224, 122, 107, 0.2));
  color: var(--wt-rose, #E07A6B);
  outline: none;
}

.wt-back-pill:focus-visible {
  box-shadow: var(--ring-shadow, 0 0 0 2px #1A1520, 0 0 0 5px rgba(224, 122, 107, 0.55));
}

.wt-back-pill__arrow {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wt-back-pill__label {
  white-space: nowrap;
}

/* Hide on scroll-down, show on scroll-up */
.wt-back-pill--hidden {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

/* Mobile: smaller text, stays visible */
@media (max-width: 640px) {
  .wt-back-pill {
    top: 10px;
    left: 10px;
    padding: 6px 12px 6px 8px;
    font-size: 12px;
    opacity: 0.7;
  }
  .wt-back-pill__arrow {
    width: 12px;
    height: 12px;
  }
}

/* Don't compete with the Marston reader topbar */
.wt-back-pill--marston {
  top: auto;
  bottom: 18px;
  left: 18px;
}

@media (max-width: 640px) {
  .wt-back-pill--marston {
    bottom: 14px;
    left: 12px;
  }
}

/* When the 48px global-nav is present (games, etc.), sit below it so
   the nav's logo/links remain clickable. Must outrank nav z-index. */
.wt-back-pill--below-nav {
  top: 60px;
  z-index: 10500;
}

@media (max-width: 640px) {
  .wt-back-pill--below-nav {
    top: 54px;
  }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .wt-back-pill {
    transition: none;
  }
}

/* Print: hide */
@media print {
  .wt-back-pill { display: none !important; }
}
