@use '../../../styles/_globals.scss' as *;

:host {
  display: contents;
}

.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  // Background fills the full height incl. the reserved system-bar area; the
  // padding-bottom below keeps the buttons above it (see --bottom-nav-safe-area).
  height: calc(var(--bottom-nav-height) + var(--bottom-nav-safe-area));
  box-sizing: border-box;
  background: var(--bottom-nav-bg);
  border-top: 1px solid var(--separator-color);
  box-shadow: var(--bottom-nav-shadow);
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--s);
  padding-bottom: var(--bottom-nav-safe-area);
  z-index: var(--z-mobile-bottom-nav);
  display: flex;

  //// Glass effect only when background image is present
  :host-context(.hasBgImage) & {
    //backdrop-filter: blur(10px);
    //-webkit-backdrop-filter: blur(10px);
  }

  .nav-button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: var(--bottom-nav-height);
    min-width: 64px;
    border-radius: var(--radius-xl);
    transition: var(--transition-standard);

    &:hover {
      background-color: var(--state-hover);
    }

    &:focus-visible {
      background-color: var(--state-focus);
    }

    mat-icon {
      font-size: 24px;
      width: 24px;
      height: 24px;
      padding: 0;
      margin: 0;
    }

    // Active state styling - reuse magic side nav theme variables
    &.active {
      background: var(--sidenav-item-active-bg);
      color: var(--sidenav-active-text);
      box-shadow: none;
      margin-bottom: 0;

      mat-icon {
        color: var(--sidenav-active-text);
      }

      // Maintain active state on hover/focus
      &:hover,
      &:focus {
        background: var(--sidenav-item-active-bg);
        color: var(--sidenav-active-text);
      }
    }
  }

  .add-task-button {
    width: 56px;
    height: 56px;
    margin-left: var(--s);
    margin-right: var(--s);
    margin-bottom: var(--s3);
    box-shadow: var(--whiteframe-shadow-4dp);
    transition: var(--transition-standard);

    &:hover {
      transform: scale(1.05);
      box-shadow: var(--whiteframe-shadow-6dp);
    }

    &:active {
      transform: scale(0.95);
    }

    &.smaller {
      height: 40px;
      margin-left: var(--s);
      margin-right: var(--s);
      margin-bottom: 0px;
    }

    mat-icon {
      font-size: 28px;
      width: 28px;
      height: 28px;
    }

    // On Android, hide during the slide-up entrance animation.
    // var(--transition-standard) on .add-task-button already transitions opacity,
    // so removing the class fades in automatically.
    &.hide-for-native {
      opacity: 0;
      pointer-events: none;
    }
  }
}

// Material Design touch target improvements
.nav-button,
.add-task-button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@keyframes slide-up-from-bottom {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

.mobile-bottom-nav.entrance {
  animation: slide-up-from-bottom 400ms ease-out 250ms backwards;
}

@media (prefers-reduced-motion: reduce) {
  .mobile-bottom-nav.entrance {
    animation: none;
  }
}
