/* Page ruler: the page in miniature down the right edge, a labelled mark per section, a sky window for what's on
   screen with a % readout, and a pop-up naming the section you're in, in the app's colours.
   Desktop with a mouse only; touch screens keep the normal scrollbar.
   Loaded in <head> so the space and the hidden scrollbar are there from the first paint (nothing shifts).
   Drawn by assets/js/ruler.js from [data-ruler-label] elements. */
#pageRuler, #rulerPopup { display: none; }
@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
  html { scrollbar-width: none; }
  html::-webkit-scrollbar { width: 0; height: 0; }
  body { padding-right: 60px; }   /* keep content clear of the ruler */
  #pageRuler { display: block; position: fixed; right: 0; bottom: 0; width: 60px; z-index: 40; cursor: crosshair; user-select: none; touch-action: none;
    background: color-mix(in srgb, #020617 55%, transparent); -webkit-backdrop-filter: blur(9px); backdrop-filter: blur(9px);
    border-left: 1px solid rgb(148 163 184 / 0.1);
    -webkit-mask-image: linear-gradient(to left, #000 85%, transparent); mask-image: linear-gradient(to left, #000 85%, transparent); }
  #pageRuler .ruler-marks, #pageRuler .ruler-view { position: absolute; inset: 0; }
  #pageRuler .tick { position: absolute; right: 0; height: 1px; width: 7px; background: rgb(100 116 139 / 0.45); }
  #pageRuler .tick.major { width: 14px; background: #94a3b8; }
  #pageRuler .label { position: absolute; right: 17px; transform: translateY(-50%); font: 600 10px/1 var(--sans); color: #94a3b8; white-space: nowrap; }
  #pageRuler .label.on { color: var(--accent); }
  #pageRuler .readout { position: absolute; right: 15px; transform: translateY(4px);   /* just under the line, so it shows at the very top too */
    font: 700 10px/1 var(--mono); color: var(--accent); font-variant-numeric: tabular-nums; background: var(--bg); padding: 2px 3px; border-radius: 4px; z-index: 1; }
  #pageRuler .window { position: absolute; right: 0; width: 100%; border-top: 2px solid var(--accent); background: linear-gradient(to left, rgb(56 189 248 / 0.14), transparent 85%); pointer-events: none; }

  /* the section you're in pops up beside the ruler when you reach it, then fades */
  #rulerPopup { display: block; position: fixed; right: 76px; z-index: 41; pointer-events: none; text-align: right; max-width: 24rem; padding: 10px 14px; border-radius: 14px;
    isolation: isolate; opacity: 0; transform: translateY(-6px); }
  /* a frosted slate box behind the text that fades out on every side (lighter than the page, so it shows on
     Thyrion's near-black background) */
  #rulerPopup::before { content: ""; position: absolute; inset: -22px -14px -22px -90px; z-index: -1;
    background: radial-gradient(ellipse 70% 90% at 100% 50%, rgb(56 189 248 / 0.2), rgb(6 182 212 / 0.06) 60%, transparent 85%), rgb(12 26 46 / 0.9);   /* sky glow from the ruler side */
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    -webkit-mask-image: linear-gradient(to right, transparent, #000 40%, #000 88%, transparent), linear-gradient(to bottom, transparent, #000 28%, #000 72%, transparent);
    -webkit-mask-composite: source-in;
    mask-image: linear-gradient(to right, transparent, #000 40%, #000 88%, transparent), linear-gradient(to bottom, transparent, #000 28%, #000 72%, transparent);
    mask-composite: intersect; }
  #rulerPopup.show { opacity: 1; transform: none; }
  #rulerPopup .near { font: 400 11px/1.6 var(--mono); text-transform: lowercase; color: #64748b; }
  #rulerPopup .near::before { content: "# "; color: #475569; }
  #rulerPopup .now { font: 700 15px/1.2 var(--sans); letter-spacing: -0.01em; color: var(--text-strong); margin: 2px 0; }
  #rulerPopup .sub { font: 600 11.5px/1.35 var(--sans); color: var(--accent); margin-bottom: 4px; }
}
@media (min-width: 1024px) and (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  #rulerPopup { transition: opacity .25s ease, transform .25s ease; }
}

/* Where the browser supports scroll-driven animation, CSS moves the window and the % readout as you scroll;
   the script only sets --ruler-travel (how far the window can move) when the page size changes. */
@property --ruler-pct { syntax: '<integer>'; inherits: false; initial-value: 0; }
@keyframes ruler-travel { from { translate: 0 0; --ruler-pct: 0; } to { translate: 0 var(--ruler-travel, 0px); --ruler-pct: 100; } }
@supports (animation-timeline: scroll()) {
  @media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
    #pageRuler.css-driven .window, #pageRuler.css-driven .readout { top: 0; animation: ruler-travel linear both; animation-timeline: scroll(root block); }
    #pageRuler.css-driven .readout { counter-reset: ruler-pct var(--ruler-pct); }
    #pageRuler.css-driven .readout::after { content: counter(ruler-pct) "%"; }
  }
}
