/*
 * FHS responsive liquid-glass app navigation.
 * Visual treatment is adapted from CodeFronts' MIT-licensed “iOS 26 Floating Tab Bar”:
 * https://codefronts.com/navigation/css-liquid-glass-navbars/ios-26-floating-tab-bar/
 * The FHS implementation keeps the desktop app switcher in the header and floats it
 * above the bottom safe area on narrow screens.
 */

.fhs-liquid-nav,
.fhs-liquid-nav *,
.fhs-liquid-nav *::before,
.fhs-liquid-nav *::after {
  box-sizing: border-box;
}

.fhs-liquid-nav {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  margin-left: 8px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14);
  isolation: isolate;
  -webkit-overflow-scrolling: touch;
}

.fhs-liquid-nav__link {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 44px;
  min-height: 44px;
  overflow: hidden;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--ice, #CADCFC);
  font-family: "Bai Jamjuree", sans-serif;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: color .2s, background-color .25s, transform .2s;
}

.fhs-liquid-nav__icon {
  display: block;
  flex: 0 0 19px;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fhs-liquid-nav__label {
  display: block;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100px;
  overflow: hidden;
  opacity: 1;
  white-space: nowrap;
  transition: max-width .45s cubic-bezier(.34, 1.4, .5, 1), opacity .3s;
}

.fhs-liquid-nav__link:hover {
  background: rgba(255, 255, 255, .14);
  color: #fff;
}

.fhs-liquid-nav__link[aria-current="page"] {
  background: #fff;
  color: #15234A;
  box-shadow: 0 5px 16px -7px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .9);
}

.fhs-liquid-nav__link[aria-current="page"]:hover {
  background: #fff;
  color: #15234A;
}

.fhs-liquid-nav__link:active {
  transform: scale(.97);
}

.fhs-liquid-nav__link:focus-visible {
  outline: 3px solid #F4C95D;
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .fhs-has-liquid-nav {
    padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  }

  .fhs-has-liquid-nav .topbar {
    gap: 8px;
  }

  .fhs-has-liquid-nav .topbar .logo {
    min-width: 0;
  }

  .fhs-has-liquid-nav .topbar .logo > div {
    min-width: 0;
  }

  .fhs-has-liquid-nav .topbar .logo b {
    display: block;
    max-width: 44vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .fhs-has-liquid-nav .topbar .logo span {
    display: none;
  }

  .fhs-has-liquid-nav .topbar .right {
    flex-shrink: 1;
    min-width: 0;
    gap: 8px;
    white-space: nowrap;
  }

  .fhs-has-liquid-nav .topbar .right #adminName {
    max-width: 20vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .fhs-has-liquid-nav .topbar .right #logout {
    white-space: nowrap;
  }

  .fhs-liquid-nav {
    position: fixed;
    z-index: 1200;
    left: 50%;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    width: min(440px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    justify-content: space-between;
    gap: 2px;
    margin: 0;
    padding: 6px;
    transform: translateX(-50%);
    border-color: rgba(255, 255, 255, .28);
    background: rgba(21, 35, 74, .88);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .26), 0 15px 34px -16px rgba(15, 26, 46, .7);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    backdrop-filter: blur(24px) saturate(180%);
    transition: width .45s cubic-bezier(.34, 1.4, .5, 1), padding .45s cubic-bezier(.34, 1.4, .5, 1), gap .45s;
  }

  .fhs-liquid-nav__link {
    flex: 1 1 0;
    min-width: 44px;
    min-height: 44px;
    gap: 5px;
    padding: 0 5px;
    font-size: 12px;
  }

  .fhs-liquid-nav__icon {
    flex-basis: 18px;
    width: 18px;
    height: 18px;
  }

  .fhs-liquid-nav__label {
    max-width: 78px;
    font-size: 11.5px;
  }

  .fhs-liquid-nav.is-compact {
    width: min(246px, calc(100vw - 24px));
    gap: 2px;
    padding: 6px;
  }

  .fhs-liquid-nav.is-compact .fhs-liquid-nav__link {
    flex: 1 1 0;
    padding: 0 7px;
  }

  .fhs-liquid-nav.is-compact .fhs-liquid-nav__label {
    max-width: 0;
    margin: 0;
    opacity: 0;
  }

  /* Keep map attribution and Leaflet controls clear of the floating capsule. */
  .fhs-has-liquid-nav .leaflet-bottom {
    bottom: 74px;
  }
}

/* Top safe-area inset: applied once, as body padding-top, so the hazard stripe and header start
   below the status bar / notch. The header must not add it again — doing both doubled the gap
   above the header on iPhone. */
body.fhs-has-liquid-nav {
  padding-top: env(safe-area-inset-top, 0px);
}

/* Stronger overrides to counter inline page styles that reset .topbar/.wrap padding.
   Some pages include large inline <style> blocks after this file, so we use a
   higher-specificity selector plus !important. */

body.fhs-has-liquid-nav .topbar {
  padding: 14px 20px !important;
  top: env(safe-area-inset-top, 0px) !important; /* when stuck, sit just below the status bar */
}

body.fhs-has-liquid-nav .wrap {
  padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important; /* keep content above floating nav */
}

/* Ensure modals / gate boxes also clear safe areas on small screens */
body.fhs-has-liquid-nav #gate .box,
body.fhs-has-liquid-nav .modal-box {
  margin-top: calc(12px + env(safe-area-inset-top, 0px)) !important;
  margin-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
}

@media (max-width: 360px) {
  .fhs-liquid-nav__link {
    gap: 3px;
    padding-right: 2px;
    padding-left: 2px;
  }

  .fhs-liquid-nav__label {
    max-width: 38px;
    font-size: 10.5px;
  }

  .fhs-liquid-nav.is-compact {
    width: min(224px, calc(100vw - 20px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .fhs-liquid-nav,
  .fhs-liquid-nav__link,
  .fhs-liquid-nav__label {
    transition: none !important;
  }
}

@media (forced-colors: active) {
  .fhs-liquid-nav {
    border: 1px solid CanvasText;
  }

  .fhs-liquid-nav__link[aria-current="page"] {
    border: 2px solid Highlight;
  }
}
