/* TFD custom desktop scroll rail. Original mark is the ONLY visible scroll thumb. */
@media screen and (min-width: 1024px) {
  /* Keep the native bar as fallback until JavaScript attaches the replacement. */
  html.tfdp-scrollbar-ready {scrollbar-width:none;}
  html.tfdp-scrollbar-ready::-webkit-scrollbar {width:0;height:0;display:none;}

  /* Disable the old flying/following capsule on desktop only. Mobile unchanged. */
  .scroll-brand,
  .brand-flight,
  .brand-flight.is-flying {display:none !important;}

  .tfd-scrollrail {
    position:fixed; z-index:105;
    right:10px;top:96px;bottom:22px;
    width:58px;
    padding:0;
    border:0; background:transparent;
    touch-action:none; user-select:none; -webkit-user-select:none;
    cursor:pointer;
  }
  .tfd-scrollrail[hidden] {display:none !important;}
  .tfd-scrollrail::before {
    content:'';position:absolute;
    width:2px;top:20px;bottom:20px;left:calc(50% - 1px);
    border-radius:10px;background:#dbe4e8;
    opacity:.70;
    pointer-events:none;
  }
  .tfd-scrollrail-progress {
    position:absolute;
    top:20px;left:calc(50% - 1px);width:2px;
    height:var(--tfd-rail-progress,0px);
    max-height:calc(100% - 40px);
    background:#b9975d;border-radius:10px;
    pointer-events:none;
  }
  .tfd-scrollrail-thumb {
    position:absolute;top:0;left:0;
    display:grid;place-items:center;
    width:58px;height:58px;
    padding:9px;
    border:1px solid #e7dfd3;
    border-radius:19px;
    background:rgba(255,255,255,.98);
    box-shadow:0 4px 16px rgba(26,49,67,.10);
    transform:translate3d(0,var(--tfd-thumb-y,0px),0);
    will-change:transform;
    touch-action:none;
    cursor:grab;
    transition:background .2s ease,border-color .2s ease,box-shadow .2s ease;
  }
  /* Refined TFD gold tracery: follows the same scroll-linked rotation as the original logo. */
  .tfd-scrollrail-thumb::before {
    content:'';position:absolute;inset:-2px;border-radius:21px;
    border:1.5px solid rgba(185,151,93,.8);
    box-shadow:0 0 0 3px rgba(185,151,93,.065);
    pointer-events:none;
  }
  .tfd-scrollrail-thumb::after {
    content:'';position:absolute;inset:-4px;border-radius:23px;
    border:2px solid transparent;
    border-top-color:#bd945a;border-right-color:#e1c18a;
    opacity:.75;pointer-events:none;
    transition:opacity .25s ease;
    animation:tfd-scroll-gold-orbit 8s linear infinite;
  }
  /* The holder responds to scroll direction; the symbol gently spins independently. */
  .tfd-scrollrail-logo-rotator {
    display:grid;place-items:center;flex:none;
    width:38px;height:38px;
    transform:rotate(var(--tfd-thumb-rotation,0deg));
    transform-origin:center;
    transition:transform .18s linear;
    pointer-events:none;
  }
  .tfd-scrollrail:is(:hover,:focus-visible) .tfd-scrollrail-thumb::after {opacity:1;}
  .tfd-scrollrail-logo-rotator img {
    width:38px;height:38px;display:block;object-fit:contain;
    transform-origin:center;
    pointer-events:none;
    /* Deliberate, visible continuous spin like TFD's original animated badge. */
    animation:tfd-scroll-logo-spin 4.8s linear infinite;
  }
  @keyframes tfd-scroll-logo-spin {from{transform:rotate(0deg)}to{transform:rotate(360deg)}}
  @keyframes tfd-scroll-gold-orbit {from{transform:rotate(0deg)}to{transform:rotate(360deg)}}
  .tfd-scrollrail:hover .tfd-scrollrail-thumb,
  .tfd-scrollrail:focus-visible .tfd-scrollrail-thumb {
    border-color:#b9975d;background:#fff;
    box-shadow:0 6px 19px rgba(26,49,67,.16);
  }
  .tfd-scrollrail.is-dragging .tfd-scrollrail-thumb {cursor:grabbing;transition:none;}
  .tfd-scrollrail:focus-visible {outline:2px solid #82bfe1;outline-offset:3px;border-radius:20px;}
}
/* Honor the app's existing animation preference. The app explicitly sets
   data-tfd-motion="on", so browser reduced-motion should not silently disable
   ONLY the desktop scrollbar while the rest of the TFD icon animations work.
   When the app mode is off (or no preference is supplied and OS requests reduced
   motion), we stop both the badge and its decorative gold orbit. */
@media (prefers-reduced-motion:reduce) {
  html:not([data-tfd-motion="on"]) .tfd-scrollrail-thumb,
  html:not([data-tfd-motion="on"]) .tfd-scrollrail-logo-rotator {transition:none!important;}
  html:not([data-tfd-motion="on"]) .tfd-scrollrail-thumb::after,
  html:not([data-tfd-motion="on"]) .tfd-scrollrail-logo-rotator img {animation:none!important;transform:none!important;}
}
html[data-tfd-motion="off"] .tfd-scrollrail-thumb::after,
html[data-tfd-motion="off"] .tfd-scrollrail-logo-rotator img {animation:none!important;transform:none!important;}
