/* PillNav CSS */
/* Ensure navbar is always visible at bottom */
html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* Force navbar to be visible */
body {
  position: relative;
  padding-bottom: 0; /* No bottom padding; navbar anchors to visible viewport bottom via JS */
}

/* Keep navbar visible on mobile */
@media (max-width: 768px) {
  .pill-nav-container {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    left: 0 !important;
    right: 0 !important;
  }
}

/* Ensure navbar is always at bottom */
.pill-nav-container {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  top: auto !important;
  z-index: 9999 !important;
  display: flex !important;
  justify-content: center;
  /* Only horizontal padding so the bar sits flush to the bottom */
  padding: 0 0.5rem;
  /* Remove safe-area bottom so it sits flush at viewport bottom */
  padding-bottom: 0;
  pointer-events: none;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.1), transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transform: translateY(0) !important;
  /* Avoid any transition on bottom that could lag when browser UI toggles */
  width: 100% !important;
  max-width: 100% !important;
}

@media (max-width: 768px) {
  .pill-nav-container {
    padding: 0 0.5rem;
    padding-bottom: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.15), transparent);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
  }
}

@media (max-width: 640px) {
  .pill-nav-container {
    padding: 0 0.25rem;
    padding-bottom: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.2), transparent);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
  }
}

.pill-nav {
  --nav-h: 42px;
  --logo: 36px;
  --pill-pad-x: 18px;
  --pill-gap: 3px;
  width: max-content;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  padding: 3px;
  pointer-events: auto;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 
              0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

@media (max-width: 768px) {
  .pill-nav {
    width: 100%;
    justify-content: space-between;
    padding: 3px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.2);
  }
}

@media (max-width: 640px) {
  .pill-nav {
    --nav-h: 38px;
    --logo: 32px;
    --pill-pad-x: 14px;
    --pill-gap: 2px;
    padding: 2px;
  }
}

@media (max-width: 480px) {
  .pill-nav {
    --nav-h: 36px;
    --logo: 28px;
    --pill-pad-x: 12px;
    --pill-gap: 1px;
  }
}

@media (max-width: 375px) {
  .pill-nav {
    --nav-h: 34px;
    --logo: 26px;
    --pill-pad-x: 10px;
    --pill-gap: 0px;
  }
}

@media (max-width: 320px) {
  .pill-nav {
    --nav-h: 32px;
    --logo: 24px;
    --pill-pad-x: 8px;
    --pill-gap: 0px;
  }
}

.pill-nav-items {
  position: relative;
  display: flex;
  align-items: center;
  height: var(--nav-h);
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.pill-nav-items::-webkit-scrollbar { display: none; }

.pill-logo { width: 40px; height: 40px; border-radius: 50%; background: #000; padding: 0; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; margin-right: 12px; text-decoration: none; transition: transform 0.2s ease; }

.pill-logo:hover {
  transform: scale(1.05);
}

.pill-logo img { width: 100%; height: 100%; object-fit: contain; display: block; border-radius: 50%; background:#000; }
/* remove text fallback */
.pill-logo .logo-text { display: none !important; }

.pill-logo .logo-text { display: none; }

.pill-list {
  list-style: none;
  display: flex;
  align-items: stretch;
  flex-wrap: nowrap;
  gap: var(--pill-gap);
  margin: 0;
  padding: 0;
  height: 100%;
}

.pill-list > li {
  display: flex;
  height: 100%;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  flex: 0 0 auto;
  padding: 0 var(--pill-pad-x);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text, #f3f6fb);
  text-decoration: none;
  border-radius: 9999px;
  box-sizing: border-box;
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  white-space: nowrap;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line, rgba(255, 255, 255, 0.1));
}

.pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line, rgba(255, 255, 255, 0.2));
}

