/* Speedmaster Gonzales™ — seamless scroll layer (LOCAL DRAFT)
 *
 * 1. Smooth anchor movement across the whole page — no instant jumps.
 *    Reduced-motion users keep instant jumps (no animation).
 * 2. Scrolled-to headings clear the sticky site header.
 * 3. Floating section nav pill: fixed, bottom-center, semi-transparent,
 *    theme-aware via existing Study/Classic tokens (--panel, --line,
 *    --ink, --muted, --accent). Appears only after the hero scrolls away.
 */

/* ------------------------------------------------------------------ */
/* 1. Smooth scrolling, reduced-motion safe                            */
/* ------------------------------------------------------------------ */
html {
  scroll-behavior: smooth;
}

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

/* ------------------------------------------------------------------ */
/* 2. Keep scrolled-to headings clear of the sticky header             */
/* ------------------------------------------------------------------ */
[id$="-heading"] {
  scroll-margin-top: 84px;
}

/* ------------------------------------------------------------------ */
/* 3. Floating section nav pill                                        */
/* ------------------------------------------------------------------ */
.sg-floatnav {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom, 1rem));
  z-index: 40; /* below the sticky header (z-index 50) */
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: calc(100vw - 2rem);
  overflow-x: auto;
  padding: 6px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-solid); /* fallback: no color-mix support */
  background: color-mix(in srgb, var(--panel) 78%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  -webkit-box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  -webkit-transform: translateX(-50%) translateY(14px);
  transform: translateX(-50%) translateY(14px);
  -webkit-transition: opacity 0.32s ease, transform 0.32s ease;
  transition: opacity 0.32s ease, transform 0.32s ease;
  scrollbar-width: none; /* Firefox */
}

.sg-floatnav::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.sg-floatnav.is-visible {
  opacity: 1;
  pointer-events: auto;
  -webkit-transform: translateX(-50%) translateY(0);
  transform: translateX(-50%) translateY(0);
}

.sg-floatnav a {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 7px 12px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.sg-floatnav a:hover {
  color: var(--ink);
  background: var(--line);
}

.sg-floatnav a.is-active {
  color: var(--accent);
  background: var(--line);
}

/* Landing-computer details: a target dot marks the section the reader is
   in, and a touchdown line sweeps under a heading when a pill jump lands. */
.sg-floatnav a.is-active::before {
  content: '';
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--accent);
}

[id$="-heading"].sg-touchdown::after {
  content: '';
  display: block;
  height: 2px;
  margin-top: 8px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  animation: sg-touchdown 1.8s ease-out forwards;
}

@keyframes sg-touchdown {
  0% { transform: scaleX(0); opacity: 1; }
  30% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(1); opacity: 0; }
}

.sg-floatnav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sg-floatnav .sg-fn-top {
  font-size: 14px;
  padding: 7px 11px;
}

.sg-floatnav .sg-fn-sep {
  flex: 0 0 auto;
  width: 1px;
  align-self: stretch;
  margin: 6px 4px;
  background: var(--line);
}

@media (prefers-reduced-motion: reduce) {
  .sg-floatnav {
    -webkit-transition: none;
    transition: none;
  }
  /* No touchdown sweep for reduced-motion users: the jump is instant,
     so there is nothing to confirm. */
  [id$="-heading"].sg-touchdown::after {
    display: none;
  }
}

@media print {
  .sg-floatnav {
    display: none;
  }
}
