/* ============================================================
   BOTTOM PILL NAV
   Ported from the DormMate case-study's spring pill tab bar
   (sticky-top there → fixed-bottom).
   ============================================================ */

.bn-wrapper {
  --bn-pill-bg: rgba(0, 0, 0, 0.08);
  --bn-pill-highlight: rgba(255, 255, 255, 0.3);
  --bn-pill-border: rgba(255, 255, 255, 0.1);
  --bn-tab-color: #555;
  --bn-tab-active-color: var(--text-color-accent);

  position: fixed;
  left: 0;
  right: 0;
  /* `bottom: 20px` alone anchors to the large viewport and ignores Safari's
     dynamic toolbar, so the bar doesn't track it as the toolbar
     collapses/expands. Anchoring off `100dvh` (which does track it) and
     pulling back up by the element's own height instead keeps the same
     20px clearance while staying reactive — and, same as before, it lands
     the box well clear of the true edge/safe area rather than flush
     against it, so it doesn't trip Safari's fixed-element edge handling
     (iOS Safari's floating bottom bar seems to opaque-paint the safe strip
     when a backdrop-filter'd fixed element sits exactly at its boundary).
     24px clears the children's drop shadow (0 4px 20px) too, since a
     fixed element's box-shadow is otherwise cut off at the true viewport
     edge if there isn't enough raw clearance for it to render into. */
  top: 100dvh;
  transform: translateY(calc(-100% - 16px));
  z-index: 20;

  display: flex;
  justify-content: space-between;
  align-items: center;

  padding: 0.75rem 1.75rem 0;
  pointer-events: none;

  /* The pill is draggable; without this, a touch-drag starting on/near its
     label text triggers the browser's native text-selection/callout instead. */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.bn-group {
  position: relative;
  transition: opacity 0.2s ease;
}

.bn-group--inactive .bn-active-row .bn-tab-content {
  color: var(--bn-tab-color);
}

@media (prefers-color-scheme: dark) {
  .bn-wrapper {
    --bn-pill-bg: rgba(255, 255, 255, 0.08);
    --bn-pill-highlight: rgba(255, 255, 255, 0.08);
    --bn-pill-border: rgba(255, 255, 255, 0.06);
  }
}

.bn-tabbar {
  pointer-events: auto;
  position: relative;

  background: var(--glass-tint);
  padding: 4px;
  border-radius: var(--radius-pill);

  box-shadow:
    0 0 0 0.1px var(--glass-outline),
    var(--glass-highlight),
    0 4px 40px 0 var(--glass-shadow-color);

  backdrop-filter: blur(var(--glass-blur-sm));
  -webkit-backdrop-filter: blur(var(--glass-blur-sm));
}

/* Outside 0.5px gradient stroke — same recipe as .header-button::after
   in style.css. */
.bn-tabbar::after {
  content: "";
  position: absolute;
  inset: -0.5px;
  border-radius: inherit;
  padding: 0.5px;

  background: var(--glass-stroke-gradient);
  opacity: var(--glass-stroke-opacity);

  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;

  pointer-events: none;
}

/* Buttons live in their own layer so a pill-shaped hole can be clipped
   out of them (hiding the gray icon/label under the pill) without also
   cutting into the bar's own translucent background/blur above. */
.bn-tabbar-items {
  display: flex;
  width: 100%;
}

.bn-tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  padding: 0.625rem 1.1875rem;

  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;

  color: var(--bn-tab-color);
}

.bn-tab-item:focus-visible {
  outline: 2px solid var(--bn-tab-active-color);
  outline-offset: -4px;
  border-radius: 999px;
}

.bn-tab-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  pointer-events: none;
}

.bn-tab-content .hgi-stroke {
  font-size: var(--text-110);
  /* hgi-stroke is a single-weight monoline font (no bold cut available via
     the CDN) — faking extra weight by thickening the glyph's own stroke. */
  -webkit-text-stroke: 0.4px currentColor;
}

