/* Tubelight Navbar: a vanilla port of ayushmxxn's "Tubelight Navbar" on 21st.dev (MIT).
   A pill of nav items; the active item wears a "lamp": a 32x4 bar in the primary colour above it,
   three blurred glow blobs, and a 5% primary wash behind the item. The lamp springs between items
   (framer-motion layoutId, spring stiffness 300 / damping 30), driven from tubelight-nav.js.
   Fixed at the bottom on phones (< 640px) and at the top from 640px; icons only below 768px, labels from 768px.
   Every value below is the original's compiled Tailwind value.

   Theme tokens (set them on the nav, or pass options to mountTubelight; unset = the original's shadcn values):
     --fx-tube-primary / --fx-tube-primary-dark   active and hover text, and the lamp. Original: hsl(240 5.9% 10%) / hsl(0 0% 98%)
     --fx-tube-lamp / --fx-tube-lamp-dark         the lamp only (bar, glow, wash). Default: the primary
     --fx-tube-bg / --fx-tube-bg-dark             the pill fill, used at 5%. Original: #fff / hsl(240 10% 3.9%)
     --fx-tube-border / --fx-tube-border-dark     the pill's 1px border. Original: hsl(240 5.9% 90%) / hsl(240 3.7% 15.9%)
     --fx-tube-muted / --fx-tube-muted-dark       the active item's fill. Original: hsl(240 4.8% 95.9%) / hsl(240 5.9% 10%)
     --fx-tube-fg / --fx-tube-fg-dark             item text, used at 80%. Original: hsl(240 10% 3.9%) / hsl(240 4.8% 95.9%)
   data-fx-tone="dark" | "light" on the nav pins one tuning whatever the page theme (e.g. over a dark hero). */

.fx-tube {
  --_primary: var(--fx-tube-primary, hsl(240 5.9% 10%));
  --_lamp: var(--fx-tube-lamp, var(--_primary));
  --_bg: var(--fx-tube-bg, hsl(0 0% 100%));
  --_border: var(--fx-tube-border, hsl(240 5.9% 90%));
  --_muted: var(--fx-tube-muted, hsl(240 4.8% 95.9%));
  --_fg: var(--fx-tube-fg, hsl(240 10% 3.9%));
}

/* Dark: explicit data-theme="dark", or the system preference when the page is not pinned to light; or a pinned dark tone. */
:root[data-theme="dark"] .fx-tube:not([data-fx-tone="light"]),
.fx-tube[data-fx-tone="dark"] {
  --_primary: var(--fx-tube-primary-dark, hsl(0 0% 98%));
  --_lamp: var(--fx-tube-lamp-dark, var(--_primary));
  --_bg: var(--fx-tube-bg-dark, hsl(240 10% 3.9%));
  --_border: var(--fx-tube-border-dark, hsl(240 3.7% 15.9%));
  --_muted: var(--fx-tube-muted-dark, hsl(240 5.9% 10%));
  --_fg: var(--fx-tube-fg-dark, hsl(240 4.8% 95.9%));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .fx-tube:not([data-fx-tone="light"]) {
    --_primary: var(--fx-tube-primary-dark, hsl(0 0% 98%));
    --_lamp: var(--fx-tube-lamp-dark, var(--_primary));
    --_bg: var(--fx-tube-bg-dark, hsl(240 10% 3.9%));
    --_border: var(--fx-tube-border-dark, hsl(240 3.7% 15.9%));
    --_muted: var(--fx-tube-muted-dark, hsl(240 5.9% 10%));
    --_fg: var(--fx-tube-fg-dark, hsl(240 4.8% 95.9%));
  }
}

/* The wrapper: fixed bottom-0 sm:top-0 left-1/2 -translate-x-1/2 z-50 mb-6 sm:pt-6.
   (From 640px the original keeps bottom:0 as well, which stretches an invisible full-height column over the
   page that swallows clicks; bottom:auto here gives the same picture without that.) */
.fx-tube--fixed {
  position: fixed;
  bottom: 0;
  left: 50%;
  z-index: 50;
  margin: 0 0 1.5rem;
  transform: translateX(-50%);
}
@media (min-width: 52rem) { /* Orism: 640px in the original; our bottom bar runs to 52rem (6 Nov) */
  .fx-tube--fixed {
    top: 0;
    bottom: auto;
    padding-top: 1.5rem;
  }
}

