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

.bn-wrapper {
  --bn-bar-bg: rgba(255, 255, 255, 0.8);
  --bn-bar-outline: rgba(255, 255, 255, 0.25);
  --bn-bar-shadow: rgba(0, 0, 0, 0.25);
  --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;
  /* Deliberately float clear of the safe area, not just flush against it —
     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. */
  bottom: 20px;
  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-bar-bg: rgba(0, 0, 0, 0.8);
    --bn-bar-outline: rgba(0, 0, 0, 0.25);
    --bn-bar-shadow: rgba(0, 0, 0, 0.45);
    --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(--bn-bar-bg);
  padding: 4px;
  border-radius: 999px;

  box-shadow:
    0 0 0 1px var(--bn-bar-outline),
    0 4px 20px 0 var(--bn-bar-shadow);

  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* 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: 1.125rem;
  /* 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;
}

.bn-pill-outer {
  pointer-events: none;
  position: absolute;
  border-radius: 999px;
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.12);
  will-change: transform;
  transform-origin: center;
}

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

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

  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 {
  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: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;

  background: var(--bn-bar-bg);
  box-shadow:
    0 0 0 1px var(--bn-bar-outline),
    0 4px 20px 0 var(--bn-bar-shadow);

  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);

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

.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: 1.125rem;
  -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;

    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: 1.3rem;
  }

  .bn-tab-label {
    font-size: 0.75rem;
  }

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

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

  .bn-search-btn-inner .hgi-stroke {
    font-size: 1.3rem;
  }
}
