/* Scroll guide - see scroll-guide.js.
   The ruler lives in one fixed layer under the nav bar (z-index 90 < nav's 100),
   so it never covers the menu. */

.sg-layer {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0;
  transition: opacity .6s ease .2s;
}
.sg-ready .sg-layer { opacity: 1; }

/* Frosted strip behind the ruler so ticks stay readable over any content. */
.sg-rail-bg {
  position: fixed;
  top: var(--sg-top, 58px);
  right: 0;
  bottom: 0;
  width: var(--sg-w, 30px);
  background: rgba(237, 241, 247, .45);
  background: color-mix(in srgb, var(--bg) 45%, transparent);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
  -webkit-mask-image: linear-gradient(to left, #000 45%, rgba(0,0,0,.35) 75%, transparent 100%);
  mask-image: linear-gradient(to left, #000 45%, rgba(0,0,0,.35) 75%, transparent 100%);
}

/* The ruler itself. Hover/drag only for a mouse - on touch the page scrolls as usual. */
.sg-rail {
  position: fixed;
  top: var(--sg-top, 58px);
  right: 0;
  bottom: 0;
  width: var(--sg-w, 30px);
  pointer-events: none;
}
.sg-rail canvas { display: block; }
@media (hover: hover) and (pointer: fine) {
  .sg-rail { pointer-events: auto; cursor: crosshair; touch-action: none; }
}

/* Percentage tag that follows the marker. */
.sg-chip {
  position: fixed;
  top: 0;
  right: calc(var(--sg-w, 30px) + 4px);
  min-width: 38px;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: 700 11px/18px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  text-align: center;
  direction: ltr;
  box-shadow: 0 2px 8px rgba(30, 58, 127, .28);
  transition: opacity .35s ease;
  will-change: transform;
}
.sg-chip.is-idle { opacity: .6; }
.sg-chip-hover {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0 6px;
  opacity: 0;
}

/* Section titles: each letter is its own box so it can fly on its own.
   While a title is in flight it sits above the page content so later
   sections can't cover the letters. */
.sg-word { display: inline-block; white-space: nowrap; }
.sg-ch { display: inline-block; will-change: transform; }
.sg-split.sg-flying { position: relative; z-index: 80; }
.sg-flying .sg-ch { text-shadow: 0 0 3px var(--bg), 0 0 8px var(--bg); }

/* The yellow underline draws itself in right after the letters. */
.sg-split.section-title::after {
  transform: scaleX(0);
  transition: transform .6s cubic-bezier(.2, .9, .25, 1) .45s;
}
.sg-split.section-title.is-in::after { transform: scaleX(1); }

@media (prefers-reduced-motion: reduce) {
  .sg-layer, .sg-chip { transition: none; }
}
@media print { .sg-layer { display: none; } }