.bn-tab-label {
  font-size: 0.625rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;

  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Selector (active-tab pill) — flat color while at rest, no shadow,
   highlight, blur or stroke; the full glass treatment (below) only kicks
   in while it's lifted, i.e. mid tap-to-navigate or drag-to-navigate
   animation (see bottom-nav.js render(), which toggles bn-pill--lifted
   off var(scale.value)). */
.bn-pill-outer {
  pointer-events: none;
  position: absolute;
  border-radius: 999px;
  will-change: transform;
  transform-origin: center;
  transition: box-shadow 0.15s ease;
}

.bn-pill-outer.bn-pill--lifted {
  box-shadow:
    0 0 0 0.1px var(--glass-outline),
    var(--glass-highlight),
    0 4px 40px 0 var(--glass-shadow-color);
}

/* Outside 0.5px gradient stroke — same recipe as .header-button::after in
   style.css, only shown while lifted. */
.bn-pill-outer::after {
  content: "";
  position: absolute;
  inset: -0.5px;
  border-radius: inherit;
  padding: 0.5px;

  background: var(--glass-stroke-gradient);
  opacity: 0;
  transition: opacity 0.15s ease;

  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;

  pointer-events: none;
}

.bn-pill-outer.bn-pill--lifted::after {
  opacity: var(--glass-stroke-opacity);
}

.bn-pill-inner {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 999px;

  background: var(--bn-pill-bg);

  transition: backdrop-filter 0.15s ease, -webkit-backdrop-filter 0.15s ease, box-shadow 0.15s ease;
}

.bn-pill-outer.bn-pill--lifted .bn-pill-inner {
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);

  box-shadow:
    inset 0 1px 0 var(--bn-pill-highlight),
    inset 0 0 0 1px var(--bn-pill-border);
}

.bn-active-row {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;

  display: flex;
  flex-direction: row;
  align-items: center;
  will-change: transform;
}

.bn-active-row .bn-tab-content {
  color: var(--bn-tab-active-color);
}

.bn-tab-active {
  /* Matches .bn-tab-item's own padding so this duplicate hugs to the exact
     same width as the gray item it sits on top of. */
  padding: 0.625rem 1.1875rem;
}

.bn-pill-hit {
  pointer-events: auto;
  position: absolute;
  touch-action: none;
  cursor: grab;
  will-change: transform;
  transform-origin: center;
}

.bn-pill-hit:active {
  cursor: grabbing;
}

/* ---- Standalone Search button, split off from the group ---- */

.bn-search-btn {
  position: relative;

  pointer-events: auto;
  flex-shrink: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  /* Width/height are set from JS (bottom-nav.js layout()) to match the
     group tabbar's own rendered height exactly, forming a perfect circle. */
  padding: 1.1875rem;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;

  background: var(--glass-tint);
  box-shadow:
    0 0 0 0.1px var(--glass-outline),
    var(--glass-highlight),
    0 4px 40px 0 var(--glass-shadow-color);

  backdrop-filter: blur(var(--glass-blur-sm));
  -webkit-backdrop-filter: blur(var(--glass-blur-sm));

  color: var(--bn-tab-color);
  will-change: transform;
}

/* Outside 0.5px gradient stroke — true circle (equal width/height, set
   from JS), so this uses the same radial-gradient mask as
   .header-button::after in style.css, not the pill-shaped box-mask
   technique below (.bn-tabbar::after) — that one seams at the cardinal
   points on a perfect circle. */
.bn-search-btn::after {
  content: "";
  position: absolute;
  inset: -0.5px;
  border-radius: inherit;

  background: var(--glass-stroke-gradient);
  opacity: var(--glass-stroke-opacity);

  -webkit-mask-image: radial-gradient(circle closest-side, transparent calc(100% - 0.5px), #fff calc(100% - 0.5px));
  mask-image: radial-gradient(circle closest-side, transparent calc(100% - 0.5px), #fff calc(100% - 0.5px));

  pointer-events: none;
}

.bn-search-btn:focus-visible {
  outline: 2px solid var(--bn-tab-active-color);
  outline-offset: -4px;
}

.bn-search-btn-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  pointer-events: none;
}

.bn-search-btn-inner .hgi-stroke {
  font-size: var(--text-110);
  -webkit-text-stroke: 0.4px currentColor;
}

.bn-search-btn.active {
  color: var(--bn-tab-active-color);
}

.bn-search-btn.active .bn-tab-label {
  font-weight: 800;
}

/* ============================================================
   DESKTOP: vertical rail, pinned top-left
   Same markup/JS, just re-flowed onto the cross axis — bottom-nav.js
   mirrors this breakpoint via matchMedia to swap its x/y math.
   ============================================================ */
@media (min-width: 600px) {
  .bn-wrapper {
    top: calc(var(--header-height, 80px) + 20px);
    left: 20px;
    right: auto;
    bottom: auto;
    transform: none;

    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 1rem;

    padding: 0;
  }

  .bn-tabbar-items {
    flex-direction: column;
  }

  .bn-tab-item,
  .bn-tab-active {
    /* Swapped from the mobile 0.625rem/1.1875rem pair, and bumped a touch
       for the larger icon/label below. */
    padding: 1.25rem 0.75rem;
  }

  .bn-tab-content .hgi-stroke {
    font-size: var(--text-125);
  }

  .bn-tab-label {
    font-size: var(--text-75);
  }

  .bn-active-row {
    bottom: auto;
    right: 0;
    flex-direction: column;
  }

  .bn-search-btn {
    padding: 1rem;
  }

  .bn-search-btn-inner .hgi-stroke {
    font-size: var(--text-125);
  }
}