/* The pill: flex items-center gap-3 bg-background/5 border border-border backdrop-blur-lg py-1 px-1 rounded-full shadow-lg.
   backdrop-filter also makes it the stacking context the lamp's z-index:-10 resolves in, as in the original. */
.fx-tube__pill {
  display: flex;
  align-items: center;
  gap: .75rem;
  box-sizing: border-box;
  margin: 0;
  padding: .25rem;
  border: 1px solid var(--_border);
  border-radius: 9999px;
  background-color: color-mix(in srgb, var(--_bg) 5%, transparent);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);
}

/* An item: relative cursor-pointer text-sm font-semibold px-6 py-2 rounded-full transition-colors text-foreground/80 hover:text-primary.
   Links and buttons share the look; the button reset keeps an action (e.g. search) identical to a link. */
.fx-tube__item {
  position: relative;
  display: block;
  box-sizing: border-box;
  margin: 0;
  padding: .5rem 1.5rem;
  border: 0;
  border-radius: 9999px;
  background-color: transparent;
  color: color-mix(in srgb, var(--_fg) 80%, transparent);
  font: inherit;
  font-size: .875rem;
  line-height: 1.25rem;
  font-weight: 600;
  letter-spacing: inherit;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
  transition-timing-function: cubic-bezier(.4, 0, .2, 1);
  transition-duration: .15s;
}
.fx-tube__item:hover {
  color: var(--_primary);
}
/* Active: bg-muted text-primary. */
.fx-tube__item.is-active {
  background-color: var(--_muted);
  color: var(--_primary);
}
/* Keyboard focus (the original has none): a 2px ring in the primary colour, following the pill shape. */
.fx-tube__item:focus {
  outline: none;
}
.fx-tube__item:focus-visible {
  outline: 2px solid var(--_primary);
  outline-offset: 2px;
}

/* Labels from 768px (hidden md:inline), icons below (md:hidden). Below 768px the label stays for screen readers. */
.fx-tube__label {
  display: inline;
}
.fx-tube__icon {
  display: none;
}
.fx-tube__icon svg {
  display: block; /* Tailwind preflight: svg { display: block } */
  width: 18px;
  height: 18px;
}
@media (max-width: 767.98px) {
  .fx-tube__item.has-icon .fx-tube__icon {
    display: inline;
  }
  .fx-tube__item.has-icon .fx-tube__label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
}

/* The lamp: absolute inset-0 w-full bg-primary/5 rounded-full -z-10. JS moves it into the active item and springs it. */
.fx-tube__lamp {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  border-radius: 9999px;
  background-color: color-mix(in srgb, var(--_lamp) 5%, transparent);
  z-index: -10;
  pointer-events: none;
}
/* The tube: absolute -top-2 left-1/2 -translate-x-1/2 w-8 h-1 bg-primary rounded-t-full. */
.fx-tube__bar {
  position: absolute;
  top: -.5rem;
  left: 50%;
  display: block;
  width: 2rem;
  height: .25rem;
  border-top-left-radius: 9999px;
  border-top-right-radius: 9999px;
  background-color: var(--_lamp);
  transform: translateX(-50%);
}
/* The glow: three bg-primary/20 rounded-full blobs, all centred on the tube so they read the same mirrored. */
.fx-tube__glow {
  position: absolute;
  display: block;
  border-radius: 9999px;
  background-color: color-mix(in srgb, var(--_lamp) 20%, transparent);
}
.fx-tube__glow--a { /* w-12 h-6 blur-md -top-2 -left-2 */
  top: -.5rem;
  left: -.5rem;
  width: 3rem;
  height: 1.5rem;
  filter: blur(12px);
}
.fx-tube__glow--b { /* w-8 h-6 blur-md -top-1 */
  top: -.25rem;
  inset-inline-start: 0;
  width: 2rem;
  height: 1.5rem;
  filter: blur(12px);
}
.fx-tube__glow--c { /* w-4 h-4 blur-sm top-0 left-2 */
  top: 0;
  left: .5rem;
  width: 1rem;
  height: 1rem;
  filter: blur(4px);
}

/* Reduced motion: the lamp jumps to the new item (JS skips the spring) and the colour fades are dropped. */
@media (prefers-reduced-motion: reduce) {
  .fx-tube__item {
    transition: none;
  }
}
