/* =====================================================================
   Shared themed scrollbars. Self-contained: link it on its own, ideally
   BEFORE the page's own stylesheet so apps that deliberately hide or
   restyle a scrollbar (scrollbar-width:none, html::-webkit-scrollbar)
   still win. Colours come from the girlypop tokens in style.css
   (light: --pink/--hot/--rim, dark: --dark-rim/--dark-pink).

   Theme follows the same switch as style.css: data-theme on <html>
   (localStorage "surya-theme"), and the system preference only when the
   page has not been forced to light.

   Two mechanisms, deliberately not stacked: Chromium 121+ ignores
   ::-webkit-scrollbar as soon as scrollbar-color is set, which would
   lose the pill thumb and hover state. So ::-webkit-scrollbar styles
   Chromium/Safari, and scrollbar-color/-width is applied only where the
   webkit pseudo-element is unsupported (Firefox).
   ===================================================================== */
:root {
  --sb-thumb: #EFA3C2;        /* between --pink #F7C3D8 and --hot #FF7FA8 */
  --sb-thumb-hover: #FF7FA8;  /* --hot */
  --sb-thumb-active: #5E4763; /* --rim */
  --sb-track: rgba(94, 71, 99, 0.07);
  --sb-size: 12px;
}

:root[data-theme="dark"] {
  --sb-thumb: #7A6699;        /* --dark-rim */
  --sb-thumb-hover: #9A84BD;
  --sb-thumb-active: #C97FA6; /* --dark-pink */
  --sb-track: rgba(23, 17, 34, 0.55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sb-thumb: #7A6699;
    --sb-thumb-hover: #9A84BD;
    --sb-thumb-active: #C97FA6;
    --sb-track: rgba(23, 17, 34, 0.55);
  }
}

/* Chromium + Safari: pill thumb with an inset (transparent) border. */
*::-webkit-scrollbar {
  width: var(--sb-size);
  height: var(--sb-size);
  background: transparent;
}
*::-webkit-scrollbar-track {
  background: var(--sb-track);
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb {
  background-color: var(--sb-thumb);
  background-clip: padding-box;
  border: 3px solid transparent;
  border-radius: 999px;
  min-height: 36px;
  min-width: 36px;
}
*::-webkit-scrollbar-thumb:hover  { background-color: var(--sb-thumb-hover); }
*::-webkit-scrollbar-thumb:active { background-color: var(--sb-thumb-active); }
*::-webkit-scrollbar-corner { background: transparent; }

/* Firefox (and anything else without the webkit pseudo-element). */
@supports not selector(::-webkit-scrollbar) {
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--sb-thumb) var(--sb-track);
  }
}
