/* ============================================================
   INK IN WATER + SCROLL SCALE (assets/ink.js, assets/scale.js)
   Self-contained: remove the marked block in index.html to revert.
   ============================================================ */

/* The ink sits under the page (main is z-index 1); transparent where there is no ink */
.ink-bg {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100vh;
  height: 100lvh;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.6s ease;
}
.ink-bg.on { opacity: 1; }

/* Scroll scale: a small instrument, bottom-right */
.vt-scale {
  --c: #d4d4d8;
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 45;
  width: 236px;
  padding: 10px 14px 12px;
  border-radius: 12px;
  background: rgba(8, 8, 10, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.08);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
  box-shadow: 0 16px 40px -18px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
.vt-scale.on { opacity: 1; transform: none; }
.vt-scale-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 9px;
  font-family: "JetBrains Mono", "SF Mono", Menlo, monospace;
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  white-space: nowrap;
}
.vt-scale-ch { color: var(--c); transition: color 0.5s ease; overflow: hidden; text-overflow: ellipsis; }
.vt-scale-pct { color: #a7a7b1; font-variant-numeric: tabular-nums; }

.vt-scale-track { position: relative; height: 16px; }
/* minor ticks every 5px, major every 25px, drawn as a ruler along the bottom */
.vt-scale-track::before,
.vt-scale-track::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}
.vt-scale-track::before {
  height: 5px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.24) 0 1px, transparent 1px 5px);
}
.vt-scale-track::after {
  height: 9px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.42) 0 1px, transparent 1px 25px);
}
/* the scale lights up behind the needle */
.vt-scale-lit {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 9px;
  background: linear-gradient(90deg, rgba(251, 146, 60, 0.3), rgba(96, 165, 250, 0.7) 40%, rgba(167, 139, 250, 0.75) 65%, rgba(74, 222, 128, 0.75));
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 1px, transparent 1px 5px);
  mask: repeating-linear-gradient(90deg, #000 0 1px, transparent 1px 5px);
}
/* where each chapter starts */
.vt-scale-mark {
  position: absolute;
  bottom: 0;
  width: 1px;
  height: 13px;
  margin-left: -0.5px;
  background: rgba(255, 255, 255, 0.28);
  transition: background 0.5s ease, box-shadow 0.5s ease;
}
.vt-scale-mark.on { background: var(--c); box-shadow: 0 0 6px var(--c); }
/* the glowing needle */
.vt-scale-needle {
  position: absolute;
  left: 0;
  bottom: -3px;
  width: 2px;
  height: 22px;
  margin-left: -1px;
  border-radius: 1px;
  background: #fff;
  box-shadow: 0 0 6px var(--c), 0 0 14px var(--c), 0 0 26px color-mix(in srgb, var(--c) 55%, transparent);
  will-change: transform;
  transition: box-shadow 0.5s ease;
}
.vt-scale-needle i {
  position: absolute;
  left: 50%;
  bottom: -3px;
  width: 7px;
  height: 7px;
  margin-left: -3.5px;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--c), transparent);
  opacity: 0.9;
}

@media (max-width: 760px) {
  .vt-scale { right: 12px; bottom: 12px; width: 168px; padding: 8px 11px 10px; border-radius: 10px; }
  .vt-scale-head { font-size: 8.5px; letter-spacing: 0.16em; margin-bottom: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  .ink-bg, .vt-scale { transition: none; }
}
