/* ==========================================================================
   APP SHELL & VIEWPORT (PWA-specific, no Bootstrap equivalent)
   ========================================================================== */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  /* Navigation tap effect color */
  --nav-ripple-color: rgba(var(--bs-light-rgb), 0.4);
}

/* Prevent double-tap zoom on touch devices */
html {
  touch-action: manipulation;
}

/* Disable tap highlight on iOS */
* {
  -webkit-tap-highlight-color: transparent;
}

/* Disable text selection on UI elements (content remains selectable) */
.btn,
.bottom-nav-wrapper,
.bottom-nav-pill,
.bottom-nav-item,
.navbar,
.nav-link,
.offcanvas-header,
.offcanvas-body,
.list-group-item {
  -webkit-user-select: none;
  user-select: none;
}

/* Disable Safari long-press context menu on nav items */
.bottom-nav-item,
.bottom-nav-item * {
  -webkit-touch-callout: none;
}

/* ==========================================================================
   MOBILE: App shell with fixed bottom nav, scrolling main (< 900px)
   ========================================================================== */

@media (max-width: 899.98px) {
  html {
    margin: 0;
  }

  body {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    margin: 0;
    overflow: hidden;
    position: fixed;
    width: 100%;
  }

  main {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding: var(--safe-top) var(--safe-right) calc(72px + var(--safe-bottom)) var(--safe-left);
  }

  .card {
    border: none;
  }
}

/* ==========================================================================
   MOBILE LANDSCAPE: Body scroll for Safari UI collapse (< 900px landscape)
   ========================================================================== */

@media (max-width: 899.98px) and (orientation: landscape) {
  html {
    height: auto;
  }

  body {
    display: block;
    height: auto;
    overflow: auto;
    position: static;
    padding-bottom: calc(64px + var(--safe-bottom));
  }

  main {
    overflow: visible;
    min-height: auto;
    padding: 0 var(--safe-right) 0 var(--safe-left);
  }

  /* Landscape: More compact pill */
  .bottom-nav-pill {
    max-width: 480px;
    /* height: 48px; */
  }

  .bottom-nav-icon i {
    font-size: 1rem;
  }

  .bottom-nav-label {
    font-size: 0.5625rem;
  }
}

/* ==========================================================================
   DESKTOP: Traditional page scroll (>= 900px)
   ========================================================================== */

@media (min-width: 900px) {
  html, body {
    height: auto;
    overflow: auto;
  }

  body {
    display: block;
    padding: 0;
  }

  main {
    overflow: visible;
    padding: 2rem 0;
  }
}

/* ==========================================================================
   OFFCANVAS: Bottom sheet with rounded corners
   ========================================================================== */

.offcanvas.offcanvas-bottom {
  display: flex;
  flex-direction: column;
  height: auto;
  max-height: 95vh;
  max-height: 95dvh;
  overflow: hidden;
  border-radius: 1rem 1rem 0 0;
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.offcanvas.offcanvas-bottom .offcanvas-header {
  flex-shrink: 0;
}

.offcanvas.offcanvas-bottom .offcanvas-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* ==========================================================================
   PILL-STYLE BOTTOM NAVIGATION
   Modern floating navigation bar for mobile
   ========================================================================== */

/* Wrapper: Handles positioning and safe area */
.bottom-nav-wrapper {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1030;
  padding: 0.5rem;
  padding-bottom: calc(0.5rem + var(--safe-bottom));
  padding-left: calc(1rem + var(--safe-left));
  padding-right: calc(1rem + var(--safe-right));
  pointer-events: none;
}

/* Pill container: The floating navigation bar */
.bottom-nav-pill {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-around;
  /* height: 56px; */
  max-width: 400px;
  margin: 0 auto;
  /* padding: 0 0.5rem;*/
  backdrop-filter: blur(25px) saturate(15%);
  border-radius: 2rem;
  border: 1px solid rgba(var(--bs-light-rgb), 0.1);
  pointer-events: auto;
  /* Transition for returning to normal state (not for tap-in) */
  transition: transform 0.2s ease-out, background-color 0.2s ease-out;
}

/* Nav bar enlarges and brightens on tap - instant response */
.bottom-nav-pill:has(.bottom-nav-item:active),
.bottom-nav-pill:has(.bottom-nav-item.touching) {
  transform: scale(1.05);
  background-color: rgba(var(--bs-light-rgb), 0.15);
  transition: transform 0s, background-color 0s;
}

/* Fallback for browsers without backdrop-filter support */
@supports not (backdrop-filter: blur(25px)) {
  .bottom-nav-pill {
    background: var(--bs-dark);
  }
}

/* Navigation item base styles */
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  padding: 0.375rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--bs-body-color);
  text-decoration: none;
  font-size: 1.3rem;
  font-weight: 500;
  transition: color 0.2s ease, transform 0.15s ease;
  border-radius: 2rem;
  min-width: 0;
  cursor: pointer;
  /* For ripple effect positioning */
  position: relative;
  overflow: visible;
}

/* Expanding border/ripple effect */
.bottom-nav-item::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 2rem;
  border: 2px solid var(--nav-ripple-color);
  opacity: 0;
  transform: scale(0.8);
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
  pointer-events: none;
}

.bottom-nav-item:active::after,
.bottom-nav-item.touching::after {
  opacity: 1;
  transform: scale(1.4);
  transition: transform 0s, opacity 0s;
}

/* Icon container */
.bottom-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 1.5rem;
  border-radius: 2rem;
  transition: background-color 0.2s ease;
}

.bottom-nav-icon i {
  font-size: 1.3rem;
}

/* Label */
.bottom-nav-label {
  line-height: 1;
  white-space: nowrap;
  font-size: 0.7rem;
}

/* Hover state */
.bottom-nav-item:hover {
  color: var(--bs-body-color);
}

/* Active item: Highlighted bubble effect */
.bottom-nav-item.active {
  color: var(--bs-primary-text-emphasis);
  background-color: rgba(var(--bs-secondary-rgb), 0.15);
  margin: 0.1rem 0.1rem 0.1rem 0.1rem;
}

/* Focus state for accessibility */
.bottom-nav-item:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

/* Touch feedback */
.bottom-nav-item:active {
  transform: scale(0.92);
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .bottom-nav-item,
  .bottom-nav-icon,
  .bottom-nav-item::after,
  .bottom-nav-pill {
    transition: none;
  }
  .bottom-nav-item:active {
    transform: none;
  }
  .bottom-nav-item:active::after {
    opacity: 0;
  }
  .bottom-nav-pill:has(.bottom-nav-item:active) {
    transform: none;
  }
}

/* ==========================================================================
   FLOATING MESSAGES
   Toast-style alerts that float over content
   ========================================================================== */

.messages-container {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1050;
  width: 100%;
  max-width: 600px;
  padding: 1rem;
  padding-top: calc(1rem + var(--safe-top, 0px));
  pointer-events: none;
}

.messages-container .alert {
  pointer-events: auto;
  box-shadow: var(--bs-box-shadow);
  margin-bottom: 0.5rem;
}

/* On desktop, position below the navbar */
@media (min-width: 900px) {
  .messages-container {
    top: 70px;
    padding-top: 1rem;
  }
}