.pill .hover-circle {
  position: absolute;
  left: 50%;
  bottom: 0;
  border-radius: 50%;
  background: var(--accent, #22d3ee);
  z-index: 1;
  display: block;
  pointer-events: none;
  will-change: transform;
  opacity: 0;
  transform: scale(0) translateX(-50%);
  transition: all 0.3s ease;
}

.pill:hover .hover-circle {
  opacity: 1;
  transform: scale(1) translateX(-50%);
}

.pill .label-stack {
  position: relative;
  display: inline-block;
  line-height: 1;
  z-index: 2;
}

.pill .pill-label {
  position: relative;
  z-index: 2;
  display: inline-block;
  line-height: 1;
  will-change: transform;
  transition: all 0.3s ease;
}

.pill .pill-label-hover {
  position: absolute;
  left: 0;
  top: 0;
  color: var(--accent-contrast, #03151a);
  z-index: 3;
  display: inline-block;
  will-change: transform, opacity;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
}

.pill:hover .pill-label {
  transform: translateY(-20px);
  opacity: 0;
}

.pill:hover .pill-label-hover {
  opacity: 1;
  transform: translateY(0);
}

.pill.is-active {
  background: var(--accent, #22d3ee);
  color: var(--accent-contrast, #03151a);
  border-color: transparent;
  font-weight: 800;
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.3);
}

.pill.is-active::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  background: var(--accent-contrast, #03151a);
  border-radius: 50px;
  z-index: 4;
}

.desktop-only {
  display: block;
}

.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: block;
  }
}

.mobile-menu-button {
  width: var(--nav-h);
  height: var(--nav-h);
  border-radius: 50%;
  background: var(--base, #000);
  border: none;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: all 0.3s ease;
}

.mobile-menu-button:hover {
  transform: scale(1.05);
}

/* mobile hamburger removed */

.hamburger-line {
  width: 16px;
  height: 2px;
  background: var(--pill-bg, #fff);
  border-radius: 1px;
  transition: all 0.3s ease;
  transform-origin: center;
}

.mobile-menu-button.active .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(3px, 3px);
}

.mobile-menu-button.active .hamburger-line:nth-child(2) {
  transform: rotate(-45deg) translate(3px, -3px);
}

.mobile-menu-popover {
  position: absolute;
  bottom: 3em; /* Changed from top to bottom for navbar at bottom */
  left: 1rem;
  right: 1rem;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 27px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  opacity: 0;
  transform: translateY(10px) scale(0.95); /* Changed direction for bottom navbar */
  visibility: hidden;
  transition: all 0.3s ease;
  display: none; /* Hide by default */
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  pointer-events: auto !important;
}

@media (max-width: 768px) {
  .mobile-menu-popover {
    display: block !important; /* Show on mobile */
    left: 0.5rem;
    right: 0.5rem;
    bottom: 2.5em;
    border-radius: 20px;
  }
  
  .mobile-menu-popover.show {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
  }
}

@media (max-width: 480px) {
  .mobile-menu-popover {
    left: 0.25rem;
    right: 0.25rem;
    bottom: 2em;
    border-radius: 16px;
  }
}

@media (max-width: 375px) {
  .mobile-menu-popover {
    left: 0.125rem;
    right: 0.125rem;
    bottom: 1.5em;
    border-radius: 12px;
  }
}

@media (max-width: 320px) {
  .mobile-menu-popover {
    left: 0.0625rem;
    right: 0.0625rem;
    bottom: 1.25em;
    border-radius: 10px;
  }
}

.mobile-menu-popover.show {
  opacity: 1 !important;
  transform: translateY(0) scale(1) !important;
  visibility: visible !important;
  display: block !important;
  pointer-events: auto !important;
}

.mobile-menu-list {
  list-style: none;
  margin: 0;
  padding: 3px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mobile-menu-popover .mobile-menu-link {
  display: block;
  padding: 12px 16px;
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.1);
  text-decoration: none;
  font-size: 16px;
  font-weight: 500;
  border-radius: 50px;
  transition: all 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.mobile-menu-popover .mobile-menu-link:hover {
  cursor: pointer;
  background-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  transform: translateX(4px);
  border-color: rgba(255, 255, 255, 0.3);
}

.mobile-menu-popover .mobile-menu-link.is-active {
  background-color: rgba(34, 211, 238, 0.3);
  color: #ffffff;
  border-color: rgba(34, 211, 238, 0.5);
}

/* Touch/click feedback */
.mobile-menu-popover .mobile-menu-link:active {
  transform: scale(0.95);
  background-color: rgba(255, 255, 255, 0.3);
}

/* Touch feedback for mobile */
@media (max-width: 768px) {
  .mobile-menu-popover .mobile-menu-link:active {
    transform: scale(0.95);
    background-color: rgba(255, 255, 255, 0.3);
    transition: all 0.1s ease;
  }
  
  .mobile-menu-popover .mobile-menu-link:focus {
    outline: 2px solid rgba(34, 211, 238, 0.5);
    outline-offset: 2px;
  }
}

/* Ensure links are clickable on mobile */
@media (max-width: 768px) {
  .mobile-menu-popover {
    pointer-events: auto !important;
    touch-action: manipulation;
  }
  
  .mobile-menu-popover .mobile-menu-link {
    pointer-events: auto !important;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
    min-height: 44px; /* Apple's recommended minimum touch target */
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Animation keyframes */
@keyframes pillHover {
  0% {
    transform: scale(0) translateX(-50%);
    opacity: 0;
  }
  100% {
    transform: scale(1) translateX(-50%);
    opacity: 1;
  }
}

@keyframes labelSlideUp {
  0% {
    transform: translateY(0);
    opacity: 1;
  }
  100% {
    transform: translateY(-20px);
    opacity: 0;
  }
}

@keyframes labelSlideDown {
  0% {
    transform: translateY(20px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Ultra small screens - ensure navbar is always visible */
@media (max-width: 240px) {
  .pill-nav-container {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 9999 !important;
    padding: 0.125rem;
    margin: 0 !important;
    transform: translateY(0) !important;
  }
}

/* Ensure navbar stays visible on mobile */
@media (max-width: 768px) {
  .pill-nav-container,
  .pill-nav,
  .pill-nav-items,
  .pill-logo,
  .pill-list {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
  /* Fixed nav height spacing for content; no safe-area to keep nav flush */
  body { padding-bottom: 0 !important; }
}
