/* Hide On Scroll: a port of ddoemonn's 21st.dev component (MIT). hide-on-scroll.js builds the tree and drives the
   springs; every size, colour and shadow below is the original's (Tailwind v4 utilities resolved to plain CSS).
   Colours are variables with a per-theme override (-l light, -d dark) that falls back to the original value:
     --fx-hos-surface-l/-d   #fff / #1D1D1A          (card, bar and the edge fades)
     --fx-hos-border-l/-d    stone-200 / white 16%   (card border and the hairline under the bar)
     --fx-hos-accent-l/-d    #4568FF / #93B0FF       (the scroll region's focus ring)
   Also here: the ddoemonn kit the demo's bar button uses (.fx-mat-cap, .fx-press, .fx-ink, .fx-ink-2). */

.fx-hos, .fx-hos-bar {
  --fx-hos-surface: var(--fx-hos-surface-l, #fff);
  --fx-hos-border: var(--fx-hos-border-l, oklch(92.3% .003 48.717));
  --fx-hos-accent: var(--fx-hos-accent-l, #4568ff);
  --fx-hos-shadow: 0 1px 2px rgba(28, 25, 23, .06), 0 4px 10px -8px rgba(28, 25, 23, .45);
}
:root[data-theme="dark"] :is(.fx-hos, .fx-hos-bar) {
  --fx-hos-surface: var(--fx-hos-surface-d, #1d1d1a);
  --fx-hos-border: var(--fx-hos-border-d, rgba(255, 255, 255, .16));
  --fx-hos-accent: var(--fx-hos-accent-d, #93b0ff);
  --fx-hos-shadow: 0 1px 6px rgba(0, 0, 0, .45);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) :is(.fx-hos, .fx-hos-bar) {
    --fx-hos-surface: var(--fx-hos-surface-d, #1d1d1a);
    --fx-hos-border: var(--fx-hos-border-d, rgba(255, 255, 255, .16));
    --fx-hos-accent: var(--fx-hos-accent-d, #93b0ff);
    --fx-hos-shadow: 0 1px 6px rgba(0, 0, 0, .45);
  }
}

/* ---- The original card: relative w-full min-w-0 overflow-hidden rounded-[14px] border border-stone-200 bg-white
   shadow-[0_1px_2px_rgba(28,25,23,0.06),0_4px_10px_-8px_rgba(28,25,23,0.45)] ---- */
.fx-hos {
  --fx-hos-bar-h: 44px;
  --fx-hos-max-h: 320px;
  position: relative;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--fx-hos-border);
  background: var(--fx-hos-surface);
  box-shadow: var(--fx-hos-shadow);
}
.fx-hos *, .fx-hos *::before, .fx-hos *::after { box-sizing: border-box; }

/* absolute inset-x-0 top-0 z-10 flex items-center gap-2 bg-white px-3, height = barHeight; slides with `translate` */
.fx-hos__bar {
  position: absolute;
  inset-inline: 0;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--fx-hos-bar-h);
  padding-inline: 12px;
  background-color: var(--fx-hos-surface);
}

/* pointer-events-none absolute inset-x-0 bottom-0 h-px bg-stone-200; opacity from the JS spring (0 at the top) */
.fx-hos__hairline {
  pointer-events: none;
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 1px;
  background-color: var(--fx-hos-border);
  opacity: 0;
}

/* overflow-y-auto overscroll-y-contain outline-none [scrollbar-gutter:stable], maxHeight, scrollPaddingTop = bar + 8 */
.fx-hos__scroll {
  max-height: var(--fx-hos-max-h);
  scroll-padding-top: calc(var(--fx-hos-bar-h) + 8px);
  overflow-y: auto;
  overscroll-behavior-y: contain;
  outline: none;
  scrollbar-gutter: stable;
}
.fx-hos__scroll:focus-visible {
  background-color: color-mix(in srgb, var(--fx-hos-accent) 6%, transparent);
  box-shadow: inset 0 0 0 1px var(--fx-hos-accent);
}
.fx-hos__spacer { height: var(--fx-hos-bar-h); }
/* pointer-events-none sticky top-0 -mb-5 h-5 bg-gradient-to-b from-white to-transparent (and the bottom twin) */
.fx-hos__fade {
  pointer-events: none;
  position: sticky;
  height: 20px;
}
.fx-hos__fade--top { top: 0; margin-bottom: -20px; background-image: linear-gradient(to bottom in oklab, var(--fx-hos-surface), transparent); }
.fx-hos__fade--bottom { bottom: 0; margin-top: -20px; background-image: linear-gradient(to top in oklab, var(--fx-hos-surface), transparent); }

/* ---- Decorating an existing bar (hideOnScroll): low specificity, so the bar's own position rules win. ---- */
:where(.fx-hos-bar) { position: relative; }
:where(.fx-hos-bar--sticky) { position: sticky; top: 0; z-index: 10; }

/* ---- ddoemonn kit used by the demo's bar button. Values from the original :root / .dark tokens. ---- */
.fx-mat-cap { background: var(--fx-panel-l, #fff); box-shadow: var(--fx-shadow-cap-l, 0 1.5px 0 #00000017, inset 0 0 0 1px #0000001c); }
.fx-press { transition: transform .12s cubic-bezier(.23, 1, .32, 1), background-color .15s; }
.fx-press:active { transform: translateY(1px); }
.fx-ink { color: var(--fx-ink-l, #131313); }
.fx-ink-2 { color: var(--fx-ink-2-l, #454545); }
:root[data-theme="dark"] .fx-mat-cap { background: var(--fx-panel-d, #1d1d1a); box-shadow: var(--fx-shadow-cap-d, 0 1.5px 0 #00000080, inset 0 0 0 1px #ffffff1a); }
:root[data-theme="dark"] .fx-ink { color: var(--fx-ink-d, #f8f8f4); }
:root[data-theme="dark"] .fx-ink-2 { color: var(--fx-ink-2-d, #c2c2ba); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .fx-mat-cap { background: var(--fx-panel-d, #1d1d1a); box-shadow: var(--fx-shadow-cap-d, 0 1.5px 0 #00000080, inset 0 0 0 1px #ffffff1a); }
  :root:not([data-theme="light"]) .fx-ink { color: var(--fx-ink-d, #f8f8f4); }
  :root:not([data-theme="light"]) .fx-ink-2 { color: var(--fx-ink-2-d, #c2c2ba); }
}
@media (prefers-reduced-motion: reduce) {
  .fx-press { transition: none; }
}
