/* ============================================================
   MINIATURE SCHOOL THAT RIDES THE SCROLL (js/school-scroll.js)
   Front page only. A small school on a rail at the right edge:
   it travels down as you scroll down and back up as you scroll
   up, leans the way it is moving, lights a window for every
   part of the page you have read, and takes you to the top
   when clicked. Decoration only — the page reads the same
   without it.
   ============================================================ */
.ss {
  position: fixed; right: clamp(8px, 1.6vw, 26px); top: 112px; bottom: 96px; width: 64px;
  z-index: 50; pointer-events: none;
}
/* the rail and how far along it you are */
.ss-rail {
  position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px;
  border-radius: 2px; background: rgba(47,91,240,.12);
}
.ss-fill {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%; border-radius: inherit;
  background: linear-gradient(180deg, #7ee3ff, #2f5bf0 60%, #8b2fd8);
  transform-origin: 50% 0; transform: scaleY(var(--p, 0));
}

/* the school itself */
.ss-car {
  position: absolute; left: 0; top: 0; width: 64px; height: 70px;
  pointer-events: auto; cursor: pointer; border: 0; padding: 0; background: none;
  transform: translate3d(0, var(--y, 0px), 0);
  will-change: transform;
}
.ss-car:focus-visible { outline: 2px solid #2f5bf0; outline-offset: 4px; border-radius: 12px; }
.ss-body {
  display: block; width: 100%; height: 100%;
  transform: rotate(var(--tilt, 0deg)) scale(var(--sq, 1), calc(2 - var(--sq, 1)));
  transform-origin: 50% 100%;
  transition: transform .5s cubic-bezier(.22,1,.36,1);
  filter: drop-shadow(0 10px 14px rgba(14,20,54,.28));
}
.ss-body svg { width: 100%; height: 100%; overflow: visible; }

/* windows light up as you read */
.ss-win { fill: #2a3570; transition: fill .45s ease; }
.ss-win.on { fill: #ffd86b; }
/* the flag never stops waving; the clock hand walks with the scroll */
.ss-flag { transform-box: fill-box; transform-origin: 0 50%; animation: ssWave 2.4s ease-in-out infinite; }
@keyframes ssWave { 0%,100% { transform: skewY(0) scaleX(1); } 50% { transform: skewY(-8deg) scaleX(.86); } }
.ss-hand { transform-box: view-box; transform-origin: 32px 19.5px; transform: rotate(var(--clock, 0deg)); }

/* a label on hover */
.ss-tip {
  position: absolute; right: calc(100% + 10px); top: 50%; transform: translateY(-50%) translateX(6px);
  white-space: nowrap; font: 700 .72rem/1 var(--sans, sans-serif); color: #f2f5ff;
  background: #0f1740; padding: 8px 11px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.ss-car:hover .ss-tip, .ss-car:focus-visible .ss-tip { opacity: 1; transform: translateY(-50%); }

/* the mobile menu (z 70) and the demo modal (z 90) cover it on their own */
.ss { transition: opacity .3s; }

/* laptops: the page's side margin is narrower, so is the school */
@media (max-width: 1320px) {
  .ss { right: 6px; width: 46px; }
  .ss-car { width: 46px; height: 50px; }
}

/* phones: smaller, tucked into the edge, faint until you scroll */
@media (max-width: 760px) {
  .ss { right: 2px; top: 100px; bottom: 84px; width: 38px; opacity: .45; }
  .ss.moving { opacity: 1; }
  .ss-car { width: 38px; height: 42px; }
  .ss-tip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ss-body { transition: none; transform: none; }
  .ss-flag { animation: none; }
}
@media print { .ss { display: none; } }
