/* =========================================================
   FS FLOATING BOTTOM NAVIGATION
========================================================= */

:root {
  --FS-nav-height: 84px;
  --FS-nav-bottom: 24px;
  --FS-nav-gap: 8px;
}

/* =========================================================
   CONTENT PROTECTION
   Fixed navigation does not occupy document space, so the
   application needs enough bottom room for the final content.
========================================================= */

#FS-app {
  padding-bottom: calc(
    var(--FS-nav-height) +
    var(--FS-nav-bottom) +
    32px +
    env(safe-area-inset-bottom)
  );
}

/* =========================================================
   NAVIGATION MOUNT
========================================================= */

#FS-navigation {
  position: fixed;
  left: 50%;
  bottom: max(
    var(--FS-nav-bottom),
    env(safe-area-inset-bottom)
  );
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 40px);
  margin: 0;
  padding: 0;
  z-index: 9999;
  display: block;
  pointer-events: none;
}

/* =========================================================
   MAIN NAVIGATION ISLAND
========================================================= */

.FS-bottom-nav {
  display: flex;
  align-items: stretch;
  justify-content: center;
  width: max-content;
  min-width: 420px;
  max-width: calc(100vw - 40px);
  min-height: var(--FS-nav-height);
  padding: var(--FS-nav-gap);
  box-sizing: border-box;
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--border-light, rgba(0,0,0,0.08));
  border-radius: 24px;
  box-shadow:
    0 12px 35px rgba(23,49,29,0.14),
    0 4px 12px rgba(0,0,0,0.08);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  pointer-events: auto;
}

/* =========================================================
   NAVIGATION BUTTONS
========================================================= */

.FS-bottom-nav button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 82px;
  min-width: 82px;
  min-height: 66px;
  margin: 0;
  padding: 8px 10px;
  box-sizing: border-box;
  border: 0;
  border-radius: 17px;
  background: transparent;
  color: var(--text-muted, #66736d);
  font-family: var(--font-body, system-ui, sans-serif);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--transition-fast, 180ms ease),
    color var(--transition-fast, 180ms ease),
    transform var(--transition-fast, 180ms ease);
}

/* =========================================================
   NAV ICON
========================================================= */

.FS-bottom-nav .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
}

.FS-bottom-nav .nav-icon img {
  display: block;
  width: 23px;
  height: 23px;
  max-width: 23px;
  max-height: 23px;
  object-fit: contain;
}

/* =========================================================
   NAV LABEL
========================================================= */

.FS-bottom-nav .nav-label {
  display: block;
  color: currentColor;
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* =========================================================
   ACTIVE PAGE
   Uses a longer pill-shaped highlight instead of a dot.
========================================================= */


.FS-bottom-nav button.active .nav-label {
  font-weight: 700;
}

/* Longer active-page pill */
.FS-bottom-nav button.active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 30px;
  height: 4px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--accent, #c99a3d);
}

/* =========================================================
   ADD DESTINATION BUTTON
========================================================= */

