/* ── BWR scrollbar — one style for every scrollable box of the site ──────────
 *
 * Linked right after tokens.css on every page (and the worker-rendered
 * /balade/ + /r/ pages), so it reaches the page itself, side panels, popups,
 * the planner drawer, modals, lists… with no per-component rule.
 *
 * The idea: a slim sage "trail" that floats in its lane, and lights up
 * forest-green → lime (the site's two brand colours) when the mouse is on it,
 * like a path you are about to take.
 *
 * Only for a mouse/trackpad (hover + fine pointer). Phones and tablets keep
 * their own thin bar that appears while scrolling and fades away: a fixed bar
 * would eat screen width and be too thin for a finger anyway.
 *
 * Two engines:
 *   - Chrome, Edge, Safari, Opera → the ::-webkit-scrollbar pieces below.
 *   - Firefox → the standard scrollbar-color / scrollbar-width (a plain
 *     colour, Firefox can't draw a gradient or a hover state there).
 * Chrome ≥ 121 ignores the ::-webkit-scrollbar pieces on any element that has
 * scrollbar-color or scrollbar-width set, so the standard properties are only
 * given to browsers WITHOUT ::-webkit-scrollbar. Keep it that way, and don't
 * put "scrollbar-width: thin" on a component: it would bring back the grey
 * browser bar there. "scrollbar-width: none" (hidden bar on a tab strip) is
 * fine.
 * ────────────────────────────────────────────────────────────────────────── */

:root {
  --sb-size:        12px;
  --sb-thumb:       #b4cca6;   /* sage, between --forest-300 and --border-strong */
  --sb-thumb-hover: linear-gradient(180deg, var(--forest-500), var(--lime-600));
  --sb-thumb-hover-x: linear-gradient(90deg, var(--forest-500), var(--lime-600));
  --sb-thumb-active: var(--forest-600);
  --sb-track:       transparent;
  --sb-track-hover: rgba(45, 107, 31, 0.07);   /* --forest-600, very light */
}

:root[data-theme="dark"] {
  --sb-thumb:       #4d6b55;   /* just above --border-strong, clear on every dark surface */
  --sb-thumb-hover: linear-gradient(180deg, var(--lime-600), var(--lime-500));
  --sb-thumb-hover-x: linear-gradient(90deg, var(--lime-600), var(--lime-500));
  --sb-thumb-active: var(--lime-400);
  --sb-track-hover: rgba(163, 230, 53, 0.06);  /* --lime-500, very light */
}

@media (hover: hover) and (pointer: fine) {

  /* Firefox (no ::-webkit-scrollbar) */
  @supports not selector(::-webkit-scrollbar) {
    * {
      scrollbar-width: thin;
      scrollbar-color: var(--sb-thumb) transparent;
    }
  }

  /* Chrome, Edge, Safari */
  ::-webkit-scrollbar {
    width: var(--sb-size);
    height: var(--sb-size);
    background: var(--sb-track);
  }
  ::-webkit-scrollbar-track {
    background: var(--sb-track);
    border-radius: var(--radius-pill);
  }
  ::-webkit-scrollbar-track:hover {
    background: var(--sb-track-hover);
  }

  /* The thumb is drawn 6 px wide inside a 12 px lane (the transparent border
     is the gap), then fills out to 8 px when pointed at. */
  ::-webkit-scrollbar-thumb {
    background: var(--sb-thumb);
    background-clip: padding-box;
    border: 3px solid transparent;
    border-radius: var(--radius-pill);
    min-height: 40px;
    min-width: 40px;
  }
  ::-webkit-scrollbar-thumb:vertical:hover {
    background: var(--sb-thumb-hover);
    background-clip: padding-box;
    border-width: 2px;
  }
  ::-webkit-scrollbar-thumb:horizontal:hover {
    background: var(--sb-thumb-hover-x);
    background-clip: padding-box;
    border-width: 2px;
  }
  ::-webkit-scrollbar-thumb:active,
  ::-webkit-scrollbar-thumb:vertical:active,
  ::-webkit-scrollbar-thumb:horizontal:active {
    background: var(--sb-thumb-active);
    background-clip: padding-box;
    border-width: 2px;
  }

  ::-webkit-scrollbar-corner { background: transparent; }
  ::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
}
