/* Workshop Tools FAB - Floating action button with menu */

.cp-workshop-fab {
  position: fixed;
  bottom: var(--md);
  left: var(--md);
  z-index: 10000;
  animation: cp-workshop-fab-bounce-in 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;

  .fab-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--red);
    border: none;
    cursor: pointer;
    color: var(--white);
    transition: background var(--fast), transform var(--fast);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);

    &:hover {
      background: var(--red-dark);
      transform: scale(1.05);
    }

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

    .icon-gear,
    .icon-x {
      display: flex;
      align-items: center;
      justify-content: center;

      svg {
        width: 24px;
        height: 24px;
      }
    }

    .icon-x {
      display: none;
    }

    .icon-gear {
      display: block;
      animation: cp-workshop-fab-gear-spin 0.9s cubic-bezier(0.4, 0, 0.2, 1) both;
    }
  }

  &.is-open {
    .fab-toggle {
      .icon-gear {
        display: none;
      }

      .icon-x {
        display: flex;
      }
    }
  }

  .fab-menu {
    position: absolute;
    bottom: calc(100% + var(--xs));
    left: 0;
    background: var(--red);
    border-radius: var(--radius);
    min-width: 200px;
    padding: var(--sm);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    transform-origin: bottom left;
    animation: fab-menu-enter 0.2s ease-out;

    .menu-heading {
      display: block;
      font-size: var(--small);
      font-weight: var(--bold);
      color: var(--white);
      opacity: 0.7;
      padding: 0 var(--xs) var(--xs);
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }

    .fab-menu-link {
      display: flex;
      align-items: center;
      gap: var(--xs);
      padding: var(--xs) var(--sm);
      color: var(--white);
      text-decoration: none;
      border-radius: calc(var(--radius) / 2);
      transition: background var(--fast);
      white-space: nowrap;

      &:hover {
        background: var(--red-dark);
      }

      &:focus-visible {
        outline: 2px solid var(--white);
        outline-offset: 2px;
      }

      .fab-link-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;

        svg {
          width: 20px;
          height: 20px;
        }
      }
    }
  }

  /* Mobile: smaller button, tighter to corner */
  @media (max-width: 640px) {
    bottom: var(--sm);
    left: var(--sm);

    .fab-toggle {
      width: 44px;
      height: 44px;

      .icon-gear svg,
      .icon-x svg {
        width: 20px;
        height: 20px;
      }
    }

    .fab-menu {
      min-width: 180px;

      .menu-heading {
        font-size: 0.75rem;
      }

      .fab-menu-link {
        padding: var(--sm) var(--md);
        font-size: var(--small);
      }
    }
  }

  /* Ultra-wide screens: prevent FAB from going too far into corner */
  @media (min-width: 2000px) {
    left: max(var(--md), calc(50vw - 700px));
  }
}

@keyframes fab-menu-enter {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes cp-workshop-fab-bounce-in {
  0% {
    opacity: 0;
    transform: translateY(100px) scale(0);
  }
  60% {
    opacity: 1;
    transform: translateY(-12px) scale(1.1);
  }
  80% {
    transform: translateY(4px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes cp-workshop-fab-gear-spin {
  from {
    transform: rotate(-540deg);
  }
  to {
    transform: rotate(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cp-workshop-fab,
  .cp-workshop-fab .fab-toggle .icon-gear {
    animation: none;
  }
}