.FS-bottom-nav button[data-route="/add"] {
  color: var(--secondary, #8b6425);
}

.FS-bottom-nav button[data-route="/add"] .nav-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  padding: 5px;
  box-sizing: border-box;
  border-radius: 50%;
  background: var(--secondary, #8b6425);
  box-shadow: var(--shadow-sm, 0 2px 6px rgba(0,0,0,0.12));
  transition:
    background-color var(--transition-fast, 180ms ease),
    transform var(--transition-fast, 180ms ease),
    box-shadow var(--transition-fast, 180ms ease);
}

.FS-bottom-nav button[data-route="/add"] .nav-icon img {
  width: 100%;
  height: 100%;
  max-width: 18px;
  max-height: 18px;
  object-fit: contain;
}

.FS-bottom-nav button[data-route="/add"] .nav-label {
  color: var(--secondary, #8b6425);
  font-weight: 700;
}

.FS-bottom-nav button[data-route="/add"].active {
  color: var(--primary, #174d3b);
}

.FS-bottom-nav button[data-route="/add"].active .nav-icon {
  background: var(--primary, #174d3b);
}

.FS-bottom-nav button[data-route="/add"].active .nav-label {
  color: var(--primary, #174d3b);
}

.FS-bottom-nav button[data-route="/add"].active::after {
  display: none;
}

/* =========================================================
   HOVER
========================================================= */

@media (hover: hover) {
  .FS-bottom-nav button:hover {
    background: var(--surface-alt, rgba(0,0,0,0.045));
    color: var(--primary, #174d3b);
    transform: translateY(-2px);
  }

  .FS-bottom-nav button[data-route="/add"]:hover {
    background: transparent;
    color: var(--secondary, #8b6425);
  }

  .FS-bottom-nav button[data-route="/add"]:hover .nav-icon {
    background: var(--secondary-light, #b68a3c);
    transform: scale(1.05);
    box-shadow: var(--shadow, 0 5px 14px rgba(0,0,0,0.12));
  }
}

/* =========================================================
   FOCUS
========================================================= */

.FS-bottom-nav button:focus,
.FS-back-button:focus {
  outline: none;
}

.FS-bottom-nav button:focus-visible,
.FS-back-button:focus-visible {
  outline: 3px solid color-mix(
    in srgb,
    var(--accent, #c99a3d) 60%,
    transparent
  );
  outline-offset: 2px;
}

/* =========================================================
   PRESS
========================================================= */

.FS-bottom-nav button:active {
  transform: scale(0.96);
}

/* =========================================================
   DESTINATION BACK NAVIGATION
========================================================= */

.FS-bottom-nav--back {
  min-width: 150px;
}

.FS-bottom-nav--back .FS-back-button {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 130px;
  min-width: 130px;
  min-height: 66px;
  margin: 0;
  padding: 8px 20px;
  border: 0;
  border-radius: 17px;
  background: transparent;
  color: var(--primary, #174d3b);
  font-family: var(--font-body, system-ui, sans-serif);
  cursor: pointer;
}

.FS-back-button .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
}

.FS-back-button .nav-icon svg {
  display: block;
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.FS-back-button .nav-label {
  color: currentColor;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

@media (hover: hover) {
  .FS-back-button:hover {
    color: var(--secondary, #8b6425);
    background: var(--surface-alt, rgba(0,0,0,0.045));
  }

  .FS-back-button:hover .nav-icon {
    transform: translateX(-2px);
  }
}

.FS-back-button:active {
  background: rgba(36,75,44,0.08);
  transform: scale(0.98);
}

/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 699px) {
  :root {
    --FS-nav-height: 76px;
    --FS-nav-bottom: 10px;
  }

  #FS-navigation {
    left: 10px;
    right: 10px;
    bottom: max(
      10px,
      env(safe-area-inset-bottom)
    );
    transform: none;
    width: auto;
    max-width: none;
  }

  .FS-bottom-nav {
    width: 100%;
    min-width: 0;
    max-width: none;
    min-height: var(--FS-nav-height);
    padding: 6px;
    border-radius: 21px;
  }

  .FS-bottom-nav button {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    min-height: 62px;
    padding: 7px 3px;
    border-radius: 15px;
  }

  .FS-bottom-nav .nav-icon {
    width: 27px;
    height: 27px;
    flex-basis: 27px;
  }

  .FS-bottom-nav .nav-icon img {
    width: 22px;
    height: 22px;
    max-width: 22px;
    max-height: 22px;
  }

  .FS-bottom-nav .nav-label {
    font-size: 10px;
  }

  .FS-bottom-nav button.active::after {
    bottom: 4px;
    width: 26px;
    height: 4px;
  }

  .FS-bottom-nav button[data-route="/add"] .nav-icon {
    width: 27px;
    height: 27px;
    flex-basis: 27px;
    padding: 4px;
  }

  .FS-bottom-nav--back {
    width: 100%;
    min-width: 0;
  }

  .FS-bottom-nav--back .FS-back-button {
    width: 100%;
    min-width: 0;
    flex: 1;
  }

  #FS-app {
    padding-bottom: calc(
      var(--FS-nav-height) +
      42px +
      env(safe-area-inset-bottom)
    );
  }
}

/* =========================================================
   SMALL PHONES
========================================================= */

@media (max-width: 399px) {
  #FS-navigation {
    left: 7px;
    right: 7px;
    bottom: max(
      7px,
      env(safe-area-inset-bottom)
    );
  }

  .FS-bottom-nav {
    padding: 5px;
    border-radius: 19px;
  }

  .FS-bottom-nav button {
    min-height: 58px;
    padding-left: 2px;
    padding-right: 2px;
  }

  .FS-bottom-nav .nav-icon {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
  }

  .FS-bottom-nav .nav-icon img {
    width: 20px;
    height: 20px;
    max-width: 20px;
    max-height: 20px;
  }

  .FS-bottom-nav .nav-label {
    font-size: 9px;
  }

  .FS-bottom-nav button.active::after {
    bottom: 3px;
    width: 23px;
    height: 3px;
  }

  .FS-bottom-nav button[data-route="/add"] .nav-icon {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
    padding: 4px;
  }
}

/* =========================================================
   REDUCED MOTION
========================================================= */

@media (prefers-reduced-motion: reduce) {
  .FS-bottom-nav button,
  .FS-bottom-nav .nav-icon,
  .FS-bottom-nav .nav-label,
  .FS-back-button {
    transition: none;
  }
}
