/* Native scrollbars only: no overflow, gutter, focus or scroll-position changes.
 * Independent help/legal/popup documents keep this default Candy palette.
 * :has() (Chrome 105+) reads the existing body appearance at the ROOT, so the
 * viewport and all descendants update together, including top-layer dialogs.
 * Keep tokens here independent of component/world/board-skin palettes. */
:root {
  --scroll-track: #fff4e6;
  --scroll-track-edge: #e8bfd0;
  --scroll-thumb: #c42e70;
  --scroll-thumb-light: #fa83b1;
  --scroll-thumb-edge: #791c49;
  --scroll-thumb-hover: #dc4285;
  --scroll-thumb-active: #a82059;
  --scroll-solid: var(--scroll-thumb);
}
:root:has(body[data-theme="adventure"]) {
  --scroll-track: #fff4d8;
  --scroll-track-edge: #d2b887;
  --scroll-thumb: #d99920;
  --scroll-thumb-light: #ffe58b;
  --scroll-thumb-edge: #64380f;
  --scroll-thumb-hover: #ecb337;
  --scroll-thumb-active: #bc7b13;
  /* Standard-only bars have no dark edging: use a deeper readable gold. */
  --scroll-solid: #b07819;
}
:root:has(body[data-theme="egyptian"]) {
  --scroll-track: #f4e0b6;
  --scroll-track-edge: #bc9865;
  --scroll-thumb: #ad7328;
  --scroll-thumb-light: #efc76e;
  --scroll-thumb-edge: #54341b;
  --scroll-thumb-hover: #c08b37;
  --scroll-thumb-active: #925b20;
}
:root:has(body[data-theme="caveman"]) {
  --scroll-track: #e3deca;
  --scroll-track-edge: #a5a38b;
  --scroll-thumb: #815538;
  --scroll-thumb-light: #c59a64;
  --scroll-thumb-edge: #382d22;
  --scroll-thumb-hover: #956846;
  --scroll-thumb-active: #69432c;
}

/* Solid-color fallback for engines with only standard scrollbar support.
 * Use auto (not thin): native hit targets remain comfortable to drag. */
* {
  scrollbar-width: auto;
  scrollbar-color: var(--scroll-solid) var(--scroll-track);
}

/* Chrome 121+ honors standard colors ahead of its detailed pseudo-elements.
 * Reset BOTH properties on EVERY scroller here, not just the inherited root,
 * to retain the dimensional treatment on supported Chrome 116+ versions. */
@supports selector(::-webkit-scrollbar) {
  * { scrollbar-width: auto; scrollbar-color: auto; }
  @media (forced-colors: none) {
    *::-webkit-scrollbar {
      width: 14px;
      height: 14px;
      /* This backing is rectangular even on a rounded scroll owner. Let the
       * owner's surface show around the separately rounded track and thumb. */
      background: transparent;
    }
    *::-webkit-scrollbar-track {
      background: var(--scroll-track);
      border: 1px solid var(--scroll-track-edge);
      border-radius: 999px;
      box-shadow: inset 1px 1px 3px rgb(60 30 10 / .18);
    }
    *::-webkit-scrollbar-thumb {
      min-height: 32px;
      min-width: 32px;
      border: 2px solid var(--scroll-thumb-edge);
      border-radius: 999px;
      background-color: var(--scroll-thumb);
      background-image: linear-gradient(90deg, var(--scroll-thumb-light), transparent 65%);
      box-shadow: inset 1px 1px 0 rgb(255 255 255 / .6), inset -1px -1px 0 rgb(40 20 0 / .18);
    }
    *::-webkit-scrollbar-thumb:horizontal {
      background-image: linear-gradient(180deg, var(--scroll-thumb-light), transparent 65%);
    }
    *::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-thumb-hover); }
    *::-webkit-scrollbar-thumb:active { background-color: var(--scroll-thumb-active); }
    *::-webkit-scrollbar-corner { background: transparent; }
  }
}

/* Let the OS supply its readable native/system treatment; no decorative
 * pseudo-element rules participate, including hover/drag, in forced colors. */
@media (forced-colors: active) {
  * { scrollbar-width: auto; scrollbar-color: auto; }
}
